Page 1 of 1
Onewire communications
Posted: Mon Feb 09, 2009 9:27 am
by asargent
Has anyone communicated with Dallas Semiconductor onewire devices such as the DS18S20 temp sensor. I am using a 5234 and was looking for some sample code to help me along. I was hoping not to have to bit-bang anything.
Re: Onewire communications
Posted: Mon Feb 09, 2009 9:51 am
by Chris Ruff
yes, on 3 different procs.
You can use the TX stuff from maxim/dallas. sort of. You have to code the low level transmit and receive bit. I pull up the one-wire bus to 3.3 or 5 volts with a 2200 ohm resistor and listen to that with an input. Then I drive the 1-wire line low with a diode from a low-going (true) signal. It is not strictly necessary to use both an input and an output, but I know it works, and you can use the lower 16 DB on, say, the MOD5270 just fine.
You have to come up with calibrated delays and any transmission to the 1-wire net has to be delay-correct at certain times in the transmission. You need to use USER_CRITICAL_ENTER() and USER_CRITICAL_EXIT() macros to bracket these critical pieces of primitive code. The 1-wire network tolerates huge gaps in both directions, but when you are speaking to 1-wire and forming bytes you need to present the proper timing for the 1-wire toys to understand you.
Figure on 2 days to get your code working. If it takes less, cool. But My first time talking to 1 toy took 2 days and my next time talking to a network of EEPROMS took another 2. One of the trickier problems is gathering the IDs of all the toys out there. They have a cool algorithm in their app notes that I finally got to work and it works great.
You'll need a scope.
Chris
Re: Onewire communications
Posted: Mon Feb 09, 2009 6:30 pm
by asargent
Sounds like its not as simple as the I2C and SPI stuff I have been doing. If I understand you correctly, you are bit-banging a GPIO pin at the correct times to do the comm? Oh well, I was hoping that there was already some library support. Of course that would ruin all the fun I suppose
Re: Onewire communications
Posted: Tue Mar 03, 2009 2:01 pm
by svlach
Sorry for the late reply. I had the same need to interface some 1-wire products to a NetBurner module and came across issues with timing, and bit-banging until I came across a device from Dallas which converts standard 5-volt serial interface to 1-wire commands. The device is a Dallas DS2480B. This device takes in 9600, 19200, 57600 or 115200 baud data and drives all of the 1-wire communications including Stiff pullups for temperature sensors etc. It also includes the ability to invert the incoming and outgoing serial levels, so you can use it with RS-232 level converters or not.
This device made interfacing to 1-wire with NetBurner almost trivial. There are also a lot of open source C sample code on the Dallas website which has the libraries you need to discover and enumerate 1-wire devices, and read and write to the 1-wire devices.
I almost can't say enough about this tiny device because it made everything so simple. You can take a look at the spec sheet here.
http://datasheets.maxim-ic.com/en/ds/DS2480B.pdf
And no, I don't work for Dallas, but I do use their products!