-- Reading ROM Codes From 1-Wire Devices --
|PicBasic Pro version 2.4 now
includes commands specifically for using the Dallas Semiconductor 1-Wire™
components. This short article will show how to use these new 1-Wire
commands to build a simple device that identifies Dallas 1-Wire components.
If you're planning to use 1-wire components you need to identify individual components before placing them on the 1-wire network, this little project comes in handy for doing this.
Components required for this project:
You're not necessarily limited to using the components listed above. The code is easy to convert to any PIC, and the serial LCD can easily be replaced by using any RS-232 terminal program.
By first identifying each 1-wire device, and recording the unique 64-bit ROM number contained within each device, you can then communicate with individual 1-wire components on the 1-wire bus. To do this you use the "Match Rom" command followed by the unique 64-bit ROM number matching a specific 1-wire component on the network you wish to communicate with.
Here's an example of talking to a 1-wire DS2405 addressable switch located on the 1-wire network.
Note: You can toggle the output of the DS2405 by simply sending the Match Rom command followed by the 64-bit ROM code of the switch. This ROM code is unique from one DS2405 to the other.
The Match ROM command is $55 or 55h. Following the Match ROM command is the 64-bit ROM code read from the DS2405 as shown in the table below. Notice data is sent LSB first. When communicating with devices on the 1-wire network, data is always read/written LSB first.
The photo above shows the LCD display with the DS2405 inserted in the circuit. Here's the simple circuit to build for this project for connecting 1-wire components to the PIC.
This project shows how to identify each 1-wire device prior to inserting them into the 1-wire network. By identifying each component you'll know the unique 64-bit ROM code for each 1-wire device, and be able to talk to individual components on your 1-wire network as necessary. You can use the 1-wire command Search ROM [$F0], but this doesn't tell you where each device is physically located on the 1-wire network. It only identifies all components on the network.
The next project will give more detailed explanations of how the PicBasic Pro OWIN & OWOUT mode numbers affect different devices on the 1-wire network.
The 20 x 4 LCD used for this project is a standard backlit serial LCD similar to this Serial LCD , but any serial LCD should work. You may or may not need to change the LCD commands, depending on which type you use. Just connect PortB.0 to the serial 'data' input of the one you use.
Part 2 is ready. Click HERE
Part 2. How to communicate with multiple 1-wire devices on the network, and how to use PicBasic Pro 1-wire command mode switches. How to read/display temperatures from 2 DS18B20 temp sensors, and control 2 DS2405 1-wire addressable switches. Complete with °C to °F conversion, how to display -°F temperatures, individual DS2405 switch status displays, and more.
For your convenience, we keep a few of the DS18B20 temperature sensors in-stock HERE.
Until the next project - have fun - and don't blow anything up...;o]