Ableton Live USB Midi Controller With Arduino MEGA #2

Hello people I was working on a prototype for a MIDI controller for Ableton Live Before ..
The project had a lot of mess and everything was super complicated and I had a lot of noise in the signal


I adjusted the design again and made everything modular so it can be replaceable and tested every single component in the whole circuit .. but this time noise in the signal is too much and even buttons are distorted for no reason and after programming the LEDs to respond to certain notes .. once the device is plugged in all LEDs turn on for no reason and keep on all time while they should turn on only when I press the note button

Note : the chip itself sends random messages whenever something gets closer to it even without connecting any wires or buttons
Note : I downgraded the VCC from 5V to 3V3 and it's sending noisy signals
The Device : -

8 instruments with volumes, AUXs, 2 control knobs for decay or else, 16 step sequencer, 2 FX control & 6 buttons for navigation and general control

The Code

#include <Control_Surface.h>

HairlessMIDI_Interface midi;

CD74HC4067 M1 = { A4, {2, 4, 6, 8} }; //Analog Input
CD74HC4067 M2 = { A6, {2, 4, 6, 8} }; //Analog Input
CD74HC4067 M3 = { A8, {2, 4, 6, 8} }; //Analog Input
CD74HC4067 M4 = { A2, {2, 4, 6, 8} }; //Digital Input (Sequencer)
CD74HC4067 M5 = { A0, {2, 4, 6, 8} }; //Digital Input (Banks & Instruments)

CCPotentiometer Potentiometers[] = {
    { M1.pin(0), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_1} }, 
    { M1.pin(1), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_1} },
    { M1.pin(2), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_1} },
    { M1.pin(3), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_1} },
    { M1.pin(4), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_1} },
    { M1.pin(5), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_1} },
    { M1.pin(6), {MIDI_CC::General_Purpose_Controller_7, CHANNEL_1} },
    { M1.pin(7), {MIDI_CC::General_Purpose_Controller_8, CHANNEL_1} },
    
    { M1.pin(8), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_2} }, 
    { M1.pin(9), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_2} },
    { M1.pin(10), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_2} },
    { M1.pin(11), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_2} },
    { M1.pin(12), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_2} },
    { M1.pin(13), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_2} },
    { M1.pin(14), {MIDI_CC::General_Purpose_Controller_7, CHANNEL_2} },
    { M1.pin(15), {MIDI_CC::General_Purpose_Controller_8, CHANNEL_2} },

    { M2.pin(0), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_3} }, 
    { M2.pin(1), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_3} },
    { M2.pin(2), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_3} },
    { M2.pin(3), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_3} },
    { M2.pin(4), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_3} },
    { M2.pin(5), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_3} },
    { M2.pin(6), {MIDI_CC::General_Purpose_Controller_7, CHANNEL_3} },
    { M2.pin(7), {MIDI_CC::General_Purpose_Controller_8, CHANNEL_3} },
    
    { M2.pin(8), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_4} }, 
    { M2.pin(9), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_4} },
    { M2.pin(10), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_4} },
    { M2.pin(11), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_4} },
    { M2.pin(12), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_4} },
    { M2.pin(13), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_4} },
    { M2.pin(14), {MIDI_CC::General_Purpose_Controller_7, CHANNEL_4} },
    { M2.pin(15), {MIDI_CC::General_Purpose_Controller_8, CHANNEL_4} },

    { M3.pin(0), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_5} }, 
    { M3.pin(1), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_5} },
    { M3.pin(2), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_5} },  
    { M3.pin(3), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_5} },
    { M3.pin(4), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_5} },
    { M3.pin(5), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_5} },
    { M3.pin(6), {MIDI_CC::General_Purpose_Controller_7, CHANNEL_5} },
    { M3.pin(7), {MIDI_CC::General_Purpose_Controller_8, CHANNEL_5} },
   
    { M3.pin(8), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_6} }, 
    { M3.pin(9), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_6} },
    { M3.pin(10), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_6} },
    { M3.pin(11), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_6} },
    { M3.pin(12), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_6} },
    { M3.pin(13), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_6} },
    { M3.pin(14), {MIDI_CC::General_Purpose_Controller_7, CHANNEL_6} },
    { M3.pin(15), {MIDI_CC::General_Purpose_Controller_8, CHANNEL_6} },

    { A10, {MIDI_CC::Foot_Controller , CHANNEL_1} }, //PEDAL
};

  NoteButton buttons[] = {
    { M4.pin(0),{10, CHANNEL_1} }, // Step 1
    { M4.pin(1),{11, CHANNEL_1} }, // Step 2
    { M4.pin(2),{12, CHANNEL_1} }, // Step 3
    { M4.pin(3),{13, CHANNEL_1} }, // Step 4
    { M4.pin(4),{14, CHANNEL_1} }, // Step 5
    { M4.pin(5),{15, CHANNEL_1} }, // Step 6
    { M4.pin(6),{16, CHANNEL_1} }, // Step 7
    { M4.pin(7),{17, CHANNEL_1} }, // Step 8
    { M4.pin(8),{18, CHANNEL_1} }, // Step 9
    { M4.pin(9),{19, CHANNEL_1} }, // Step 10
    { M4.pin(10),{20, CHANNEL_1} }, // Step 11
    { M4.pin(11),{21, CHANNEL_1} }, // Step 12
    { M4.pin(12),{22, CHANNEL_1} }, // Step 13
    { M4.pin(13),{23, CHANNEL_1} }, // Step 14
    { M4.pin(14),{24, CHANNEL_1} }, // Step 15
    { M4.pin(15),{25, CHANNEL_1} }, // Step 16

    { M5.pin(0),{35, CHANNEL_2} }, //Instrument 1
    { M5.pin(1),{36, CHANNEL_2} }, //Instrument 2
    { M5.pin(2),{37, CHANNEL_2} }, //Instrument 3
    { M5.pin(3),{38, CHANNEL_2} }, //Instrument 4
    { M5.pin(4),{39, CHANNEL_2} }, //Instrument 5
    { M5.pin(5),{40, CHANNEL_2} }, //Instrument 6
    { M5.pin(6),{41, CHANNEL_2} }, //Instrument 7
    { M5.pin(7),{42, CHANNEL_2} }, //Instrument 8
};


CCButton Buttons[] = {
    { M5.pin(8), {MIDI_CC::General_Purpose_Controller_1, CHANNEL_7} },  
    { M5.pin(9), {MIDI_CC::General_Purpose_Controller_2, CHANNEL_7} },  
    { M5.pin(10), {MIDI_CC::General_Purpose_Controller_3, CHANNEL_7} }, 
    { M5.pin(11), {MIDI_CC::General_Purpose_Controller_4, CHANNEL_7} }, 
    { M5.pin(12), {MIDI_CC::General_Purpose_Controller_5, CHANNEL_7} }, 
    { M5.pin(13), {MIDI_CC::General_Purpose_Controller_6, CHANNEL_7} }, 
    { M5.pin(14), {MIDI_CC::General_Purpose_Controller_7, CHANNEL_7} }, 
    { M5.pin(15), {MIDI_CC::General_Purpose_Controller_8, CHANNEL_7} }, 
};

  SPIShiftRegisterOut<24> sreg {
  14,       // Latch pin (ST_CP)
  MSBFIRST, // Byte order
};
 
// Create an array of LEDs that listen to MIDI Note messages, turning on and off
// the LEDs connected to the eight output pins of the shift register
 NoteValueLED leds[]{
  {sreg.pin(0),{35, CHANNEL_1} }, // Instrument 1   // LED pin, address (note number, channel, cable)
  {sreg.pin(1),{36, CHANNEL_1} }, // Instrument 2
  {sreg.pin(2),{37, CHANNEL_1} }, // Instrument 3
  {sreg.pin(3),{38, CHANNEL_1} }, // Instrument 4
  {sreg.pin(4),{39, CHANNEL_1} }, // Instrument 5
  {sreg.pin(5),{40, CHANNEL_1} }, // Instrument 6
  {sreg.pin(6),{41, CHANNEL_1} }, // Instrument 7
  {sreg.pin(7),{42, CHANNEL_1} }, // Instrument 8
  
  {sreg.pin(8),{18, CHANNEL_1} }, // Step 9
  {sreg.pin(9),{19, CHANNEL_1} }, // Step 10
  {sreg.pin(10),{20, CHANNEL_1} }, // Step 11
  {sreg.pin(11),{21, CHANNEL_1} }, // Step 12
  {sreg.pin(12),{22, CHANNEL_1} }, // Step 13
  {sreg.pin(13),{23, CHANNEL_1} }, // Step 14
  {sreg.pin(14),{24, CHANNEL_1} }, // Step 15
  {sreg.pin(15),{25, CHANNEL_1} }, // Step 16
  
  {sreg.pin(16),{10, CHANNEL_2} }, //Step 1
  {sreg.pin(17),{11, CHANNEL_2} }, //Step 2
  {sreg.pin(18),{12, CHANNEL_2} }, //Step 3
  {sreg.pin(19),{13, CHANNEL_2} }, //Step 4
  {sreg.pin(20),{14, CHANNEL_2} }, //Step 5
  {sreg.pin(21),{15, CHANNEL_2} }, //Step 6
  {sreg.pin(22),{16, CHANNEL_2} }, //Step 7
  {sreg.pin(23),{17, CHANNEL_2} }, //Step 8
  
};


void setup() {
   Control_Surface.begin();
   
}

void loop() {
    Control_Surface.loop();
 
}

I need help in :
1 - programming the 16 buttons and the 16 LEDs to work as a 16 step sequencer automatically
2 - eliminate the unreasonable noise coming out of the chip that prevents me from doing anything
.
Thanks in advance.

