Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Communicating With Multiple 1-Wire Devices

Status
Not open for further replies.

tpetar

Advanced Member level 7
Joined
Sep 27, 2010
Messages
6,417
Helped
1,713
Reputation
3,456
Reaction score
1,673
Trophy points
1,393
Location
Pancevo-Belgrade, Serbia
Activity points
37,363
Communicating With Multiple 1-Wire Devices
Original Web address : Dallas 1-Wire Projects With PicBasic Pro

one-wire003.gif


Example:

OWOUT DQ, 1, [$33] ' Read ROM command, byte-sized data, reset before data

This will reset the 1-wire bus, [Send reset pulse before byte-sized data], and issue the byte-sized Read ROM command. This will work [only] if there is a single 1-wire device on the network. If there are more than a single 1-wire device on the network, we need to do the following:

Switch_1:
OWOUT DQ, 1, [$55,$05,$C5,$C3,$08,$00,$00,$00,$CD]' Match ROM, byte-sized, reset before
OWIN DQ, 4, [Stat]' Get bit-sized response, no reset pulse
IF Stat = 0 THEN
DEBUG Ins, Line2, "Switch #1 = OFF"
ELSE
DEBUG Ins, Line2, "Switch #1 = ON "
ENDIF

The example above shows how to individually address 1 DS2405 addressable 1-wire switch on the network. Notice we have substituted the Read ROM command with the Match ROM command. The red hexadecimal number $55 is the command for Match ROM. The blue hexadecimal numbers $05,$C5,$C3,$08,$00,$00,$00,$CD are the unique 64-bit ROM code numbers inside the specific DS2405 addressable 1-wire switch we're trying to communicate with.

What we're doing with --> OWOUT DQ, 1, [$55,$05,$C5,$C3,$08,$00,$00,$00,$CD]is: Attention, Match the following ROM code. Were leaving the 1-wire bus open for communications since we didn't RESET the 1-wire bus after we have sent several byte-sized data packets containing the ROM code. The device matching the ROM code [as shown in blue above], will respond if it's present on the 1-wire bus.

What we're doing with --> OWIN DQ, 4, [Stat]is: Reading the bit-sized data from the 1-wire bus into the bit-sized variable Stat, without issuing a reset pulse. The DS2405 will return a logic 0 on the 1-wire bus if its switch output PIO is ON or at logic 0. If the switch output is OFF, the DS2405 will return bit-sized data at logic 1, indicating to the Master controller that its switch output is OFF. Refer to the schematic at top again, and you'll notice that logic 0 will turn the NPN transistors OFF, and logic 1 will turn them ON again.

If you jumped into this page without reading the previous article showing how to read individual ROM codes from 1-wire components, visit this link HERE to see how this is done. You'll need to individually identify each of the 1-wire component unique 64-bit ROM codes before you can make sense of this article. Knowing the unique 64-bit ROM codes for all devices you're using [if you're building this project], is essential.

Let's move on to more of the mode switches, and see how they work with the DS18B20 temperature sensor on the 1-wire network.

Temp_1:
OWOUT DQ, 1, [$55,$28,$B1,$FE,$22,$00,$00,$00,$5D,$44]
W1:
OWIN DQ, 4, [Stat]' Check for still busy converting
IF Stat = 0 THEN W1' Still busy?, then loop
OWOUT DQ, 1,[$55,$28,$B1,$FE,$22,$00,$00,$00,$5D,$BE]
OWIN DQ, 2, [Temp.LOWBYTE,Temp.HIGHBYTE]' Read two bytes, then end communications
GOSUB Convert_Temp
DEBUG Ins,Line1, "Temp #1 = ", Sign, DEC (Temp / 100),".", DEC2 Temp, Deg, "F "

Notice from the code sample above that we have again issued the Match ROM command $55, and left the 1-wire bus open for communications. We next use mode 4 [bit-sized data, no reset pulse], and OWIN command to read the bit-sized response from the device addressed with the unique 64-bit ROM code $28,$B1,$FE,$22,$00,$00,$00,$5D.

Did you notice that the $44 is missing from end of the original first line of code? $44 is the last byte of data sent to the DS18B20 after the ROM code, and is telling the DS18B20 to begin a temperature conversion. I have made commands RED, and data BLUE for easy recognition.

What we're doing here --> OWIN DQ, 4, [Stat]: is reading the bit-sized response from the DS18B20. A logic 0 means the DS18B20 is still performing the temperature conversion, so we wait until it's finished before proceeding.

Notice how mode 4 allows us to read single-bit responses from the 1-wire bus without resetting the bus. This is important to remember if you're going to build a reliable 1-wire network. Sometimes the Master 1-wire controller will be required to read single-bit data, and be able to control [reset or no reset] the 1-wire bus as necessary. That's why it's important to carefully read the datasheet for any 1-wire device you're planning to use, and learn how to use the PicBasic Pro 1-wire command mode switches.
 

Very good,
 

Of course below every title is original link, maybe I didnt write exactly "Original article link:" I write "Web link or Web address:". No problem to change to "Original web link:"

Also permission is given for publishing.
 

I'm sorry, I didn't notice your link directly under the title, maybe because I was looking for it in the text below the image

Alex
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top