@ Guywithknife
Thank you so much!
This will be extremely helpful when i get to the programming part!
Im very interested in the instant midi channel changing part of your script.
@ Guywithknife
Thank you so much!
This will be extremely helpful when i get to the programming part!
Im very interested in the instant midi channel changing part of your script.
Is it possible to "stack" these 16 way multiplexers on the data pins to allow 64 total analog inputs to the 4 analog input spots on the MF board? I see that's how sidetrakd got 32 analog inputs for his build using 8 way multiplexers. The design I'm contemplating would need more than 32 analog inputs though.
edit: nevermind, answered my own question: http://www.djtechtools.com/forum/sho...3&postcount=56
Last edited by einsteinx2; 01-13-2012 at 05:48 PM.
Hi guys,
New to the forum. Very interesting topic, I was working on a multi-fader controller with Teensy and the multiplexer IC. I saw mention of Limey's Teensy code on here. Is that public anywhere? Would love to play around with it if it is
Hi awacs,
Not sure if fatlimey has teensy code or where it is (too lazy to search), but what are you trying to do? I may be able to lend a hand. Not sure if I have any multiplexers handy, but I have a couple of teensy's and I remember the CD4051B being incredibly simple to use.
Actually, they really are not hard to use once you have them wired up correctly:
They have three digital inputs, a common in/out and a number of multiplexed in/out pins (8 I think it was?). Connect the common in/out to one of the teensy's analogue pins. Connect the multiplexed pins to the faders. Connect the three digital pins to three of the teensy's general purpose pins. Configure the analogue pin as an input and the three digital pins as outputs.
Now your teensyduino code looks something like this (untested and off the top of my head, so please excuse typos and memory lapses):
And to use:Code:int readFader (int fader_number) { // Select the fader from the multiplexer digitalWrite(MUX_DIGITAL_1, fader_number & 0x1 != 0); digitalWrite(MUX_DIGITAL_2, fader_number & 0x2 != 0); digitalWrite(MUX_DIGITAL_3, fader_number & 0x4 != 0); // Read the analogue value return analogRead(MUX_ANALOG_PIN); }
Hope that helps!Code:for (int fader = 0; fader < 8; fader++) { Serial.print("Fader "); Serial.print(fader + 1); Serial.print(" = "); Serial.println(readFader(fader)); }
Was looking at this code from Mayhew, wasn't quite sure how the bitwise operator and & functionality was working to scan through the multiple inputs...
//Mux_Shield_AnalogIn_Example
//http://mayhewlabs.com/arduino-mux-shield
/*
This example shows how to read and store all 48 pins as analog inputs into arrays and print the results over serial.
Multiplexer pin inputs that do not have a voltage reading (i.e nothing connected) will have erratic values.
To simplify this code further, one might use nested for loops or function calls.
*/
//Give convenient names to the control pins
#define CONTROL0 5
#define CONTROL1 4
#define CONTROL2 3
#define CONTROL3 2
//Create arrays for data from the the MUXs
//See the Arduino Array Reference: http://www.arduino.cc/en/Reference/Array
int mux0array[16];
int mux1array[16];
int mux2array[16];
void setup()
{
//Set MUX control pins to output
pinMode(CONTROL0, OUTPUT);
pinMode(CONTROL1, OUTPUT);
pinMode(CONTROL2, OUTPUT);
pinMode(CONTROL3, OUTPUT);
//Open the serial port at 28800 bps
Serial.begin(28800);
}
void loop()
{
//This for loop is used to scroll through and store the 16 inputs on the FIRST multiplexer
for (int i=0; i<16; i++)
{
//The following 4 commands set the correct logic for the control pins to select the desired input
//See the Arduino Bitwise AND Reference: http://www.arduino.cc/en/Reference/BitwiseAnd
//See the Aruino Bitshift Reference: http://www.arduino.cc/en/Reference/Bitshift
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
//Read and store the input value at a location in the array
mux0array[i] = analogRead(0);
}
//This for loop is used to scroll through the SECOND multiplexer
for (int i=0; i<16; i++)
{
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
mux1array[i] = analogRead(1);
}
//This for loop is used to scroll through the THIRD multiplexer
for (int i=0; i<16; i++)
{
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
mux2array[i] = analogRead(2);
}
//The following lines are for printing out results of array0
Serial.print("mux0array: ");
for (int i=0; i<16; i++)
{
Serial.print(mux0array[i]);
Serial.print("-");
}
Serial.println(); //line feed
//The following lines are for printing out results of array1
Serial.print("mux1array: ");
for (int i=0; i<16; i++)
{
Serial.print(mux1array[i]);
Serial.print("-");
}
Serial.println();
//The following lines are for printing out results of array2
Serial.print("mux2array: ");
for (int i=0; i<16; i++)
{
Serial.print(mux2array[i]);
Serial.print("-");
}
Serial.println();
}
I was working through this code, wasn't quite sure how the input select bit shift operator and & operator were working. It seems as a filter, but a bit unclear for me..
//Mux_Shield_AnalogIn_Example
//http://mayhewlabs.com/arduino-mux-shield
/*
This example shows how to read and store all 48 pins as analog inputs into arrays and print the results over serial.
Multiplexer pin inputs that do not have a voltage reading (i.e nothing connected) will have erratic values.
To simplify this code further, one might use nested for loops or function calls.
*/
//Give convenient names to the control pins
#define CONTROL0 5
#define CONTROL1 4
#define CONTROL2 3
#define CONTROL3 2
//Create arrays for data from the the MUXs
//See the Arduino Array Reference: http://www.arduino.cc/en/Reference/Array
int mux0array[16];
int mux1array[16];
int mux2array[16];
void setup()
{
//Set MUX control pins to output
pinMode(CONTROL0, OUTPUT);
pinMode(CONTROL1, OUTPUT);
pinMode(CONTROL2, OUTPUT);
pinMode(CONTROL3, OUTPUT);
//Open the serial port at 28800 bps
Serial.begin(28800);
}
void loop()
{
//This for loop is used to scroll through and store the 16 inputs on the FIRST multiplexer
for (int i=0; i<16; i++)
{
//The following 4 commands set the correct logic for the control pins to select the desired input
//See the Arduino Bitwise AND Reference: http://www.arduino.cc/en/Reference/BitwiseAnd
//See the Aruino Bitshift Reference: http://www.arduino.cc/en/Reference/Bitshift
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
//Read and store the input value at a location in the array
mux0array[i] = analogRead(0);
}
//This for loop is used to scroll through the SECOND multiplexer
for (int i=0; i<16; i++)
{
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
mux1array[i] = analogRead(1);
}
//This for loop is used to scroll through the THIRD multiplexer
for (int i=0; i<16; i++)
{
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
mux2array[i] = analogRead(2);
}
//The following lines are for printing out results of array0
Serial.print("mux0array: ");
for (int i=0; i<16; i++)
{
Serial.print(mux0array[i]);
Serial.print("-");
}
Serial.println(); //line feed
//The following lines are for printing out results of array1
Serial.print("mux1array: ");
for (int i=0; i<16; i++)
{
Serial.print(mux1array[i]);
Serial.print("-");
}
Serial.println();
//The following lines are for printing out results of array2
Serial.print("mux2array: ");
for (int i=0; i<16; i++)
{
Serial.print(mux2array[i]);
Serial.print("-");
}
Serial.println();
}
I've been trying to figure out the select code from Mayhew. The bit shift and & operation seems a bit confusing to me. Not quite sure what is being done. I tried posting this as code, how do you guys do that? Also, am I getting the posting question cause im a newbie?
http://mayhewlabs.com/code/Mux_Shiel...In_Example.pde
|
Bookmarks