logo elektroda
logo elektroda
X
logo elektroda

Raspberry Pi - relay - Relay "does not bounce" raspberry PI 2

maleo77 3033 4
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 15286317
    maleo77
    Level 8  
    Good evening,

    I am implementing lighting control using Raspberry PI 2. I have implemented the same layout as one of the users shows here: youtube.com/watch?v=r83Vs3pcuVE . However, he doesn't have a problem with it, but with me the problem is that I switch on via the website, everything is ok. On the other hand, when I want to switch off the lamp responds to the command, but the relay does not. When I disconnect the cable from this GPIO pin, the relay switches off. I have the same relay as in the video.

    I have seen one similar topic on the forum, but it was not fully resolved. I have seen some people explain the placement of transistors etc as the solution, but to this and many other users it works. I wonder how this problem can be solved?

    Thank you for any pointers.
  • ADVERTISEMENT
  • Helpful post
    #2 15286688
    adamz74
    Level 33  
    Show the code responsible for switching on and off. Looks like a bug in the control of the GPIO lines.

    You can't see much in the video, but the author seems to have done the switching off by setting the GPIO line as an input (mode in), which means that you don't know what potential on that line appears.
    The effect you get suggests that the pull-up resistors are on. The voltage on the lines is too low to drive the indicator diodes (they may "glow" slightly), but sufficient to drive the transistors that control the relays. Therefore they do not reflect :(

    Greetings!
  • ADVERTISEMENT
  • #3 15287386
    maleo77
    Level 8  
    adamz74 wrote:
    Show code responsible for switching on and off. Looks like a bug in the control of the GPIO lines.


    Here is the code: lukemore.o12.co.uk/rpi_project/GPIO_project_php&css.zip


    adamz74 wrote:

    You can't see much in the video, but the author seems to have done the deactivation by setting the GPIO line as an input (mode in), which means you don't know what potential is on that line.
    The effect you get suggests that the pull-up resistors are on. The voltage on the lines is too low to drive the indicator diodes (they may "glow" slightly), but sufficient to drive the transistors that control the relays. Therefore they do not reflect :(


    It is exactly as you say. The shutdown is done by setting the mode in. The question is why does it work for him and not for me? :D We have the same relay etc.
  • ADVERTISEMENT
  • Helpful post
    #4 15287704
    adamz74
    Level 33  
    To the best of my knowledge, controlling an output by setting "mode in" is a mistake. You control something, clearly the mode of the ports should be set as output, and suddenly you switch the mode as input.... at which point you don't know what is happening. You have roulette... the questions begin: how were the pins initialised when the Raspberry started? aren't there some subtle changes in the design of the processor ports, because, for example, the processor series has changed? what about the relay module, because maybe, for example, the value of the resistors has been changed?

    At the very beginning of the start-up, it would be advisable to take a voltmeter and check how the potential changes during control.

    I would further modify the code of the controlPin function:
    Code: PHP
    Log in, to see the code


    and see if there would be an improvement.

    At the very end I would move the setting of the GPIO line mode and initial state to the system startup script (/etc/rc.local).
  • #5 15287972
    maleo77
    Level 8  
    I managed to make it happen. Your cue:

    adamz74 wrote:
    The effect you get suggests that the pull-up resistors are on. The voltage on the lines is too low to drive the indicator diodes (they may "glow" slightly), but sufficient to drive the transistors that control the relays. Therefore they do not reflect :(


    I did some research on these pull-up resistors and found that the pin pull-up should be turned off (tri option in gpio) and it now works perfectly.

    Thanks!
ADVERTISEMENT