Putting two Teensys on a PCB

Status
Not open for further replies.

c1223

Member
Quick question. I'm building a controller that requires two Teensys to be connected to two different computers or laptops. Each Teensy is triggered by a button so they can redundantly control an application on each computer. They'll also be some LEDs. I've been advised, that if I want the Teensy to work as a failover and control the LEDs that I should tie the 5V and GND of both Teensy together respectively? Is that correct?
 
No. Be careful with that.

Tying grounds together might be ok, but not the supply voltages directly. That could easily lead to damage to the computers or Teensys or burned out wires. Fire hazard either way.
 
What about using an opto-coupler to trigger the events so that you aren't electrically connecting the two devices?
 
Electrically you need shared grounds and some form of shared power, however neither the grounds nor the 5V USB may be the same. The problem with grounds is that two different computer power supplies may have slightly different ground potentials, and connecting them will get power flowing from one PC to the other in amounts large enough to melt things and or trip RCDs. Good design by the engineers will reduce that and in theory if the PCs are side by side and grounded by the same sockets then you will probably be fine. Simple test is to use a meter to measure from on to the other. If they are zero then you are fine, but you may find some sizable difference and need to have a think about things.

With the powers most USB power supplies are 'about 5 volts' so again if you plug on to the other the higher voltage one will try to feed the other. This may just share the total load but equally possibly you will have the results you'd expect when you force feed something. Also interesting results will happen if one PC is off but it's USB 5V still has power from it's partner.

Basic answer is never connect to supplies together unless they are specifically designed for load sharing. What you do instead with the 5V is run them through diodes. This means that which ever has the higher voltage will power everything and not upset the other, akin to this https://www.pjrc.com/teensy/external_power.html but for the whole PCB.

So most likely this can be done by checking gnds and then connecting them and putting diodes on the 5V.

If you can't connect the gnds then this is why most industrial equipment has https://en.wikipedia.org/wiki/Opto-isolator, and you will need to have them on the serial connections.
 
Connecting a switch to both Teenys is the easiest part as I can do that with two schottky diodes. It's getting 5V, GND and data to the WS2811 that is the harder part. There is an option to just power the WS2811 from one computer which I will probably end up doing, as it doesn't look like there is an easy solution.
 
Assuming ground potentials are the same you can power the strip through diodes. getting the data there is a bit trickier. If you are using an offboard level converter you could take one sides' drive to pinMode(x,DISABLE); but if you are using an onboard level converter that gets a bit trickier. The normal solution in redundancy cases would actually use a relay. Wire it up so the primary side powers the relay and connects the data line through, if power is lost it goes to unpowered state and connects the fallback. Does depend on how fussy the data lines are to being unconnected while the switching happens, may require a 1M pullup or pulldown, depending on how the input stage is designed.
 
I was thinking more the power supply rails being a problem than the data lines. It would be nice to see a mock up schematic for those though I suppose.

As GremlinWrangler says, a common solution is to connect each power source through a diode, so there is no way for one to feedback into the other.

Re: data lines, yes you should take account of what voltages might appear on a pin of an unpowered chip, if there is a possibility of the other chip being powered. Usually the datasheet will tell you not to have a pin at greater voltage than some percentage of the input power to avoid damage. Or, if the pin effectively becomes a short to ground, it might damage the track to it.

Potential solutions may again involve diodes, or even just a small resistor, something just big enough to sink any power that would otherwise be a short. As I say, seeing the schematic would be useful.
 
This is my initial thought. It isn't completely failsafe in terms of the LEDs remaining on, however as far as I can see it would never allow the WS2811 to be powered and/or received data from two sources.

fHEVziK.jpg


I've actually drawn the diagram slightly wrong. The idea is to have a depletion mode MOSFET controlled by the USB power of Teensy #1. That way, the data line from Teensy #2 only ever gets connected if we're sure that there is no power coming from the first Teensy. Also I don't think there is any need for either Schottky diode.
 
Worth being aware that the WS2811 waveform is pretty sensitive to slew rate (how square the waveform is). So those diodes will probably be a problem since the circuit needs to activly sink current to pull the level down. Did at one stage make a discrete transistor level converter and found the hard way that it's very easy to destroy the pulse train enough that the self clocking breaks down, so you need a way for Teensy #2 to pull the line level down, which won't work through that transistor. Would suggest either some prototyping or some time with a simulation package looking at how much any solution mucks with the square edges of the waveform.

Also the design as drawn has no level conversion, assuming these are T3.X 3.3v devices?

One two birds with one stone option would be to use a schmitt triggered logic gate (OR I think would be easiest to work with) and use that to combine things, assuming you can code Teensy #2 to not send data while Teensy #1 is functioning.

Otherwise the part you want would be a multiplexor, though finding one fast enough for the job may be tricky.
 
Include some way of the backup teensy (T2) monitoring the output of the main teensy (T1) in order to know when to switch over control; you can either directly probe the data from T1 or send a "still alive" signal from T1 to T2. As long as T2 sees this signal it will do nothing, when it stops T2 will take over. Then you can just combine the data lines together. Gremlinwrangler suggests using an OR gate, which I would simplify to another pair of diodes.
Untitled.png

It seems nasty but it has the same effect as an or gate, but should preserve the waveform a little better. The 37 ohm resistor there is recommeded on the datasheet for the WS2811 i found at adafruit.
Of course the bigger question is what kind of failure you're anticipating/protecting against. This soloution will only work if T1 fails and stops driving it's data out - should it hang with the ouput high T2 will be unable to change the output. If you're protecting aggainst power loss to T1 then this will be fine, as the Diode will prevent any power flowing back into the pin.

In terms of a perfect switch-over from T1 to T2 without any loss that's probably impossible without an-over engineered solution. You'd have to perfectly syncronise both chips and have T2 take over as soon as T1 stops, and even then you'd have at least one bit in error, unless failure occured during the reset time. That being said you should be able to switch over control faster than the eye can notice!
 
Status
Not open for further replies.
Back
Top