Go Down

Topic: Generating a hardware signal (Read 2761 times) previous topic - next topic

bhagi

I am doing a project in which I used OpenCV and wrote a C/C++ code to detect human presence. Now, I have to generate a hardware signal and send it to a relay to light a bulb.

I thought of doing this using arduino uno. I need help with the cicuitory. As in which pins should I use to connect to the relay. Mine is a mechanical 3pdt relay.

CrossRoads

Serial message from PC to Arduino is simple enough.

What is the coil current and voltage needed by your relay? If more than 5V/35mA, you will need to have Arduino drive a transistor to drive the coil current.
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.

bhagi

The specifications given are like this:
10 A at 120 VAC
10 A at 28 VDC
10 A at 250 VAC

(Just in case I am attaching the datasheet too)

Please help me further. Thanks a lot for the quick reply :-)

CrossRoads

The ratings you provided are what the contacts can handle.
Need the coil rating, current thru the coil is what makes the contacts open & close.

File is corrupted and adobe will not open.
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.

bhagi

I am attaching it again and also giving the info here. Please check and tell:
Rated       Rated
Voltage (VAC)    Current (mA at 60Hz)

6                  360
12                180
24                  88.0
50                  39.0
110                 21.0
120                 18.0
220                 11.0
240                   9.2

I am really sorry I have very little idea in this so I don't know if that's what you are looking for.

CrossRoads

#5
Apr 16, 2013, 10:14 pm Last Edit: Apr 16, 2013, 10:16 pm by CrossRoads Reason: 1
Bottom of page 2, DC coil current.
You will need 5V to one coil pin, other coil pin to collector of NPN transistor, emitter of NPN to Gnd.
Arduino pin to 220 ohm resistor, other side of resistor to base of NPN transistor.
Diode across the coil pins; cathode to +5, Anode to collector.

Simple 2n2222A will work fine
http://www.digikey.com/product-detail/en/P2N2222AG/P2N2222AGOS-ND/920244
and 1n4001 diode.

If it will not turn on with 5V, then you will need a higher voltage source for the coil.
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.

bhagi

Can I use a ULN2803 IC instead of the transistor and the diode??

bhagi

Also how should I write the code. Basically the thing is my face detection software (written in C++) detects faces. Whenever a face is detected I have to  generate a signal which will switch ON/OFF the power supply.
I am a newbie to the arduino environment, so I don't have an idea how to write the code and also sync it with the C++ code i.e. whenever my C++ code detects faces this code(which will generate the hardware signal) should run on the arduino.
Please help :)

CrossRoads

Yes to ULN2803, still need diode.
Up to you to make the PC send out a message.
On Arduino side, is easy to receive a short message and act on it.  There are plenty of examples in the playground.

Basically, in void loop (and this may need a little tweaking):
Code: [Select]

if (Serial.available()>0){ // byte received?
// read it & act on it
incomingByte = Serial.read();
if (incomingByte == 0xFA){
digitalWrite(pinX, HIGH); // High to ULN2803 brings the output Low
}
if (incomingByte == 0xF5){
digitalWrite(pinX, LOW); // Low to ULN2803 releases the output
}
if ( (incomingByte != 0xFA) && (incomingByte != 0xF5){
Serial.println("bad byte received");
}
} // end serial available check
} // end loop
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.

bhagi

Thanks a lot :-) will try and get back to you :-)

bhagi

Sir, you said:

You will need 5V to one coil pin, other coil pin to collector of NPN transistor, emitter of NPN to Gnd.
Arduino pin to 220 ohm resistor, other side of resistor to base of NPN transistor.
Diode across the coil pins; cathode to +5, Anode to collector.

how should I implement that above circuit with the uln2803 that I have mentioned. Help me with the circuit diagram please if possible. Thanks a lot

CrossRoads

See the right-hand side of this drawing, the M is coil of your relay.
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.

Go Up