Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

Thread: Teensy LC with relay board

  1. #1
    Junior Member
    Join Date
    Nov 2018
    Posts
    6

    Teensy LC with relay board

    Hello I would like to manage 12v leds using a Teensy LC to this Relay board https://www.amazon.com/gp/product/B0...?ie=UTF8&psc=1
    Its a SainSmart 16 channel with 2 ULN2803a's and optocouplers. I am confused as to how to hook my LC the proper way to it. I understand the low level input pins but as to power the LC I get a little confused. The LC will be connected to usb to my pc. Any help would be great.

    D

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,258
    Is there a schematic or tech info on this relay board?

    From the photos, it looks like it's designed to just have 16 ordinary digital I/O pins connected to control the 16 relays. But that's a bit of guesswork from the low-res photos of the parts I can see on the boards. The Amazon page doesn't seem to have a schematic or other reliable technical specs.

  3. #3
    Junior Member
    Join Date
    Nov 2018
    Posts
    6
    I can't find one anywhere, I tried finding over the internet but no luck with a schematic. I was thinking because it has the 2803's that the 3.3v output pins from the LC would be sufficient. I just don't know if I should also put an external 5v to the LC along with the usb.I know I would have to cut the v pads apart.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,258
    My best guess from the photos is you'd give the relay board a separate 12V power supply on it's 2 pin terminal block.

    If you get one of these, the very first thing I'd suggest doing is testing with an ohm meter between the GND pin on the 12V power input and the 2 GND pins on the control input. If there's no conduction (max resistance), that's a good sign the 16 inputs really are fully optically isolated from the 12V power. In that case, you could power the Teensy pretty much any way you like, since it's isolated from the rest.

    If those GND pins are connected, probably not a big problem. You'll just need to use a 12V power supply that can have its GND connected to Teensy's GND.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,258
    Looks like this might be the schematic.
    Attached Files Attached Files

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,258
    SainSmart's website also has a file that looks like the PCB layout.

    Here's an image of the control electronics part.

    Click image for larger version. 

Name:	pcb.jpg 
Views:	4 
Size:	98.7 KB 
ID:	15894

    Based on this info, I would *NOT* recommend use with Teensy LC. The board has a 5V power supply and the inputs go to the optocoupler diodes and then resistor right to the 5V power.

    Teensy LC is not 5V tolerant. Using it with this board will risk damage to the hardware!


    Also, this relay board optocoupler section seems to be a rather stupid design. I can't imagine what Sainsmart's engineers were thinking. Well, actually I can imagine... very likely an arbitrary requirement to have optocouplers (probably copying the specs of some well designed relay product) and their engineers were either lazy, incompetent, or just didn't care.

    The way they designed this board, the optocouplers don't actually isolate you from anything, other than isolation already provided by the relays. The optocouplers are truly redundant, serving no useful purpose. Well, no purpose other than to sell the board to people who can't tell the difference and believe the optocouplers must be adding some value. They aren't. The optocoupler inputs are all connected by resistors to the 5V, which shares GND with the 12V power - so you are indeed galvanicly coupled to the 12V power supply despite the fact this board has 16 (useless) optocouplers!

    I would not recommend buying this Smartsain product. Its design is just terrible.

    If you do get it, use Teensy 3.2 or 3.5 (which are 5V tolerant), or Teensy 2.0 (which runs on 5V). For use with Teensy 3.2 or 3.5, to control these relays you would connect GND from the relay board to Teensy's GND, and connect digital pins to the inputs. To control the relay, you would do something that may seem strange. To turn the relay on, you'd use pinMode(pin, OUTPUT) and digitalWrite(pin, LOW). To turn the relay off, you would use pinMode(pin, INPUT). Changing to input mode is needed, because Teensy 3.2 & 3.5 have 3.3V outputs. You can't drive the pin to 5V. But if you just put the pin into INPUT mode, it will stop driving the optocoupler and the relay will turn off.

    I'm pretty sure that will make this relay board work. But only try that on Teensy 3.2 or 3.5. Do not use Teensy LC or Teensy 3.6, because they are not 5V tolerant.

    If you haven't purchased this relay board yet, I would advise against wasting your money. Get a better one. If it has optocouplers, get one where the engineers who designed the board were smart enough (or copied a design from a competent engineer) where the optocouplers really do give you a second layer of protection. This Smartsain 16-Channel 12V Relay Module is at best a shoddy product designed by people who either didn't understand optocouplers or just didn't care.

  7. #7
    Junior Member
    Join Date
    Nov 2018
    Posts
    6
    Thanks Paul for the wealth of info here. Very valuable. Unfortunately it should be here tomorrow. I have a few 3.2's so will give those a go. I can use a 5v external power as well as the usb for the 3.2 yes? I am controlling real hardware via Xplane 11, which is why I need the usb.

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,258
    The most important thing will be connecting GND on Teensy to GND on that relay board.

    If Teensy gets external 5V power, usually you would cut the VIN-VUSB pads apart, so the external 5V power can't try to flow back into your computer.

  9. #9
    Junior Member
    Join Date
    Nov 2018
    Posts
    6
    Ok cool thanks Paul. I'll give it a go.

  10. #10
    Junior Member
    Join Date
    Nov 2018
    Posts
    6
    Hey Paul, is the Teensy 2.0 X Plane friendly?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •