Skip to content

electronics

I want the Marimbatron to be modular, so I want to create a module board that can drive and measure 19 sensors. This equals 1 Marimbatron octave (octave has 12 notes, but for this key layout to be playable, additional overlapping notes are needed). These module boards connect to the MCU board which also contains the LCD/OLED, buttons, etc.

module boards

Interesting thought of Henk is to use a microcontroller in combination with a multiplexer on each module board. The microcontroller can drive the LEDs, drive the multiplexer, and use its internal ADC to get the pressure level. Next it can send it using I2C to a main microcontroller. Example of a multiplexer would be the 4067 (16 channel analog multiplexer). Microcontrollers can be the SAM-D family. Will not be too expensive because not a lot of pins are needed this way. And has fast ADC so that’ll do I guess :-) So every module board will get its own microcontroller that communicates to the main controller using I2C.

Sensors

Each sensor will consist of a WS2812 chainable RGB LED (requires 4 wires: Vcc, Di, Do and GND) and a velostat sensor (requires 2 wires: Vsens and GND). Connecting this sensor to a module board would need a flatcable with 5 cores (combined ground). For example: these on Farnell. I don’t see any flatcable shorter than 30mm. Maybe regular wire will work too?

WS2812B RGB LED

Explanation of how WS2812B LEDs work and how to use them in your own custom board: hackster.io.
From the WS2812B datasheet at adafruit:
sm

ADC

Microcontroller ADC speed is important. could be too slow. So this is an important selection criteria for my microcontroller. For example an arduino Uno ADC does a little under 10k samples per second. Other microcontrollers will be faster. The Raspberry RP2040 has 500k samples/sec. I’m not familiar with STM chips but according to this tech note the STM32H7 has a maximum ADC sampling rate of 3.6 Msps in 16-bit mode. The SAM-D21 has a maximum sample rate of 2100 kHz. Another way it to use a I2C/SPI dedicated multichannel ADC chip. Microchip MCP3008 is a 8-channel 10-bit SPI ADC that might be faster. See microchip website . It does 200k samples/second. But that currently feels like an overkill to me.

Multiplexing

A common approach to measuring multiple sensors is by putting them into a grid of columns and rows and multiplex them. So scan the columns and measure the row values.

The way to measure the velostat resistance is like this:
sm

To do this in a multiplexed way:
sm

Multiplexers are available in a lot of different version. A standard general purpose mux is the 74HC4067. This is a 16 channel mux. This is the datasheet of TI. The 74HC4051 is it’s 8-channel little brother (datasheet here).
Choosing the right multiplexer is done by comparing a few characteristics and then just choose and try. This is an excellent TI presentation on what to take into account. Critical parameters are:
- On-resistance: for 4067 this is 70 Ohm @ 4.5V typically - On-capacitance: typically 10pF to 30pF - Leakage current: typically 8 uA - Charge injection: pC order of magnitude.

sm

These parameters will hardly influence my measurements. Resistance of my sensor will be in kOhms and MOhms so orders of magnitude higher. The other parameters are interesting when doing high-speed switching (10uS order of magnitude). If I would be able to achieve something like 3ms readtime for 19 channels, my switchingspeed will be something like 150uS. So that’s all fine too. I can just use a general purpose mux, no need to go for something exotic.

Selecting a channel is done using the S0~S3 pins, according to this truth table:
sm

Microcontroller selection

I’m going to use WS2812B LEDs that are chainable. I need 1 output pin to control them. Every module board will have 19 pressure sensors. So I will need 1x 74HC4051 and 1x 74HC4067 to get 24 channels in total. I will have to switch them on and off individually to I need to use the Enable pin next to all Select pins. That means 5 pins for the 4067 and 4 pins on the 4051, totaling to 9 control pins (I/O) for the multiplexers. This totals to 10 I/O pins that my microcontroller needs to have. The microcontroller also needs at least 1 ADC and I2C for communication.
The selection guide of the SAM microcontrollers can be found here.
I’m very interested to try the SAM-D family. Interestingly enough, the SAMD21J15, J16, J17 and J18 have 20 ADC channels. I wouldn’t even need to use multiplexers in this case. The only difference is program memory size, RAM and EEPROM size:
sm

ATSAMD11C14 is 1,50 euro per piece. 4051 is 0,66 euro. 4067 is 1,00 euro. Totalling to 3,12 euro per piece.
ATSAMD21J17 is 3,12 euro per piece. And no further soldering required.

Board size final project module board is around 45x70mm.

Main board

The requirements for my main board:

  • I2C to communicate to the module boards
  • SPI to control a round LCD display
  • at least 4 inputs for buttons
  • 1 input for a foot pedal
  • USB to output midi data
  • nice to have: 2 outputs in case I want to use on-board sound synthesis

Again this is going to be a microcontroller of the SAM-D family. Perhaps an ATSAMD21E18A (32 pin TQFP).
So I created the schematic and board layout in Kicad. Getting the hang of this software tool is nice!
Here are screenshots of the schematic and the PCB design of the main board:
sm sm
And here’s the main board after assembly. The 2 wires on top are intentionally. This prevents from having a 2-sided PCB for just these wires and also prevents lots of 0 Uhm SMD connectors on the back.
I’ve chosen through-hole connector components due to their better mechanical stability. That meant that I had to use through-hole pin headers too, because otherwise the PCB would become too high to fit into the controller fixture.

sm sm
Very quickly (within 24 hours) the copper started to corrode. So I used a conformal coating spray by Kontakt Chemie called Plastik 70.

Source files of this design can be found here in my repo

Power supply

The main board will do power distribution to the sensor module boards. Every board will consume max 1.2A (for the LEDs) + a little bit for the sensors and the microcontroller. So let’s assume 1.3A max. at 3.3V = 4.29W.
There will be maximum 4 octaves in a full Marimbatron, so max 4 sensor boards. That means max 4x1.3A + a bit for the main microcontroller and the display. Let’s assume 5,2A max at 3.3V which is around 17W. So a 12V, 1.5A main power supply will be enough.
I will use 5 separate 12V to 3.3V voltage regulators on the main PCB. One for each sensor board and one for the main board itself (including LCD). Due to component tolerances, each voltage regulator can output a slightly lower or higher output voltage. Worst case, a sensor board has a higher voltage than the main board. This could potentially result in an analog input pin on the main board to go above the Vdd of the main microcontroller. According to the maximum ratings of the SAMD21 the Vpin is allowed to be Vdd+0.6V (table 41-2). That is way more than the voltage difference between voltage regulators. So we should be fine.
I will not connect the outputs of these voltage regulators together. I could do so but again, due to component tolerances, one voltage regulator might do more than the other, and as such can go over its maximum ratings. If one regulator will fail, changes are that the others will fail one after another too (domino).

Sensor module board

The sensor module board will be based around a SAMD21J18A microcontroller (64 pin TQFP). It has enough ADCs to not have to multiplex.
This microcontroller will communicate to the main microcontroller using I2C. Power to the board will be done through the I2C connector as well.
The microcontroller will drive a string of 19 WS2812B addressable LEDs. One for each sensor. There will be a LED and reset button on the board too. And a USB header for debugging (adds a serial UART).
I originally wanted to daisy-chain multiple sensor module boards using the I2C connector (I2C SDA and SCL + VCC & GND). Unfortunately that will not work because 19x WS2812B will consume at maximum 19 x 60mA = 1.2A. The 1.27mm ribbon cables that I’ll use can only carry 1.4A, so it will be good for 1 sensor board, but not multiple boards. So I’m going to create connectors on the main PCB, one for each sensor board.

Here’s the schematic and the PCB of the sensor module board:
sm sm
sm

Source files are here in my repo

Creating solder stencil using 100um PET sheet (transparent overhead sheet for inkjet printers). On kiCAD: export paste layer as SVG. In trotec Ruby: convert pads to black, outline to red.
Set both black (engrave) as well as red (cut) to 4% speed and 30% power. Use 1000 DPI (engraving quality).

sm sm

The solder stencil works nice, but the TQFP64 pads of the microcontroller are meh… Not sure if this will work out properly.
sm

All components placed. Time for the oven.
sm sm
sm sm

Unfortunately the oven didn’t work out as expected. The solder paste on the pads of the outside of the PCB weren’t fully melted/soldered. And there we’re lots of bridges on the microcontroller pins. That looks nasty:
sm

Hot air gun to the rescue! I was able to remove the microcontroller and solder the remaining solder paste. Next I handsoldered a new microcontroller:
sm sm

And using a test program I got it to work:

/*
blinkhelloworld-samd21.ino
Leo Kuipers april 2024

inital test of samd21j18a microcontroller.

actual pin numbering of samd21 chips (e.g. portA21 or portB30) is in no way related to arduino pin numbering used in sketches.
To get to the arduino pin number, see https://github.com/qbolsee/ArduinoCore-fab-sam/blob/master/variants/Generic_xx1J/variant.cpp
In this file you'll find the PinDescription table of this microcontroller.
Look for the actual pin number you want to program and check the commented line above it to find the arduino numbering. e.g. 
PORTA, 21 on line 130 -> // 12..Digital functions (line 120) -> meaning actual pin number PA21 = arduino number 21 
PORTB, 30 on line 166 -> // 43..46 - SPI Header (line 165) -> meaning actual pin number PB30 = arduino number 43

This work may be reproduced, modified, distributed,
performed, and displayed for any purpose, but must
acknowledge this project. Copyright is retained and
must be preserved. The work is provided as is; no
warranty is provided, and users accept all liability.  
*/

int counter;
bool led;
const int PB30 = 43; // actual pin number PB30 = arduino pin number 43 
const int PB31 = 46; // actual pin number PB31 = arduino pin number 46
void setup() {
  pinMode(PB30, OUTPUT);
  pinMode(PB31, OUTPUT);
  Serial.begin(115200); // start serial communication
//  while (!Serial); // wait for serial port to open before continuing. otherwise the first serial.prints will not be shown in serial monitor. if serial monitor is not opened, the program will not continue.
}

void loop() {
  Serial.print("Hello World! The counter is " );
  Serial.println(counter);
  counter++;
  digitalWrite(PB30, led);
  digitalWrite(PB31, !led);
  led = !led;
  delay(1000);
}

So electronics for my sensor PCB works. Documentation on final programming for this board can be found in final-project/.

Flexible sensor PCB

I created a flexible PCB to fit into the sensor. I did this during Electronics design week, so you can find the documentation here.
sm sm

UI interface

The last PCB in the Marimbatron is the UI interface PCB. It consists of 4 switchbuttons and a round LCD made by Waveshare (https://www.waveshare.com/wiki/1.28inch_LCD_Module)

The schematic and PCB design are here:
sm sm

sm sm

And the kicad files can be found in my repo here.