What is the best way to push a 5v or 12v relay (Output 220V/10A)
What is the best way to push a 5v or 12v relay (Output 220V/10A)
Hi Menta,
If your question is how to trigger a relay (5 or 12 volt) then I would use a transistor such as a 2n2222A. A 1K resistor from the PIC pin to the base of the transistor is needed. Don't forget to put a diode across the relay coil to protect the transistor.
HTH,
BobK
PIC pin thru 1K resistor to the base, collector to power, emitter to the relay coil, other side relay coil grounded, diode across relay coil pins 'backwards'.
Basic connection for an NPN transistor that's set up to apply power to something.
Get a copy of 'The Art of Electronics' and read it. Great book. Loads of info...
If I need 16 relay outputs that alot of transistos and resistors.
Why not using 2 relay drivers to control the massive relays ?
http://www.datasheetcatalog.org/data...a/ULN2068B.pdf
Last edited by menta; - 7th July 2008 at 13:12.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
ok i get how to connect it to the pic but what i need to know is how to write code for the operation of the relay. I want to switch the relay on when it reaches a setpoint value of 30 degrees. How would i do that?
I'm doing a temperature control system. Pretty new to PIC programming. I have managed to display temperature on the LCD using an LM35 sensor and a 16 x 2 lcd with a 16F873. I want to add on a 4 x4 matrix keypad so that i can set setpoints to switch a relay and a low warning buzzer I have no idea how to program for the above mentioned add-ons. Please could someone help me. below is my code which will obviously need additions and a scematic of my circuit is attached . Please could somebody help me with this!!
' Define LCD registers and bits
Define LCD_DREG PORTB
Define LCD_DBIT 0
Define LCD_RSREG PORTB
Define LCD_RSBIT 5
Define LCD_EREG PORTB
Define LCD_EBIT 4
dEFINE LCD_BITS 4
DEFINE LCD_LINES 2
adval var word ' Create adval to store result
temp var word ' Create temp to store result
temp1 var word ' Create temp1 to store result
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and RIGHT justify result
ADCON0 = %11000001 ' Configure and turn on A/D Module
Pause 100 ' Wait 0.1 second
loop: ADCON0.2 = 1 ' Start Conversion
AGAIN: Pause 1
If ADCON0.2 = 1 Then AGAIN ' Wait for low on bit-2 of ADCON0, conversion finished
adval.highbyte = ADRESH ' Move HIGH byte of result to adval
adval.lowbyte = ADRESL ' Move LOW byte of result to adval
Lcdout $fe, 1 ' Clear screen
temp=50*adval ' Conversion to Degrees
temp=temp/100
Lcdout "TEMP = ",DEC temp,$DF,"C" ' Display the value of temp
temp1 = temp*18 ' Conversion to Fahrenheit
temp1 = temp1+320
temp1 = temp1/10
lcdout $FE,$C0, "TEMP = ",dec temp1,$DF,"F" ' Display the value of temp
Pause 1000 ' Wait 1 second
Goto loop ' Do it forever
End
Bookmarks