Midi controller but only half of the potentiometer are working

Hi !

I've build a midi controller with 64 knobs, 8faders 1 arduino Méga using 4 multiplexer 74HC4067. As you can see on the schema below , fader are connected directly on arduino and works fine.

But for the potentiometer i'got a pb. half of them are not working. i'm using the software midi hairless to monitor the arduino midi output and I can see the reason why only the half of the pot are responding :

for one move on one pot i get 2 signals (ex: if i move the first potentiometer on hairless midi i can see : controler 0 value 120 and just after controler 1 valuee 120) and of course i'm looping on mux until iterator's value = 16.

But i dont know what is the reason of this signal duplication .

here is the code and the schema :


controlleur_mux.zip (1.2 KB)

Nice picture but a schematic it is not. You have no grounds, you have no power source. Posting a schematic would help a lot towards us solving your problem.

EDIT never mind, would make no difference:
EDIT or would it? I must now go take a nap, sry.

At a glance I do not see , oh wait! pot_1[i]

This

    MIDI.sendControlChange(i (+ something maybe), pot_1[i], MidiChannel);}}

appears three times while
    MIDI.sendControlChange(i+48, pot_4[i], MidiChannel);}}

appears once.

So some sloppy cut and paste code duplication?

All the other differences amongst the four nearly-identical functions are plausible.

BTW what do you have against the number 13? :wink:

a7

You say that Knob 0 changes both 0 and 1. Does Knob 2 change both 2 and 3? If so, it sounds like the low-order address but on the multiplexer is stuck low.

1 Like

Posting the code (in tags) would help people to help you as well.

Please describe what the intent of the below code is, your function reformatted. And pot_2 where it makes more sense than pot_1.

It will be called 1000s of times per second.

I don't know what if anything that has to do with your problem, I am just curious.

void potentiometers_2 ()
{
  /// MIDI CC = 16 ---> 31
  int i ;

  for (i = 0; i < 16; i++) {
  	pot_2[i] = muxANALOG_2.read(i);
    if (abs(pot_2[i] - OldPot_2[i]) > 3) {
      OldPot_2[i] = pot_2[i];
      pot_2[i] = pot_2[i] >> 3;
      MIDI.sendControlChange(i + 16, pot_2[i], MidiChannel);
    }
  }
}

BTW if this is a hit and run, that is once it works you are done with programming, that's cool. Otherwise it is time to go further into arrays - you already use them to good effect, one dimensional.

Using 2D arrays would make this more readable and fix/maintainable.

a7

Hehe ! indeed I had not seen this error. I made the correction but it has unfortunately no impact .

Exactly ! so when I get to the 8th knob I get a message controler 14 value ... controler 15 value...

not shure how long can the post be

do you knows a software that'is free to draw such schematic ?

Post your current code, it fits. Use the </> tool in the reply tool bar.

Have you tried leaving out the faders? Just comment out that line in the loop() function.

Did you fix pot_1 in three places? I agree I think it won’t fix anything, but it is wrong.

And I am still curios about the potentiometer_1 &c. functions, please describe what they are supposed to accomplish.

a7

yup i tried this but not changes.

#include "MUX74HC4067.h"
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();

MUX74HC4067 muxANALOG_1(0, 22, 24, 26, 28);  /// Multiplexer 1  ---> (NC,S0, S1, S2, S3)
MUX74HC4067 muxANALOG_2(0, 30, 32, 34, 36);  /// Multiplexer 2  ---> (NC,S0, S1, S2, S3)
MUX74HC4067 muxANALOG_3(0, 38, 40, 42, 44);  /// Multiplexer 3  ---> (NC,S0, S1, S2, S3)
MUX74HC4067 muxANALOG_4(0, 46, 48, 50, 52);  /// Multiplexer 4  ---> (NC,S0, S1, S2, S3)

/* POTENTIOMETRE */
int pot_1 [16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,12,14,15};
int OldPot_1 [16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,12,14,15};
int pot_2 [16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,12,14,15};
int OldPot_2 [16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,12,14,15};
int pot_3 [16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,12,14,15};
int OldPot_3 [16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,12,14,15};
int pot_4 [16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,12,14,15};
int OldPot_4 [16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,12,14,15};

