Arduino "chatter" Resolved!

I’ve recently built the expression pedal to CC converter, which worked fine to start with. I then added a second PRS socket, and as I had a pickup selector switch knocking around I connected that to the ring of the PRS socket and put it to 2 of the outputs on the Arduino meaning I now had 3 possible outputs. This was primarily with the idea of finding out about Ardiuno but also to let me use my one expression pedal either straight through (socket 1) or using one or other or both of the other 2 outputs (socket 2).

I’ve checked my soldering and it is (surprisingly) clean and there are no shorts. Socket 2 has on one 5V in and one ground, but can go to either or both of 2 outputs.

I’m finding that if an output has no pedal connected to it then there is constant chatter on the output CC signal - with no pedal plugged in there is chatter on all 3 outputs, with a pedal plugged in to socket 1 there is chatter on outputs 2 and 3, and with the pedal plugged into socket 2 there is chatter on all but the selected channel. Also, when connected to socket 2 both channels will move when I depress the pedal - so if I choose to use the first of the pair of channels that can be used with socket 2 then output 1 and 3 are noisy, and when I depress the pedal both of the outputs 2 will move smoothly and output 3 will move jerkily. This is the other way round if output 3 is chosen. If I select both then both move smoothly.

Sorry for the mass of detail but can anyone tell me what is going on, and if the expression pedal to CC box cannot be used without a pedal plugged in and if I can switch a signal just at the analog out? Do I need to add some code to silence the empty sockets?

It looks like Arduino can work well, but I just need to work out the small print!

cheers

Simon

1 Like

Unfortunately, your description of your issue is a bit confusing. First, the arduino uses “Inputs” and not “Outputs”.

A potentiometer has 3 prongs (left middle and right). The ground goes to the left prong, VCC goes to the right and the middle prong will be going to the analog input on the Arduino (ex: A0).

In your case, if I understand correctly, you want to have 3 expressions. So, you will need to use 3 analog pins on the Arduino (ex: A0, A1 and A2) one for each potentiometer on their center prong. And of course, the Arduino code to reflect this.

Having “Jitter” when no potentiometer is connected is normal because the Arduino analog pin is “floating” meaning that since it is neither drawn to 0V nor to 5V, it oscillates between the two.

The easy way to fix this jitter is to comment the processing of this “socket” in the Arduino code when not in use.

The hard way is to use a 1/4" jack (or socket) with a built in “switch” that will connect a resistor to 5V (pull up) when no plug is inserted and disconnect this resistor when a pedal is plugged in to allow normal potentiometer operations. The resistor pulling up to 5V will keep the Arduino analog pin to a fixed value and thus eliminating the jitter.

Take a look at my thread on the MIDI expression with Arduino: Arduino MIDI Volume

1 Like

Sorry for my confusing description - I’m new to all this! When talking of outputs I was referring to the CC control on the MOD Dwarf which is seen as channel numbers on the Control Chain Assign. I understand the cabling of the potentiometer and all is as you say.

However, what I want to do is have two TRS sockets into which the cable from an expression pedal can be inserted. 1 of these is simply wired directly as you describe, if the coding is set use only one input on A0 then it works absolutely fine, as long as the pedal is plugged in.

The second socket is more complicated. The 5V and ground lines are wired directly but the third goes to a 3 way switch which means the analog signal can be routed to either A1, A2 or both. If I understand you correctly it would be difficult to get rid of the jitter on the analog in that is not being used, meaning that I would not have the desired flexibility of having, for instance, the same pedal controlling wah if set to A1 and volume if set to A2 (or both if set to both). The ideal of getting a resistor in the circuit is possible, but it’ll take a bit of working out, and it means that the value coming into the Dwarf on Contol Chain x, where x is 1 or 2, will be a set value when the switch is moved away from that pin, which means any pre-set volume would be overwritten - so I wouldn’t be able to set a volume level, flick the switch and use the way at the same level.

Sorry for the diatribe, I’m writing things down here as I think of them, perhaps not the best idea!

Thanks for your thoughts

Simon

Hey, no sweat, we all start somewhere :wink:

Ok, now I think I get what you want to do.

So, instead, of all that wiring, here’s what you should do:

  • One jack (socket) for the expression pedal (as per my MIDI Expression article)
  • One Jack (socket) for a switch (button) configued as “latched” (but not using the Stomp object in my MIDI Expression code).

Modify the code to use the switch as a “toggle” between “Wah” and “Volume”.

In other words, upon pressing the switch, the code will reconfigure the expression pedal to send MIDI CC for “Wah”. Press again and now the expression sends MIDI CC for “Volume”.

This way, the physical potentiometer is always connected to the Arduino analog removing all jitter issues and using up only one Arduino pin.

But this requires a bit more work on the coding side. I can help you with this… :wink:

Actually, this is a very good feature that I’m almost sure no commercial products are offering…

3 Likes

That’s nice to hear, means I’m not totally off my rocker yet!

You almost have what I’m after, and things are looking much more positive now - I was seeing the Arduino as much less capable that in actually is! So, rather than a button I have a 3 way rocker switch which is actually a pickup selector from an old bass, so it has options of “1”, “2” or “1 and 2”, but I’m sure I can work a way to wire it into a jack, or perhaps 2 jacks. I’d appreciate help with the coding, the last I really did was Visual Basic in Excel in the mid 90s - before that I learnt C but that was a long, long time ago. Basically, I know that ideas but forget how to actually do it!

1 Like

Then, you use 2 digital pins on the Arduino.

1 TRS (tip, ring, sleeve) jack is all you need in this case. Have one side of the switch to “Tip”, the other side to “Ring” and then use “Sleeve” to the common prong of the switch.

Although I do not know what model of switch you are using, I’ll try to make a wiring schematic for you.

No sweat, I’ll look into this either tonight or tomorrow…

2 Likes

Now that is more than I expected!

I’ll get out and play with a soldering iron tomorrow and sort out what I need to do.

If it’s of any use I’m using the code from the Arduino wiki here as what I starting with: https://github.com/moddevices/cc-arduino-lib/blob/master/examples/ExpressionPedalToCC/ExpressionPedalToCC.ino

Simon

1 Like

Ok, it seems that you are using the Mod Control Chain with an Arduino Shield. I never looked at this library so I will have to study the sample code you are pointing to. I do not own a Mod Arduino Shield so I will not be able to test this but here’s what I think:

Need to add a 2nd port:
#define amountOfPorts 2

I would also rename port 0 and 1 with suitable names:

        case 0:
            actuator_config.name = "Volume";
            break;
        case 1:
            actuator_config.name = "Wah";
            break;

And the new “loop” function becomes:

void loop() {
// Since we have only 2 ports, it is safe to harcode. Port 0 = Volume and Port 1 = Wah
int aValue = analogRead(A0); // Read the value presented by the expression pedal
//if digital pin 4 (right side of the 3 way switch) is LOW, then assign the value of the expression pedal to port 0
if (digitalRead(4) == “LOW”) portValues[0] = aValue;
//if digital pin 5 (left side of the 3 way switch) is LOW, then assign the value of the expression pedal to port 1
if (digitalRead(5) == “LOW”) portValues[1] = aValue;

//Note: If both digital pins are LOW (3 way switch in the middle), both Volume and Wah will receive the same value

// this function always must be placed in your program loop
// it’s responsible for the control chain processing
cc.run();
}

2 Likes

That is awesome - I̶’l̶l̶ p̶l̶a̶y̶ t̶o̶m̶o̶r̶r̶o̶w̶!̶ I’ll play after the power is restored after it’s cut off for tree cutting :frowning:

2 Likes

Just tried the code, got an error on load “stray \342 in program” which turned out to be Unicode quotation marks rather than ASCII quotation marks (who knew?) - replaced them and the upload was fine, however there is no movement from the pedal wherever the switch is. I’ve wired the switch directly to the Arduino Shield, with the two outer pins going to Digital pins 4 and 5, but I’m not too sure where to attach the common - I’ve tried on both the 5v and the GND strips (not at the same time!) and neither give any response on the Dwarf.

Things that I’ve noticed and tried with the code are replacing int aValue = analogRead(A0) with int aValue = analogRead(0) (losing the ‘A’ in the analogRead command, to follow what seems to be given in the original code I had - no difference.

The wiring seems good on the switch, I’ve checked circuits from the Shield and everything seems to switch as expected.

Any ideas about where to go next?

Cheers

Simon

I’ve just tried throwing in a pinMode(4, INPUT_PULLUP); pinmode(5, INPUT_PULLUP); in the setup area to see if the digital pins needed to be set HIGH by default, but that had no effect. Basically I’m doing a learn coding by copying and pasting other folks code, but not successfully yet!

I’ve also reloaded the original code that I used to make sure the pedal is working properly and that seems fine. I’ve just rechecked the wiring of the switch - I’m linking digital pin 4 to one side, digital pin 5 to the other side and the GND bus that I linked the pedal socket to the common, so when the switch is on there is a circuit made between the selected digital pin and gnd (or both pins and gnd).

1 Like

As someone who works in software I can assure you you’re doing it like a professional. :joy:

6 Likes

The “A” in Arduino pin names is used to differentiate between the “analog” and “digital” pins. If you connected your expression pedal to pin “A0” then your code must use “A0” as the name for the pin. Any other pins between 1 and whatever you board has is for digital pins such as the ones used by your 3 way switch.

Now, I found an error in the code I gave you earlier:

if (digitalRead(4) == “LOW”) should be if (digitalRead(4) == LOW)

Sorry about that.

If this still does not resolve your issue, I would suggest at this point that you use an LED to help you debug the hardware part of your project. Depending on the Arduino model you use, you may be able to use the onboard LED (pin13) for this.

2 Likes

That cured it! The A is used in the pin names on the board, but as I’m using analogRead(0) in the code I’m guessing it already knows that it’s an analog pin, and analogRead(0) works. I needed to put in the pinMode(4, INPUT_PULLUP) and pinMode(5, INPUT_PULLUP) commands to ensure the values went back to HIGH otherwise I was getting the pedal moving both no matter where the switch was.

Thank you for all your input on this, I’ve learnt a lot about what this thing can do, and I’ll be able to work on more things to try in the future! (Which means I’ll probably be calling out for more help!)

After playing with it for a bit longer I realised that using && along with HIGH and LOW states I could turn it into a three way switch, using LOW/HIGH, HIGH/LOW and LOW/LOW to let me control 3 ports, now named BERT ERNIE and BOTH. The only problem I have with that now is that when moving through BOTH it set the value to whatever level the pedal is at at the moment - but it was more of a challenge to see if I could do it!

I like this Arduino thing!

2 Likes