One-wire protocol through long distances

Discussion in 'General Electronics Chat' started by cmartinez, Aug 10, 2015.

  1. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,535
    I've been successfully using these DS1822 temperature sensors for a while now, but the distance between the sensor and my MCU seems to be limited to less than 3 or 4 feet before trouble begins to show. They're cheap, simple and reliable.
    These sensors are interfaced to my MCU through the use of one-wire protocol technology, which allows for a single line to both transmit and receive data. That is, the line is bidirectional.

    Would it be possible to incorporate some sort of level shifter so as to make the signal run at a higher voltage, and hence allow for much greater distance between the sensor and the MCU? I'm powering these sensors at 5V, and I'd like to shift their signals to say, 12V, for instance.
    Or... maybe a converter to RS485 would be best, and allow me to transmit the signal to much greater lengths? After all, transmission runs at an average of around 30 KHz... how can I design such a bidirectional converter?

    Any ideas?
     
  2. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,308
    884
    I've never used the 1-wire interface and am not very familiar with it. As I understand it, though, it is not readily adapted to RS-485 or other similar physical layer.

    However, Maxim has an application note, "Guidelines for Reliable Long Line 1-Wire Networks", at http://www.maximintegrated.com/en/app-notes/index.mvp/id/148. Maybe that could give some worthwhile suggestions?
     
    cmartinez likes this.
  3. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,535
    Thanks, I had already read that note a while ago ... and it seems that I discarded it too soon. I just noticed that in that note there's a mention of another one titled Advanced 1-Wire Network Driver that seems to do what I'd like it to do.
    I'm going to study it thoroughly, and see if I can understand it.
    Thanks again!
     
  4. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,308
    884
    YW, sorry I couldn't be of more help but you've hit on an area in which I'm a total n00b!
     
    cmartinez likes this.
  5. Brevor

    Active Member

    Apr 9, 2011
    279
    54
    Something must be wrong with your setup, I have a DS1820 running off almost 50 feet of cable with no problems.
     
    cmartinez likes this.
  6. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,535
    Which MCU are you using, and where is the pull-up resistor placed? Close to the sensor, or close to the MCU?
     
  7. Brevor

    Active Member

    Apr 9, 2011
    279
    54
    8051, with a 4.7K pullup at the MCU.
     
  8. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,535
    Yup... that's exactly how I'm doing it... same MCU, same resistor.
    Are you using shielded twisted pair cable for that?
     
  9. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,535
    How are your 8051's outputs configured? quasi-bi, open collector, push-pull? or do you switch between states?
     
  10. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,648
    762
    Hola César,

    Just completed the writing of my code for a PIC succesfully. I've read the AN suggested by OBW. With due precautions, longer distances are possible, of course more than those poor cm of yours...:)

    Not tested that myself...but soon will do. Otherwise there is that chip and others.

    Buena suerte.


    /EDIT to add.

    My PIC 18F452 uses one pin that releases the bus when set as IN (high Z) or OUT (showing a logical 0) what brings the bus down. It works flawlesly.

    EDIT/
     
    cmartinez likes this.
  11. Brevor

    Active Member

    Apr 9, 2011
    279
    54
    Hmm.. Trying to remember, I built it almost 20 years ago. I know the cable is shielded, but I dont believe it's twisted.

    Output is open collector.
     
    cmartinez likes this.
  12. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,535
    Maybe what I'm doing wrong is that I configured the mcu's outputs as quasi bi-dir and also used a 4k7 pull-up...
    Gonna try open collector only and see what happens... thanks!
     
  13. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    The only thing that should ever pull the bus high should be the pull-up resistor. The things that can drive it low is the MCU or the sensor...

    PS Nope, I misremembered it. I just went and read the data sheet, and here is what it says:

    ds.gif
     
    Last edited: Aug 10, 2015
    cmartinez likes this.
  14. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,535
    the bi-dir mode in an AT89LP4052 works through a strong pull-up when its state changes from low to high, and is held high through a weak pull-up after a brief time has elapsed.
    Maybe that's what's bringing noise to my circuit. A plain open-collector i/o would probably not do that and fix things.
     
  15. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    The 4.7K can already source 20X more current than the "weak pullup" in a MCU, and according to the data sheet, the 4.7K cannot supply enough current to the sensor while it is doing a conversion, so must be shunted by the PMOS shown in Fig 6, above.

    Here is what the data sheet says:

    ds1.gif
    DS2.gif
     
    Last edited: Aug 11, 2015
    cmartinez likes this.
  16. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,535
    Yeah, but that is only true when parasite-powered mode is being used. My circuit always provides power to the Vdd pin, and is not connected as in fig 6
     
  17. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,648
    762
    I spent a while looking for an AN... and it was a TB instead!!

    Read it César. It even talks about the wire selection. The way I configure the pin, works OK always, provided you use an external pull up resistor.
     
    cmartinez likes this.
  18. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,535
    Gracias, Agustín! I'm sure going to read it.
     
Loading...