Go Down

Topic: Multiplexer Programming (Read 273 times) previous topic - next topic

tyra

Hi,

Im trying to program my 8:1 mux with the Arduino. However, Im not really sure how to do the coding to select one switch at one time. Im using 6 input pins and 1 output pin which connected to the instrumentation amplifier. The circuit design can be seen in the attachment. Can anyone help me?

ieee488

We know what a mux is. We don't know which mux.

Riva

We know what a mux is. We don't know which mux.
The drawing says it's a 4051 8-channel analog multiplexer/demultiplexer
Don't PM me for help as I will ignore it.

CrossRoads

Drive A-B-C pins with one of these combinations:
000
001
010
011
100
101
110
111 - no input from this pin, I would connect it to Gnd.
and the Inhibit pin Low to let the selected input show up at the output.
http://www.ti.com/lit/ds/symlink/cd74hc4051.pdf
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

tyra

I know about the 8-bit binary digits, however, im not really sure how to program it. Thank you. :)

ieee488

The drawing says it's a 4051 8-channel analog multiplexer/demultiplexer
For something so simple, you'd think a Google search 'Arduino 4051' would have landed more than enough results.

Riva

I know about the 8-bit binary digits, however, im not really sure how to program it. Thank you. :)
Untested but something like this.
Code: [Select]
#define pinA 3
#define pinB 4
#define pinC 9

void setup(){
  Serial.begin(9600);
  pinMode(pinA,OUTPUT);
  pinMode(pinB,OUTPUT);
  pinMode(pinC,OUTPUT);
}

void loop(){
  for (byte x = 0; x < 8; x++){
    digitalWrite(pinA,bitRead(x,0));
    digitalWrite(pinB,bitRead(x,1));
    digitalWrite(pinC,bitRead(x,2));
    Serial.println(x);
    delay(1000);
  }
Don't PM me for help as I will ignore it.

tyra

what is this line means? is the 'x' belong to pinA and 0 belong to bitRead?

digitalWrite(pinA,bitRead(x,0));

PaulRB

No, "x" is the channel number (0 to 7). "0" is the is the bit of the channel number that needs to be written to pinA.

Riva

what is this line means? is the 'x' belong to pinA and 0 belong to bitRead?
Paul has already explained the meaning but for further reference check out the description here and digitalWrite here. The reference says HIGH/LOW but basically LOW = 0 and HIGH = number anything other than zero.
Don't PM me for help as I will ignore it.

Grumpy_Mike


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy