how far can I go with a MCU io pin over a cable? - Page 1
Forum section: electronics / beginners

author: fagiano
author_rank: Regular Contributor
timestamp: December 03, 2013, 04:09:03 pm
content: Hi,I have to connect from my MCU board to several external modules over a distance of about 1 to 1.5 meters.I have to carry a 3.3v PWM signal to another board and a DC analog + power signal to a temperature sensors(TMP36).I was wondering if is fine to just use a cable. I was thinking to use USB cables as I have 1000 around the house.Do I have to buffer buffer/boost the signal or should I use some fancier cable? I made a small test and it seems towork but I'm scared as my electronic book rant for an entire chapter about signal integrity over cables.thank you for your timeciaoAlberto

author: con-f-use
author_rank: Unknown
timestamp: December 03, 2013, 04:30:21 pm
content: As long as you don't transmit data, just power, only the cable resistance matters.

author: fagiano
author_rank: Regular Contributor
timestamp: December 03, 2013, 05:30:26 pm
content: Thank you, I'll make sure to measure resistance before I commit to any cable.ciaoAlberto

author: minime72706
author_rank: Frequent Contributor
timestamp: December 03, 2013, 06:41:21 pm
content: Current-mode sensors will typically work better over long cable runs. You still have noise to deal with, but you shouldn't have a problem with voltage droop.LM335

author: Maxlor
author_rank: Frequent Contributor
timestamp: December 03, 2013, 08:34:54 pm
content: So, how much of a difference does a length of cable make? I realized I had no good feeling for it. So hey, let's measure it!I connected 8 breadboard jumper wires together (M-M F-F M-M...) for a length of about 1.6m, which should give me about the crappiest cable there is, which I suppose is a lower baseline. I had an arduino toggle one of its outputs at 100kHz (the fastest you get if you use digitalWrite, apparently) and connected the wires to another pin configured as input.Measuring at the output, the signal looks like out.png. 1.6m of jumper wires later, we see a notable overshoot (in1.png, and zoomed in in in2.png.)Adding a 10k series resistor on the input side cures the overshoot (res10k.png), but also hugely increases the flank rise time. A lower value resistor would work better, but oh well, this gave me enough of an idea of how the wire behaves, so I'll stop here.Edit: oops, the Arduino's pull-up seems to be active in the last image. Doesn't matter much though, it only means the high voltage is a bit lower, the signal's basic shape remains the same without it.

author: Zero999
author_rank: Super Contributor
timestamp: December 03, 2013, 08:48:48 pm
content: If the cable length is fixed, it can be tuned to remove any reflections.If you know the characteristic impedance of the cable, then you can match the impedance so the length doesn't matter until it's so long the resistive losses become a problem.

author: Maxlor
author_rank: Frequent Contributor
timestamp: December 03, 2013, 09:01:16 pm
content: Quote from: Hero999 on December 03, 2013, 08:48:48 pmIs there a rule of thumb for doing this?

author: minime72706
author_rank: Frequent Contributor
timestamp: December 03, 2013, 11:29:12 pm
content: If you use something like CAT5/6/7 twisted pair stuff, the characteristic impedance is about 100-120 ohms.If it were me, I'd send data digitally and differentially over twisted pair, but if you don't want to add the cost of "smarts" in your remote sensors, I would at least make a differential temperature sensor. See the datasheet for the LM335.It may just end up being overkill, but overkill can be fun if you learn something advanced.

author: fcb
author_rank: Super Contributor
timestamp: December 03, 2013, 11:37:58 pm
content: Sending a bit of PWM over 1.5M over a USB cable. Sure - it'll work fine, or more precisely I can't see why it won't.Try it.

author: minime72706
author_rank: Frequent Contributor
timestamp: December 04, 2013, 02:01:22 am
content: Quote from: fcb on December 03, 2013, 11:37:58 pmMy concern is the signal integrity of the temperature data being returned. 1.5M isn't a lot, but single-ended voltage-mode signals take issue with long single wires.

