Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Help needed for coding a Teensy 3.2 With MUxes and FSRs to resurrect an old Hammond

  1. #1
    Junior Member
    Join Date
    Oct 2019
    Posts
    3

    Help needed for coding a Teensy 3.2 With MUxes and FSRs to resurrect an old Hammond

    Somehow, at some point, some weeks ago, I pictured myself with a kaputt Hammond from the 70s with 88 keys somehow repaired and even converted to the MIDI religion. That happened maybe one week ago, while I found out that some midi could be not bad as an additional protocol for a musical project that Im currently developing. So, I discovered that the best way would be the Teensy and I went for it even knowing that I would have to better have some notions of programming which i knew i just didnt have, and that already deciding to try to acquire them if it would be extremely necessary to maybe really acquire them for really being able to fulfill the ambicious obsession of conveying the dusty soul of the hammond into a Midified corpse.
    So, I guess I have the elements (Teensy 3.2, Multiplexers, cables, 10K resistors, Kraft, etc) and I have aswell a week of info from here and other places and tryouts by trying to mix one of the codes I found from Oddson for MUXes with potentiometers and buttons with some multiplexers and another code from this same forum (that I modified a bit) about some Force sensitive Resistors working as triggers of notes with sensibility. The problem is this: I just cannot get this code (below) work with the other code (more below) even that I tried to tweak it (not really knowing the sources or really understanding the source or the functions of certain symbols of the code) so far achieving all sorts of crazy behaviours from the midi electric piano vst and another midi-thing, mostly related to triggering just all the 16 notes of one of the 74hc4076 MUX (only one for trying out) by pressing only one of the multiplexed analog inputs and shaping like this only odd strange eclectic melodies that were playd by itself or by a rather invisible entity rather than me and other weird things like emulating some sort of sinthetizersounds.. which I liked and not at the same time, and so on...

    This are the codes (I would really apreciate some help with this. since Im really far from being a programmer even though I really like playing with keys)

    IVe tryied withe THE MUX ONE (from Oddson) ....
    Code:
    //************LIBRARIES USED**************
    // include the ResponsiveAnalogRead library for analog smoothing
    #include <ResponsiveAnalogRead.h>
    #include <Bounce.h>  // need the bounce library to stabilize signals from switch contacts
    //usbMIDI.h library is added automatically when code is compiled as a MIDI device
    
    // ******CONSTANT VALUES******** 
    // customize code behaviour here!
    
    //**TIMING -- higher is more stable, lower more responsive
    const int muxTimeMin = 500; // minimum micro-seconds between MUX reads - 500 = half a millisecond!
    const int BOUNCE_TIME = 15; // max time before the physical contacts of switches settle. 
    
    //**HARDWARE
    const int MUX_PINS = 16; // number of MUX Channnels
    //mux control out pin assignement
    const int pin_Out_S0 = 0;
    const int pin_Out_S1 = 1;
    const int pin_Out_S2 = 2;
    const int pin_Out_S3 = 3;
    //data from mux pin assignement
    const int pin_In_Mux1 = A1;
    const int pin_In_Mux2 = A2;
    const int pin_In_Mux3 = 4; // data pin of 'digital' MUX
    
    //**MIDI 
    const int channel = 1; // MIDI channel
    const int CCID1[MUX_PINS] = {21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36}; // CC (D1) values for analog MUX one
    const int CCID2[MUX_PINS] = {41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56}; // CC (D1) values for analog MUX two
    const int note[MUX_PINS] = {48,49,50,54,52,53,54,55,56,57,58,59}; // note values for MUX3 (digital section)
    const int ON_VELOCITY = 105; // note velocity for note on events
    
    
    //******VARIABLES***********
    
    // a data array and a lagged copy to tell when MIDI changes are required
    byte data1[MUX_PINS];
    byte data1Lag[MUX_PINS]; // when lag and new are not the same then update MIDI CC value
    
    //amd again for second MUX
    byte data2[MUX_PINS];
    byte data2Lag[MUX_PINS]; // ditto
    
    //third mux don't need memory!
    
    //NB - index variable i is incremented and rolled over manually inside the main loop so that on each pass one MUX pin is read.
    byte i=0; // global index for MUX channel reads 
    
    
    //****** TIMER VARIABLE *** change scale here!
    elapsedMicros muxUpdated; // switch to micros to run at speed and tune with muxTimeMin setting above
    //elapsedMillis muxUpdated; // switch to millis to troubleshoot 
    
    //************INITIALIZE LIBRARY OBJECTS**************
    // initialize the ReponsiveAnalogRead objects
    ResponsiveAnalogRead analog1[]{
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true},
      {pin_In_Mux1 ,true}
    }; 
    
    ResponsiveAnalogRead analog2[]{
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true},
      {pin_In_Mux2 ,true}
    }; 
    // initialize the bounce objects all to the same MUX data pin
    Bounce digital[] =   {
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME), 
      Bounce(pin_In_Mux3,BOUNCE_TIME)
    }; 
    
    //************SETUP**************
    void setup() {
      //! don't forget to set for output!
      pinMode(pin_Out_S0, OUTPUT);
      pinMode(pin_Out_S1, OUTPUT);
      pinMode(pin_Out_S2, OUTPUT);
      pinMode(pin_Out_S3, OUTPUT);
    }
    
    //************LOOP**************
    void loop() {
      nextMUXpin();
      while (usbMIDI.read()) {
         // controllers must call .read() to keep the queue clear even if they are not responding to MIDI
      }
    }
    
    
    //************MUX SECTION**************
    void nextMUXpin(){  
      if (muxUpdated>muxTimeMin) {  
        // update the ResponsiveAnalogRead object every loop
    
    // read PIN i of MUX 1
        analog1[i].update(); 
        // if the repsonsive value has change, print out 'changed'
        if(analog1[i].hasChanged()) {
          data1[i] = analog1[i].getValue()>>3;
          if (data1[i] != data1Lag[i]){
            data1Lag[i] = data1[i];
            usbMIDI.sendControlChange(CCID1[i], data1[i], channel);
          }
        }  
    
    
    // read PIN i of MUX 2
        analog2[i].update(); 
        // if the repsonsive value has change, print out 'changed'
        if(analog2[i].hasChanged()) {
          data2[i] = analog2[i].getValue()>>3;
          if (data2[i] != data2Lag[i]){
            data2Lag[i] = data2[i];
            usbMIDI.sendControlChange(CCID2[i], data2[i], channel);
          }
        }
    
    // read PIN i of MUX 3 (DIGITAL!)
        digital[i].update();
          if (digital[i].fallingEdge()) {
            usbMIDI.sendNoteOn(note[i], ON_VELOCITY, channel);  
          }
          // Note Off messages when each button is released
          if (digital[i].risingEdge()) {
            usbMIDI.sendNoteOff(note[i], 0, channel);  
          }
        }
        
        //reset timer
        muxUpdated = 0; 
        //increment index
        i++;
        if (i>15)   {i=0;}      
        // set mux control pins for next pass
        digitalWrite(pin_Out_S0, HIGH && (i & B00000001));
        digitalWrite(pin_Out_S1, HIGH && (i & B00000010));
        digitalWrite(pin_Out_S2, HIGH && (i & B00000100));
        digitalWrite(pin_Out_S3, HIGH && (i & B00001000));
      }


    (THE FSR ONE)
    Code:
    #include <ResponsiveAnalogRead.h>
    
    const int pinCount = 1;
    const int velocityThreshold = 45;
    const int afterThreshold = 50;
    const int velocityTime = 500;
    const int afterTime = 2500;
    const int defaultMax = 100;
    const float chargeTime = 1; //rise time for external capacitors in us.
    int VELMASK = 0;
    int ATMASK = 0;
    
    ResponsiveAnalogRead pinReader[pinCount] = {
      ResponsiveAnalogRead(A4,true),
     
    };
    int pin[] = {A4};
    int note[] = {38};       //MIDI notes
    const int midiMin = 20;
    
    int pinMin[pinCount];
    int pinMax[pinCount];
    int pinTimer[pinCount];
    
    
    
    void setup() {
      Serial.begin (32500);
    }
    
    void loop () {
      for (int i = 0; i < pinCount; i++) {
           pinReader[i].update();
        int value = pinReader[i].getValue();
        int velocity = map (value, 0, 800, midiMin, 127);
        int aftertouch = map (value, 0, 800, midiMin, 127);
           if (value > velocityThreshold) 
         {
          pin[i] ++;
          if (!(VELMASK & (1 << i)) && (pin[i] == velocityTime)) {
            usbMIDI.sendNoteOn (note[i], velocity, 1);
            VELMASK |= (1 << i);
            pin[i] = 0;
            
           }
          if (pin[i] == afterTime) {
            usbMIDI.sendPolyPressure (note[i], aftertouch, 1);
            pin[i] = 0;
           }
        }
        else {
          if (VELMASK & (1 << i)) {
            usbMIDI.sendNoteOff (note[i], 0, 1);
            VELMASK &= ~ (1 << i);
            pin[i] = 0;
          }
        }
      }
    }

    And as well with this other code that already contains my sort of interaction with it (which consisted mostly in copy past and then tweaking it till I could understand a bit more and more getting excited with it till I didnt have no clue anymore and getting very frustrated by it) (Originally the code its supposed to be for more than one MUX and for POTS and BUTTONS but I reduced it into 1 MUX of 16 inputs for Testing (6 connected to homemade FSRs that worked so far with the first code above and without the multiplexer, and with this one (one MUX) being just peaks of voltage going up after some aplied pressure according to the Serial Plotter of the Arduino... and being just the sixteen notes of the array Note[A_PINS] played very fast one after another or in weird secuences after pressing one single FSR sensor... and the same with each one of them...

    Code:
    // ******CONSTANT VALUES******** 
    // customize code behaviour here!
    const int muxTimeMin = 50; // minimum micro-seconds between MUX reads
    const int channel = 0; // MIDI channel
    const int A_PINS = 16; // number of Analog PINS (these are now MUX pins)
    // define the CC ID numbers on which to send them..
    const int Note[A_PINS] = {51,52,53,54,55,56,57,58,59,20,31,55,39,34,35,36}; // set your own CC values for the 16 MUX pins
    int midiMin = 20;
    const int dbt = 100; // a threshold value for how big the dead-band is before recalc
    const int velocityTime = 80;
    const int afterTime = 1500;
    const int defaultMax = 100;
    const float chargeTime = 1; //rise time for external capacitors in us.
    int VELMASK = 0;
    int ATMASK = 0;
    int VELTHRESH = 0;
    
    //******VARIABLES***********
    //mapping of mux to teensy digital pins
    int pin_Out_S0 = 1;
    int pin_Out_S1 = 2;
    int pin_Out_S2 = 3;
    int pin_Out_S3 = 4;
    int pin_In_Mux1 = {A4};
    //the state of the mux channels(initialized to zero)
    int Mux1_State[16] = {0};
    int Mux1_State_Lagged[16] = {0};
    elapsedMicros mux1Updated;
    //elapsedMillis mux1Updated; // switch to millis to troubleshoot 
    byte i = 0; // index for mux loop
    
    
    void setup() {
      //! don't forget to set for output!
      pinMode(pin_Out_S0, OUTPUT);
      pinMode(pin_Out_S1, OUTPUT);
      pinMode(pin_Out_S2, OUTPUT);
      pinMode(pin_Out_S3, OUTPUT);
    }
    
    //************LOOP**************
    void loop() {
      getMUX1Data();
      // other work here... mux is called once in each loop rather than updating all in every loop
      while (usbMIDI.read()) {
         // controllers must call .read() to keep the queue clear even if they are not responding to MIDI
      }
    }
    
    
    //************MUX1 SECTION**************
    void getMUX1Data(){  
      if (mux1Updated>muxTimeMin) 
      delayMicroseconds(80);
        
      {
    
         Mux1_State[i] = analogRead(pin_In_Mux1);
    
          if(abs(Mux1_State[i] - Mux1_State_Lagged[i]) > dbt ) {
          (Mux1_State_Lagged[i] = Mux1_State[i]);
          int velocity = map (Mux1_State[i]>>3, 0, 800, midiMin, 127);
          int aftertouch = map (Mux1_State[i]>>3, 0, 800, midiMin, 127);
          if ((VELMASK & (2 << Mux1_State[i])) && (Mux1_State[i]>>3 == velocityTime)) {
            usbMIDI.sendNoteOn (Note[i], velocity, channel);
            
            
            }
          if (Mux1_State[i]>>3 == afterTime) {
            usbMIDI.sendPolyPressure (Note[i], aftertouch, channel);
            
            }
        }
        else {
          if (VELMASK & (1 << Mux1_State[i]>>3)) {
            usbMIDI.sendNoteOff (Note[i], 0, channel);
            VELMASK = (1 << Mux1_State[i]);
             
             }                 
            serialPringMIDIdata(); // use to troublshoot
            
             
       delayMicroseconds(50);
                  
               }  
    
     
         
      
    //reset timer
        mux1Updated = 0; 
        //increment index
        i++;
        if (i>15)   {i=0;}
        // set mux control pins for next pass
        digitalWrite(pin_Out_S0, HIGH && (i & B00000001));
        digitalWrite(pin_Out_S1, HIGH && (i & B00000010));
        digitalWrite(pin_Out_S2, HIGH && (i & B00000100));
        digitalWrite(pin_Out_S3, HIGH && (i & B00001000));
      }
    }
    
    // ****useful for debugging, comment out function call to run full speed
    void serialPringMIDIdata(){
      Serial.print(i,DEC);
      Serial.print(" :");
      Serial.print(HIGH && (i & B00000001),BIN);
      Serial.print(HIGH && (i & B00000010),BIN);
      Serial.print(HIGH && (i & B00000100),BIN);
      Serial.print(HIGH && (i & B00001000),BIN);
      Serial.print(" MUX_PIN: ");
      Serial.print(i,DEC); 
      Serial.print(" Note: ");
      Serial.print(Note[i],DEC); 
      Serial.print(" MUX1 HEX: ");
      Serial.println(Mux1_State[i],HEX);  
    }
    Thanks in advance !

  2. #2
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,237
    That FSR code is using the main loop speed as a timing feature.

    Polling for elapsed time is preferred.

    Also I think some of your changes may be obscuring how this is supposed to work.

    Can you point to the source of this code?

  3. #3
    Junior Member
    Join Date
    Oct 2019
    Posts
    3
    THE source FSR code is from Adrian and this sort of old topic :https://forum.pjrc.com/threads/31797...IDI-controller
    Original Code:
    Code:
    int FSRpin[] = {A9, A1};      //number of FSRs, and the relevant analog pins ...
    const int FSRs = 2;           //making the sensors is pretty cheap and easy ... see the photos ...
    int Note [] = {63, 64};       //MIDI note numbers ... listed in order of FSRpin
    int counter [FSRs];
    int VELMASK = 0;
    int ATMASK = 0;
    int AFTERTHRESH = 50;          //analog sensor value above which aftertouch messages are sent
    
    int THRESH = 45;               //analog sensor value above which note / velocity is recognised
    
    int VELTIME = 500;              /*counter value at which point velocity is sampled ...
                                    counter is zero when first touched, velocity is sampled X ticks later
                                    500 ticks sounds like a lot, but the teensy LC is clocked at 48Mhz       */
    
    int AFTERTIME = 2500;           /*counter value at which point aftertouch is sampled ...
                                    every X ticks of a touch, until released ...
                                    you don't want too many aftertouch messages per touch, and 2500 gives a surprising number */
    
    int MIDIMIN = 20;             //bottom MIDI value for the MIDI velocity AND aftertouch messages
    void NoteOnSend (int);
    void PolyTouchSend (int);
    
    void setup()
    
    {
      Serial.begin (32500);
    }
    
    void loop ()
    
    {
      for (int i = 0; i < FSRs; i++)
      {
        int FSRRead = analogRead(FSRpin[i]);
        if (FSRRead > THRESH)
        {
          counter[i] ++;
          if (!(VELMASK & (1 << i)) && (counter[i] == VELTIME)) {
            VELMASK |= (1 << i);
            counter [i] = 0;
            NoteOnSend (i);
          }
          if (counter [i] == AFTERTIME) {
            counter [i] = 0;
            PolyTouchSend(i);
          }
        }
        else {
          if (VELMASK & (1 << i)) {
            usbMIDI.sendNoteOff (Note[i], 0, 1);
            VELMASK &= ~ (1 << i);
            counter [i] = 0;
          }
        }
      }
    }
    
    void NoteOnSend (int j)
    {
      int FSRRead = analogRead(FSRpin [j]);
      int velocity = map (FSRRead, 0, 800, MIDIMIN, 127);
      usbMIDI.sendNoteOn (Note[j], velocity, 1);
    }
    
    void PolyTouchSend (int j)
    {
      int FSRRead = analogRead(FSRpin [j]);
      if (FSRRead > AFTERTHRESH) {
        int aftertouch = map (FSRRead, 0, 800, MIDIMIN, 127);
        usbMIDI.sendPolyPressure (Note[j], aftertouch, 1);
      }
    }
    AND, this is how Im going so far but Im pretty much stucked in these midi events: which means one single note is behaving like crazy after I barely touch one fsr sensor
    Click image for larger version. 

Name:	fsr.jpg 
Views:	2 
Size:	84.0 KB 
ID:	18019

    This is the code I have so far:
    Code:
    //************LIBRARIES USED**************
    // include the ResponsiveAnalogRead library for analog smoothing
    #include <ResponsiveAnalogRead.h>
    //usbMIDI.h library is added automatically when code is compiled as a MIDI device
    
    // ******CONSTANT VALUES********
    // customize code behaviour here!
    const int muxTimeMin = 500; // minimum micro-seconds between MUX reads
    const int channel = 1; // MIDI channel
    const int MUX_PINS = 16; // number of MUX Channnels
    
    // define the CC ID numbers on which to send them..
    
    const int Note[MUX_PINS] = {70,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36};
    int VELMASK[MUX_PINS];
    int PinMUX[MUX_PINS];
    int midiMin = 50;
    int afterTime = 50;
    int velocityTime = 30;
    const int velocityThreshold = 5;
    //******VARIABLES***********
    // a data array and a lagged copy to tell when MIDI changes are required
    byte data[MUX_PINS];
    byte dataLag[MUX_PINS]; // when lag and new are not the same then update MIDI CC value
    byte i=0; // global index for MUX channel reads
    
    //mapping of mux to teensy digital pins
    int pin_Out_S0 = 2;
    int pin_Out_S1 = 3;
    int pin_Out_S2 = 4;
    int pin_Out_S3 = 5;
    int pin_In_Mux1 = A0;
    
    
    //****** TIMER VARIABLE *** change scale here!
    elapsedMicros mux1Updated; // switch to micros to run at speed and tune with muxTimeMin setting above
    //elapsedMillis mux1Updated; // switch to millis to troubleshoot
    
    //************INITIALIZE LIBRARY OBJECTS**************
    // initialize the ReponsiveAnalogRead objects
    ResponsiveAnalogRead analog[]{
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true},
    {pin_In_Mux1 ,true}
    };
    
    
    
    //************SETUP**************
    void setup() {
    //! don't forget to set for output!
    pinMode(pin_Out_S0, OUTPUT);
    pinMode(pin_Out_S1, OUTPUT);
    pinMode(pin_Out_S2, OUTPUT);
    pinMode(pin_Out_S3, OUTPUT);
    }
    
    //************LOOP**************
    void loop() {
    nextMUXpin();
    while (usbMIDI.read()) {
    // controllers must call .read() to keep the queue clear even if they are not responding to MIDI
    }
    }
    
    
    //************MUX SECTION**************
    void nextMUXpin(){
    if (mux1Updated>muxTimeMin) {
    // update the ResponsiveAnalogRead object every loop
    analog[i].update();
    // if the repsonsive value has change, print out 'changed'
    if(analog[i].hasChanged()) {
    data[i] = analog[i].getValue();
    if (data[i] > dataLag[i])
    {
      PinMUX[i] ++;
      int velocity = map (data[i], 0, 800, midiMin, 127);
    if (!(VELMASK[i] & (1 << data[i]) && (data[i] == velocityTime))) {
    usbMIDI.sendNoteOn(Note[i], velocity, channel);
    VELMASK[i] |= (1 << data[i]);
            pin_In_Mux1 = 0;
            
          if (data[i] == afterTime) {
            usbMIDI.sendPolyPressure (Note[i], velocity, channel);
            pin_In_Mux1 = 0;
            }
    else {
          if (VELMASK[i] & (1 << data[i])) {
            usbMIDI.sendNoteOff (Note[i], 0, channel);
            VELMASK[i] &= ~ (1 << data[i]);
            pin_In_Mux1 = 0;
            }
          delayMicroseconds (50);
          }
          
        } 
      }    
          serialPringMIDIdata(); // use to troublshoot
    }
    
    
    //reset timer
    mux1Updated = 0;
    //increment index
    i++;
    if (i>15) {i=0;}
    // set mux control pins for next pass
    digitalWrite(pin_Out_S0, HIGH && (i & B00000001));
    digitalWrite(pin_Out_S1, HIGH && (i & B00000010));
    digitalWrite(pin_Out_S2, HIGH && (i & B00000100));
    digitalWrite(pin_Out_S3, HIGH && (i & B00001000));
    }
    }
    
    // **useful for debugging, comment out function call to run full speed
    void serialPringMIDIdata(){
    Serial.print(i,DEC);
    Serial.print(" :");
    Serial.print(HIGH && (i & B00000001),BIN);
    Serial.print(HIGH && (i & B00000010),BIN);
    Serial.print(HIGH && (i & B00000100),BIN);
    Serial.print(HIGH && (i & B00001000),BIN);
    Serial.print(" MUX_PIN: ");
    Serial.print(i,DEC);
    Serial.print(" CC: ");
    Serial.print(Note[i],DEC);
    Serial.print(" DATA HEX: ");
    Serial.println(data[i],HEX);
    }
    Im sure its probably a mess...

  4. #4
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,237
    I don't think there is any point in me trying to understand your code as I'm pretty sure you don't. I think you're not getting how his timing system is meant to work.

    Did you have something working before you added MUX support?

    I'm considering how it might be done best but it's a very complex project for a novice and it's difficult to replicate your hardware to test.

  5. #5
    Junior Member
    Join Date
    Oct 2019
    Posts
    3
    well, Ive already tested with a single FSR connected to the Analog input without any MUx and it worked as expected... and currently i have a couple of Fsrs connected to the Mux with the mux unused inputs attached to ground and each is sending its corresponding note On but followed by one single fleeting aftertouch signal and then again a note On and again aftertouch and so on till I release the pressing and it sends a note off... so the result in terms of sound is a bit too strange. As for understanding, Im not very sure of what im doing, thats why Im asking for some advice.. but I think Im kind of slowly getting in ... and I would like to get to know your approach.

  6. #6
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,237
    Let's not talk about any of your code as I believe you have made a fundamental error in understanding what it's doing.

    It is clear to me you have not understood how it works and have muddled a number of my variables with the counter array's functionality in his code.

    That's OK but let's not keep bringing it up.


    Adrain's code uses an array (counter[]) for timing readings which keeps track of how many passes through the loop there have been since the last reading.

    IMHO* this is fraught if the loop is doing anything other than the same thing on every pass. Once there's MUX timing and MIDI calls I suspect this will not work.

    Can you try his code with multiple sensors (as many as you can feed free pins on your T3.2??) and report how that works?


    * I'm not an expert at this stuff and I don't use MUX in my projects (I make controllers with a very small number of performance sensors). I'm just guessing at this based on limited knowledge and zero experience.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •