#potentiometer

2025-06-17

Fine-tune with precision!
Bourns Potentiometers offer reliable control for signal adjustment, tuning, and calibration in any circuit. Trusted performance, compact design.
smidmart.biz/6nwBE
#Bourns #Potentiometer #Electronics #CircuitDesign #TechTools

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2025-06-16

Atari 2600 Controller Shield PCB Revisited

As previously mentioned in my Atari 2600 Controller Shield PCB Build Guide the PCB doesn’t work so well with paddle controllers due to the way they are wired up.

This is an update to the PCB to allow the paddles to be used in a very similar way to the original Atari 2600.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to Arduino, see the Getting Started pages.

PCB Update

This is basically the PCB design as described here: Atari 2600 Controller Shield PCB Design but with the addition of a resistor and capacitor in the paddle circuit as shown below.

These are the values used in the original Atari circuit as can be found in the following references:

These also describe the operation of the TIA and paddle INPUT circuit:

The block diagram for the TIA shows the transistors mentioned, that are controlled by D7 in VBLANK.

The basic idea being described is that setting D7 turns on the transistors that will drop the voltage from the capacitor to zero. Then the capacitor will charge again and the time it takes to charge depends on the position of the paddle, which is connected to a 1M variable resistor. By measuring the time it takes to charge the capacitor back up, the position of the paddle can be determined.

From all this, we can conclude that the required approach for an Arduino should be as follows (assuming the paddles are connected to analog INPUT ports):

SET pin to OUTPUT
SET pin to LOW
SET pin to INPUT
Start timer
WAIT WHILE (voltage on the analog INPUT pin is NOT HIGH)
Stop timer

This works because the ATmega328P’s analog input ports (at least A0 to A5) can also be used as digital input and output ports.

Note: the Arduino reference documentation states that if swapping from digital output to analog input, then the mode should be explicitly set prior to any calls to analogRead (see “caveats” here).

Build Steps

Solder the components in the following order:

  • Resistors
  • Capacitors
  • Arduino headers
  • 9-way D-type connectors

Testing

I recommend performing the general tests described here: PCBs.

The following sketch will read the value of one of the paddle controllers, implementing the algorithm described above.

#define PAD_PIN A0

#define RAW_MAX 950
#define RAW_SHIFT 7
#define RAW_OFFSET 3
#define RAW_BREAK 150000

unsigned long atariRawAnalogRead (int pin) {
unsigned long start = micros();
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
pinMode(pin, INPUT);
while ((analogRead(pin)<RAW_MAX) && (micros()<(start+RAW_BREAK)))
{}
return (micros() - start);
}

int atariAnalogRead (int pin) {
unsigned long val = atariRawAnalogRead(pin) >> RAW_SHIFT;
if (val < RAW_OFFSET) {
return 1023;
} else if (val < 1023+RAW_OFFSET) {
return 1023-(val-RAW_OFFSET);
} else {
return 0;
}
}

void setup() {
Serial.begin(9600);
}

void loop() {
Serial.print(atariRawAnalogRead(PAD_PIN));
Serial.print("\t");
Serial.print(atariAnalogRead(PAD_PIN));
Serial.print("\t");
Serial.println(analogRead(PAD_PIN));
}

The configuration values at the top are determined through a bit of trial-and-error, noting the following:

  • A single reading could take up to 150 mS.
  • The maximum analog reading corresponds to a voltage of around 4.6V, which is around 940 out of 1023.
  • Timing the charging using microseconds gives more resolution, especially at the quicker end.
  • Shifting the measurement >>7 turns the up to 150,000 value into a value of up to 1170.
  • The residual readings are largely in the range 3 to 1170 now, so a subtraction is required to drop that down to 0, and the top reading needs capping at 1023 to match that returned by analogRead().
  • Reversing the sense of the readings means that clockwise reads higher than anticlockwise.
  • Note: if not controller is plugged in, then the while loop would never complete, so a breakout timer value is provided set to the expected maximum of around 150mS.

The Arduino functions are relatively slow compared to direct register access, but as the time out involved is up to 150mS, I’m not too worried about trying to speed up the Arduino calls.

If I was attempting to read all four paddle controllers at the same time, some optimisation would be required. It might even be worth attempting to read them using a timer interrupt and a sampling routine.

If this was to be used properly, some averaging of values would also be required.

Other PCB Notes

  • This PCB still works fine with keypad controllers. The additional resistor and capacitor does not affect the keypad scanning function.
  • This PCB also still works fine with joysticks, as the digital lines have not be altered.
  • It is possible to use this PCB with the “additional resistor” method described in Atari 2600 Controller Shield PCB Build Guide. This requires installing a resistor where the capacitor is meant to go and shorting the existing resistor link together.

Find the updated PCB on GitHub here.

Closing Thoughts

There are now several approaches that can be used to read Atari paddle controllers from an Arduino.

  • Doctor the wiring of the paddles themselves to internally connect the potentiometer to the 5V and GND line, then connect it directly to an Arduino analog input like any other potentiometer.
  • Use the approach described in Atari 2600 Controller Shield PCB Build Guide to add a resistor and make a variable potential divider, adjusting the read values in software.
  • Use the approach described above to time the charging of a capacitor, mirroring how the original Atari circuit and TIA would have worked.

Kevin

#arduinoUno #atari #atari2600 #pcb #potentiometer

2025-05-28

Everything you ever (or never) wanted to know about Potentiometers in this >200 pages Handbook by Bourns from 1975.
Fun, how it changes from serious to comic style in chapter 9: TO KILL A POTENTIOMETER

bourns.com/docs/technical-docu

#electronics #potentiometer #historical #book #handbook #guide

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2025-05-25

ESP32 S3 DevKit Experimenter PCB Build Guide

Here are the build notes for my ESP32 S3 DevKit Experimenter PCB Design.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to electronics and microcontrollers, see the Getting Started pages.

Bill of Materials

  • ESP32S3 DevKit Experimenter PCB (GitHub link below)
  • ESP32S2 DevKitC (official or clone – see ESP32 S3 DevKit)
  • MIDI Circuit:
    • 1x H11L1 optoisolator
    • 1x 1N4148 or 1N914 signal diode
    • Resistors: 1x 10Ω, 1x 33Ω, 1x 220Ω, 1×470Ω
    • 1x 100nF capacitor
    • Either: 2x MIDI DIN sockets (see photos and PCB for footprint)
    • Or: 2x 3.5mm stereo TRS sockets (see photos and PCB for footprint)
    • Pin headers and jumpers
    • Optional: 6-way DIP socket
  • Audio Output Circuit:
    • Resistors: 2x 1K, 2x 2K
    • 2x 10uF non-polar capacitors
    • 2x 33nF ceramic capacitors
    • 1x 3.5mm stereo TRS socket
  • Power Circuit:
    • 1x 7805 regulator
    • Electrolytic Capacitors: 1x 100uF, 1x 10uF
    • 1x 100nF Ceramic Capacitor
    • SPST switch with 2.54mm pitch connectors
    • 2-way header pins
    • 2.1mm barrel jack socket (see photos and PCB for footprint)
  • 8x 10K potentiometers (see photos and PCB for footprint)
  • Optional: 2x 22-way pin header sockets
  • Additional pin headers or sockets as required

Each circuit module is effectively optional. The position of the 22-way headers will depend on which type of module is used. The clone versions are 1 pin row wider than the official version.

There are some solder-bridge configuration options too, which will be discussed later.

Build Steps

Taking a typical “low to high” soldering approach, this is the suggested order of assembly:

  • All resistors and diode.
  • DIP socket (if used) and TRS socket(s).
  • Disc capacitors.
  • Switch
  • Jumper and pin headers.
  • 22-way pin sockets (if used).
  • Non-polar and electrolytic capacitors.
  • 7805 regulator.
  • Potentiometers.
  • DIN sockets.

Here are some build photos for the MIDI DIN version of the board. If using MIDI TRS sockets, then these can be installed at the same time as the audio socket.

If using 22-way headers for the DevKit, then the position will depend on which type of DevKit module is being used. In the photo below, I’ve installed 3 sets of 22-way headers to allow me to use either a clone or official module.

The remaining components can almost be installed in any order that makes sense at the time.

Once the main build is complete, two additional capacitors are required for the audio PWM output circuit. Two 33nF capacitors should be soldered across the 1K resistors. This is probably best done on the underside of the PCB as shown below.

Ignore the red patch wire. I managed to cut through a track whilst clipping the excess leads after soldering.

Configuration Options

The following are configurable and can be set by using pin headers and jumpers; solder bridges; or possibly wire links.

  • UART for MIDI – pin header + jumpers.
  • Audio Output – can be disconnected by breaking solder jumpers on rear of the board under 1K/2K resistors.
  • GPIO used for RV3 and RV8 – can be set using solder jumpers on rear of the board under RV3 and RV8.

Testing

I recommend performing the general tests described here: PCBs.

WARNING: The DevKit can be powered from either the USB sockets or the new power circuit, but not both at the same time.

The sample application section includes some simple sketches that can be used to test the functionality of the board.

PCB Errata

There are the following issues with this PCB:

  • I should have oriented the DevKit the other way up so that the USB sockets were on the edge of the board, not overhanging the prototyping area!
  • The Audio filter requires additional capacitors (see notes).

Enhancements:

  • None 

Find it on GitHub here.

Sample Applications

Analog Potentiometers

The following will read all 8 pots and echo the values to the serial monitor.

void setup() {
Serial.begin(115200);
}
void loop() {
for (int i=0; i<8; i++) {
int aval = analogRead(A0+i);
Serial.print(aval);
Serial.print("\t");
}
Serial.print("\n");
delay(100);
}

Audio PWM Output

The following will output a 440 Hz sine wave on the PWM channel on GPIO 15. Change to 16 to see the other one.

int pwm_pin = 15;#define NUM_SAMPLES   256uint8_t sinedata[NUM_SAMPLES];#define PWM_RESOLUTION 8#define PWM_FREQUENCY  48000#define TIMER_FREQ 10000000#define TIMER_RATE 305#define FREQ2INC(f) (f*2)uint16_t acc, inc;void ARDUINO_ISR_ATTR timerIsr (void) {  acc += inc;  ledcWrite (pwm_pin, sinedata[acc >> 8]);}hw_timer_t *timer = NULL;void setup () {  ledcSetClockSource(LEDC_AUTO_CLK);  for (int i=0; i<NUM_SAMPLES; i++) {    sinedata[i] = 127 + (uint8_t) (127.0 * sin (((float)i * 2.0 * 3.14159) / (float)NUM_SAMPLES));  }  timer = timerBegin(TIMER_FREQ);  timerAttachInterrupt(timer, &timerIsr);  timerAlarm(timer, TIMER_RATE, true, 0);  ledcAttach(pwm_pin, PWM_FREQUENCY, PWM_RESOLUTION);  inc = FREQ2INC(440);}void loop () { }

I’m getting a pretty good signal with a 33nF filter capacitor, but the signal still retails some bias. I’m getting a Vpp of around 1.1V.

But it starts out with a swing from around -200mV to +900mV. But this slowly improves over time and after a few minutes is much closer to a nominal -500mV to +600mV. I guess that is probably my cheap capacitors!

MIDI

Most of the MIDI monitors, routers and sending projects I have should work with the MIDI setup. In the default configuration, using UART0 (GPIO 43/44) for MIDI, that appears as Serial0 or the default MIDI configuration (more on serial ports on the ESP32S3 here: ESP32 S3 DevKit).

So the Simple MIDI Serial Monitor should just work and anything sent to the board should:

  • Illuminate the on-board (RGB) LED.
  • Echo back out to the MIDI OUT port.

Here is the full test code:

#include <MIDI.h>

MIDI_CREATE_DEFAULT_INSTANCE();

void setup() {
MIDI.begin(MIDI_CHANNEL_OMNI);
pinMode (LED_BUILTIN, OUTPUT);
}

void loop() {
if (MIDI.read()) {
if (MIDI.getType() == midi::NoteOn) {
digitalWrite (LED_BUILTIN, HIGH);
delay (100);
digitalWrite (LED_BUILTIN, LOW);
}
}
}

Note: as the MIDI is (probably) hanging of UART0 which is also routed to the USB “COM” port, it will be easier to upload via the USB “USB” port. This won’t clash with the MIDI circuitry on UART0.

Closing Thoughts

I seem to be having a run of “doh” moments with a few of these PCBs, but then that is the price I pay for taking shortcuts by only designing them in my head rather than prototyping them first!

But arguably, it is still a lot easier using a soldered PCB than attempting to build the various elements on solderless breadboard, so in a way that is what these prototypes are largely for.

So apart from the filter issue which is actually fairly easily solved, this seems to work pretty well.

Kevin

#define #ESP32s3 #include #midi #pcb #potentiometer #pwm

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2025-05-25

ESP32 S3 DevKit Experimenter PCB Design

This a version of the ESP32 WROOM Mozzi Experimenter PCB for the latest ESP32-S3 DevKitC board I’ve found.

For the background on the boards themselves, see my notes here: ESP32 S3 DevKit.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to Microcontrollers, see the Getting Started pages.

The Circuit

This is mostly just breaking out the pins of the ESP32S3 DevKitC to header pins, but there are a couple of additional features too:

  • There are additional rows of headers. The idea is to support the official and clone boards, which means coping with the fact the clone boards are 1 row of pins wider than the official boards.
  • There is MIDI IN and OUT with jumpers to select UART0 or UART1.
  • There is a stereo PWM output circuit (see notes below).
  • There are 8 potentiometers connected to ADC1.
  • There is a 7805 or equivalent regulator to provide power if required.

One slight complication is the possibility that GPIO3 (ADC1_CH2) is required as a STRAPPING pin or that GPIO8 (ADC1_CH7) is required for I2C (more in the previous post) so there is a solder bridge option for either of them to switch over to GPIO10 (ADC1_CH9) instead.

The complete GPIO usage is as follows:

GPIO0On board BOOT buttonGPIO 1-8Potentiometer 1-8GPIO 10Optional replacement for GPIO 3 or 8GPIO 15, 16PWM audio outputGPIO 43, 44MIDI if UART0 is selectedGPIO 17, 18MIDI if UART1 is selectedGPIO 1-20Analog breakout area*GPIO 21, 38-49Digital breakout area*GPIO 38 or 48Onboard RGB LED

* As already mentioned some of these have alternative or preferred functions.

Audio PWM Output

I based this on the output circuit for my ESP32 WROOM Mozzi Experimenter PCB Design, but I was forgetting that the original ESP32 has a DAC and so only requires a potential divider to reduce the voltage levels and a capacitor to remove the DC bias.

The ESP32S3 does not have a DAC, so the output will have to be via PWM if no external DAC is added. This means this output circuit really needs a low-pass filter to smooth out the pulses from the PWM signal.

That hasn’t been included in the design, but can be implemented by adding capacitors across the terminals of the 1K resistors, as shown below.

Following the discussion from Arduino PWM Output Filter Circuit, we can see that a 2K/1K potential divider can (loosely) be treated as a ~666K resistor for the purposes of a low-pass filter calculation. So this gives me various options in terms of capacitor size as follows.

ResistorCapacitorRoll-off frequency666K10nF24 kHz666K33nF7 kHz666K68nF3.5 kHz666K100nF2.4 kHz

The greatest smoothing will come with the lowest cut-off, but 2.4kHz or 3.5kHz will limit the higher audio frequencies somewhat. But a 10nF might not give me enough smoothing.

It will also depend somewhat on the PWM frequency chosen. The higher, i.e. above the audio frequency range required, the better.

I’ll start with adding 33nF and see how that looks then might change with some experimentation.

If an external DAC is used, then there are solder jumpers provided that can be broken to disconnect this part of the circuit anyway.

PCB Design

I initially considered only breaking out GPIO pins that weren’t being used for additional functions, but then decided I’d just break them all out alongside the prototyping area. Any pins that might be problematic or have an existing function on the board are labelled in brackets – e.g. (GPIO 43).

The solder jumpers for the GPIO/ADC choices are on the underside of the board.

As previously mentioned, the headers are arranged such that it will support the official DevKitC or the slightly wider clones.

The jumper for UART selection for MIDI can serve as a “disable MIDI to allow use of the serial port” function too if required.

There is also a twin jumper option for direct 5V input instead of going via the barrel jack and regulator.

Closing Thoughts

The omission of the capacitors in the PWM filter is a small annoyance, but it is relatively easily fixed.

Apart from that, there is a fair bit included on this board. It should serve as a good platform for further experimentation.

Kevin

#ESP32s3 #midi #pcb #potentiometer #pwm

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2025-04-27

Duppa I2C MIDI Controller 3D Print Case

This is a simple 3D printed case for my Duppa I2C MIDI Controller PCB.

https://makertube.net/w/nf7u1sYBRRzj2TUBRduQC2

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to microcontrollers, see the Getting Started pages.

Parts list

OpenSCAD Design

This uses some of the techniques from my Raspberry Pi 2,3,4 A+/B+ Synth Cases to define a basic box, then some cut-outs, and then to split the box and add some overlapping “lips” for a snap-fit.

There a number of functions to achieve this, but some of them are just collecting together the others in the right sequence.

  • rounded – a basic “rounded” box module.
  • standoff – the PCB supports.
  • build_lips/build_lip – as expected, creates the overlapping lips. There is a parameter (solid) which determines if the lip is added to or subtracted from the case.
  • base – the main box shape, less the actual top.
  • top – the top plate that includes holes for the potentiometer and the LED ring.
  • box – uses base() and top() to build a complete box.
  • box_base/box_top – uses box and an intersection to produce the two halves of the main box.

At the top level box_base, box_top and standoff (four times) actually builds the complete case.

In terms of assumptions about the build:

  • Most importantly, this assumes the use of PH5.0 headers to mount the Waveshare Zero device.
  • It also assumes the use of a serial MIDI TRS socket.
  • It should allow for M3 spaces and is build to assume two sets of 10mm spacers as described in the Build Guide.

Notes on printing:

  • I found getting adhesion for the top with all those circular holes quite a challenge. In the end I increased the bed temperature and slowed the print right down to around 40% for the first layer and that seemed to improve thing quite a bit.
  • Once complete I had to tidy up the LED holes a little by hand with a 2.5mm drill bit.
  • The additional tag above the USB socket is quite delicate, so care is needed when snapping the case together.

Errata/Improvements:

  • For my own build, the potentiometer shaft doesn’t stick out as much as I’d like. It is hard to find a knob that doesn’t have to be altered to fit and stay in place.
  • I did wonder about using a thinner layer of 3D print over the LEDs rather than complete holes. I might still try that as an option to see how it works.

Find it on GitHub here.

Closing Thoughts

This is a little tall, but I’m not sure what, in reality I could do about that. There might be some option for shrinking it a little, especially if the Waveshare Zero RP2040 is soldered directly to the PCB. But it would only save, maybe up to 6 mm in height, so it is probably not worth the effort.

But apart from that, this seems to have come out really well. The holes the LEDs I thought were perhaps a bit of a compromise, but actually they seem to work fine.

Kevin

#controlChange #duppa #midi #potentiometer #WaveshareZero

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2025-04-27

Duppa I2C MIDI Controller PCB Build Guide

Here are the build notes for my Duppa I2C MIDI Controller PCB.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments! 

If you are new to microcontrollers, see the Getting Started pages.

Bill of Materials

  • Duppa I2C MIDI Controller PCB (GitHub link below)
  • Waveshare Zero format dev board
  • 1x Duppa Small RGB LED Ring
  • 10KΩ potentiometer
  • 5-pin plug and lead (see photo).
  • 1x 100nF ceramic capacitor
  • Optional: 1×10Ω, 1×33Ω resistor
  • Optional: 1x 3.5mm stereo TRS socket – PCB mount (see footprint and photos)
  • Optional: 2x 9-way header sockets. Ideally low-profile, PH5.0 sockets.

There are a range of possibilities for the potentiometer, so one has to consider if mountings are required or if a knob will be used. These are some of the pots I could have used:

I used the one with a nut in the end and plan to add a knob at some point.

On that lead… The Duppa ring is described as requiring a “5-way Molex Picoblade, 1.25mm pitch” connector. The lead I ended up with was described on an online, overseas marketplace, as “JST 1.25mm” which I’m not sure is strictly a thing, but that is what worked for me.

Build Steps

Taking a typical “low to high” soldering approach, this is the suggested order of assembly:

  • Resistors and diode.
  • Disc capacitors.
  • TRS socket (if used).
  • If using headers for the devboard, now is a good time to solder those.
  • Potentiometer.
  • Duppa connector cable.

Be sure to get the connector cable the right way round. For the colouring of the cable above, and orientation of the pins, the I2C connectors ended up being the red and black ones for me. More about that in a moment.

Here are some build photos.

The cable has to be cut and then positioned to correctly align with the positions of the wires on the Duppa connector. The following shows which wires align to which solder pads and the position in the connector.

Once all soldering is complete, I used 8x 10mm M3 spacers as shown below.

I’m planning on designing an enclosure that the above posts will slot into. You may need different senses and sizes of spacers depending on your final arrangements.

Testing

I recommend performing the general tests described here: PCBs.

Note that the LED ring is configured using solder jumpers as described previously, for S1, S5 and to use pull-ups, as shown below.

PCB Errata

There are the following issues with this PCB:

  •  None at this time.

Enhancements:

  • The schematic already supports MIDI IN in addition to MIDI OUT, so at some point I could add that too. 

Find it on GitHub here.

Sample Applications

This is designed for use with my Duppa I2C MIDI Controller – Part 4. The Arduino code for that works directly when used with a Waveshare Zero RP2040 with the following configuration:

#define WAVESHARE_RP2040

#define MIDI_USB
#define MIDI_SER

#define LED_PER_CC
#define LED_SCALE_TO_RING

#define CC_POTENTIOMETER
#define PIN_ALG A3
#define MAX_POT_VALUE 1023

The full code is available on Github here.

Closing Thoughts

I’m really pleased with how this turned out. These LED rings are really neat!

Now on to that case…

Kevin

#controlChange #define #midi #pcb #potentiometer #WaveshareZero

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2025-04-27

Duppa I2C MIDI Controller PCB Design

This is the design for a simple carrier PCB for a Waveshare Zero format microcontroller and a Duppa small LED Ring. It is essentially a PCB version of Duppa I2C MIDI Controller – Part 4.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments! 

If you are new to microcontrollers, see the Getting Started pages.

The Circuit

This connects a Waveshare Zero format board to a MIDI IN and OUT interface and a potentiometer. There is a header required to connect to the Duppa Small LED ring.

The following IO pins are used:

Physical PinGPIO: C3, S3, RP2040Function1Power5V2GroundGND3Power3V34GP0, GP1, A3Potentiometer13GP9, GP10, GP5LED SCL14GP10, GP11, GP4LED SDA17GP20, RX, GP1MIDI RX18GP21, TX, GP0MIDI TX

For the RP2040 this is using I2C0 and UART0.

PCB Design

I’ve actually opted not to include MIDI IN functionality in order to keep within a minimal PCB footprint. I’m aiming to have it occupy essentially the same space as one of the small Duppa LED rings itself. I’m also only support MIDI OUT via a TRS jack.

But I have attempted to ensure that both the Waveshare USB socket and TRS socket will protrude enough to be brought out to the edge of a case.

I’ve included a 2.54mm pitch set of header pads that I plan to solder a connecting wire to for the Duppa ring.

Closing Thoughts

I was in two minds about including MIDI IN. It is nice to be able to use this to merge into an existing MIDI stream, but then I also considered that it would probably be used just as a controller in most cases, so went with the small PCB footprint.

I also considered the four control options I’ve experimented with so far. In the end I decided I still liked having an absolute-value potentiometer for a MIDI Controller like this over either a rotary encoder or an endless potentiometer, so that is what I’ve used.

Kevin

#controlChange #midi #pcb #potentiometer #WaveshareZero

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2025-04-06

Duppa I2C MIDI Controller – Part 4

This is revisiting my Duppa I2C MIDI Controller this time using a Waveshare Zero format device.

  • Part 1 – getting to know the devices and testing them out.
  • Part 2 – adding MIDI to the LED ring and I2C encoder.
  • Part 3 – adding normal encoder, plain potentiometer, and endless potentiometer control.
  • Part 4 – revisits the idea with Waveshare Zero format devices and adds USB MIDI.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to Arduino, see the Getting Started pages.

Parts list

  • Waveshare Zero ESP32-S3 or RP2040.
  • DuPPa small RGB LED Ring.
  • 10K potentiometer.
  • Bespoke hook-up wires (available from duppa.net).
  • Optional: 3V3 MIDI Interface.
  • Breadboard and jumper wires.

Waveshare Zero, Duppa LED Ring, Potentiometers

I’m planning on being able to use any Waveshare Zero format board that I have (so that includes ESP32-S3, ESP32-C3 and RP2040) with the Duppa Ring so that means finding common pins to support I2C.

From the various pinouts (see Waveshare Zero, Pimoroni Tiny, and Neopixels) I can see I can use two pins in the bottom right-hand (with the USB connector at the top) corner of the board.

I’ll also need an analog connection and potentially connecting RX/TX to MIDI.

The various pins I’ll be using are as follows:

PinFunctionESP32-S3ESP32-C3RP204015V2GND33V34ADCGP1GP0GP29/A313SCLGP10GP9GP514SDAGP11GP10GP417RXGP44GP20GP118TXGP43GP21GP0

Note, I’m not using physical pins 11 and 12, even though they also support I2C, as for the RP2040, these are on I2C bus 1, not 0 (see note later).

As the Pimoroni Tiny2040 is largely compatible too, that could also be used, but it will be physical pins 11 and 12, corresponding to GP5 and GP4, and 15 and 16 for GP1, GP0 (RX,TX).

The LEDs on the LED ring are powered from 5V, which comes directly off the Waveshare Zero USB port. The logic “VIO” is powered from 3V3.

The Code

I2C LED Ring

As the I2C pins to be used are configurable, this means changing the Duppa example code (and any other Arduino code) to initialise the I2C bus on specific pins as follows:

Wire.begin(11,10);    // SDA, SCL for ESP32-S3
Wire.begin(10,9); // SDA, SCL for ESP32-C3

Using the ESP32 Arduino Core, there is a specific board entry for the Waveshare Zero ESP32-S3. There isn’t one for the ESP32-C3 so I just used “ESP32C3 Dev Module”.

I used the Arduino core for RP2040 from here rather than the official core: https://github.com/earlephilhower/arduino-pico

But the I2C initialisation is a little different.

  Wire.setSDA(4);
Wire.setSCL(5);
Wire.begin();

If I’d have been using GP6 and GP7, then these would have required the initialisation of Wire1 rather than Wire with the RP2040 core.

Note: to use the serial port once a sketch has been loaded onto the board, requires the following to be set (via the Arduino Tools menu):

USB CDC On Boot -> Enabled

Once again, I’ve soldered the jumpers on the LED ring to enable pull-ups and set the address for S1 and S5, so that has to be changed in the demo code too.

Analog Potentiometer

In terms of analog read, the ESP32 has a resolution of 0..4095 compared to the Arduino’s 0..1023, so that has to be taken into account when calculating the MIDI CC values.

To do this, the reading has to be divided by the ratio of Pot Range / 128.

int newpot = algpot.avgeAnalogRead(PIN_ALG) / ((MAX_POT_VALUE+1)/128);

Serial MIDI

For these boards, the serial port has to be specified. There are different options depending on the board being used (more here).

To use the pins nominally designated as RX/TX on all of these boards, use:

// ESP32-S3 GP43,GP44 or ESP32-C3 GP20,GP21
MIDI_CREATE_INSTANCE(HardwareSerial, Serial0, MIDI);
// RP2040 GP1,GP0
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);

It is a quirk of the RP2040 Arduino core that UART0 appears on Serial1 and UART1 on Serial2. Serial0 does not exist but USB is Serial (more here).

Also, for the RP2040 the pins can be changed prior to calling MIDI.begin() if required as follows:

Serial1.setRX(rxpin);
Serial1.setTX(txpin);
MIDI.begin();

MIDI USB

I want to make this a fairly stand-alone MIDI USB device, so for the ESP32 and RP2040 this means using the TinyUSB stack. There is an Adafruit library for Arduino that supports both and also works with the Arduino MIDI Library. References:

I’ve cribbed most of the code from: https://github.com/adafruit/Adafruit_TinyUSB_Arduino/blob/master/examples/MIDI/midi_test/midi_test.ino

And added the appropriate parts to my own midiSetup() and midiLoop() functions.

MIDI USB – ESP32-S3

For this to work on the ESP32-S3, the board settings (via the Arduino Tools menu) need to be changed as follows:

USB CDC On Boot -> Enabled
USB Mode -> USB-OTG (TinyUSB)
USB Firmware MSC On Boot=Disabled
USB DFU On Boot=Disabled

Naturally this means USB can’t be used for serial output anymore.

It also means that automatic sketch reset and download often didn’t work for me. It was quite normal to now have to use the BOOT and RESET buttons to get the ESP32 back into listening for a new sketch – not always, but also not uncommon. But this might be some serial port remapping weirdness that often occurs when the USB stack is running on the same microprocessor as the main code…

MIDI USB – RP2040

For the RP2040, the USB stack needs to be changed from the Pico SDK to TinyUSB, so in the Tools menu:

USB Stack -> Adafruit TinyUSB

There are some other RP2040 specific notes here, but I don’t believe they apply unless one is interested in rebuilding the core, default TinyUSB support directly.

USB MIDI – ESP32-C3

I don’t believe USB MIDI works on the ESP32-C3

Adafruit TinyUSB doesn’t seem to anyway and I haven’t looked into what the options might be yet.

Other Notes

I’ve left in all the conditional compilation from Duppa I2C MIDI Controller – Part 3 but for now am just working with potentiometer control.

Pretty much everything is configurable, but the most important config option is to specify the board at the top:

//#define WAVESHARE_ESP32S3
//#define WAVESHARE_ESP32C3
#define WAVESHARE_RP2040

I could probably auto detect from the build settings but for now, this will do.

Other options include GPIO pins, whether to include serial or USB MIDI (or both), and whether to enable MIDI THRU or not.

Find it on GitHub here.

Closing Thoughts

This is the first go at getting my Duppa controller working on 3V3 Waveshare Zero format boards, and so far it looks pretty good.

For the ESP32-S3 and RP2040 being able to enable MIDI USB is particularly useful. I might see if I can support MIDI THRU across the interfaces, which might be handy for a built-in USB to serial MIDI converter, but for now MIDI THRU is on the same port only.

I’ve not tested this with encoders or the endless potentiometer, but in theory it ought to work. I’d have to add some conditional compilation for GPIO numbers if I want to keep the same physical pins again.

Kevin

#controlChange #duppa #endlessPotentiometer #esp32c3 #ESP32s3 #i2c #midi #potentiometer #rgbLed #rotaryEncoder #rp2040 #WaveshareZero

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2025-04-04

Forbidden Planet “Krell” Display – MIDI CC Controller – Part 2

This revisits my Forbidden Planet “Krell” Display – MIDI CC Controller using my Forbidden Planet “Krell” Display PCB with a Waveshare RP2040 to create more of a “all in one” device.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to Arduino, see the Getting Started pages.

Parts list

PCB

This requires a built of the Forbidden Planet “Krell” Display PCB with the following:

  • 2 potentiometers
  • MIDI IN and OUT

I’ve used potentiometers that are their own knob, as they only poke through the casing by around 5mm or so.

If it you are able to get longer shaft pots, then that would probably be worthwhile.

Updated 3D Printed Case

This requires the following from the Krell Display 3D Printed Case:

This requires the following options in the OpenSCAD code:

show_frame = 1;
show_quadframe = 0;
show_insert = 1;
show_support = 0;
show_quadsupport = 0;
show_eurorack = 0;
show_eurorack_support = 1;

alg_pot1 = 1;
alg_pot2 = 1;
alg_cv = 0;

The frame does not really take into account the PCB at present, but I’ve reached the “good enough I want to do something else” stage, so I’ve just added a couple of small cut-outs (using a hacksaw) for the two MIDI sockets, and am content that the components stick out a bit from the back.

This cutout has to be 10.5mm from the end, 6mm wide, and 5mm deep.

At some point I might go back and design a deeper frame that has the cut-outs included and some kind of snap-on back to make it a self-contained box.

But for now, this is left as an exercise for, well, anyone else 🙂

Construction

I’ve used four brass 6mm spacers to screw into the mounting holes in the frame. Then the PCB can be inserted, taking care to squeeze in the 3D printed support around the LEDs and pots, and fixed with 20mm spacers which will also act as “legs”.

The Code

I’ve used a Waveshare Zero RP2040 and Circuitpython for this build. This is a combination of some of the test code used for the Forbidden Planet “Krell” Display PCB but with added MIDI.

The code supports both Serial and USB MIDI.

I wanted an equivalent of the Arduino map() and constrain() functions and didn’t immediate spot them in Circuitpython so wrote my own:

def algmap(val, minin, maxin, minout, maxout):
if (val < minin):
val = minin
if (val > maxin):
val = maxin
return minout + (((val - minin) * (maxout - minout)) / (maxin - minin))

This allows me to map the analog read values (0 to 65535) down to MIDI CC values (0 to 127) whilst also allowing for some inaccuracies (I’ve treated anything below 256 as zero for example):

alg1cc = int(algmap(alg1_in.value,256,65530,0,127))

I’ve used the Adafruit MIDI library, which I’m still not really a fan of, but I wanted to include MIDI THRU functionality to allow the controller to sit inline with an existing MIDI stream. But it doesn’t seem to work very well.

I was already only updating the LEDs/MIDI CC if the pot values had changed, to cut down on the number of Neopixel writes required.

I experimented with changing the scheduling of the analog reads and MIDI but that didn’t seem to help very much. In the end I made sure that all MIDI messages queued up in the system would be read at the same time before going back to checking the pots.

    msg = midiuart.receive()
while (msg is not None):
if (not isinstance(msg, MIDIUnknownEvent)):
midiuart.send(msg)
msg = midiuart.receive()

It will do for now. Moving forward, I might try the Winterbloom SmolMIDI library. If that still doesn’t give me some useful performance then I might have to switch over to Arduino C.

Find it on GitHub here.

Closing Thoughts

The MIDI throughput is disappointing, but then I’ve never really gotten on with the Adafruit MIDI library. I use it as USB MIDI on Circuitpython is so easy, so will need to do something about that.

I’m still deciding on the PCB-sized supports too. The original seemed to have nicer diffusion of the LEDs, but that could have been the difference between 5mm SMT neopixels and these THT APA106s which seem more directional in the first place.

And I really ought to finish the 3D printed case properly too.

So this is “that will do” for now, but I ought to come back and finish it off properly at some point.

Kevin

#APA106 #circuitpython #ForbiddenPlanet #Krell #midi #midiController #NeoPixel #potentiometer #rp2040 #WaveshareZero

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2025-04-03

Forbidden Planet “Krell” Display EuroRack Module

This project uses my Forbidden Planet “Krell” Display and the Forbidden Planet “Krell” Display PCB Design but with some slight variations that means it could be EuroRack mounted with a control voltage (CV) input.

This is a DIY module only for use in my own DIY system.

Do NOT use this alongside expensive modules in an expensive rack. It is highly likely to cause problems with your power supply and could even damage your other modules.

https://makertube.net/w/qJqgTxxsEznTuF2DRVZT9o

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to microcontrollers, see the Getting Started pages.

Parts list

EuroRack 3D Print Design

This is an evolution of my original Forbidden Planet “Krell” Display box, but fitting into EuroRack dimensions: 128.5 x 60, which essentially makes it a 12 HP module.

It still takes the same inserts however, but now also includes options for holes for jack sockets or potentiometers:

show_eurorack = 1;
show_eurorack_support = 1;

alg_pot1 = 1;
alg_pot2 = 1;
alg_cv = 0;

I’ve also included a special “supports” option for use with the PCB and the EuroRack case.

Krell Display PCB – EuroRack Build

To build one of my Forbidden Planet “Krell” Display PCB Designs for use with a EuroRack, follow the previous Build Guide but note the following differences:

  • The MIDI circuits are not required when used as a CV input device.
  • The lower potentiometer should be replaced with a CV input circuit.
  • The upper potentiometer is optional, but I’m omitting it for my build.
  • Power will come via the 5V jumper headers from an additional EuroRack power PCB (details below).
  • Low-profile (e.g. 9mm high in total) headers should be used for the Waveshare Zero, but once again note the errata about the footprint on the PCB being too wide.

Here are some build photos of a build for EuroRack use. For this build there are only two diodes (the two BAT43) and two resistors (22K and 33K). Also note that none of the 100nF ceramic capacitors are required either.

Both electrolytic capacitors have been soldered into position on their sides as show below.

The Thonkiconn style mono jack shares the footprint are of the lower potentiometer on the LED side of the board, but be sure to get use the correct mounting holes as shown by the orientation below.

Nothing has been soldered to the power jumper yet. See the discussion below for how to link this to the power board.

Krell Display Companion EuroRack Power PCB

Bill of Materials:

  • Waveshare Zero “Krell” Display EuroRack power PCB (Github Link below).
  • L7805 TO-220 format regulator or equivalent (see discussion below).
  • 1x 16-way DIP EuroRack shrouded header.
  • 1x 1N5017 Zener diode.
  • 2x 47uF electrolytic capacitors.
  • 1x 100nF ceramic capacitor.
  • 2-way Jumper header socket and pins (probably need extended pins – see discussion).

I’ve opted to use a DC-DC converter with a 7805 physical footprint as shown below.

If a 7805 regulator is used then a heatsink will almost certainly be required. I’ve oriented the regular to allow for a “tab up” mounting which hopefully leaves plenty of room for some kind of heatsink to be used.

Here are some build photos.

There is an option on the PCB to install a 10R resistor as is sometimes recommended for EuroRack modules. From what I’ve read this seems to be to allow it to act as a “fuse” in the case of an incorrectly wired module. As I’ve discussed before (see here) I’m not sure this is so relevant for me, so I’m using the provided solder bypass bridge to leave it out.

Note the orientation of the DC-DC converter.

I’ve used extended pin headers for the power link between the two boards, but due to an error in positioning, they’ve had to be bent over slightly – more on that later.

Physical Build

A completed unit has the following parts:

  • 3D printed case, PCB supports, and two “krell” inserts.
  • Main PCB built for EuroRack use as described above.
  • Power PCB as described above.
  • M2.5 spacers and fixings as follows:
    • 4x 6mm M2.5 brass fixings.
    • 4x 15mm M2.5 nylon fixings.
    • 4x M2.5 nylon screws.

The power link between the two PCBs has to be trimmed and slightly bent as shown below.

Once the whole thing is put together, there isn’t room, at least on my build, for the nut to be put on the jack socket. Also, the 6mm and 15mm spacers might be slightly too short, depending on how far off the PCBs the LEDs ended up. Some experimentation and “encouragement” is probably required to get everything together.

The Code

The code is relatively straight forward, and is largely a mix of the analog and neopixel test code from the Forbidden Planet “Krell” Display PCB Build Guide.

One quirk is scaling the analog read from 0..65535 to a useful 0-10 to allow for zero to 10 leds to light up. I’ve allowed for a range of values to be “basically zero” too to allow for some jitter or noise.

As I only write out to the neopixels when something changes, this code seems to be quite responsive.

This requires the following Adafruit Circuitpython Library Bundle libraries:

  • neopixel.mpy
  • adafruit_pioasm.mpy
  • adafruit_pixelbuf.mpy

In fact, the entire Circuitpython code is given below.

import time
import board
import neopixel
from analogio import AnalogIn

cv_in = AnalogIn(board.A3)

pixel_pin1 = board.GP2
pixel_pin2 = board.GP3
num_pixels = 5

pixels1 = neopixel.NeoPixel(pixel_pin1, num_pixels, brightness=0.3, auto_write=False, pixel_order=neopixel.RGB)
pixels2 = neopixel.NeoPixel(pixel_pin2, num_pixels, brightness=0.3, auto_write=False, pixel_order=neopixel.RGB)

col = (80, 35, 0)

lastcv = -1
while True:
cv = cv_in.value / 256

if (lastcv != cv):
lastcv = cv
led = cv / 25
for pix in range(5):
if (pix < led and cv > 5):
pixels1[pix] = col
else:
pixels1[pix] = 0

if (pix+5 < led and cv > 5):
pixels2[pix] = col
else:
pixels2[pix] = 0

pixels1.show()
pixels2.show()

GiHub Resources

There is now an updated version of the OpenSCAD code for the case on GitHub and the PCB and code are also now available.

Closing Thoughts

This isn’t a perfect build in mechanical terms, but I’m not sure I ever do anything perfectly anyway, especially where mechanical things are concerned, but the final result is pretty pleasing.

The video shows it running with a Pimoroni RP2040 in the driving seat. First a potentiometer provides a 0 to 5V input, then I’m using my Educational DIY Synth Thing‘s LFO to provide a 0 to 3V3 input.

Kevin

#circuitpython #EuroRack #Krell #NeoPixel #potentiometer

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2025-03-18

Duppa I2C MIDI Controller – Part 3

This is a follow up post to Part 2 expanding on the code and adding in some of the alternative control options I mentioned.

  • Part 1 – getting to know the devices and testing them out.
  • Part 2 – adding MIDI to the LED ring and I2C encoder.
  • Part 3 – adding normal encoder, plain potentiometer, and endless potentiometer control.
  • Part 4 – revisits the idea with Waveshare Zero format devices and adds USB MIDI.

https://makertube.net/w/ncLFMqBwCUcrrM4r3mHJwd

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to Arduino, see the Getting Started pages.

Parts list

  • Arduino Uno/Nano.
  • DuPPa small RGB LED Ring.
  • 10K potentiometer.
  • KY-040 rotary encoder module.
  • Bespoke hook-up wires (available from duppa.net).
  • Breadboard and jumper wires.

The Circuit

This circuit shows all three control options on the same diagram, but naturally use whichever one you require. There are the following three options:

  • Duppa I2C Encoder (from the previous project) on A4, A5 (SDA, SCL).
  • Plain potentiometer on A0.
  • Rotary encoder on D10, D11, D12.

In addition to the I2C LED Ring on A4, A5 (SDA, SCL) of course.

Here is a separate diagram for the endless potentiometer. I can be used alongside the above, but I’ve drawn it on its own for clarity.

Mine has the pins in the following order: Wiper A, GND, Wiper B, VCC.

The Code

This uses the code from Part 2 as a starting point and adds in some additional features.

The main aim is to add additional control options and then make them selectable in code. There are several definitions at the top of the file. One of them should be uncommented to enable that control option.

//#define CC_ENCODER
#define CC_POTENTIOMETER
//#define CC_I2CENCODER
//#define CC_ENDLESSPOT

Each control method will have some associated functions, but the interface will be hidden away behind these definitions and called from the main code, something like the following.

#ifdef CC_ENCODER
#include <librarycode.h>
... control specific definitions ....

void encSetup() {
// Control specific setup code
}

void encLoop() {
// Control specific loop code
}
#else
void encSetup() {}
void encLoop() {}
#endif

If that control option is not enabled, then it will just end up with the two empty functions.

Normal Potentiometer

This is fairly straightforward. I’m using the averaging technique I’ve mentioned before (details here) and include a counter so that the pot isn’t read on every scan, otherwise it slows down all other processing significantly.

The pot reading is scaled down to 7-bits from the default 10-bit value with a bitshift.

I’ve opted to have a jump if the CC value is updated over MIDI rather than anything more sophisticated, as that is probably the simplest.

All the same display options are available as used previously: one LED per CC; scaled to multiples of the ring size; or scaled to a single ring.

This works quite well with all of them, but probably makes most sense when the MIDI CC range is scaled to a single revolution of the LED ring.

CC_WRAP has no effect when used with a normal potentiometer, as the pot itself does not wrap around.

Rotary Encoder

This is using the same encoder library I’ve used before in my Arduino MIDI Rotary Encoder Controller. This makes the scanning code relatively straight forward.

I’ve refactored out the increment/decrement functions from the I2C encoder code into midiCCIncrement and midiCCDecrement, so these can now be used by both encoder options.

These encoder modules are often switched, but I’m not making use of the switch here.

Once again, all the same display options are available: one LED per CC; scaled to multiples of the ring size; or scaled to a single ring. CC_WRAP can be on or off.

Endless Potentiometer

There is a detailed discussion of how these work here: https://hackaday.io/project/171841-driveralgorithm-for-360-deg-endless-potentiometer
My initial thought was that I could just use one of the wipers, assuming it would go from 0 to full resistance and immediately back to zero, but they don’t – they gradually go from 0 to full resistance and then gradually back to 0 again. See the diagram in the above link.

This means that some processing is required to get a single reading out of them, so I ended up using a library from here:

Well actually, I ended up using the slight variant of the library as used on the “Ottopot” MIDI controller, which can be found here:

In my case I just dropping in the endlesspotentiometer.cpp/h files into my Arduino sketch (swapping any includes from <> to “” in the process). There was one reference to main.h that needed removing, and it required a definition of MAX_POT_VALUE which is 1023 for an Arduino Uno.

Then the code is fairly straight forward as the library is able to give an indication of direction and how much the pot has moved.

One thing to watch out for – I wanted this to be able to act on midiCC in a relative manner, replication the benefits of an encoder, but with a potentiometer, so I needed to know how much the pot had changed and then add that to the current midiCC value, rather than set it directly.

To do this I allowed midiCCIncrement/Decrement to take a parameter – how far to increase or decrease midiCC.

The core code for handling the endless pot was thus:

endpot.updateValues(epot1.avgeAnalogRead(PIN_EALG_1),
epot2.avgeAnalogRead(PIN_EALG_2));
if (endpot.isMoving) {
if (endpot.direction == endpot.CLOCKWISE) {
midiCCIncrement(endpot.valueChanged);
} else if (endpot.direction == endpot.COUNTER_CLOCKWISE) {
midiCCDecrement(endpot.valueChanged);
}
}

I also turned the potentiometer averaging code into a class of its own so I could also use it here for both analog readings of the endless pot.

It took a bit of experimentation with the sensitivity and threshold settings and how they interacted with the frequency of reading, but I’ve ended up with something that seems to work ok for me.

Summary

Although at the start I said that one of the options should be commented out to select it, in reality, if the devices are all on separate IO pins, then actually they can all be enabled at once.

And it does seem to work pretty well, with all four methods: I2C encoder, plain encoder, potentiometer – all interacting as you might expect they would.

Find it on GitHub here.

Closing Thoughts

I was quite surprised how usable everything was with all four input methods enabled. I probably wouldn’t recommend it for typical use, but it was a bit of fun.

It is particularly satisfying to sweep through the entire range using the pot with “one LED per CC” enabled, even though scaling a single ring to the potentiometers range makes more sense (to me).

At some point I will try to get several controls up and running.

Kevin

#arduinoNano #duppa #endlessPotentiometer #i2c #ifdef #midi #potentiometer #rgbLed #rotaryEncoder

2025-02-21

#Drilling holes and test fitting the #enclosure for my 10 step #sequencer
On the front slope, there are ten #potentiometer, LEDs, and toggle switches. The LED fixtures are still missing.
On the top, unsloped part will be the step selector, inputs and outputs.
At the back side will be the power connector and the power switch.
#diysynth #synthesizer

drilling is half done. I printed a layout and glued it onto the enclosure.after drilling the front holes, with potentiometers and toggle switches inserted. LEDs are still missing and also the holes for the inputs at the top part
5021tips5021tips
2025-02-21

Input into , from it's the rate at which come in, , may be NO reference😏!
For , it's force electrons come in, 🫣, compared to some known standard force🧐!

www.5021.tips/ujanja/ec

☝️👆☝️
This some nonsense do , all with doing

2025-02-11

(bouteille à la mer) je cherche à remplacer ce vieux potentiomètre provenant d'une boite à rythmes korg (mini pops 35) Je ne comprends pas vraiment ce qu'il y a indiqué dessus 😞 #electronic #potentiometer #korg #drummachine #vintagerepair

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2025-01-12

Multi-Mode MIDI Step Sequencer – CDR Format – Part 3

This post revisits the “CDR format” (CD Rack Format) panel version of my Multi-Mode MIDI Step Sequencer.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to Arduino, see the Getting Started pages.

Parts list

Panel Design

A key issue was that I hadn’t really documented the dimensions I’d used in the design of the original panel, but after finding the old cardboard cutout and comparing to my built panel I was able to reproduce the dimensions.

It also turns out that I haven’t really listed the hole sizes I’ve been using for panels either, so that was part of the first task too.

I had to create a custom KiCad part for an M7 hole. I based this on the existing M8 holes (one with a pad and one without).

The rest of the holes used, that match the connectors I’m using, are as follows:

PotentiometerM7 (7.4mm) mounting holeAudio OutM8 (8.4mm) mounting holeMIDI TRSM6 (6.4mm) mounting holeToggle SwitchM7 (7.4mm) mounting hole“Thonkiconn” Jack SocketM6 (6.4mm) mounting hole3mm LED3mm mounting hole5mm LED5mm mounting holePower Switch12.5mm diameter edge cut cutout

The key dimensions are indicated below. The whole panel is 250×80 mm with mounting holes 10x10mm from each corner and 20mm clearance top and bottom for mounting.

As I’m using a PCB design tool for the panel, I’ve included a rear GND zone, so left a small pad exposed near the bottom to solder to if required. I did think about using “pads” rather than plain holes to allow switches and potentiometers and so on to connect to the GND zone, but in the end opted for plain holes.

Note: there is one error on the final PCB – the toggle switch was designed with a M6 hole and actually I need an M7, so I had to widen it slightly.

There were a couple of complications with switching over, that I wouldn’t have had with a new build:

  • The power switch needed desoldering and resoldering as the nut is on the inside. Unfortunately I managed to damage the click mechanism and on first try, it was quite unreliable latching in the on position. I had to replace it completely.
  • Two of the three-way switches had their nut/shaft fail on me – I managed to do up the nut most of the way, but not completely and then the threaded shaft started rotating meaning I could neither do it up or undo it. They work, they are fixed in, but they are a little wobbly which is really annoying! But I’d need to desolder a fair bit to replace them. They’ll do for now. Sigh.

Some enhancements were possible too whilst updating the board:

  • I’ve added a 10nF capacitor across the terminals of the toggle switch to aid debouncing.

Other enhancements I’m considering that I might add at a later date:

  • Add capacitors across all pots for smoothing.
  • Add clamp Schottky diodes to the sync IN/OUT sockets, so they aren’t just a direct connection to the microcontroller’s GPIO ports. This was always something I meant to do anyway.

In fact, I might even add a proper buffer stage for the sync jacks anyway – a transistor input stage and protected output stage, as used in my Arduino Drum Trigger to MIDI Shield PCB and my Arduino Clock Generator Shield PCB. Or even include a buffer in the shape of a 74HC14 or similar.

Closing Thoughts

I thought this would be a straight swap and relatively straight forward to do. Unfortunately the use of cheap components caught up with me on this one.

Still, I think the result looks pretty good and it does all now work fine.

It certainly looks great next to my MiniDexed TX816.

Kevin

#ATmega2560 #cdrFormat #digitalPins #led #midi #pcb #potentiometer #ProMega2560 #sequencer #stepSequence

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2025-01-01

EuroRack 6HP MCU Pots and Jacks PCB Build Guide

Here are the build notes for my EuroRack 6HP MCU Pots and Jacks PCB designed to be used with my EuroRack 6HP MCU Experimenter Module.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to electronics, see the Getting Started pages.

Bill of Materials

  • EuroRack 6HP MCU Pots and Jacks PCB (GitHub link below)
  • Several 10KΩ or 100KΩ potentiometers, PCB mounted, common “RK09” footprint, as required.
  • Several “Thonkiconn” PCB mounted mono jacks as required.
  • Pin headers – if mounting into PH5 headers on the IO board then 9.5mm pin headers are required.
  • Jumper wires or long pin headers for inter-board connections (see below).
  • M2 nuts, mounting posts, screws.

Naturally the exact list of components will depend on the eventual application.

See the application and usage notes later in this post for more details, but if header pins are used for the inter-board connections, then it is recommended that PH5 headers and 9.5mm header pins are used to keep connections as slim as possible. But that will largely depend on the maximum height of the components on the IO board.

Build Steps

This should be a relatively straightforward build. The suggested order of assembly being:

  • Jack sockets.
  • Potentiometers.
  • Header pins – note these will be on the underside of the board and should not be confused with the intra-board connecting pads (see usage notes).
    • IMPORTANT: The VCC/GND link will have to be joining wires NOT header pins as it doesn’t line up perfectly.
  • Joining wires – see usage section.

Assuming pin headers are used for the inter-board links, here is a photo showing the main inter-board pin headers fixed to the underside of the board.

When it comes to the inter-board VCC/GND link, it isn’t possible to have a direct jumper connection. Here are a couple of options:

  • Use flexible jumper wires soldered to both boards (using longer wires is recommended – see later).
  • Use extended pin-headers, bent over to line up with the VCC/GND connections on the IO board.

Here is how the bend the pins – some experimenting will be required to get it exact.

Here is the final effect I’m aiming for:

IO Board Connections

The following shows how the IO board should be prepared for use with the Pots and Jacks board if using pin headers for the inter-board connections.

List of components required:

  • 3x 2 pin PH5 header sockets.
  • 1x 4 pin PH5 header socket.
  • 1x 2 pin PH3.5 header socket or jumper wires.

This photo shows the locations of the (PH5) main jumper header sockets.

The VCC/GND link has to connect to the central set of header links. This can be done with flexible jumper wires or another option is to use extended pin headers on the Pots and Jacks board into a pin header socket on the IO board.

I’m using a 2-pin PH3.5 header socket to give me more clearance, which is a bit fiddly to solder on if the IO and MCU board connecting headers are already in place.

Here are a few photos showing how I’ve bent the extended header pins on the Pots and Jacks board to fit the IO board.

The biggest issue is ensuring that the pins cannot be shorted on the potentiometer or jack in position RV3 or IN4.

Testing

I recommend performing the general tests described here: PCBs.

PCB Errata

There are the following issues with this board:

  • The IN jack connections are labelled the wrong way round. IN4 should be at the top and IN1 at the bottom. The jacks themselves are labelled correctly.

 In an ideal world, a better solution to the VCC/GND connection would be found, but joining wires will have to do for now.

Find it on GitHub here alongside a template that can be used to develop and document new designs.

Applications and Usage Notes

Potentiometers or Jacks

As is hopefully obvious from the layout of the PCB, not all 8 jacks can be used with all 4 potentiometers. Jack positions 3 and 4 overlap with RV3 and RV4.

Hopefully this will still allow for plenty of flexibility in the configuration.

Note that care must be taken that RV3 and IN4 do not connect to the VCC/GND link wires or headers when connected to the IO board.

It is assumed in the labelling that INPUT jacks will be on the left and OUTPUT jacks on the right, but this is just a suggested convention and only really matters when finding the intra-board link points for the jacks.

Links to IO Board

As already mentioned there are five sets of header pins designed to (mostly) line up and plug into the EuroRack 6HP MCU Experimenter Module IO board. These are highlighted below on the top and underside views of the PCB. Recall that they should be fixed to the underside of the board.

The four sets of headers should match the IO board exactly hence could be pin headers and sockets or even directly soldered pin header links.

As already mentioned, the VCC/GND connection does not match. One strategy using extended pin headers has already been described.

The alternative is to use jumper wire links. In this case it is recommended that longer wires are used, especially if header pins and sockets are still used for the other connections. This will allow the board to still be largely separated whilst still attached via VCC/GND.

Intra-board Links

There are intra-board links for the jacks and potentiometers as shown below (in yellow).

Note: The silkscreen “IN 1-2-3-4-” is the wrong way round. The diagram above has the correct ordering of the IN jack connectors.

These would be mapped across to some of the inter-board link connecting pads (in blue). Typical links might be:

Intra Board Link (yellow)Inter Board Link (blue)Usage NotesOUTPUTSAudioOUTPUT jacks can be used for PWM audio-type outputs.OUTPUTSOUTGeneric CV or GATE outputs can be routed to OUTPUT jacks.INPUTSCV INCV inputs can come from INPUT jacks.INPUTSGATE INGATE inputs can come from INPUT jacks.POTSCV INCV inputs can come from potentiometers.POTSOUTAdditional CV inputs can come via the “OUT” links when used with potentiometers.

Note that there is also an additional VCC/GND connector (shown in orange) which can be used for any panel-mounted additional IO if required.

Jack Intra-connections

The connection points for the jacks include two pins. One is for the main signal (the tip of the jack) and one is for the switched part of the connector.

These are labelled “4-3-2-1- OUT” and “IN 1-2-3-4-” respectively (although the “OUT” label is at the edge of the board, not right next to the connector), where the number corresponds to the main signal and the “-” corresponds to its equivalent switched connection. In each case, the switched connection is the one towards the bottom of the PCB for each pair.

Important Errata: The “IN 1-2-3-4-” is actually the wrong way round – it should say “IN 4-3-2-1-“.

In most cases, the switched connector can probably be ignored. In some cases it might be useful to have INPUT jack switched points connected to GND.

It might also be possible to implement a switched Mono/Stereo audio output using two inter-connected jacks. This is left as a postulate for now, to be explored perhaps in a future project.

Front Panel Measurements

The following indicates the positions and key dimensions (all in mm) of the pots and jacks compared to my generic (blank) panel.

Typically the pots will require M7 (7.4mm) holes and the “Thonkiconn” style jacks will require M6 (6.4mm).

The pre-existing panel mounting holes are 6.4 x 3.2 mm and designed to take M3 screws.

Note that some of the holes will overlap with the GND rail, which won’t matter, and the VCC rail, which could matter quite a lot if it was connected. However as the pots and jacks are all connected via the tracks on the PCB the GND/VCC rails are not actually required when used with the Pots and Jacks PCB.

It wouldn’t hurt to connect the GND rail to GND though.

Closing Thoughts

There is a lot of flexibility built into these (now) three boards, so hopefully that should allow me to get on and implement a range of modules.

I did wonder about producing a generic panel too, and might still do so – one containing four pots and two of each IN and OUT jacks might be quite versatile. I’m still thinking about it.

At the very least, it would be useful to have blank panels with the above pattern in the rear silkscreen to make drilling of holes a lot easier.

Kevin

#EuroRack #pcb #potentiometer

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2025-01-01

EuroRack 6HP MCU Pots and Jacks PCB Design

This is an add-on for my EuroRack 6HP MCU Experimenter Module to support several different configurations of potentiometers and jack sockets.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to electronics, see the Getting Started pages.

The Circuit

All the schematic is doing is connecting up footprints for potentiometers and mono jacks to the connectors used on my EuroRack 6HP MCU Experimenter Module.

It also includes patch-points to connect them together and some mounting holes.

PCB Design

The mounting holes and main connectors must line up with those used on my EuroRack 6HP MCU Experimenter Module IO board. The footprints for potentiometers and jacks are the common “RK09” and “Thonkiconn” types.

Then it is just a case of providing patch points from the potentiometers and jacks to allow them to be suitable routed as required for any particular design of module.

I’ve supported up to four potentiometers and up to eight jacks. Two of the pots overlap four of the jacks, so that is an “either/or”. The jacks are arranged in a 2×4 grid, implying inputs on the left and outputs on the right.

Connectors have been provided for the following:

  • VCC/GND (which couldn’t align to the VCC/GND points on the IO board, so some creative connecting is required).
  • CV and GATE inputs.
  • CV/GATE/TRIGGER outputs.
  • Audio output.

Naturally the use of any of the inputs or outputs is entirely optional and dependent on the specific function coded into the module.

Note: one of the VCC/GND connectors can be used for additional power connections to the panel or free-mounted components if required.

Closing Thoughts

I have toyed with the idea of providing a panel to match, but it isn’t obvious how to allow for a panel that permits a range of pot and jack configurations without leaving holes.

Instead, I’m happy to use the generic panel I already have for my EuroRack 6HP MCU Experimenter Module.

To make things easier to drill out the holes, I’ve included a user-drawing layer that shows where the holes would be in relation to the panel.

Note that some of the holes will overlap with the “VCC” track if used, so either that shouldn’t be used for VCC or will need to be cut in a suitable place.

Kevin

#EuroRack #pcb #potentiometer #rk09 #thonkiconn

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2024-12-14

Arduino MIDI Master Volume Control

This project uses an Arduino Uno or Nano with a potentiometer to create a MIDI Master Volume Control.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

These are the key Arduino tutorials for the main concepts used in this project:

If you are new to Arduino, see the Getting Started pages.

Parts list

The Circuit

A potentiometer is connected to A0, 5V and GND. To help smooth out the readings a 100nF ceramic capacitor can be connected between A0 and GND.

A MIDI OUT circuit is required. If full software MIDI THRU is required, then a MIDI IN circuit is also required, but it is not necessary to work. In fact a simple “two resistor” MIDI OUT interface would do the trick too (see DIY MIDI Interfaces).

I’ve used my Arduino Nano Mozzi Experimenter Shield PCB simply because it has a built-in MIDI interface and readily available potentiometers, but most of the additional circuitry is unused in this case.

The Code

This is a variation of the Arduino Serial MIDI Program and Control Messenger in principle, but in practise there are significant differences. Whilst the MIDI Control Change messages include a volume control, it has been long considered that this should be treated as a “channel message volume control” and not meant for “whole device” operation.

Consequently, at some point it was decided that one of the System Exclusive, System Real-time messages would be reserved as a “whole device” master volume control. That is what is required here.

The MIDI specification describes the require message as follows:

The Arduino MIDI library includes a sendSysEx function which has to be given a byte-sequence containing the required message. If the last parameter is “true” then it expects the SysEx start and end bytes to be included in the message.

Note that this MIDI message is using the common MIDI method for higher resolution values – it splits a 14-bit value (0 to 16363) into two “almost bytes” of 7-bits each so this has to be accounted for in the code.

Also, as the control will come from an Arduino analog INPUT port the starting values will be 0 to 1023, so they need to be scaled to the required MIDI range. This all happens in the function below.

void setMasterVolume (int volume) { 
uint16_t midivol = map(volume, 0, MAX_POT, 0, 16383);
byte sysex[9] = {0xF0, 0x7F, 0x7F, 0x04, 0x01, 0, 0, 0xF7, 0};
sysex[5] = midivol & 0x7F; // LSB
sysex[6] = (midivol >> 7) & 0x7F; // MSB
MIDI.sendSysEx(8, sysex, true);
}

I’ve also used, and slightly updated, the analog read averaging routine I used in Arduino PSS-680 Synth Editor- Part 2. This code maintains a “running average” reading to smooth out any jitters in the readings.

One thing I was finding though, especially at full-reading (1023), it was still quite jittery even with the smoothing, then I realised that this is because of integer arithmetic always rounding down to the last whole number. This means that no matter how many of the sampled readers were at the full value of 1023 if there was just a single reading of 1022 the rounding down would make the “average” also 1022.

The way around that was to use a single decimal place for each reading and then add 0.5 to the final averaged value to ensure it would also round to the nearest integer rather than round down.

To save having to move into floating point arithmetic I multiply the value by 10 giving me a pseudo single fixed-point decimal.

The complete averaging routine is thus as follows:

#define AVGEREADINGS 32
int avgepotvals[AVGEREADINGS];
int avgepotidx;
long avgepottotal;

int avgeAnalogRead (int pot) {
int reading = 10*analogRead(pot);
avgepottotal = avgepottotal - avgepotvals[avgepotidx];
avgepotvals[avgepotidx] = reading;
avgepottotal = avgepottotal + reading;
avgepotidx++;
if (avgepotidx >= AVGEREADINGS) avgepotidx = 0;
return (((avgepottotal / AVGEREADINGS) + 5) / 10);
}

Notice how the analogRead() is multiplied by 10 and then once the average is calculated in the last line 5 is added (or 0.5 when we know it is a fixed-single-point decimal) prior to the final divide by 10 to get back into the 0 to 1023 range.

Coupling this with a capacitor across the signal of the potentiometer as shown in the schematic, this gives me a much more stable reading, which is important for a MIDI controller as it means there is no MIDI messages being sent unless something has really changed.

The code is using the MIDI serial transport which has MIDI THRU enabled by default. This means that the board could be used within an existing MIDI link by connecting both MIDI OUT and IN. This would add Master Volume control alongside whatever else is being transmitting and as the MIDI library works on the basis of complete MIDI messages, it should work relatively intelligently while merging the two MIDI streams.

Find it on GitHub here.

Closing Thoughts

There are many directions this code could go next. The obvious ones are:

  • Include options for additional MIDI interfaces, especially USB MIDI.
  • Support Master Balance in addition to Master Volume.
  • Switch to a rotary encoder rather than a potentiometer.

Kevin

#arduinoNano #arduinoUno #masterControl #midi #potentiometer #sysex #systemExclusive

Simple DIY Electronic Music Projectsdiyelectromusic.com@diyelectromusic.com
2024-12-09

ESP32 WROOM Mozzi Experimenter PCB Build Guide

Here are the build notes for my ESP32 WROOM Mozzi Experimenter PCB Design.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to electronics and microcontrollers, see the Getting Started pages.

Bill of Materials

  • ESP32 WROOM Mozzi Experimenter PCB (GitHub link below)
  • ESP32 WROOM 32-D DevKit (see photos and PCB for pinout – in particular note position of 3V3 and GND pins)
  • 1x H11L1 optoisolator
  • 1x 1N4148 or 1N914 signal diode
  • 1x 10Ω, 1x 33Ω, 1×220Ω, 1×470Ω, 2x1K, 2x2K resistors
  • 8x 10K potentiometers (PCB mount, see PCB and photos for footprint)
  • 2x 100nF ceramic capacitors
  • 2x 10uF non-polar capacitors (electrolytics probably fine too)
  • 1x 100uF electrolytic capacitor
  • 1x 3.5mm stereo TRS socket (PCB mount – see photos/PCB)
  • Either 2x 180 degree DIN sockets (PCB mount – see photos/PCB)
  • Or 2x 3.5mm stereo TRS sockets
  • 1x 2.1mm barrel jack socket (PCB mount – see photos/PCB)
  • Optional: 2x or 4x 15-pin header sockets
  • Optional: 1x 6 way DIP socket
  • Optional: pin headers
  • Optional: jumpers
  • Optional: SPDT slider switch, 2.54mm pitch connections (see photos/PCB)

Build Steps

Taking a typical “low to high” soldering approach, this is the suggested order of assembly:

  • All resistors and diode.
  • DIP socket (if used) and TRS socket(s).
  • Disc capacitors.
  • Headers.
  • Switch (if used).
  • Barrel jack.
  • Non-polar and electrolytic capacitors.
  • DIN sockets (if used).
  • Potentiometers.

Here are some build photos.

There are several options for headers – there is an additional breakout of all the pins of the ESP32 module and these can be populated with sockets, pins or just left unpopulated as shown below.

And finally adding the potentiometers.

Configuration Options

Two of the potentiometers, RV1 and RV2, have configurable GPIO connections, which are selected by solder jumpers on the rear of the board. The default has them mapped as follows:

RV1GPIO 13RV2GPIO 12

The alternative is configured by cutting the default track between the top solder pads and re-soldering to the bottom pads:

Only one can be changed if required. The alternative configurations are:

RV1GPIO 39RV2GPIO 36

Testing

I recommend performing the general tests described here: PCBs.

Functionality testing is covered by the Sample Applications given below.

PCB Errata

There are the following issues with this PCB:

  • The UART jumper is labelled UART0 and UART1, but in actually, UART1 is almost certainly going to end up being UART2 as UART1 is typically used for onboard flash memory.

Enhancements:

  •  I could add a slightly larger prototyping area, perhaps mirroring the layout of a mini solderless breadboard and still keep within a 100x100mm footprint.

Find it on GitHub here.

Sample Applications

Recall that the GPIO used can be found listed in the ESP32 WROOM Mozzi Experimenter PCB Design.

Potentiometer Analog Read Test

The following code will echo the values from all 8 potentiometers to the serial monitor.

#define NUM_POTS 8
int potpins[NUM_POTS] = {
13, 12, 14, 27, // ADC 2.4, 2.5, 2.6, 2.7
33, 32, 35, 34 // ADC 1.4, 1.5, 1.7, 1.6
};

void setup() {
Serial.begin(115200);
}

void loop() {
for (int i=0; i<NUM_POTS; i++) {
int aval = analogRead(potpins[i]);
Serial.print(aval);
Serial.print("\t");
}
Serial.print("\n");
delay(100);
}

DAC Write Test

The following code will generate two sawtooth waveforms on the two DAC pins, GPIO25 and GPIO26, which are connected to the audio output L and R channels.

GPIO 25 will generate a 440Hz saw tone, and GPIO26 will generate a 880Hz saw tone.

This works, as the code generates a 6-bit (i.e. 0 to 63) value saw wave, updating the value every time through the loop() function. The value is effectively scaled up to 8-bits (0 to 255) by multiplying by 4. The frequency is doubled for pin 26 by multiplying by 8.

In reality, I’m actually taking advantage of the fact that “count” is a uint8_t – i.e. only an 8-bit value – and will automatically wrap around back to zero when the value gets to 255. So in the code, every time the actual “count” variable wraps (0 to 255), the multiplied by 4 version will have wrapped 4 times (i.e. 0 to 63 four times – well, actually it is going 0 to 255, but in steps of 4 at a time, so it will do that 4 times). Similarly the multiplied by 8 version will have wrapped 8 times.

The code has to output these 64 values, 440 times a second, to generate the 440Hz saw tone – so 64 x 440 = 28,160 values a second. That means there is one value required every 35 uS or so. I use the ESP32 microsecond timer to manage this.

uint8_t count;
uint32_t timer;
void setup() {
count = 0;
timer = 0;
}

void loop() {
uint32_t newtime = esp_timer_get_time();
if (newtime >= timer) {
dacWrite(25, count*4); // Auto wraps at 256
dacWrite(26, count*8); // Twice frequency of wrapping...
count++;
timer = newtime + 35; // 35 uS in future of last timer read
}
}

MIDI Test

The ESP32 Simple MIDI Monitor code can be used for a simple MIDI test. The code is configurable for either UART0 or UART1 (in reality mapped onto UART2 in the ESP32) for MIDI.

In use, on reception of any NoteOn message the onboard LED will light up. Also, any MIDI data received over MIDI IN is software-THRU echoed to MIDI OUT.

When using UART1 (UART2) then there will also be a MIDI message dump to the serial monitor.

Closing Thoughts

This board seems to work well. But I have a bit of a problem at the moment. There seems to be a problem with the current (at the time of writing) Mozzi library and the ESP32. There is an incompatibility with the I2S driver used for streaming data out to the DAC.

So at the time of writing, as a Mozzi experimenter board, my options are a little limited. But as soon as Mozzi is updated to the latest ESP32 SDK I2S interfaces, hopefully I’ll be able to properly get going. Watch this space.

Kevin

#dac #esp32 #midi #mozzi #pcb #potentiometer

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst