• AVR Freaks

Hot!PIC PIN Latch Issue

Page: 12 > Showing page 1 of 2
Author
Designer
Super Member
  • Total Posts : 506
  • Reward points : 0
  • Joined: 2007/11/20 20:28:41
  • Location: 0
  • Status: offline
2020/05/21 10:47:47 (permalink)
0

PIC PIN Latch Issue

I'm doing a small relay timer design. It will turn ON a relay when PIC powers up & turn it OFF after the selected timeout. I'm driving a 12V relay from a PIC pin.From that relay I'm driving another 230V relay coil.
Without the 230V relay, the circuit works well.But when I hook the 230V relay coil it will ON but it never turns OFF.I need to power down the whole circuit to make it OFF.
 
How to solve this? Please see the schematic.
post edited by Designer - 2020/05/21 10:50:49

Attached Image(s)

#1

24 Replies Related Threads

    upand_at_them
    Super Member
    • Total Posts : 437
    • Reward points : 0
    • Joined: 2005/05/16 07:02:38
    • Location: Pennsylvania
    • Status: online
    Re: PIC PIN Latch Issue 2020/05/21 11:01:40 (permalink)
    0
    Is Relay1 staying latched too?  Or just Relay2?
    #2
    Designer
    Super Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2007/11/20 20:28:41
    • Location: 0
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/21 11:08:35 (permalink)
    0
    Yes Relay 1 staying Latch too.So both the relays staying latched
    #3
    Designer
    Super Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2007/11/20 20:28:41
    • Location: 0
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/21 11:08:37 (permalink)
    0
    Yes Relay 1 staying Latch too.So both the relays staying latched.
    #4
    upand_at_them
    Super Member
    • Total Posts : 437
    • Reward points : 0
    • Joined: 2005/05/16 07:02:38
    • Location: Pennsylvania
    • Status: online
    Re: PIC PIN Latch Issue 2020/05/21 12:00:30 (permalink)
    0
    Does it switch off if you ground the base of the transistor?  If so, try a 10K resistor there.
    #5
    ric
    Super Member
    • Total Posts : 27022
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/21 13:24:20 (permalink)
    +1 (1)
    Most likely, the bits of the circuit you have not shown, or the bits of the code that you have not shown are the culprit.
    Also, we shouldn't have to open an image just to find out the PIC is a PIC12F675.
     
    Most likely explanation is a RMW effect from your code because this PIC lacks LATx registers.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    Designer
    Super Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2007/11/20 20:28:41
    • Location: 0
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/21 17:41:40 (permalink)
    0
    Thanks for the inputs.

    In latch state if I Ground the base of the transistor using a jumper wire the relay is turning OFF.But when I remove the jumper it is again latching.Inside the PIC logic does not come to a Logic LOW.
    #7
    upand_at_them
    Super Member
    • Total Posts : 437
    • Reward points : 0
    • Joined: 2005/05/16 07:02:38
    • Location: Pennsylvania
    • Status: online
    Re: PIC PIN Latch Issue 2020/05/21 17:47:21 (permalink)
    +1 (1)
    What ric said.  You can't write a single bit to the port.  You have to use a shadow register.  You change the shadow register and write the entire thing to the port.
    #8
    Designer
    Super Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2007/11/20 20:28:41
    • Location: 0
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/21 17:47:47 (permalink)
    0
    ric
    Most likely, the bits of the circuit you have not shown, or the bits of the code that you have not shown are the culprit.Also, we shouldn't have to open an image just to find out the PIC is a PIC12F675. Most likely explanation is a RMW effect from your code because this PIC lacks LATx registers.


    Very good information.I'll show the code.

    Today for Testing I hooked up an Arduino Relay Board which has an optocoupler driving a transistor module .It worked with 230AC loads. But it needs to invert the logic.

    I need to make this work by directly drive transistor as in my image (without using arduino modules ).Because I'm testing on a PCB.
    #9
    Designer
    Super Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2007/11/20 20:28:41
    • Location: 0
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/21 18:56:22 (permalink)
    0
    *Also I noticed that when I use a different type relay its is working.
    *Also when I use a arduino relay board (with a buit in opto coupler) its working.
    *Also when I remove the 230V lines its working.
     
    But when I direct turn a relay from PIC via a resistor+transistor it wont turn OFF.
     
    Probably a induce effect as I guess..!!
     
    ;====================================================================
    ;Turn ON relay with adjusted timing
    ;====================================================================

    Do_Relay bsf S_GPIO,5
        movf S_GPIO,W
        movwf GPIO ;turn ON relay
        ;
        call Delay_50mS
        call Delay_50mS
        movlw .100
        movwf ISR_Count
        movlw .40
        movwf Led_Counter
        ;
        call Calculate_AD ;get the preset delay seconds
        ;---------
    Do_Delay btfss INTCON,T0IF
        goto $-1
        movlw d'217'
        movwf TMR0
        bcf INTCON,T0IF ;5mS
        ;
    LED_Blink decfsz Led_Counter,F
        goto $+3
        movlw .40
        movwf Led_Counter
        movf Led_Counter,W
        sublw .20
        btfsc STATUS,C
        bcf S_GPIO,4 ;Toggle led
        btfss STATUS,C
        bsf S_GPIO,4
        ;
        movf S_GPIO,W
        movwf GPIO
        ;
        decfsz ISR_Count,F ;500ms
        goto Do_Delay
        movlw .100
        movwf ISR_Count
        ;
        decfsz Seconds,F ;500mSx6 = 3sec
        goto Do_Delay
        ;
        call Delay_50mS
        call Delay_50mS
        bcf S_GPIO,5
        movf S_GPIO,W
        movwf GPIO   ;turn OFF relay
        call Delay_50mS
        call Delay_50mS
        goto Main_Loop

    post edited by Designer - 2020/05/21 19:01:18
    #10
    ric
    Super Member
    • Total Posts : 27022
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/21 19:13:31 (permalink)
    +2 (2)
    It sounds like your power supply for the PIC is no good, and the PIC is latching up when the original relay energises.
    A full schematic of the circuit, and a photo of the real hardware could give some clues here.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #11
    Designer
    Super Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2007/11/20 20:28:41
    • Location: 0
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/21 20:25:07 (permalink)
    0
    Here is my schematic.I don't see any wrong..!!
    When relay latch happens, the PIC is working as normal.Ex;LED blinking, Input sensing happens.Only this relay PIN is latch.
    post edited by Designer - 2020/05/21 20:28:21

    Attached Image(s)

    #12
    ric
    Super Member
    • Total Posts : 27022
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/21 20:30:17 (permalink)
    +2 (2)
    Relay 1 is draining power from the capacitor supplying your 7805, and there is very little capacitance after the 7805.
    What happens if you supply relay one from an independant 12V supply?
     
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #13
    Designer
    Super Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2007/11/20 20:28:41
    • Location: 0
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/21 20:44:48 (permalink)
    0
    Now I checked, powered the relay from a seperate 12V power supply, but the issue is same.
     
    #14
    ric
    Super Member
    • Total Posts : 27022
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/21 20:51:49 (permalink)
    +2 (2)
    Where is this "SR-04" sensor?
    Does it have long wires going to it?
    You have no protection on the two PIC pins it is connected to.
     
    A photo of the whole arrangment could answer a lot of questions.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #15
    Designer
    Super Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2007/11/20 20:28:41
    • Location: 0
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/21 20:57:33 (permalink)
    0
    Hi, I directly connect those ULTRASONIC sensor pins to PIC.All in the same PCB.
    post edited by Designer - 2020/05/21 20:59:31

    Attached Image(s)

    #16
    XorLor
    Starting Member
    • Total Posts : 52
    • Reward points : 0
    • Joined: 2009/10/23 00:17:05
    • Location: 0
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/21 22:40:15 (permalink)
    0
    upand_at_them
    Does it switch off if you ground the base of the transistor?  If so, try a 10K resistor there.



    Designer
    In latch state if I Ground the base of the transistor using a jumper wire the relay is turning OFF.But when I remove the jumper it is again latching.Inside the PIC logic does not come to a Logic LOW.



    Did you try the 10k resistor? Also, make sure the transistor isn't backwards.
    #17
    Designer
    Super Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2007/11/20 20:28:41
    • Location: 0
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/21 22:49:57 (permalink)
    0
    XorLor
    upand_at_themDoes it switch off if you ground the base of the transistor?  If so, try a 10K resistor there.


    Designer
    In latch state if I Ground the base of the transistor using a jumper wire the relay is turning OFF.But when I remove the jumper it is again latching.Inside the PIC logic does not come to a Logic LOW.


    Did you try the 10k resistor? Also, make sure the transistor isn't backwards.


    Hi, I didn't Try the 10K pull Down ( Base to GND).I'll try with it.

    The PCB footprint was to put a 2N2222.After I changed the transistor to BC547.It needs to swap the transistor before soldering.
    #18
    Designer
    Super Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2007/11/20 20:28:41
    • Location: 0
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/22 01:04:27 (permalink)
    0
    Is it good to replace the BJT with 2N7000 N channel FET with a 10K Gate to Source?
    #19
    teenix
    Junior Member
    • Total Posts : 60
    • Reward points : 0
    • Joined: 2017/12/21 13:47:21
    • Location: Australia, Melbourne
    • Status: offline
    Re: PIC PIN Latch Issue 2020/05/22 05:07:35 (permalink)
    +1 (1)
    Will the pcb relay reliably switch a DC load, (say a few 100mA or whatever the contacts are rated for) or does it stick also?
     
    Is there any EMI generated when the PCB relay switches the AC relay coil, (ie. contact arcing)? If so then the PIC may do strange things, especially as it is not far from the relay contacts. The AC relay coil may need a snubber circuit across it.
     
    Maybe unlikely unless a high current flowing, but the AC PCB traces may also upset the PIC, especially if you have unconnected PIC pins set as inputs.
     
    cheers
     
    Tony
     
     
    post edited by teenix - 2020/05/22 05:15:09
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5