author: fcb
author_rank: Super Contributor
timestamp: December 04, 2013, 07:31:38 am
content: To properly look into the signal intergrity margins, we need to know more.i.e. how much current do you expect to pass down the cable (min and max), what sensor are you using? what voltage is your fan system running at? and so on.It might be worth encoding your temperature as another PWM signal returning down the cable, it might (depending on how you plan on controlling things) make your conversation easier.

author: codeboy2k
author_rank: Super Contributor
timestamp: December 04, 2013, 10:57:49 am
content: for such a short distance, and especially if you are not in an industrial, electrically noisy environment, then you can probably stick with voltage mode sensing and don't need to go to a current loop.For signal integrity issues just make sure you compensate and terminate. Compensation can include overdriving the line, and termination is resistive termination to match the source and destination impedances to the cable's characteristic impedance. This will remove most of the ringing and you will be able to get a decent signal for your needs.

author: abyrvalg
author_rank: Frequent Contributor
timestamp: December 04, 2013, 11:04:02 am
content: TMP3x datasheet contains several pages dedicated to measurements over a long cable -http://www.analog.com/static/imported-files/data_sheets/TMP35_36_37.pdf#page15But their "long" means tens meters in a harsh industrial environment. 1.5m of cable will do little harm even in those "harsh industrial" coditions (unless routed along with some megawatt building supply power input). For things like heating/ventilation air temp measurements it is typical to have a bare 22K NTC sensor connected to a PLC some 30m away over a shielded twisted pair. No need for overkill there.If you are still in doubt - apply some simple filtering like average calculation over 2-4 measurements.

author: minime72706
author_rank: Frequent Contributor
timestamp: December 04, 2013, 12:12:09 pm
content: Quote from: abyrvalg on December 04, 2013, 11:04:02 amnote the word SHIELDED in this post

author: slateraptor
author_rank: Frequent Contributor
timestamp: December 05, 2013, 09:11:10 am
content: Curiously, what's the measured 10-90 rise time of your PWM signal?

author: fagiano
author_rank: Regular Contributor
timestamp: December 05, 2013, 07:27:57 pm
content: the sensor is a Analog Devices TMP36. I haven't measured rise time of the pwm, the MCU is a stm32f4, tomorrow if I have time I'll try to measure it.I thought about using a digital sensor but as the chip will be submerged in salt water 24/7 (enclosed in a potted 1cm diameter plastic pipe) I'm trying to keep things small.thank you for all the comments, I seem to have opened a can of wormsAlberto

author: fcb
author_rank: Super Contributor
timestamp: December 05, 2013, 08:51:56 pm
content: Again, you need to furnish more information.The TMP36 has quite a low signal output, and if you don't amplify it, it will get swamped by the Vdrop on your cable.If you treat your USB cable as 5 wires (shield + 4 conductors), then you probably can give the temp sensor it's own 0V, and probably get away with it.More info!

author: minime72706
author_rank: Frequent Contributor
timestamp: December 06, 2013, 04:14:17 am
content: Most digital temperature sensors will be exactly the same size as the TMP36.

author: fagiano
author_rank: Regular Contributor
timestamp: December 06, 2013, 04:33:22 pm
content: All i2c temp sensor I could find with a decent precision are in some tiny smd package that would require a tiny pcb or some flimsy soldering hack. the only TO-92 digital sensor is a maxim part that uses 1-wire that would have to be bitbanged. Maybe I could hack something with a DIP package. am I missing something?Alberto

author: Monkeh
author_rank: Super Contributor
timestamp: December 06, 2013, 08:25:22 pm
content: I don't know about digital sensors, but as for your Analog Devices part.. Look at the MCP9700A. It's a quarter of the price..

author: minime72706
author_rank: Frequent Contributor
timestamp: December 06, 2013, 09:41:28 pm
content: Quote from: Monkeh on December 06, 2013, 08:25:22 pmI have some of these sensors you mentioned though I have not used them yet. I'm sure they work just as well as the TMP36/LM34/LM35/etc. This is a good source for them:http://www.dipmicro.com/store/MCP9700-E-TO