Author Topic: Software (RPi) controlling relays  (Read 2456 times)

0 Members and 1 Guest are viewing this topic.

Offline fourierTopic starter

  • Newbie
  • Posts: 4
Software (RPi) controlling relays
« on: March 11, 2015, 11:02:08 pm »
Hi everyone, this is my first post, so bare with me if I am a bit ignorant. My electronics skills are squarely in the hobby category, so I'm pretty out of my depth on this.

What I am trying to do:

I have a 3D Printer that I am trying to turn on and off with a Raspberry Pi (running Octoprint). The printer is powered by a regular PC ATX PSU, on a P4 ATX connector (like one of these: http://www.picco.nl/catalog/images/A65604.jpg ). I know I need either a MOSFET or relay to control a relatively high current source like this. I believe, after a lot of googling and research that I have found a workable solution, but I want to make sure it is adequate, and most importantly: safe.

I should also mention that I do not wish to turn the PSU itself on and off, as I am using it to power other things as well (such as a string of nice LED lighting for my bench). I know that's the easiest solution, but I need to be able to turn the printer off independently of the PSU.

Solution:

Using one of these: http://www.amazon.com/gp/product/B0057OC5O8/
I will wire up two of the relays to the positive lines of the P4 ATX connector. I will connect the relay board to the RPi. I believe that I can control two relays with a single RPi GPIO pin (shorting two of the relay INs together to the GPIO), which I think is the best idea so that both relays toggle on/off at the same time? I hope I am not wrong in the assumption that I can control both from a single pin.

I also want to make sure the current draw will be safe. Based on some sketchy specifications, I believe the printer draws, at most, around 8 amps (at 12V DC), and drops as the heating elements reach their set temperatures. By using two 10 amp relays, am I correct in assuming this would provide ample headroom to make this safe to use? Although I do not think the device will be drawing anywhere near 8 amps when the relays are actuated on or off, I do want to have the ability, as a failsafe mechanism if something goes wrong with the printer.

Finally, is there any other concerns that I should be made aware of with this? Thanks for your assistance!
 

Offline Phaedrus

  • Frequent Contributor
  • **
  • Posts: 714
  • Country: us
Re: Software (RPi) controlling relays
« Reply #1 on: March 11, 2015, 11:23:12 pm »
I know you said you don't want to turn the PSU itself on and off, but is it possible you could put your LEDs and other extras on the standby rail? You'll typically have 2-3A @5V available, which should be enough for LEDs, with a boost converter if necessary.

I say this because it's much, much cheaper and easier to switch the TTL level PS_ON wire, than to switch 8 amps @12V. We're talking a <$2 solution, vs. >$20.
« Last Edit: March 11, 2015, 11:25:10 pm by Phaedrus »
"More quotes have been misattributed to Albert Einstein than to any other famous person."
- Albert Einstein
 

Offline fourierTopic starter

  • Newbie
  • Posts: 4
Re: Software (RPi) controlling relays
« Reply #2 on: March 11, 2015, 11:28:46 pm »
I know you said you don't want to turn the PSU itself on and off, but is it possible you could put your LEDs and other extras on the standby rail? You'll typically have 2-3A @5V available, which should be enough for LEDs, with a boost converter if necessary.

I say this because it's much, much easier to switch the TTL level PS_ON wire, than to switch tens of amps @+12V.

The Pi is going to be powered by the standby rail, but the LED strip draws far too much current for that rail. They're 12V LEDs, and I think my off-the-cuff calculation was about 20-25W (this is about 6 feet of LEDs by the way, the entire underside of a shelf). That's almost double the maximum for the standby rail on my PSU unfortunately.

 

Offline Rick Law

  • Super Contributor
  • ***
  • Posts: 3423
  • Country: us
Re: Software (RPi) controlling relays
« Reply #3 on: March 12, 2015, 03:17:07 am »
Fourier,

Make sure you have enough current to the relay unit.

The product link you posted said: "5V 4-Channel Relay interface board, and each one needs 15-20mA Driver Current"

That is not all the current the board needs.  You will need a total of 440mA!  The driver current turns on the current for the relay coil only but does provide the current for the relay coil.  You need to add that in.

From the Songle relays spec sheet, each relay will need 80mA-90mA for the coil.  Four relays, each 80-90mA for coil and 15-20mA for driver current.  In total, you are looking at 380-440mA.  440mA would be too much for an Arduino; but you are using RPi and I don't know if the RPi can give 440mA.  You may need to supply the coil separately.  (Yeah, I have a board like that.  I did the math first, so I decided to go with dual relay only for an Arduino.)

You can provide up to 440mA to this unit and turn it on first, or turn it on at the same time as the MCU.  Alternatively, you can power the coil separate.

(Took me some research and tracing the board...) On the product picture with your link at the lower right corner, you see a blue jumper (JD-VCC & VCC)JD-VCC is the coil-side of the opto-coupler and VCC is the DataIn(from MCU) side of the opto.  The jumper connects JD-VCC to VCC.  Remove the jumper and you can connect separate coil power to the JD-VCC pin.  You can share the same ground pin.

If you power VCC with the MCU, the unit's logic will function properly.  If JD-VCC is absent, the coils will not operate till you have JD-VCC, but with VCC, the logic is powered and will not freak out.  (Now you can power them up at any order)

Lastly, one thing that may trip you.  The logic in is INPUT LOW to trigger the relay (and LED).  So, if you INPUT HIGH and expect something to happen- nothing will happen and even LED on the board will stay dark... you may think the unit is not working.

Good luck!

Rick
« Last Edit: March 12, 2015, 03:32:06 am by Rick Law »
 

Offline fourierTopic starter

  • Newbie
  • Posts: 4
Re: Software (RPi) controlling relays
« Reply #4 on: March 12, 2015, 04:53:18 am »
Thank you so much for that information and research!

The Pi definitely won't be able to put out 440ma on its own. So I assume if I pull some 5V off of the PSU standby, I can use that to power the JD-VCC.

This won't be a problem if the VCC side is 3.3v from the Pi, right? I assume they're isolated so it would be irrelevant. This board is said to be compatible with the Pi, so the VCC should work with 3.3v.

And finally, yes I'm aware of the logic part. I'm not going to wire this thing up to anything until I know for sure the relays are clicking proper.

Thanks again!
 

Offline Rick Law

  • Super Contributor
  • ***
  • Posts: 3423
  • Country: us
Re: Software (RPi) controlling relays
« Reply #5 on: March 12, 2015, 06:40:34 am »
Thank you so much for that information and research!

The Pi definitely won't be able to put out 440ma on its own. So I assume if I pull some 5V off of the PSU standby, I can use that to power the JD-VCC.

This won't be a problem if the VCC side is 3.3v from the Pi, right? I assume they're isolated so it would be irrelevant. This board is said to be compatible with the Pi, so the VCC should work with 3.3v.

And finally, yes I'm aware of the logic part. I'm not going to wire this thing up to anything until I know for sure the relays are clicking proper.

Thanks again!

Ahem, too much thanks there.   I did that research for myself when I had to figure it out if it would work for me.  It was so damn difficult to find so I want to make sure others don't have to get as annoyed as I did.

0V Low 3.3V High DataIn is no problem.

While it is designed to work at Vcc=3.3V (should and likely does work), but looking at the spec sheets for the opto and how the input is designed, it is rather close to the margin.  To void the extra trouble of finding out later, I would test it prior to deploying it.  I would tests VCC down a little (3.0/3.1V) to make sure it works with some leeway for small power fluctuation.

Details:
The Vf for the opto, the Vf for red led in series, and a balast 1K resistor all in series.  Vcc minus sum of these three voltages has to be > logic=low for the opto to go full ON.
 * Vf for the opto is 1.2V norminal, 1.4V max (faichild FO817), 1.6V max (vishay K817p), God knows what brand of 817 opto this board uses.
 * Vf for the red LED is probably 1.8V to 2V
If Vf for both the opto and the red LED are near typical, things are great.  But if both are high, that is 3.6V right there even without the balast.  You need [Vcc - (sum of the three Vf's)] to be greater than V(logic=low).  That looks too close for comfort to me - the opto's output drives a transistor.  Unless this transistor, and the output transistor of the opto are designed to turn on at minimal V(gate) (or current of opto) which I would not know since the part number is not readable.
EDIT: my worry is probably just because I am not very experienced.  When the spec's Vf adds well only at nominal with hardly any margins, that worries me.
« Last Edit: March 12, 2015, 07:38:56 am by Rick Law »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf