Author Topic: how far can I go with a MCU io pin over a cable?  (Read 5892 times)

0 Members and 1 Guest are viewing this topic.

Offline fagianoTopic starter

  • Regular Contributor
  • *
  • Posts: 61
  • Country: it
how far can I go with a MCU io pin over a cable?
« on: December 03, 2013, 04:09:03 pm »
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 to
work but I'm scared as my electronic book rant for an entire chapter about signal integrity over cables.

thank you for your time

ciao
Alberto
 

Offline con-f-use

  • Supporter
  • ****
  • Posts: 807
  • Country: at
Re: how far can I go with a MCU io pin over a cable?
« Reply #1 on: December 03, 2013, 04:30:21 pm »
As long as you don't transmit data, just power, only the cable resistance matters.
 

Offline fagianoTopic starter

  • Regular Contributor
  • *
  • Posts: 61
  • Country: it
Re: how far can I go with a MCU io pin over a cable?
« Reply #2 on: December 03, 2013, 05:30:26 pm »
Thank you, I'll make sure to measure resistance before I commit to any cable.

ciao
Alberto
 

Offline minime72706

  • Frequent Contributor
  • **
  • Posts: 267
  • Country: us
Re: how far can I go with a MCU io pin over a cable?
« Reply #3 on: December 03, 2013, 06:41:21 pm »
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
I have more incomplete projects than I have digits and toes.
 

Offline Maxlor

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: ch
Re: how far can I go with a MCU io pin over a cable?
« Reply #4 on: December 03, 2013, 08:34:54 pm »
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.
« Last Edit: December 03, 2013, 08:37:59 pm by Maxlor »
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19523
  • Country: gb
  • 0999
Re: how far can I go with a MCU io pin over a cable?
« Reply #5 on: December 03, 2013, 08:48:48 pm »
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.
 

Offline Maxlor

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: ch
Re: how far can I go with a MCU io pin over a cable?
« Reply #6 on: December 03, 2013, 09:01:16 pm »
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.
Is there a rule of thumb for doing this?
 

Offline minime72706

  • Frequent Contributor
  • **
  • Posts: 267
  • Country: us
Re: how far can I go with a MCU io pin over a cable?
« Reply #7 on: December 03, 2013, 11:29:12 pm »
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.
I have more incomplete projects than I have digits and toes.
 

Offline fcb

  • Super Contributor
  • ***
  • Posts: 2117
  • Country: gb
  • Test instrument designer/G1YWC
    • Electron Plus
Re: how far can I go with a MCU io pin over a cable?
« Reply #8 on: December 03, 2013, 11:37:58 pm »
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.
https://electron.plus Power Analysers, VI Signature Testers, Voltage References, Picoammeters, Curve Tracers.
 

Offline minime72706

  • Frequent Contributor
  • **
  • Posts: 267
  • Country: us
Re: how far can I go with a MCU io pin over a cable?
« Reply #9 on: December 04, 2013, 02:01:22 am »
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.

My 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.
I have more incomplete projects than I have digits and toes.
 

Offline fcb

  • Super Contributor
  • ***
  • Posts: 2117
  • Country: gb
  • Test instrument designer/G1YWC
    • Electron Plus
Re: how far can I go with a MCU io pin over a cable?
« Reply #10 on: December 04, 2013, 07:31:38 am »
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.
https://electron.plus Power Analysers, VI Signature Testers, Voltage References, Picoammeters, Curve Tracers.
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: ca
Re: how far can I go with a MCU io pin over a cable?
« Reply #11 on: December 04, 2013, 10:57:49 am »
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.
 

Offline abyrvalg

  • Frequent Contributor
  • **
  • Posts: 824
  • Country: es
Re: how far can I go with a MCU io pin over a cable?
« Reply #12 on: December 04, 2013, 11:04:02 am »
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#page15
But 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  >:D). 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.
« Last Edit: December 04, 2013, 11:06:56 am by abyrvalg »
 

Offline minime72706

  • Frequent Contributor
  • **
  • Posts: 267
  • Country: us
Re: how far can I go with a MCU io pin over a cable?
« Reply #13 on: December 04, 2013, 12:12:09 pm »
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#page15
But 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  >:D). 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.

note the word SHIELDED in this post
I have more incomplete projects than I have digits and toes.
 

Offline slateraptor

  • Frequent Contributor
  • **
  • Posts: 833
  • Country: us
Re: how far can I go with a MCU io pin over a cable?
« Reply #14 on: December 05, 2013, 09:11:10 am »
Curiously, what's the measured 10-90 rise time of your PWM signal?
 

Offline fagianoTopic starter

  • Regular Contributor
  • *
  • Posts: 61
  • Country: it
Re: how far can I go with a MCU io pin over a cable?
« Reply #15 on: December 05, 2013, 07:27:57 pm »
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 worms :D

Alberto
 

Offline fcb

  • Super Contributor
  • ***
  • Posts: 2117
  • Country: gb
  • Test instrument designer/G1YWC
    • Electron Plus
Re: how far can I go with a MCU io pin over a cable?
« Reply #16 on: December 05, 2013, 08:51:56 pm »
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!
https://electron.plus Power Analysers, VI Signature Testers, Voltage References, Picoammeters, Curve Tracers.
 

Offline minime72706

  • Frequent Contributor
  • **
  • Posts: 267
  • Country: us
Re: how far can I go with a MCU io pin over a cable?
« Reply #17 on: December 06, 2013, 04:14:17 am »
Most digital temperature sensors will be exactly the same size as the TMP36.
I have more incomplete projects than I have digits and toes.
 

Offline fagianoTopic starter

  • Regular Contributor
  • *
  • Posts: 61
  • Country: it
Re: how far can I go with a MCU io pin over a cable?
« Reply #18 on: December 06, 2013, 04:33:22 pm »
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
 

Offline Monkeh

  • Super Contributor
  • ***
  • Posts: 7992
  • Country: gb
Re: how far can I go with a MCU io pin over a cable?
« Reply #19 on: December 06, 2013, 08:25:22 pm »
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..
 

Offline minime72706

  • Frequent Contributor
  • **
  • Posts: 267
  • Country: us
Re: how far can I go with a MCU io pin over a cable?
« Reply #20 on: December 06, 2013, 09:41:28 pm »
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..

I 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
I have more incomplete projects than I have digits and toes.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf