HOME > >
DALLAS 1-WIRE / MICROLAN SECTION INDEX
Overview of working with the 1-Wire (aka MicroLan) network
This page goes into some of the detail of how you use the Dallas Semiconductor 1-Wire system. If you're not yet ready for the detail, but just want to get an idea of why I'm impressed by it, that information is here.
Just before I tell you more, I should explain that I have no connection with Dallas, beyond being a happy user of their products for many years. "1-Wire", "MicroLan" and "iButton" are all trademarks of Dallas Semiconductor.
!-- Start eXTReMe Non Public Tracker Code V3/5
Vers the 1-Line vers still as 3/19 at 9/23. This page given eXTReMe Tracker 4 Sep 23-->
I'm going to start with the cable which connects the elements of the system. There are details we could go into, but basically, the cable consists of two wires. Connected to it is one master and many slaves. One of the wires is the common ground and the other (the power/data cable) usually carries a positive voltage which comes out of the interface between the cable and the master.
(I am a programmer first, and a hardware person second. Some of you will find the early part of this essay way beneath you level of expertise. Hang in there. When we get to the software side, I think you'll find more "meat".)
Because of the way the positive voltage is fed into the wire, it is permissible to create short circuits between the power/data cable without doing the components any damage. If such a short circuit exists, the voltage in the power/data cable will drop so low as to be as good as zero. This is called "pulling it low". Herein lies the "secret" of the 1-Wire system. More on this in a moment.
The master is a computer of some sort. A computer running Windows is an easy-to-use answer... if "expensive". (Well, I suppose I'm a Scrooge. I have to admit that a machine I bought for $40 has run Windows 95 and a program I wrote to monitor weather just fine... months of up-time without crashes.) This essay is about using a 1-Wire connected to a Windows computer, BUT: once you have the hang of that, replacing the Windows machine with something smaller, cheaper, is no big deal. In particular, you may want to think about using a Tini (TM, Dallas semiconductor. $50.)
The slaves are whichever Dallas 1-Wire chips or iButtons (a chip in a robust, easily hot-swapped package) you choose to connect to the network. Connecting almost couldn't, in the electronics world, be simpler: there are only two pins from the chip to be connected. (You do have to get them the right way 'round!). Some 1-Wire devices will have additional connections, but those are for other things, not for the slave's communications with the network.
Now. The slave can do two important things. It can sense the voltage in the power/data cable, and it can create one of the short circuits we spoke of before.
MicroLan is much more powerful than the scenario I am about to describe, but for the moment, image it being used for a simple fire alarm system. You have the master someplace safe. As I said, it supplies the voltage to the power/data line. What I didn't mention earlier is that the master can also sense the voltage level in the line "downstream" of where the voltage is generated, i.e., the master's sensing will "see" the near zero condition created by any slave generated shorts.
Further imagine that there is a 1-Wire chip that behaves as follows: Normally, it produces no short circuit, but if it gets hot, it does. For the fire alarm system, all you need is the simple cable extended to all of the areas you wish to protect, with lots of slaves on it. If any of them gets hot, all of the line will be pulled low. The master will see this, and ring the bells.
You don't need a computer to accomplish what we have so far!
However: I've oversimplified things, just to get us started. (Dallas don't make a chip like the one I've described, by the way.
Suppose your fire alarm system is in a Very Big Building. Wouldn't it be nice if you not only knew there was a fire, but if you also knew where? No problem, with MicroLan!
Enter the next Thing You Need To Know: Every 1-Wire device has a number built into it.... and every single 1-Wire device ever made, and ever to be made, has a UNIQUE number! Think of them as built in, machine readable, serial numbers, if you like.
Now imagine that our fire alarm chips don't merely pull the line low, but they do it in some sort of Morse code which tells the master WHICH chip is hot. As long as the master had a list that said, for instance, that chip 428989245982 was in the broom cupboard, if the pattern of lows in the line was saying "428989245982", you'd know where to send the firefighters.
We're nearly there! The scheme as described would be fine... until two chips got hot. If at the same time, they were pulling the line low in some pattern, how would the master know which lows came from which chip? (I.e., in networking terms, we have a collision going on.) So! Dallas came up with a more complex, but brilliantly capable scheme....
The last as-yet-unrevealed element is that the master can also pull the line low.
Now I'm going to give you a scenario which is much closer to Dallas's. From there it is but a small step to what actually goes on.
The system involves what is called a "Reset pulse". This is the line pulled low for a special period of time. Only the master ever causes a reset pulse.
The slaves are designed so that when they are attached to a live network, or if they are attached to a network when it goes live, they just sit there, not pulling the line low, until after they see a reset pulse. When they see a reset pulse, they briefly pull the line low. (This is so that the master can tell that there is at least one slave present.) After sending this "presence" pulse response, the slaves sit and watch the line for further instructions. The instructions are conveyed by patterns of pulses, almost like Morse code.
In our previous scenario, the slaves were more powerful. When they got hot, they "spoke up". In the more complex, more capable, scenario, slaves must speak only when they are spoken to, to avoid collisions. The master starts by sending a number. All the slaves can "see" it... but none take any action yet, other than noting the number. The master then sends a code for what the slave with that number... and no other slave... should do. If the master has sent a code that requires some response, it will sit back and watch the line for a bit, so that the message coming in from the slave (which is generating it by pulling the line low in some code) doesn't collide with anything the master might, in a badly designed system, put on the line just as the message from the slave was coming in.
For the fire alarm system, the master would go through all the slaves on the network, asking each if it was hot.....
... "Slave number 25234... are you hot?" Slave answers by pulling line low twice if hot, once if not. When master has had answer from number 25234, master asks next slave....
... "Slave number 66542... are you hot?" Slave answers.
... "Slave number 35234... are you hot?" Slave answers.
... "Slave number 42359... are you hot?" Slave answers.
... "Slave number 73423... are you hot?" Slave answers.
Once every slave has been asked (polled), the controller goes back to the first slave, and starts through the list again.
Brilliant! That's almost all there is to it.... in essence. The details take a little while to get straight, but they aren't much more complicated than the above.
There are many chips in the Dallas 1-Wire family. There are chips (e.g. DS2401) that simply say "I'm here" when the master asks. (They DO have their uses. For a start, if they are connected to the network by a switch (actual, or electronic equivalent) then if the master asks "Are you there" and gets no answer, it "knows" that the chip is there, but that the switch is open.)
There are chips with an extra pin besides the two for connecting to the network. (e.g. DS2405). The voltage (high or low) on that pin can be reported, on request, to the master. The same chip can also be used to drive an LED. I.e., an LED (and resistor) are connected to the extra pin and the LED switched on or off by messages from the master. If you can turn on an LED, you can turn on the Trafalgar Square Christmas tree, or the individual parts of General Motors's assembly line... there's a little bit of interfacing to do, but it's not a big deal.
There are ships with counters (DS2422). You apply digital inputs to the extra pin. when the master interrogates the chip, it is told how many pulses have been seen.
The DS2405 is for digital inputs and outputs. (I.e. it recognises/provides "on" and "off" conditions, such as a simple switch provides.) There are also chips for analogue signals (I.e. "off", "on a little bit" "on a lot" "mostly on", "fully on", e.g. the volume control of a radio). There are chips with various sensors and their ADCs built into the chip. With these, you connect the basic two wires of the 1-Wire system, and you are done adding a way for the master to read a temperature, a humidity, a light level. (They are not expensive. Remind me to go back and revise e1d.htm to include some prices.)
There are chips with memory (non-volatile RAM, OTP EPROM and EEPROM) built in. (And software that lets you use them like tiny floppy discs!)
We must digress to look at a detail. Where does the electricity come from to power the slaves? Usually from the MicroLan. How can this be? It consists just of the line for the data to flow in (in a series of "ons" and "offs"), and the signal ground wire. In essence, the system works like this: Most of the time, the voltage of the data line (which I earlier called the power/data line) is high. It is pulled low only briefly, only from time to time. You can imagine a tiny rechargeable battery within each slave which is kept charged by the power/data line. It takes over powering the chip during the moments when the power/data line is pulled low. (LEDs use too much power to be powered from the MicroLan. Remind me to write up some details. Also, until I write up the details, look closely at the data sheet if you want to use one of the temperature sensors... though I use one on a short MicroLan without any extra electronics... in accordance with the suggestion in the 1-Wire demo kit from Dallas (DS9091K))
The next page takes you through the Dallas documentation and software, showing you how to use them.....
Ad from page's editor: Yes.. I do enjoy compiling these things for you...
hope they are helpful. However.. this doesn't pay my bills!!! If you find
this stuff useful, (and you run an MS-DOS or Windows PC) please visit my
freeware and shareware page, download something, and circulate it for me?
At least (please) send an 'I liked the parallel port use page, and I'm
from (country/ state)' email? (No... I don't do spam)
Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.
Click here to learn how to contact this page's editor, Tom Boyd.
Click here to go up to general 'electronic projects' page by editor of this page.