Relay integration
#11
(08-22-2016, 10:20 PM)MarkHaysHarris777 Wrote:
(08-22-2016, 10:11 PM)Boring Wrote: Do you also need a diode when using a solid state relay?

You need a protection diode anytime you are driving an inductive load (um, it has a coil as part of the load).

I'm not sure what you mean by solid state relay... if its a power fet or some other solid state device like that, then no, you don't need the diode protection.  The protection diode is only for going across a 'coil' to alleviate the back EMF that might otherwise destroy your Pine board. 

Some relays are in a solid block (they look solid state) but are inductive loads... and these need the diode protectors.  Again, many relay driver boards have the diode built-in, so check the data sheet of the boards you purchase ...


Using a board in between your CPU board and the load is a great tip. Some years back I used a Panasonic AQA211VL 
https://www.panasonic-electric-works.com...en_aqa.pdf

I used it directly on a Arduino Uno without diode or intermediate driving board. Guess I was lucky I didn't blew the Arduino.

Tanks again for the great tip. It is something I will definitely use in the future.
  Reply
#12
I would add that you should protect the arduino also...

... but the Arduino Uno is way more forgiving than the PineA64 or the Raspberry PI; however, the newer 3v3 Arduino systems will be just as susceptible to back EMF from the coil of an inductive load.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#13
(08-22-2016, 10:11 PM)Boring Wrote: Do you also need a diode when using a solid state relay?

Solid state relays (SSRs) do not need diodes as they do not kick back (EMF) when triggered. Unlike electromechanical (traditional) relays, they don't use a coil/electromagnet to 'switch' - hence the name 'solid state'. Instead they use generally use SCRs or TRIACs for for AC rated SSRs, or MOSFETS for DC rated SSRs. J

Just like with cheap relay boards like this one, they are have an optically isolated control signal, meaning you don't have to worry about feedback (so no diodes for the control signal, although one is still needed on the relay board) or some catastrophic failure which somehow connects the high voltage (typically your AC mains) to the low side (your control board - pine64 in this case)... killing both the board, and potentially you if touching it when it goes bang. 

SSRs are better than electromechanical relays in that they are silent, can switch on and off faster, and because there are no moving parts, can last a lot longer. Only real gotcha with SSRs is that there are AC and DC ones - unlike traditional relays you can't use them for both. Plus with low loads (think a 3W led lamp) they don't always switch off properly... there is some leakage current when they are in their off state. But that may be becoming  less of an issue with better manufacture techniques.
  Reply
#14
There is another little chip that you can look into --  the 4N35.

... the 4N35 is a optical coupled transistor.  Similar to a driver transistor; but, instead of having the signal from the PineA64 touch the gate directly (whether junction or fet) the PineA64 pin only activates an internal LED.  The light from the LED optically triggers the transistor internally so that there is an effective isolation between what is being driven (whatever the load) and the driver-- the Pine board.

But, just as pfeerick has stated, if the optical isolator (4N35) is not protected by a diode while driving a coil (inductive load) then back EMF can destroy the optical coupler !

I have used the 4N35 frequently; its a cool little device, and very inexpensive; almost as inexpensive as a regular 2N2222 transistor.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#15
Alright, the relay via GPIO project works, my python code attached at the bottom, one anomaly i noticed just now, whenever i power cycle or turn on the pine64 board, it triggers the relay, which is obviously a bad thing because my relay triggers the garage gate to open or close.
so then if power blips - my garage gate will open.

Any idea how to prevent GPIO blips on boot or on power on ?

my python code (no rocket science, and based on relay rpi lab):
import RPi.GPIO as GPIO ## Import GPIO library
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(15, GPIO.OUT)
GPIO.output(15,False)
time.sleep(4)
GPIO.output(15,True)
  Reply
#16
(08-25-2016, 01:17 AM)vigor Wrote: Alright, the relay via GPIO project works, my python code attached at the bottom, one anomaly i noticed just now, whenever i power cycle or turn on the pine64 board, it triggers the relay, which is obviously a bad thing  because my relay triggers the garage gate to open or close.
so then if power blips - my garage gate will open.

Any idea how to prevent GPIO blips on boot or on power on ?

my python code (no rocket science, and based on relay rpi lab):
import RPi.GPIO as GPIO ## Import GPIO library
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(15, GPIO.OUT)
GPIO.output(15,False)
time.sleep(4)
GPIO.output(15,True)

You have to have a two or three level AND condition;  the relay must never be connected to just one GPIO pin, not directly anyways. You must have fail safe protocols in place... its a more complex project than you anticipated.

Another thing you can do is to place a power control circuit in-line with the relays so that when the power blips the relays do not get power until a set duration of power ON time... allowing your PineA64 board to initialize and do a full POR (um power on reset).  This also is more complicated than it at first appears.

Lastly , you need to have more than one control board running... at least two, but maybe three.  The purpose is that there is a closed loop of control structures which can 'watch' each other; for redundancy and for backup. At least two have to agree before an action is taken.

its just not as simple as turning a GPIO pin on and off.

edit: and PS... I hope you have your control system on a good UPS (uninterruptable power supply)
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#17
(08-25-2016, 01:17 AM)vigor Wrote: Alright, the relay via GPIO project works, my python code attached at the bottom, one anomaly i noticed just now, whenever i power cycle or turn on the pine64 board, it triggers the relay, which is obviously a bad thing  because my relay triggers the garage gate to open or close.
so then if power blips - my garage gate will open.

Any idea how to prevent GPIO blips on boot or on power on ?

my python code (no rocket science, and based on relay rpi lab):
import RPi.GPIO as GPIO ## Import GPIO library
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(15, GPIO.OUT)
GPIO.output(15,False)
time.sleep(4)
GPIO.output(15,True)

Unless one of the GPIO pins always starts up in a state that is usable as an 'off' state and stays that way until your python code can take over (which I wouldn't personally rely on), you're going to be out be out of luck. The pine64 is not suited for direct control of something like this, and needs a bit of help. Since it is a full blown computer, it has the inherent problem of things like the GPIO pin state being unreliable until they are initialised, it taking while for it to start up if it is powered down or reset, and the odd crash. So either it is better to use secondary boards that are intelligent enough to be able to wait for the pine64 to initialise / or can confirm/verify an command before doing something to make sure it's not a false trigger. Last thing you want is for the board to crash and in doing so... open your garage door for whoever wants to wander in...

 To do the sort of thing you want to do, I would be considering using something like an 3v Arduino Nano to do the actual relay control (you can buy cheap clones for around $3 on eBay). This means you would have a chip/board that is dedicated to driving the relay. One way to get the two to communicate could be to connect the serial of the pine to the serial of the Arduino, meaning you could send a message via the serial to instruct the Arduino to trigger the relay on or off, and the Arduino could confirm that back. If invalid data goes over the serial to the arduino, it can just ignore it as it isn't what it's waiting for. 

You might also have override switches on the Arduino for 'manual control' if the pine64 crashes and you just want to open/close the door. You can even take it a step further, and have the Arduino monitor the pine64 for a regular heartbeat, and if it doesn't see it, trigger a reset (basically a software emulation of a hardware watchdog timer).
  Reply
#18
   

Another option for you is the Gert-Board !

... named for its designer, Gert van Loo. Gert is a Raspberry PI engineer, and a brilliant and talented developer of hardware as well as software.

The Gertboard has the Atmel Atmega328p chip... the same chip that is on the Arduino.  it also has the ULN2803 driver, and also GPIO buffer chips.

...  the idea here is that you program the 328p to actually do the relay control (opening and closing the door) and you 'talk' to the 328p via serial uart from the PineA64 for high level commands. (of course you could use GPIO too, once the POR takes place).  But, again, you have some buffer between the unreliable GPIO states of the PineA64 (until POR) and the actual relay interface which is low-level controlled by the 328p.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#19
is this the "3v Arduino Nano" http://goo.gl/oHtVZx ?
  Reply
#20
(08-25-2016, 03:30 PM)vigor Wrote: is this the "3v Arduino Nano"   http://goo.gl/oHtVZx   ?

Yes, another fine option too. 

... not as robust as the Gertboard mind you, but a 3v3 system compatible with the PineA64, and again, a micro controller for handling the low-level stuff, while the PineA64 handles the high-level stuff.

I guess I really don't know what you're doing with your garage door project exactly... and probably, not definitely, the Arduino nano may be able to handle it alone... only you will be able to judge that.

( check carefully whether the arduino products you purchase use a 5v or 3v3 system )
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)