Digitally Controlled Analog Pedals

Started by POTL, November 22, 2021, 02:10:31 PM

Previous topic - Next topic

POTL

The Chase Bliss effects made me think about how you can implement an analog pedal that will be able to memorize the position of the potentiometers (presets) and be controlled by Midi. In their pelals, a method is implemented, with the help of optics, I think that the microcontroller simply applies voltage to the optics, which are installed in parallel with the potentiometer and thus changes the total resistance. Perhaps there are other ways, encoders, digital pltentiometers or something else? I think it's time to dive into the digital control rabbit hole. I'm waiting for tips and links to articles.

Kevin Mitchell

Buckle up  ;D

I've been getting into midi myself lately. There's a protocol for standard midi. When it comes to custom stuff you can probably swing it any way that fits your needs. Midi is for one microcontroller to communicate to another in the form of bytes consisting of 8 bits.

Here's an example of what I've been personally working on for a keyboard controller.

When I press or release a key it sends information through the midi and/or serial/USB port. So let's say I hit & release C1 on a keyboard where the lowest key is C0. The first signal to be transmitted is the "Status Byte" which is indicated by the MSB (most significant bit, or first bit) as a "1". "0" indicates a "Data Byte".

1001000 - This is a first line which is actually 2 sections of 4-bit data. "1001" means note on and the following 4 bits "0000"  means midi channel 1.

Next signal is a "Data Byte". Specifically, what key is pressed.
00001100 - this is the binary representations of the number "12" which is the 13th key if C0 is 0. If you didn't know, an octave holds 12 keys. So if C0 is 0, C1 is 12.

Then typically there's another data byte right after for velocity - how fast a key is pressed or released. Let's say it was hit as hard/fast as it can be.
0111111 - this is the binary representation of the number 127 which is the max number we can send for velocity as well as key/note data since the MSB is taken to indicate if it's a status or data byte. There are some functions that use more bits or rather, 2 8-bit bytes where larger information is required. But this is just the most basic.

Finally key off along with what key and the release velocity. While "1001" means note on, "1000" means note off.
1000000 (key off, channel 1)
00001100 (key C1)
0111111 (maxed velocity)

When programming it's easier to use the hex value of the byte. The above example written in hex would look like this;
090
00C
03F
Nothing here for as long as the key remains pressed...
080
00C
03F


Here's a great read for staring out - where you'll find everything I just attempted to cover and much more.
Here's a good read on optos used for midi.

Again, this is the standard for midi keyboards. You can build a pedal around those standards or decide to create your own.
  • SUPPORTER

POTL

thanks, I will try to understand what is written in the article. The midi keyboard is fine, but what if I need to use the jog dial instead of the buttons? How much do I imagine a midi keyboard works like a button? on or off. Or does the key have many intermediate values? I apologize for the stupid questions.

Kevin Mitchell

For something like a jog dial you would use a rotary encoder. I'm not familiar with jog dials, but I think the principle is the same as my velocity example where it'll send a data byte containing a value between 0 and 127. It would only refresh the data when it had changed - just like the key on/off process. You only need to know what "Status Byte" and channel to call for whatever you're trying to control. There are many controls - most of which I'm not yet familiar with.
Here's a page from the first article on my previous post displaying some of the midi commands.

For more info you'd have to do a specific search on programming jog dials for midi. There could exist a specific command for them which the to & from controllers would use an an identifier and they could possibly go above the 0-127 value. Sorry I can't explain or expand too much! Figured I'd give the basics as that's where I'm at  :P
  • SUPPORTER

Ripthorn

I've done several projects like this and have a couple more in the queue. It's a great marriage, if you ask me.
Exact science is not an exact science - Nikola Tesla in The Prestige
https://scientificguitarist.wixsite.com/home

ElectricDruid

Quote from: POTL on November 22, 2021, 04:27:34 PM
thanks, I will try to understand what is written in the article. The midi keyboard is fine, but what if I need to use the jog dial instead of the buttons? How much do I imagine a midi keyboard works like a button? on or off. Or does the key have many intermediate values? I apologize for the stupid questions.

The search term you need is "MIDI Control change messages", also known as CCs. A lot of the standard defined Control Change messages are actual switch on/off type things, like 80-83 which are defined as general purpose buttons. Since these are sent as a 7-bit value like other MIDI data, and value from 0-63 represents "Off" and any value from 64-127 represents "On". To put that another way, only bit 6 matters, the one that represents 64 in binary.

If you need more accuracy than CCs give you, there is a specific format for "non-registered parameter numbers" (NPRNs) which use two data bytes and consequently give you a 14-bit value instead. There are a few of these defined (the "Registered Parameters Numbers" (RPNs) but they're pretty sparse. Pitch Bend is the really famous one.



Kevin Mitchell

That's a great explanation, Tom!
I was wondering what commands use 14 bit values other than pitch shift. NPRNs must be the ticket for anything requiring higher resolution under the standard MIDI protocol.
  • SUPPORTER


ElectricDruid

Quote from: Kevin Mitchell on November 23, 2021, 10:44:51 AM
That's a great explanation, Tom!
I was wondering what commands use 14 bit values other than pitch shift. NPRNs must be the ticket for anything requiring higher resolution under the standard MIDI protocol.

Well, actually, I need to make one correction:

The RPN for Pitch Bend is actually "Pitch Bend Range". Pitch Bend itself has a dedicated status byte (so it's its own type of message, essentially) because it's just *that* important!

The other RPNs are:

0x0000 – Pitch bend range
0x0001 – Fine tuning
0x0002 – Coarse tuning
0x0003 – Tuning program change
0x0004 – Tuning bank select
0x0005 – Modulation depth range

0001 and 0002 together give you theoretically 28-bits of tuning resolution, which allows all sorts of microtuning schenanigans, if that's your thing. And then 0003 and 0004 allow a mechanism for instruments to provide various different tuning tables, so you can have equal temperament, but also pythagorean, perfect tuning for different keys, quarter tones, etc etc. There are thousands possible.