5V relay with ND+
#1
Posted 18 February 2012 - 05:39 PM
#2
Posted 18 February 2012 - 07:05 PM
For those who have not followed the link Adam gave, this relay card is designed to be driven by a micro controller like the Netduino, it does not require transistors, inductors or resistors.
Following your link, there is no circuit diagram, but someone has added details of the signal voltages needed to drive the logic inputs of the relay board. The voltages stated: 0 to 0.5V (Relay ON), and 2.5 to 5V (Relay OFF), are compatible with the 0V and 3.3V that the Netduino will output on its pins. Without seeing a real circuit diagram I can't see why you would be having a problem with the supply voltage set to 5V.
It might be worth taking the connections apart and then reconnecting from scratch - just in case you made a mistake the first time when trying 5V.
Following the link to the two relay board, there was a comment that a buyer had been supplied a board different from the picture on Amazon. Maybe they have changed the design so that it is not compatible with 3.3V logic unless the supply is set to 3.3V....
Possible design changes aside; to ensure correct operation of the relay coils, I believe the relay board should be powered with 5V not 3.3V. At 3.3V you may find issues turning on the relays reliably.
The negative logic behaviour you found when running at 3.3V is correct - the Netduino pulls all the digital pins high at reset/power on, and this will turn the relays OFF. Pulling an output to ground (logic zero) turns the relays ON.
Assuming you find you can drive the relays reliably, you might consider buying the two way relay board to give you the extra relay plus a spare.
There should still be enough pins left over on the Netduino to drive the LCD you linked to with one of the Netduino COM ports. Someone is bound to have tried that particular model before and will have some driver code.
Hang in there software guy!
Paul
#3
Posted 18 February 2012 - 07:21 PM
#4
Posted 18 February 2012 - 08:52 PM
Sorry - my mistake.You say the comment about the different "variant" actually being shipped was in the 2-relay one? Looked at the two and four, couldn't find it.
The comment was actually on the eight relay board that you bought - not the two relay!
Comment:
The board I received appears to be a newer revision than the one pictured: the LEDs are surface-mount instead of thru-hole and are next to their corresponding relay, and the control headers are centered instead of in one corner.
I saw the extra pins in the picture too. On the two relay board, it is a little easier to see the labelling of the pins:JD-VCC, VCC, Gnd. Not very helpful labelling!Possibly most relevant, all of their pictures show an extra set of pins off to the side. My board does not have this. It only has the main 10-pin connector (VCC, IN1-8, GND). I notice in the 8-relay picture, it appears there is a jumper across two of them. I wonder if the newer revisions with that extra set are what that user was referring to by "the supply is set to 3.3V."
If I am reading it correctly, the 8 relay review says that JD-VCC is the supply for the relays, and VCC is the logic supply. In the picture these are linked by a jumper.
Its not unusual to give separate supply connections, it allows the supply lines for noisy motors and relays to be kept isolated from the supply for digital logic components.
It does sound like the logic on your board works best with 3.3V. It might be possible to supply 5V for the relays (JD-VCC) and 3.3V for the logic (VCC) - but only if you had been sent that version of the board I think it would be worth asking the supplier for the schematics - ideally for both versions of the board so we can play spot the difference.
Try experimenting with the relay board to check how reliable it is running at 3.3V - you might find it is OK for you. You could try some simple tests like turning on all the relays at the same time and verifying that they all come on. (The large current drawn by all relays being on together might make the power supply reduce such that some of them don't turn on fully.) When checking, don't trust the LEDs, check that the relay contacts have really closed.
Paul
#5
Posted 18 February 2012 - 11:19 PM
Well, I've got the smaller 2-relay board on order. Hopefully it will come in the new variety, and I'll see if it responds any differently.I saw the extra pins in the picture too. On the two relay board, it is a little easier to see the labelling of the pins:JD-VCC, VCC, Gnd. Not very helpful labelling!
If I am reading it correctly, the 8 relay review says that JD-VCC is the supply for the relays, and VCC is the logic supply. In the picture these are linked by a jumper.
Its not unusual to give separate supply connections, it allows the supply lines for noisy motors and relays to be kept isolated from the supply for digital logic components.
I shot off an email to them indicating when I got the old board and asked for the schematics on both. I also explained what I was seeing with the "mixed" 5V power + 3V3 signal, just in case they immediately know if that's just the way it is or not.It does sound like the logic on your board works best with 3.3V. It might be possible to supply 5V for the relays (JD-VCC) and 3.3V for the logic (VCC) - but only if you had been sent that version of the board I think it would be worth asking the supplier for the schematics - ideally for both versions of the board so we can play spot the difference.
Try experimenting with the relay board to check how reliable it is running at 3.3V - you might find it is OK for you. You could try some simple tests like turning on all the relays at the same time and verifying that they all come on. (The large current drawn by all relays being on together might make the power supply reduce such that some of them don't turn on fully.) When checking, don't trust the LEDs, check that the relay contacts have really closed.
Well, it made it through the first 3 no problem. Then it started acting strangely. Note that I do not have anything else actually hooked up to the relay - I'm 1) looking at the LEDs and 2) listening for the very noticable "click" when it toggles on and off.
Turning on the 4th one - it still clicked, but it was a much softer click. Turning on the 5th got no click at all (the LED turned on though). Strangely, turning on the 6th yielded a "strong" click again. The 7th was a "weak" click, then the 8th was strong again.
Actually, did some more testing as I was writing this. It turns out that 5th one doesn't seem to turn on at all (even if I turn off most of the others). I wonder if that relay is bad. That or it just isn't responding well to the 3V3.
The other side of this - my application is a irrigation controller. I don't have enough water pressure to turn them all on at once anyway!
#6
Posted 18 February 2012 - 11:50 PM
#7
Posted 19 February 2012 - 05:22 PM
I just did a Google search for "SainSmart + schematic" and I found this page that has a schematic for a four channel relay board. The picture is different from the one you linked to on Amazon, but I think it explains what is going on:
http://www.hoyasourc...92p9eaa2pt55p32
This schematic only has one Vcc connection (+5V).
Vcc is connected to the emitter of a PNP transistor (the leg with the arrow). When the base (the leg connected to the resistor) is pulled down by around 0.7V below the emitter, the transistor will turn on and allow current to flow from the emitter (Vcc) to the collector which is connected to the relay and LED.
If the base is left unconnected, or if it is pulled up close to 5V, the transistor will turn off and this will stop current flowing into the relay and LED.
If we assume that this is the same design as your board, I think the symptoms you reported would all be the same.
When the relay board Vcc is powered with 5V, setting any of the inputs to 3.3V (the maximum from the Netduino), the base of the transistor will see a voltage that is 2.7V less than the emitter, and this will turn on the transistor. So no voltage from the Netduino is high enough to turn off the transistor.
But, I think you can solve the problem by using a TristatePort instead of the normal OutputPort.
When you want to turn on a relay, set the pin to an output with logic zero - this will pull the output low and turn on the transistor as before.
When you want to turn off a relay, set the pin to an input (with ResistorMode.Disabled), this will cut off the path for the current and the transistor should turn off.
I'm afraid I have not used a TristatePort before, but from reading the class definition on the link above, it looks like you set port.Active = true to make the pin an output, and set it false to make it an input.
I am guessing that you can set the pin to logic zero as normal port.Write(false)
Doing this, I am hoping that it should be possible to run the relay board Vcc at either 5V or 3.3V, rather than just at 3.3V as you have been forced to do so far. Once you can use 5V, the relays will be much more reliable.
See if this helps - Paul
#8
Posted 19 February 2012 - 05:47 PM
#9
Posted 19 February 2012 - 05:59 PM
I ran the following small test program in the debugger, stepping one line at a time:
TristatePort port = new TristatePort(Pins.GPIO_PIN_D0, false, false, Port.ResistorMode.Disabled); port.Active = true; port.Active = false;
Before the first line executes (as the ND boots up), as you suspected the relay turned on. Except... it didn't. The LED turned on, but there was no "click."
First line executes - apparently by default the TristatePort is set to be Active=false. Convenient for me! The LED turns off (still no click, confirming the relay really wasn't on).
Second line executes, port goes active. Relay LED turns on, very audible click.
Third line executes, port goes inactive. Relay LED turns off, very audible click.
I essentially just replace my port.Write calls with port.Active calls (after converting to TristatePort).
So on bootup, all the LEDs will turn on, but the relay won't actually do anything (I actually haven't tried with them all connected yet, will do shortly). I'll just consider it a status indicator on boot up that my ND is still wired correctly into the relay. If a light doesn't come on briefly on boot, I know I won't be turning that relay on.
The only part that makes me somewhat nervous is the LEDs on startup. Can I trust that it will "never" trigger the relays?
Comparing this behavior to the OutputPort with 5V:
On bootup the LED turned on (no click).
Create the output port, relay clicks (LED stays on). Stays in this state regardless of what I actually output (true/false).
#10
Posted 19 February 2012 - 06:15 PM
#11
Posted 19 February 2012 - 06:21 PM
#12
Posted 19 February 2012 - 07:44 PM
SpookyBefore the first line executes (as the ND boots up), as you suspected the relay turned on. Except... it didn't. The LED turned on, but there was no "click."
Maybe the Netduino weak "pullup" resistor is not allowing enough current to flow through the transistor to power the relay coil on. The transistor is a current amplifier - so the more current that flows from the emitter to the base, the more that can flow between the emitter and the collector. When interfacing to large loads, we usually use them with a large base current that is guaranteed to turn the transistor fully on. Perhaps its a combination of the weak resistor in the Netduino limiting the current, and the fact that the voltage will be 3.3V not Gnd.
(I see that in you later post you found that the relays do sometimes come on - so this needs sorting.)
A lot of people have had an issue with the Netduino power on / reset behaviour causing connected devices to burst into life unexpectedly. (I'm not blaming the Netduino - it is only doing what is sensible.) I hope that the additional resistors solve the issue of the LEDs (and sometimes relays) coming on at power on.
Do consider adding a Wiki page with what you know - I think this family of relay boards will be useful to others.
Your welcome - glad I could help.Thanks so much for your help in getting this to the next step. The TristatePort was a great idea.
#13
Posted 20 February 2012 - 03:32 AM
Do consider adding a Wiki page with what you know - I think this family of relay boards will be useful to others.
Definitely. I'll probably hold off though until I get the resistors into this and hopefully that resolves the remaining quirk.
Thanks,
#14
Posted 20 February 2012 - 09:19 AM
#15
Posted 20 February 2012 - 09:34 AM
#16
Posted 20 February 2012 - 09:37 AM
we usually use them with a large base current that is guaranteed to turn the transistor fully on. Perhaps its a combination of the weak resistor in the Netduino limiting the current, and the fact that the voltage will be 3.3V not Gnd.
(I see that in you later post you found that the relays do sometimes come on - so this needs sorting.)
A lot of people have had an issue with the Netduino power on / reset behaviour causing connected devices to burst into life unexpectedly. (I'm not blaming the Netduino - it is only doing what is sensible.) I hope that the additional resistors solve the issue of the LEDs (and sometimes relays) coming on at power on.
Do consider adding a Wiki page with what you know - I think this family of relay boards will be useful to others.
Your welcome - glad I could help.
You could use an NPN transistor and a PNP transistor with appropriate biasing to get high trigger impedance and guaranteed saturation switching. It would certainly be educational. Or you could use an op-amp, if you don't want a high current. You also need protection from over-voltage and reverse voltage. Like many things, it's easy to do this badly and quite a bit harder to do it well. A good way to learn would be to get a kit like this http://www.jaycar.co...w.asp?ID=KC5434 and figure out what all the components do. That particular circuit is simple but thorough, with clever use of opto-isolation to achieve both protection and very low trigger current.
#17
Posted 20 February 2012 - 09:42 AM
Arbiter, do the relays on these boards all turn on when the Netduino reboots / powers on?
Paul
The Jaycar relays do. I'll have to check with the 4-relay board. If you want to inhibit switching during power up you first need to decide whether you want high-side or low-side switching, and then put either pull-up or pull down resistance on the switching side through a high value cap.
Even that may not produce a long enough delay, in which case you can use a 555 in monostable configuration (one-shot).
#18
Posted 21 February 2012 - 12:38 AM
I've been using the relay kit from Jaycar. Switching current is less than a milliamp, it's happy at 3.3V and it can switch up to 30A DC. For low power stuff I also use the 4-relay board from Little Bird Electronics with great success.
Unfortunately, the Jaycar one doesn't indicate it can switch the 24AC I need for this particular project. The shield looks tempting, although I don't have a way to power it's 9V source at the moment (and I also need 9 total relays).
I'm still sorting out how to power things though. Right now it is something like:
Main -> 24VAC Transformer -> Splits here ->
- Sprinkler valves (what the relay is actually controlling)
- 24VAC to 12VDC regulator -> WiFi Bridge -> Netduino -> (5V) Relay
Right now the relay is being powered off the Netduino, but I was also planning ultimately to add a LCD to the mix.
Due to the combined current requirements of the relay and LCD, I was considering breaking them off and powering them external to the Netduino, probably off of the 24VAC transformer as it has the highest rating (50VA, the 24VAC to 12VDC has 1500mA).
One of my end goals was to keep whole system powered via a single wall plug (currently the 24VAC transformer). Although, I'm still trying to sort out the components I'll need to make that happen. I'm mostly trying to look at premade boards because I don't really trust my circuit-building skills enough to handle the power connections and not screw something up and toast something.
On a related note, I got the specs and schematics on the "newer" version of the relays I am using. I found this very interesting:
Input control signal voltage:
0V - 0.5V Low stage (relay is ON)
2.5V –5V High state (relay is OFF).
If that is true, and it is different from older variant of the board I have, this means it should work fine with the 3.3V signal lines coming from the Netduino. It also means that it should handle the boot-up case since the Netduino is using a pull-up resistor to get it up to 3.3V.
I emailed them back asking them to confirm this (I'll also know for sure once I receive the new 2-channel one I ordered). If that really is the case, then I might order a new 8-channel one to replace the older 8-channel one. That should allow me to connect it straight in via the Netduino without needing external hardware on the signal lines. *crosses fingers*
I've attached the schematic if anyone wants a read over. Full specs are:
Size: 138 x 56 x 20mm
Power Supply: 5V DC / 400mA (relay all ON)
Input control signal voltage:
0V - 0.5V Low stage (relay is ON)
2.5V –5V High state (relay is OFF).
Input control signal LOW state current:
2.5V: 0.1mA.
3.3V: 0.18mA.
5V: 0.35mA.
JD-VCC or VCC: Power supply input, 5V DC. (JD-VCC RELAY POWER VCC:SYSTEM VCC)
GND: Power supply ground and control signal ground.
CH_x: Control signal input, Low: relay ON, High: relay OFF.
COM / NO / NC: (C1=COM1, C2=COM2)
Control signal state low, the relay ON, COM - NO disconnected, COM - NC connected.
Control signal stage high, the relay OFF, COM - NO connected, COM - NC disconnected
Attached Files
#19
Posted 21 February 2012 - 01:54 AM
#20
Posted 28 February 2012 - 01:22 AM
And they just responded - the ability to take 3.3V control signal IS a change from the original version. Hopefully that will be confirmed when I receive the new 2-channel one!
Short update - I've received the new 2-relay board. Works fine. I power it via 5V into the JD-VCC. The VCC next to the IN1/IN2 gets 3.3V. And everything works great. I'll start working on a wiki page for it.
- Giuliano likes this
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users