« Close

Datasheets and User Guides

App Notes

Software & Driver

 

5.2.23 - 1-Wire

This function performs 1-Wire communication.

Because the EIO lines on the U3 can be configured as either digital or analog, ensure that the I/O being used for 1-Wire sensor comm is first configured as either digital input or digital output, then use the function outlined below. For additional information on how to use this function, please see the 1-Wire App Note.

Table 5.2.23-1. 1-Wire Command Response

Command:    
Byte    
0 Csum8  
1 0xF8  
2 0x1D  
3 0x3C  
4 Csum16 L  
5 Csum16 H  
6 Options  
    Bit 0: DPU Control Enable
    Bit 1: DPU Polarity
    Bit 2: DPU Idle
7 Reserved  
8 Sense Pin  
9 DPU Pin  
10 Reserved  
11 ROM Function  
12 ROM0 (LSB)  
13 ROM1  
14 ROM2  
15 ROM3  
16 ROM4  
17 ROM5  
18 ROM6  
19 ROM7 (MSB)  
20 Reserved  
21 Num TX  
22 Reserved  
23 Num RX  
24 TX Byte 0  
...  
63 TX Byte 39  
     
Response:    
Byte    
0 Csum8  
1 0xF8  
2 0x1D  
3 0x3C  
4 Csum16 L  
5 Csum16 H  
6 Error Code  
7 Reserved  
8 Reserved  
9 Warnings  
    Bit 0: No Devices Detected
    Bit 1: Type 1 interrupt (Not Tested)
    Bit 2: Type 2 interrupt (Not Supported)
10 Reserved  
11 Reserved  
16 Data 0  
 
63 Data 47  

Options: This byte provides control of the dynamic pull-up. 

Bit 0: enables control of the DPU line.
Bit 1: sets the polarity of the switch. 1 = high on the specified DIO turns the switch on.
Bit 2: sets the idle state. 1 = DPU on while IDLE.
Sense Pin: This is the DIO on the LabJack that is connected to the data line of the 1-Wire bus.
DPU Pin: This is the DIO line that will control the dynamic pull-up if enabled in the options byte.
ROM Function: This byte specifies the function to be performed on the 1-Wire bus.
ROM[0:7]: This is the ROM of the target device or search path.
Num TX: This is the number of data bytes to transmit.
Num RX: This is the number of data bytes to receive.

Depending on the ROM function used the data returned can have different meanings. Refer to the following table for data definitions.

Table 5.2.23-2. ROM Functions

    Parameter Data Returned  
ROM Function: Number ROM Bytes 0-7 Bytes 8-15
Search ROM 0xF0 List of branches to take. Discovered ROM Code 1s indicate detected branches.
Read ROM 0x33 None ROM read from device  
Match ROM 0x55 The specific ROM    
Skip ROM 0xCC      
Alarm Search 0xEC      

Additional information

U3 firmware v1.31 and hardware v1.30 are required for 1-Wire.

Maxim has a 1-Wire App Note on Dynamic Pull-Ups, and another on the search algorithm. There are several kinds of 1-wire temperature sensors from Maxim(DS1820, DS1821, DS1822, DS18S20, and DS18B20). The most common part is probably the DS18B20. Note that these temperature sensors require about 750ms of time to resolve a temperature reading.

2 comments

ElectroLund's picture

I'm struggling to understand how to implement.  Here's some snippets from above:

This function performs 1-Wire communication...then use the function outlined below. For additional information on how to use this function, please see...

"This function"... what function?  I don't see any documentation on a function or class name.  I've searched in the LabJackUD.h for "1-wire" and variants.

The data packet structure outlined above... do I simply send this packet to either the CIO or EIO with an ePut?  This isn't clear at all to me.

LabJack Support's picture

The 1-Wire functionality of the U3/U6/UE9 is an advanced feature and likely requires the use of a digital logic analyzer and requires a good deal of understanding for how the LabJack works.To use the 1-Wire protocol with a U3/U6/UE9 you have to use the low level or RAW functions in the LabJackUD Driver.  Essentially, you use the information on this page to build a packet of 64 bytes that gets sent to your device.  You then read the data that you get in response which is formatted how this page says.  A few places that you can look in to find information about making performing raw IO with a LabJack device are below:

  1. There is a comment on the 1-Wire AppNote page that shows this being done by Jeff. Example calls with LabJackUD Driver.  
  2. If you are using python there is some example code in the LabJack Python examples directory.
  3. In the LabJackUD.h file, look at the comments by the constant "LJ_ioRAW_OUT"