Relay help!!

Discussion in 'The Projects Forum' started by elex09, Mar 24, 2010.

Thread Status:
Not open for further replies.
  1. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    hi

    needed a little help with an spdt relay...

    1.) in the NO position i want the relay to light an led or not connect to anything. and

    2.)in the NC position i want the relay to connect to a battery that will power a small bulb or fan...

    i searched the net for help but got thoroughly confused..all i read was that in NO position COM and NC are shorted and in NC position COM and NO are shorted..

    can someone pls suggest a suitable schematic..
    i'd be very grateful!
     
  2. Wendy

    Moderator

    Mar 24, 2008
    20,766
    2,536
    NO means there is no contact if the coil is not energized. NC means it is connected if the coil is not energized. Energize the coil and they flip. A relay is a simple switch, nothing more.
     
  3. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    Thanks for yr response Bill, i am aware that NO is Normaaly open and similarly for NC but i needed a little assistance in the connection to the relay...

    Correct me if i am wrong:
    1). I want the relay to cut off supply in the NO postion so I leave the NO pin open..
    2). I want the relay to turn on a battery supply that is driving a bulb/fan so I connect the NC pin to the battery..

    I'd appreciate if someone checks this and lets me know asap as I need to implement this and interface it to the microcontroller AT89c52..
     
  4. Bernard

    AAC Fanatic!

    Aug 7, 2008
    4,176
    397
    Is this about what you wanted? Relay shown energised from battery.
     
  5. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    i wanted the relay to connect to a battery in the energized condition and the battery will turn ON the bulb and fan.. in unenergized condition relay should be left open i.e. no action..
     
  6. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    anyone able to help me out with a schematic? ....do i connect the battery to the NO terminal and leave NC open?
     
  7. williamj

    Active Member

    Sep 3, 2009
    180
    32
    elex90,

    I'm not entirely sure what it is you are trying to do but maybe this is what you are looking for.

    The switch energizes the relay coil and the coil contacts energize the light and the fan.

    williamj
     
  8. JoeJester

    AAC Fanatic!

    Apr 26, 2005
    3,373
    1,159
    NO, NC, typically describe the contacts with the relay "de-energized". NC (Normally Closed) is typically a short between the NC and C connections. NO (Normally Open) is typically high resistance between the C and NO connections. When the relay is energized, the states change. C and NC is open, C and NO is short.

    Williamj's circuit fits your description.
     
  9. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    Thanx JoeJester...

    makes things a lot clearer now...I have finished all the hardware in my project..I am giving the output of IR rxers to P2.0 to P2.3 of the uC 89C51..and programming the output from P1.6 to 0 or 1 according to state of IR rxers o/p...this i am giving to a 1k resistor and then to BC547 transistor...and to 12v spdt relay...
    all the voltage levels on the i/p pins of uC are accurately varying according to IR beam being detected or broken but the output from P1.6 stays constant at 0.65 volts...don't know why? and the drop across the 1k resistor is 0v...
    can someone pls help?
    i'll put up my code which i wrote for this, shortly.any sort of troubleshooting help is welcome!! :)
     
  10. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    this is my code....pls correct me if wrong somewhere...

    ; Program to monitor status of Infrared Receiver according
    ;to occupancy in classroom and switch ON/OFF supply

    org 0000h;

    mov P2,#00h; ;clear the other pins other than i/p pins

    mov P2,#0Fh ;make P2.0 to P2.3 input port

    ;if the IR beam is not blocked i.e. nobody is present in
    ;class so relay is OFF,o/p is low

    ;if the IR beam is blocked i.e.
    ;someone present so relay must energize,o/p is high

    back:mov A,P2 ;copy input in ACC
    JNZ relay1 ;if ACC is 1,somebody is present in class so relay must switch ON supply
    acall delay ;

    ;Using Timer 0 in mode 1 for 10 sec delay
    delay: mov tmod,#01h ;use timer0 in mode1
    mov R0,#1680 ;

    back2: mov th0,#00h ;load the delay in high byte of timer reg
    mov tl0,#00h ;load the delay in lower byte of timer reg
    setb tr0 ;start the timer0
    back1: jnb tf0,back1 ;till time has elapsed stay here
    clr tf0 ;
    clr tr0 ;
    djnz R0,back2 ;

    ;Now using timer 1 in mode 1 for another 10 sec delay
    mov tmod,#10h ;use timer1 in mode1
    mov R1,#1680 ;

    back3: mov th1,#00h ;load the delay in high byte of timer reg
    mov tl1,#00h ;load the delay in lower byte of timer reg
    setb tr1 ;start the timer0
    back4: jnb tf1,back4 ;till time has elapsed stay here
    clr tf1 ;
    clr tr1 ;
    djnz R1,back3 ;

    setb P1.5 ;light up LED to indicate that class is empty
    sjmp back ;continue monitoring the status of the receiver
    RET ;

    relay1:
    setb P1.6 ;give base drive to transistor to energize the relay
    sjmp back ;continue monitoring the status of the receiver

    end ;
     
  11. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
  12. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    hey sorry abt that retched...it is a bit difficult to read, i know...but im new to the forum...will try and put it in that form soon...

    giving preliminary exams at college rite now! ;)
     
  13. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Just because messy code is hard to look at...
    Code ( (Unknown Language)):
    1. ; Program to monitor status of Infrared Receiver according
    2. ; to occupancy in classroom and switch ON/OFF supply
    3.  
    4.          org 0000h        ;
    5.          mov P2,#00h;     ; clear the other pins other than i/p pins
    6.          mov P2,#0Fh      ; make P2.0 to P2.3 input port
    7.  
    8.   ; if the IR beam is not blocked i.e. nobody is present in
    9.   ; class so  relay is OFF,o/p is low
    10.        
    11.   ; if the IR beam is blocked i.e.
    12.   ; someone present so relay must energize,o/p is high
    13.  
    14. back:    mov A,P2         ; copy input in ACC
    15.          JNZ relay1       ; if ACC is 1,somebody is present in class so relay must switch ON supply
    16.          acall delay      ;
    17.  
    18.   ; Using Timer 0 in mode 1 for 10 sec delay
    19.  
    20. delay:   mov tmod,#01h    ; use timer0 in mode1
    21.          mov R0,#1680     ;
    22.    
    23. back2:   mov th0,#00h     ; load the delay in high byte of timer reg
    24.          mov tl0,#00h     ; load the delay in lower byte of timer reg
    25.          setb tr0         ; start the timer0
    26. back1:   jnb tf0,back1    ; till time has elapsed stay here
    27.          clr tf0          ;
    28.          clr tr0          ;
    29.          djnz R0,back2    ;
    30.        
    31.   ; Now using timer 1 in mode 1 for another 10 sec delay
    32.  
    33.          mov tmod,#10h    ;use timer1 in mode1
    34.          mov R1,#1680     ;
    35.    
    36. back3:   mov th1,#00h     ;load the delay in high byte of timer reg
    37.          mov tl1,#00h     ;load the delay in lower byte of timer reg
    38.          setb tr1         ;start the timer0
    39. back4:   jnb tf1,back4    ; till time has elapsed stay here
    40.          clr tf1          ;
    41.          clr tr1          ;
    42.          djnz R1,back3    ;
    43.          setb P1.5        ;light up LED to indicate that class is empty
    44.          sjmp back        ;continue monitoring the status of the receiver
    45.          RET              ;
    46. relay1:
    47.          setb P1.6        ;give base drive to transistor to energize the relay
    48.          sjmp back        ;continue monitoring the status of the receiver
    49.          end              ;
    50.  
     
    elex09 likes this.
  14. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    Thanx for putting my code in proper format so soon! i would have tried doing it after 5/6 hours after giving my exam!!
     
  15. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    so can anyone suggest what the problem is?
    1. why is there 0V drop across 1k base resistor?
    2.why am i continuously getting 0.65V on the output P1.6 pin? it doesn't change even when i/ps at p2.0-p2.3 change acc to ir rxers?

    do i need to put the (code) routine in an interrupt?
    I just need the rite o/p from P1.6 port pin...to run the relay...thats all i need to get this proj running...i gotta finish in 3 days!!
    any suggestions?
     
  16. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    urgent help required....
    pls someone?
     
  17. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    Its only been 2 hours on a Friday.. Give it some time.. People have jobs.
     
  18. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    One of the problems is the topic in the thread has changed, and now the discussion is about 89C51 programming in Assembler instead of relay troubles.

    You might get more response if the programming portion were posted over in the Programming or Embedded Microcontroller forums with a relevant subject line, like:

    "Help with 89C51 uC Assembler code to toggle relay"
     
  19. elex09

    Thread Starter Member

    Mar 17, 2010
    39
    0
    You're right SgtWookie...i realized that..i have already posted my query along with the code with proper indenting in the Microcontroller Forum...Waiting for a response from there...
    btw, is there a way by which i can edit and change the title of my thread?
     
  20. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    I've never tried to do it, so I can't answer your question.

    However, changing the subject of THIS thread would likely cause confusion.

    You should reference this thread from your other thread; just include a link.

    That way if people want more background information, they can refer back here.
     
Loading...
Thread Status:
Not open for further replies.