relays with Teensy 3.1 help needed

Status
Not open for further replies.

donkeyahoy

Well-known member
Hi. I need some advice with starting this project. I'm fairly new at all this.

I would like to trigger 3 relays with the Teensy 3.1. Could someone recommend relay part numbers for these specs :

contact specs : non-latching 12V DC 100mA
coil specs : Teensy digital output pin

3 different relays needed :

1) momentary spst normally open
2) momentary spst normally closed
3) momentary dpst normally open

Are there relays out there that would be triggered by Teensy 3.1's digital output? So I could just program a digitalWrite high. I also suppose I could substitute two relays for the dpst and just program for both of them to trigger.

Is there also a circuit to do this? I suppose I might need diodes, NPN transistors, and resistors.

Thanks for the help! Let me know what you think and if this is feasible or if I should be going about it in another way.

Hope to hear from you soon. :)
 
Honestly, you might be better off getting started by using something like this, which you can connect directly to the digital output pins.
 
Honestly, you might be better off getting started by using something like this, which you can connect directly to the digital output pins.

Ok I went with your suggestion on the SainSmart 4-Channel Relay Module. It should be here tomorrow.

I read that there is no documentation with it. Is it as simple as wiring it's GND and VCC to my 5V power supply? And PINS 1,2,3,4 to some Teensy digital outs?

What is this JD-VCC on it that people are discussing?

I plan to use my SN74ABT125N buffer if the 3V Teensy pin outs aren't enough.

Thank you for the recommendation.
 
if you have that module with an opto-isolator on the digital input side, then all the Teensy needs to do is to turn on the LED inside the opto-isolator. Just like any other LED. Current limiting resistor in line. I recommend having the Teensy output a 0 to activate so the GPIO is sinking, not sourcing current. The device might name the LED cathode "-" on the connector. The resistor goes from "+" (anode) to Vcc.

Beware the relay coil current needs vs. the power source.
 
if you have that module with an opto-isolator on the digital input side, then all the Teensy needs to do is to turn on the LED inside the opto-isolator. Just like any other LED. Current limiting resistor in line. I recommend having the Teensy output a 0 to activate so the GPIO is sinking, not sourcing current. The device might name the LED cathode "-" on the connector. The resistor goes from "+" (anode) to Vcc.

Beware the relay coil current needs vs. the power source.


My 5V power has 1A available. I'm using 3 out of the 4 relays. The description said 20mA to drive each coil, so I think this will be fine.

I don't see any cathode "-" on the connector. It only has GND, IN1, IN2, IN3, IN4, VCC. There is also a jumper area with JD-VCC AND VCC. Hmm.. may need some more help with connecting these 3V Teensy GPIO to this 5V relay module. I'll keep reading and trying to figure it out, but if anyone has any advice to post, go ahead!
 
I'm guessing that IN1 is the anode of a diode. That means the Teensy must source (not sink) the LED current which will be about 5-10mA. Uses a resistor, about 220 ohms for IN1. And wire the relay board's digital side GND to the GND of the Teensy board.
I'd email the seller and ask them to point you to a schematic from the manufacturer.
The opto-isolator chip on the board -- you can use its part # to lookup data sheet.

When you get the board, it'll be easy to figure out, even without a schematic.
 
Cool. Thanks. Should arrive tomorrow.

I did find this schematic off their website. It's for one of the four relays.

SainSmart relay.jpg
 
Ah, that shows that IN3 is the cathode. That's better. And there's a built-in resistor (R14) for the LED.
So all you have to do is tie IN4 (or IN1) to a GPIO pin on the Teensy and Vcc to the V3.3 pin of Teensy. The right side of the optoisolator runs on JD-VCC but the schematic doesn't show where JD-VCC goes to a connector, e.g., for 5VDC. Don't connect JD-VCC to 3.3V due to the relay coil.
 
So I'm thinking the VCC will go to 3V on Teensy and I'll use 3 GPIOs to IN1,IN2,IN3. GND will go to Teensy GND. Sounds like JD-VCC will need to be connected to 5V from the power supply for the coil power. And then it will seem like it needs another isolated GND for this 5v?

Or option 2 maybe easier to buffer all the GPIOs to 5V level and then just connect the VCC to 5V power and GND to power GND.

Still not sure. Here are some things they were saying on Amazon :

"Is the ground common for both the relay and the signal ? May 18, 2014"

"The signal is active low(pull the pin to ground) relative to VCC on the signal connector. If you want to isolate the signal from the relay supply, pull the jumper from the 3pin connector, and supply relay power through the GND and JD-VCC pins (outer two) on the 3pin connector. Signals are applied between the VCC and IN1-IN4 pins. Remember, signal pins are active low. VCC is the common element here, as the relay is activated when the signal line is at logic ground potential."

"Will it work with 3.3V Logic?"

"It will need an external 5v power source to deliver enough power to power the relays, but the relays can be controlled by 3.3V. I use this and the Sainsmart SSR boards with a Raspberry Pi which uses similar voltage as an Arduino."

"Relays are triggered by taking the corresponding pin to ground. However, the the supply to the relays (and opto-isolators) is 5v. So if the Due is 5v tolerant, then the answer is yes, otherwise, you would need to interface with a uln2003 or other chip to safely translate levels. I have used it successfully in a 3.3v system, but it was a Z8 Encor micorcontroller, which IS 5V tolerant."

"It takes an active LOW (Gnd) to energize a relay and light the associated LED. A active HIGH, or a disconnect, will de-energize the relay."
 
Your option 1 sounds right to me. I'm pretty sure that's how I did it, although it was a while ago and I may have been using an Arduino board (5V). Is your 5V supply running the Teensy? In that case they are sharing a ground anyway. Just send 5V to relay_JD-VCC, 3.3V to relay_VCC, GND to relay_GND and teensy_GND, and teensy_GPIO to relay_IN.
 
Your option 1 sounds right to me. I'm pretty sure that's how I did it, although it was a while ago and I may have been using an Arduino board (5V). Is your 5V supply running the Teensy? In that case they are sharing a ground anyway. Just send 5V to relay_JD-VCC, 3.3V to relay_VCC, GND to relay_GND and teensy_GND, and teensy_GPIO to relay_IN.

Yes 5V running the Teensy too.

Ok, I'll try this option 1.

I think the SainSmart 4-Channel Relay Module has a jumper between VCC and JD-VCC that should be removed. Besides that I don't see what else I really need to do.

5V to relay_JD-VCC, 3.3V to relay_VCC, GND to relay_GND. Teensy_GPIOs to relay_INs. <= like you said

I think all the resistor, transistor, diode setup is already on the relay module INs (shown in that schematic a few posts ago). I could be wrong though, not sure. Any last advice before I try the above wiring, anybody?
 
You have it correct. That's why I recommended that relay module. For just getting things connected, it's completely awesome. And it has all the right features like current-limiting resistors and optoisolation. I have a few of their modules. They also make modules with solid-state relays, if that is more appropriate for a give application.
 
Status
Not open for further replies.
Back
Top