/* FADER */
int Fader [8] = {0,1,2,3,4,5,6,7};
int OldFader [8] = {0,1,2,3,4,5,6,7};

/* MIDI_CHANNEL */
int MidiChannel = 1;


void setup() {

  MIDI.begin();
  //Serial.begin(115200); 
   Serial.begin(19200);
   
  /* MULTIPLEXER */  
  muxANALOG_1.signalPin(A0, INPUT, ANALOG); /// Multiplexer 1  ---> SIG
  muxANALOG_2.signalPin(A1, INPUT, ANALOG); /// Multiplexer 2  ---> SIG
  muxANALOG_3.signalPin(A2, INPUT, ANALOG); /// Multiplexer 3  ---> SIG
  muxANALOG_4.signalPin(A3, INPUT, ANALOG); /// Multiplexer 4  ---> SIG
}

void loop() {
  
  potentiometers_1();
  potentiometers_2();
  potentiometers_3();
  potentiometers_4();
  //faders();

}

void potentiometers_1 ()
{
  /// MIDI CC = 0 ---> 15
  int i ;
  for(i = 0; i < 16; i++)
  {pot_1[i] = muxANALOG_1.read(i);
  if (abs(pot_1[i] - OldPot_1[i]) > 3)
  {OldPot_1[i] = pot_1[i]; 
  pot_1[i] = pot_1[i] >> 3; 
  MIDI.sendControlChange(i, pot_1[i], MidiChannel);}}
}

void potentiometers_2 ()
{
  /// MIDI CC = 16 ---> 31
  int i ;
  for(i = 0; i < 16; i++)
  {pot_2[i] = muxANALOG_2.read(i);
  if (abs(pot_2[i] - OldPot_2[i]) > 3)
  {OldPot_2[i] = pot_2[i]; 
  pot_2[i] = pot_2[i] >> 3; 
  MIDI.sendControlChange(i+16, pot_2[i], MidiChannel);}}
}

void potentiometers_3 ()
{
  /// MIDI CC = 32 ---> 47
  int i ;
  for(i = 0; i < 16; i++)
  {pot_3[i] = muxANALOG_3.read(i);
  if (abs(pot_3[i] - OldPot_3[i]) > 3)
  {OldPot_3[i] = pot_3[i]; 
  pot_3[i] = pot_3[i] >> 3; 
  MIDI.sendControlChange(i+32, pot_3[i], MidiChannel);}}
}

void potentiometers_4 ()
{
  /// MIDI CC = 48 ---> 63
  int i ;
  for(i = 0; i < 16; i++)
  {pot_4[i] = muxANALOG_4.read(i);
  if (abs(pot_4[i] - OldPot_4[i]) > 3)
  {OldPot_4[i] = pot_4[i]; 
  pot_4[i] = pot_4[i] >> 3; 
  MIDI.sendControlChange(i+48, pot_4[i], MidiChannel);}}
}


void faders()
{
  int i; 
  
  {i = 0;
  Fader[i] = analogRead(A8);
  if (abs(Fader[i] - OldFader[i]) > 3)
  {OldFader[i] = Fader[i]; 
  Fader[i] = Fader[i] >> 3; 
  MIDI.sendControlChange(64+i, Fader[i], MidiChannel);}
  }

  {i = 1;
  Fader[i] = analogRead(A9);
  if (abs(Fader[i] - OldFader[i]) > 3)
  {OldFader[i] = Fader[i]; 
  Fader[i] = Fader[i] >> 3; 
  MIDI.sendControlChange(64+i, Fader[i], MidiChannel);}
  }

  {i = 2;
  Fader[i] = analogRead(A10);
  if (abs(Fader[i] - OldFader[i]) > 3)
  {OldFader[i] = Fader[i]; 
  Fader[i] = Fader[i] >> 3; 
  MIDI.sendControlChange(64+i, Fader[i], MidiChannel);}
  }

  {i = 3;
  Fader[i] = analogRead(A11);
  if (abs(Fader[i] - OldFader[i]) > 3)
  {OldFader[i] = Fader[i]; 
  Fader[i] = Fader[i] >> 3; 
  MIDI.sendControlChange(64+i, Fader[i], MidiChannel);}
  }

  {i = 4;
  Fader[i] = analogRead(A12);
  if (abs(Fader[i] - OldFader[i]) > 3)
  {OldFader[i] = Fader[i]; 
  Fader[i] = Fader[i] >> 3; 
  MIDI.sendControlChange(64+i, Fader[i], MidiChannel);}
  }

  {i = 5;
  Fader[i] = analogRead(A13);
  if (abs(Fader[i] - OldFader[i]) > 3)
  {OldFader[i] = Fader[i]; 
  Fader[i] = Fader[i] >> 3; 
  MIDI.sendControlChange(64+i, Fader[i], MidiChannel);}
  }

  {i = 6;
  Fader[i] = analogRead(A14);
  if (abs(Fader[i] - OldFader[i]) > 3)
  {OldFader[i] = Fader[i]; 
  Fader[i] = Fader[i] >> 3; 
  MIDI.sendControlChange(64+i, Fader[i], MidiChannel);}
  }

  {i = 7;
  Fader[i] = analogRead(A15);
  if (abs(Fader[i] - OldFader[i]) > 3)
  {OldFader[i] = Fader[i]; 
  Fader[i] = Fader[i] >> 3; 
  MIDI.sendControlChange(64+i, Fader[i], MidiChannel);}
  }
  
}

It seems like your code would produce a constant high volume of MIDI traffic, which I think should be OK, but for testing you might place a small delay(50) after the MIDI.sendControlChange call in all potentiometers_N functions.

Another idea would be to MIDI.sendControlChange on just two potentiometers, one and another that it has been seen to trigger, like 8 and 14 or 15 from your description.

It sounds and looks here in print (!) that you have a wiring or power issue. Code looks plausible, even if the pot/OldPot stuff looks very odd.

a7

   ***???***

delay change nothing (i tested on one). But your second idea is interresting, i'm gonna test this.

Why are you not using the 'Pot' object included in V1.2 of the Controller.h library? It supports pots connected through multiplexers as well as pots connected directly to analog inputs (your sliders). You'd have to change your wiring a bit because it assumes all MUX's are addressed by pins 2, 3, 4, and 5.

1 Like

it could be a solution too

So ! i've removed the loop and set iterator to specific value for example 15 and surprinsigly the 15'th potientiometer is still the one that is on CH7 unstead of CH15 (the 8th pot). As the value of my iterator is defined i get only one signal this time. I will do some change but i will maybe regroupe all adressing input together to connect them only on 4 pin of the board.

void potentiometers_1 ()
{
  /// MIDI CC = 0 ---> 15
  int i=15 ;
  
  //for(i = 0; i < 16; i++)
 // {
  pot_1[i] = muxANALOG_1.read(i);
  if (abs(pot_1[i] - OldPot_1[i]) > 3)
  {OldPot_1[i] = pot_1[i]; 
  pot_1[i] = pot_1[i] >> 3; 
  MIDI.sendControlChange(i, pot_1[i], MidiChannel);
  delay(50);}
  //}
}

tl;dr: you have a wiring error somewhere.

Good idea, it's sorta the whole thing about multiplexing - I would be surprised if the library did not support using the same address pins for more than one MUX74HC4067 object.

Assuming, however, that 1) you haven't a wiring error, and 2) there is nothing special about any of the i/o pins you've wired as multiplexor address lines, this should not change the behavior of your system.

Which is why I think you looking at some difference between your schematic and reality. So if that change dose fox it, it might mean you inadvertently corrected a wiring error.

a7

1 Like

There are a lot of them free for the downloading. I use KiCad and it is great. A bit hard to use at first but it does a great job. The hard part is doing the PCBs and footprints. There are some great libraries.