Modulate UART into VCC? () - Page 1
Forum section: electronics / general

author: halkabar
author_rank: Contributor
timestamp: December 17, 2015, 12:17:55 am
content: Hi, I'm currently working on a project where multiple microcontrollers communicate through the hardware serial port. They are connected via a 4pin wire (Vcc, GND, TX, RX). I was wondering if it was possible to modulate the serial data into VCC so I could get away with fewer cables...

author: rs20
author_rank: Super Contributor
timestamp: December 17, 2015, 12:21:00 am
content: It's more productive to describe it as "powering the microcontroller off RX". I.e., if you have a diode running from RX to the VCC pin of the microcontroller, and a large capacitor on the VCC pin of the microcontroller, then you can get rid of the Vcc cable -- it'll just power off the RX line, with the capacitor providing power for the periods while RX is low. Importantly though, you must ensure that the low periods of RX are never longer than a certain period, as determined by the current draw of the microcontroller and the capacitance of your large capacitor.

author: halkabar
author_rank: Contributor
timestamp: December 17, 2015, 01:22:02 am
content: Thanks, I just tried it, works nicely with a 100uF cap. I should try to use a diode with the lowest forward voltage possible, right? (Now I'm using a 1n4004 with a Vf of about 0.75V) a Schottky maybe?

author: Ian.M
author_rank: Super Contributor
timestamp: December 17, 2015, 01:42:32 am
content: An alternative that may be less hairy is to redesign your hardware and software for half-duplex communication over a single RX/TX wire. If you've got enough spare bandwidth, you can even put multiple devices on the same wire, but then you need to get into stuff like addressing so that the individual slave devices know which messages are for them and therefore, when to respond.At its simplest, if you aren't using line drivers, assuming you are using logic level signelling with inverted RS232 framing (the most common), simply connect a Scottky diode from the TX pin to the RX pin, cathode to TX, and add a pullup at RX. The shared wire then connects all the RX pins together. That way the TX pin can pull the line low, but there can never be a damaging conflict as it cannot drive it high. Because its a passive pullup, you have to be careful with the baud rate and cable length as the signal integrity may not be as good as you want..

author: halkabar
author_rank: Contributor
timestamp: December 17, 2015, 02:02:48 am
content: Thanks Ian, that's exactly what I was thinking..How many microcontrollers can I hook up this way without a line driver?

author: langwadt
author_rank: Super Contributor
timestamp: December 17, 2015, 02:17:57 am
content: Quote from: Ian.M on December 17, 2015, 01:42:32 amcould combine it,current limit the VCC and use it for both supply and RX/TX, each device TX by pulling the VCC line low(er)

author: Ian.M
author_rank: Super Contributor
timestamp: December 17, 2015, 02:59:06 am
content: Quote from: halkabar on December 17, 2015, 02:02:48 amIt depends on line length, capacitance, and the baud rate and pullup resistors you use, as the CMOS inputs themselves are a very small load compared to the pullup resistors.As a rough rule of thumb: If risetime>bit_period/3 you are in trouble. Risetime is approximately 2*R*C, where R is the parallel combination of all the pullups. That assumes your UART samples between 1/2 and 2/3 of each bit period. If you know it samples closer to the beginning of the bit, you need a faster rise time so lower R and/or C to compensate.Lets look at the constraint on how low you can go with the pullup resistors. That depends on your Vdd and how much current your MCU can sink on its TX pin without excessive voltage drop. If, for example, it can sink 10mA with 1V drop, and you have a 820R pullup at each end of the bus, and you are using a BAT42 diode which has a max Vf @10mA of 0.4V, you are already marginal with 5V Vdd if the logic 0 threshold is 1/3 of Vdd.If you need more drive, there are two easy options:* Replace the diode with a non-inverting open drain line driver (or use a tristate buffer with /EN and Din connected together) which gives you more current capability and also avoids the diode Vf drop.*use LIN Bus transceivers with 12V signalling. As LIN is designed for automotive environments it is extremely robust and the drive levels are such that, ignoring the actual LIN protocol, you could have hundreds of nodes and 19.2 kbit/s @ 40 meter bus length.Edit: Dropped the pullup values a bit. I hadn't allowed for the voltage drop in the lower pin driver. It now runs at 9mA worst case.

author: rs20
author_rank: Super Contributor
timestamp: December 17, 2015, 03:43:45 am
content: It's also worth pointing out that the1-wire interfaceis a fairly standard protocol (if not standardized), and it proves power and bidirectional communication over just a single wire (only other wire required is ground). A lot of sensors (digital thermometers, etc) have this interface to reduce cabling costs.This is basically what you arrive at if you take langwadt's suggestion to its logical conclusion.

author: tszaboo
author_rank: Super Contributor
timestamp: December 17, 2015, 09:26:10 am
content: I would look up the HART Communications Protocol, AKA 4-20mA. That is standardised, and you will find nice ICs doing it. On the other hand, if you can live with it, you can buy these Nordic semiconductor radio modules for something like 2-300 Ft.

author: macboy
author_rank: Super Contributor
timestamp: December 18, 2015, 02:56:06 pm
content: Quote from: halkabar on December 17, 2015, 02:02:48 amThe answer is simple: "It depends".Seriously though, it depends on things like overall cable length between devices, and the strength of the pullup(s). This scheme looks a lot like I2C in an electrical sense. The strength of the pull-ups (and the drive strength of the micros' output lines) will determine the rise and fall times of the signal, which in turn directly limit the baud rate. Don't forget that the talking device needs to sink current from all pullups in the system, so don't exceed its ratings. Because this is asyncronous and not a clocked signal, you need to make sure that the pulse shape is even better than it would need to be for I2C, or you will start seeing data errors. You may even need a resistor in series with the diodes in order to reduce the fall time to match the rise time to get a more symmetric pulse, which will reduce bit errors related to edge timing.

author: Ian.M
author_rank: Super Contributor
timestamp: December 18, 2015, 05:04:20 pm
content: That is highly dependent on the MCU's UART module implementation. *MOST* will start their sample timing from the first falling edge of the start bit and slowing down that edge by adding a resistor in series with the diode will make the timing less certain + increase the voltage drop for the low state which will increase the risk of an invallid logic level. The rise time is purely set by the pullup resistors and the bus capacitance, which consists of the wire capacitance + the su,m of the node capacitances. The Schottky diode contributes it junction capacitance to each of those so its a bit more than the few pF of a CMOS input pin.For maximum speed over use a linear bus topology, place the pullups at the ends of the bus, not at intervening nodes.Async serial with RS232 framing is actually more robust than I2C because the timing is from the actively driven leading edge of the first bit and it and subsequent bits are sampled mid bit, often several times. I2C samples on a per bit basis timing it from the slow rising edge provided by the pullups so is much more vulnerable to disturbances on the bus shifting the sampling point or even double-clocking one bit Also the UART will detect a framing error if the recieved data byte is badly malformed.It may be of interest to note that Sinclair's ZXNET, using similar hardware (though with an external drive transistor) could do 100Kbit/s over up to about 200m of cabling and 64 nodes.

author: halkabar
author_rank: Contributor
timestamp: December 20, 2015, 04:12:48 am
content: Thanks for all of you for all the great ideas! I decided to implement a simple 3 wire interface (Vcc, GND, TX/RX), really it works even without the Vcc but I'm trying to stay on the safe side of things... Also this requires the least software/hardware changes and the few extra diodes cost next to nothing anyways.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: December 21, 2015, 02:48:16 pm
content: For something more robust especially with distance, I've contemplated a modulated RF link superimposed on the supply. You'd use an RF oscillator for TX and a resonant circuit and diode for RX. Inductors and capacitors make a bias tee, so you can get DC and AC into and out of the power line independently. The simplest implementation wouldn't be nearly as simple as the above (self/phantom powered) case, but much more power handling and range would be possible. (Range and bitrate could be made comparable to RS-422/485 with a little help, i.e. stable frequency control/tuning, and some amplification/AGC work.)Tim