Hi,
Just a brief of the project I am working on. I am trying to connect inductors in circular array which are connected to two MUX acting as a transmitter and receiver which is controlled by arduino UNO. The MUX i am using is ADG508A (data sheet attached, schematics attached). I have written the coding, but i feel it is not working well with the MUX. I will explain the algorithm and put the code in after it.
The example of how my mux's should work is
Transmitter MUX Selection pin 1(selected): the signal goes to the inductor of value 220uH, The other inductors get induced by the signal, and the receiver mux from selection pin 2 should be selected and the value to written on the serial monitor. then the receiver should go for the selection pin 3 and write it down, like wise till the Selection pin 8.
So, it's like this
Output should be like below, only receiver voltage is measured.
transmitter 1 - Receiver 2 3 4 5 6 7 8
transmitter 2 - receiver 3 4 5 6 7 8
TX 3 - RX 4 5 6 7 8
TX 4 - RX 5 6 7 8
TX 5 - RX 6 7 8
TX 6 - RX 7 8
TX 7 - RX 8
TX 8 - none
Should follow n(n-1)/2
for(count=0;count<=7;count++)
{
i = pin[count];
a0 = bitRead(i,0);
a1 = bitRead(i,1);
a2 = bitRead(i,2);
digitalWrite( 3,a0);
digitalWrite( 5,a1);
digitalWrite( 6,a2);
delay(3000);
}
while(i==pin[count])
{
for(count1=count+1;count1<=7;count1++)
{
i = pin[count1];
a00 = bitRead(i,0);
a11 = bitRead(i,1);
a22 = bitRead(i,2);
digitalWrite( 6,a00);
digitalWrite( 7,a11);
digitalWrite( 8,a22);
delay(2);
}
}
}
Since this code didn't work with the MUX i went for the analogWrite command which has a similar programming
int a0_LH[] = {0, 255, 0, 255, 0, 255, 0, 255};
int a1_LH[] = {0, 0, 0, 0, 255, 255, 255, 255};
int a2_LH[] = {0, 0, 0, 0, 255, 255, 255, 255};
for(i=0;i<=7;i++)
{
a0 = a0_LH[i];
a1 = a1_LH[i];
a2 = a2_LH[i];
analogWrite(3, a0);
analogWrite(5 ,a1);
analogWrite(6 ,a2);
delay(80);
if (i==i)
for(i1=i+1;i1<=7;i1++)
{
int a3_LH[] = {0, 255, 0, 255, 0, 255, 0, 255};
int a4_LH[] = {0, 0, 0, 0, 255, 255, 255, 255};
int a5_LH[] = {0, 0, 0, 0, 255, 255, 255, 255};
a3 = a3_LH[i1];
a4 = a4_LH[i1];
a5 = a5_LH[i1];
analogWrite(9,a3);
analogWrite(10,a4);
analogWrite(11,a5);
//analogReference(INTERNAL);
Val = analogRead(analogPin);
Serial.println( Val); // prints the values in volts
delay(10);
}
}
This program makes 4 of the selection pins work [s1,s2,s7,s8] and the remaining 4 doesn't work [s3- s8].
Please kindly help to figure out where I have done the mistake. Is it my logic is wrong or my understanding of the MUX and arduino?
TXRXMUXREVA.pdf (18.3 KB)
ADG508A_509A.pdf (381 KB)