Arduino Forum

Forum 2005-2010 (read only) => Hardware => Troubleshooting => Topic started by: stinky on Dec 27, 2005, 11:35 pm

Title: How to use a hex inverter???
Post by: stinky on Dec 27, 2005, 11:35 pm
I'm trying to use a hex inverter to create a DPDT switch which can be controlled by a single pin on the arduino board.

Below is a bad drawing of my circuit (Please forgive me - I am an electronics newbie!)

(http://www.jonathanbryan.com/hex_inv_circuit.gif)

A is connected to a pin on the arduino board.

The idea is that when ...

A is HIGH,     B is HIGH and C is LOW
and when ...
A is LOW,     B is LOW and C is HIGH

Anyway, its not working. I guess i'm doing this totally wrongly. Could somebody please put me right??

(merry christmas! to you all and I wish you a geeky 2006!)
Title: Re: How to use a hex inverter???
Post by: DojoDave on Jan 01, 2006, 12:28 pm
Hej,

sorry for the delay, we took a couple of days vacation visiting mum and eating Xmas candy ;-)

However your circuit looks great to me. I think you plugged everything right. The only thing I could ask is:

a) how big is your resistor?

b) can you take a picture of the circuit as you mounted it and upload it?

/David
Title: Re: How to use a hex inverter???
Post by: stinky on Jan 04, 2006, 05:00 am
hi David,

thanks for the help.

here is a picture of my circuit....

(http://www.jonathanbryan.com/arduino/hex_inv_bb.jpg)

the long orange wire is the output, 'A' in my circuit diagram.

the two green wires are connected back onto the arduino board, for the purposes of testing. they are B & C

the resistor is 10Kohms

This is the 'quick and dirty' program I have on the arduino board to test the circuit...

------------------------------

int inA = 0;
int inB = 0;

void setup()
{
  pinMode(11, OUTPUT);  
  pinMode(9, INPUT);  
  pinMode(8, INPUT);              
  beginSerial(9600);
}

void loop()
{
  digitalWrite(11, HIGH);

  inA = digitalRead(8);
  inB = digitalRead(9);
  printByte('h');
  if (inA == 0) printByte('0');
    else printByte('1');
  printByte(' ');
  if (inB == 0) printByte('0');
    else printByte('1');
  printByte(10);
  printByte(13);  

  delay(1000);  
  
  digitalWrite(11, LOW);

  inA = digitalRead(8);
  inB = digitalRead(9);
  inA = 0;
  printByte('l');
  if (inA == 0) printByte('0');
    else printByte('1');
  printByte(' ');
  if (inB == 0) printByte('0');
    else printByte('1');
  printByte(10);
  printByte(13);

  delay(1000);
}

------------------------------

i get the following repeating output in ZTerm

h   0   1
l   0   0

meaning that when A is High, B is High and C is Low
and when A is Low, B is Low and C is Low.

So, something is obviously wrong.

what does the digital doctor suggest??
Title: Re: How to use a hex inverter???
Post by: DojoDave on Jan 04, 2006, 10:35 pm
Hej,

take a look at your program:

Quote

delay(1000);    
   
 digitalWrite(11, LOW);

 inA = digitalRead(8);
 inB = digitalRead(9);

 // THIS IS IT!!
 // YOU ARE MAKING INA BECOME 0 AGAIN!!

 inA = 0;


 printByte('l');
 if (inA == 0) printByte('0');
   else printByte('1');
 printByte(' ');
 if (inB == 0) printByte('0');
   else printByte('1');
 printByte(10);
Saw it?

;-)

/David
Title: Re: How to use a hex inverter???
Post by: stinky on Jan 05, 2006, 12:42 am
whoops! how embarrassing!!!

yeah, i put that line in at one point, when I was trying to debug things and I forgot to remove it. without it, everything works as expected!

I put a scratch through that line, so that anybody looking at this thread can easily see what was wrong.

I hope the pictures will be useful to anyone else trying to do the same thing.

Thanks doctor - I'll try not to waste your time in future!!
Title: Re: How to use a hex inverter???
Post by: DojoDave on Jan 07, 2006, 12:07 am
No waist,

a pleasure

/D