Nice looking object.

Why did you drop the voltage, that will increase the noise?
The Mega uses 5V, but it looks like you are using some sort of clone.

I can’t see any capacitors though. You need a 0.1uF ceramic capacitor between power and ground for each multiplexer chip, and also one every four or so pots on the power and ground . In addition I would have a 1uF or so capacitor on each pot between wiper and ground. That will go a long way to reducing the noise.

As to the code, when you find yourself writing almost the same thing line after line, it is time to start using arrays and for loops.

I don’t use that control library so I am unable to comment on how to convert it to a sequencer, but it is simple enough to do that without a library.

1 Like

Thanks a lot for your response ..

According to the design I actually design equipment but this is the first time to try making one :joy:

About the voltage I lowered it thinking that it would help but looks like I'm not right :joy: so it's still noisy ..

I'm using a clone for a smaller size chip inside the device housing so I can save some space

The device has 5 multiplexers, 48 pots, 24 Buttons and 24 LEDs ..
How many capacitors should I use ? And where exactly to connect them ?

From what you said it will take around 5 capacitors for the multiplexers, 48 capacitors for the 48 pots, and additional capacitors every 4 pots which is around extra 12 capacitors .. total of 65 capacitors
Can't you see that it's too many ? :joy:

And about the code if you have any other way to program the sequencer it will help me a lot I can mix between libraries and codes to get the best out of it :smiley:

Do you want it to work or not?

It is a big project with a lot of parts, you can’t just ignore decoupling capacitors. The bigger the project the more they are needed, and the more you have to use.

I did say where they should be.
Between power and ground on each multiplexing chip, and get the capacitors as close to the chips as you can. I can’t actually see those chips so I don’t know if they are on a board or not. If they are on some sort of board it is likely that board has decoupling capacitors on them already. Can you send a link or photograph of exactly what you have?

The supply to the pots are chained, that means any noise on the pot’s supply is passed on to them all. What value are the pots, they should be about 10K for optimum results. You should use a combination of a 0.1uF ceramic capacitor in parallel with a larger one say 1uF to 47uF. Finally I would put a 0.1uF ceramic between each wiper and ground.
The buttons and LEDs do not need them although I would put a few large ones 100uF + between the power distribution wires in your system.

How are your push buttons wired? Are you using the internal pull up resistors? If so I would add extra 1K external pull up resistors. If you are using pull down resistors then don’t and swap the wiring ( and the software ) to use pull up resistors.

Here is a link to help you understand about decoupling supplies
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

Scaling up electronics requires a lot of extra things that are not so critical at a lower level of complexity.

Are you using the multiplexers to drive the LEDs? If so that is a very bad design decision and is probably the main source of your noise.

ok I will use them then

I'm using CD74HC4067 16-Channel Analog Digital Multiplexer Breakout Board

all of them are 10K already

I will do that ..
1 capacitor between all grounds and wipers and between GND and 5V pins

my push buttons are all just switches and I didn't have such problem in the old device and buttons were perfectly responding with no use of any resistors

No I'm using 3 daisy chained shift registers and each led has 220 Ohm Resistor

I've seen a producer making a similar controller with no single capacitor and no one told me about it when I asked about the old design which made me a little confused :joy::joy::joy::joy:

Sorry I'm not an electronic engineer .. it's my hobby to make things and this will be a turning point in my life If I made it right you know .. sorry for asking too much :sweat_smile::sweat_smile:

OK if you look at that board you will see a component next to the G of the GND that brown component is a 0.1uF ceramic capacitor so that is fine.

So does that mean you wire the button between input and ground and you enable the pull up resistors?

yeah .. the input pin from the multiplexer connected to the button and the other side to GND
there's a common 5V & GND for all buttons & pots and common 5V & GND for all chips and ICs
this way I'm gonna add 0.1 uF capacitors to all pots and one between GND and 5V every 4 pots

If you know anything about the sequencer code please tell me
and I coded the LEDs to light up responding to certain notes and they don't do that
I don't know what's wrong

I have not used the control_surface library but it is maintained by @PieterP - lets see if this summons him.

1 Like

This is not something that the library supports. It can help you in the sense that you can reuse the Button class for debouncing the inputs and the midi.sendNoteOn(...) functions for MIDI communication etc., but you'll have to program the actual logic of the sequencer yourself.

Regarding the other issues you're having, I think the sketch is way too long. You should test individual components, not all at once. In one of your previous threads, I believe we discussed ways to use the AnalogReadSerial sketch to verify that the potentiometers can be read correctly, or Blink to test the LEDs and so on.

1 Like

I've already did that and tested every multiplexer separately and found 12 faulty pots out of the 48 pots .. and LEDs aren't responding to anything however they're connected correctly and responding as a chain when I upload a code ..
I will use capacitors then see what's going on ..
And there are some non responding pots and buttons however they are responding very well on the multimeter and connected correctly with no mistakes this time ...
I've done every single thing you told me about before