Next revision | Previous revision |
en:iot-open:embeddedcommunicationprotocols2:1wire [2023/06/25 19:09] – created ktokarz | en:iot-open:embeddedcommunicationprotocols2:1wire [2024/05/27 11:18] (current) – ktokarz |
---|
====1-Wire==== | ====== 1-Wire ====== |
1-Wire is a master-slave communication bus system designed formerly by Dallas Semiconductor Corp((https://www.maximintegrated.com/en/products/digital/one-wire.html)) ensuring low data transmission speed, signalling and can be powered directly by data line signals. The 1-Wire concept is similar to I²C transmission standard, but can transmit data in longer distances then I²C but with lower speed. The implementation area is very wide and typically 1-Wire protocol is used to share data between small, inexpensive devices such as a digital thermometer, humidity or pressure sensors or actuator systems. A network chain of 1-Wire devices consists of one master device and many slave devices. Such a chain is called a MicroLAN. 1-Wire devices may be a part of the circuit board within a product, could be a single component device such as temperature probe, or may be attached to a remote device for monitoring purposes. Typical data acquisition and laboratory networks use CAT-5 cables to connect 1-Wire devices together, can be mounted in a socket of small PCB boards, attached to the device which must be monitored. In such implementations, the RJ11 connectors (telephones 6P2C/6P4C modular plugs) are very popular. | {{:en:iot-open:czapka_b.png?50| General audience classification icon }}{{:en:iot-open:czapka_e.png?50| General audience classification icon }}\\ |
Each 1-Wire device must contain logic unit to operate on the bus. The 1-Wire products include temperature, voltage, current sensors, loggers, timers, battery monitors, memory and many more. To connect them to a PC the special bus converter is needed. The most popular PC/1-Wire converters use USB, RS-232 serial, and parallel port interfaces allowing connect the MicroLAN to the host PC. 1-Wire devices can also be connected directly to the microcontroller boards. | 1-Wire is a master-slave communication asynchronous bus interface designed formerly by Dallas Semiconductor Corp((https://www.maximintegrated.com/en/products/digital/one-wire.html)). It can transmit data at long distances at the cost of transmission speed. The typical data speed of the 1-Wire interface is about 16.3 kbit/s, and the maximum length is approx. 300m. Name 1-Wire comes from the feature that the data line can directly power elements connected to the bus. A network chain of 1-Wire devices consists of one master device and many slave devices (figure {{ref>1wire0}}). Such a chain is called a MicroLAN. 1-Wire devices may be a part of a product's circuit board, a single component device such as a temperature probe, or a remote device for monitoring purposes. |
| |
===1-Wire Protocol Description=== | Each 1-Wire device must contain a logic unit to operate on the bus. A dedicated bus converter is needed to connect a 1-wire bus to a PC. The most popular PC/1-Wire converters use a USB plug to connect to the PC and the RJ11 connectors (telephones 6P2C/6P4C modular plugs) for MicroLAN. 1-Wire devices can also be connected directly to the microcontroller boards. |
Within the MicroLAN, there is always one master device, which may be a PC or a microcontroller unit. The master always initiates activity on the bus to avoid collisions on the network chain. If a collision occurs, the master device retries the communication. In the 1-Wire network, many devices can share the same bus line. To identify devices in the MicroLAN, each connected device has a unique 64-bit ID number. The least significant byte of the ID number defines the type of the device (temperature, voltage etc. sensors). The most significant byte represents a standard 8-bit CRC. | |
The 1-Wire protocol description contains several broadcast commands and commands used to address the selected device. The master sends a selection command, then the address of a slave selected device. This way, the next command is executed only by the addressed device. The 1-Wire bus implements enumeration procedure which allows the master to get information about ID numbers of all connected slave devices to the MicroLAN network. Device address includes the device type, and a CRC allows to identify what type of slaves are currently connected to the network chain for inventory purposes. The 64-bit address space is searched as a binary tree. It allows to find up to 75 devices per second. | |
| |
The physical implementation of the 1-Wire network is based on an open drain master device connected to one or more open drain slaves. One single pull-up resistor for all devices pull the bus up to 3/5 V and can be used to power the slave devices. 1-Wire communication starts when a master or slave sets the bus to low voltage (connects the pull-up resistor to ground through its output MOSFET). Typical data speed of the 1-Wire interface is about 16.3 kbit/s. | ===Protocol Description === |
| Within the MicroLAN, there is always one master device, typically a PC or a microcontroller unit. The master always initiates activity on the bus to avoid collisions on the network chain. If a collision occurs, the master device retries the communication. In the 1-Wire network, many devices can share the same bus line. To identify devices in the MicroLAN, each connected device has a unique 64-bit ID number. The ID number's least significant byte defines the type of the device (temperature, voltage, etc.). The most significant byte represents a standard 8-bit CRC. |
| The 1-Wire protocol description contains several broadcast commands and commands used to address the selected device. The master sends a selection command, then the address of the selected slave device. This way, the following command is executed only by the addressed device. The 1-Wire bus implements an enumeration procedure that allows the master to get information about the ID numbers of all connected slave devices to the MicroLAN network. The device address includes the device type, identifying what type of slaves are connected to the network chain. The 64-bit address space is searched as a binary tree. It makes it possible to find up to 75 devices per second. |
| |
1-Wire protocol allows for bursting the communication speed up by 10 factor. In this case, the master starts a transmission with a reset pulse pulling down the data line to 0 volts for at least 480 µs. It resets all slave devices in the network chain bus. Then, any slave device shows that it exists generating the "presence" pulse. It holds the data line low for at least 60 µs after the master releases the bus. To send a "1", the bus master sends a 1–15 µs low pulse. To send a "0", the master sends a 60 µs low pulse. The negative edge of the pulse is used to start a slave's monostable multivibrator. The slave's multivibrator clocks to read the data bus about 30 µs after the falling edge. The slave's multivibrator has analogue tolerances that affect its timing accuracy, for the "0" pulses are 60 µs long, and "1" pulses are limited to max 15 µs. When the designed solution doesn't contain a dedicated 1-Wire interface peripheral, a UART can be used as a 1-Wire master. Dallas also offers the Serial or USB "bridge" chips, very useful when the distance between devices is long (greater than 100 m). For longer, up to 300 m buses, the simple twisted pair telephone cable can be used. It will require adjustment of pull-up resistances from 5 kΩ to 1 kΩ. The basic sequence is a reset pulse followed by an 8-bit command, and after it, data can be sent/received in groups of 8-bits. In the case of transmission errors, the weak data protection 8-bit CRC checking procedure can be used. | The physical implementation of the 1-Wire network is based on an open drain master device connected to one or more open drain slaves. One single pull-up resistor for all devices pulls the bus up to 3/5 V and can be used to power the slave devices. 1-Wire communication starts when a master or slave sets the bus to low voltage (connects the pull-up resistor to ground through its output MOSFET). |
| |
To find the devices, the enumeration broadcast command must be sent by a master. The slave device response with all ID bits to the master and at the end it returns a 0. | <figure 1wire0> |
| {{ en:iot-open:embeddedcommunicationprotocols2:1wire_bus.png?450 | 1-Wire bus connection}} |
<figure label> | <caption>1-Wire bus connection</caption> |
{{ en:iot-open:embedded_systems_communication_protocols:1wire_reset.png?nolink&450 |}} | |
<caption>1-Wire reset timings.</caption> | |
</figure> | </figure> |
| |
<figure label> | The 1-Wire protocol allows for bursting the communication speed up by 10 factors. In this case, the master starts a transmission with a reset pulse, pulling down the data line to 0 volts for at least 480 µs. It resets all slave devices in the network chain bus. Then, any slave device shows it exists, generating the "presence" pulse. It holds the data line low for at least 60 µs after the master releases the bus. To send a "1", the bus master sends a 1–15 µs low pulse. To send a "0", the master sends a 60 µs low pulse. The negative edge of the pulse is used to start a slave's monostable multivibrator. The slave's multivibrator clocks to read the data bus about 30 µs after the falling edge. The slave's multivibrator has analogue tolerances that affect its timing accuracy, for the "0" pulses are 60 µs long, and "1" pulses are limited to a max of 15 µs. When the designed solution doesn't contain a dedicated 1-Wire interface peripheral, a UART can be used as a 1-Wire master. Dallas also offers Serial or USB "bridge" chips, which are very useful when the distance between devices is long (greater than 100 m). For longer, up to 300 m buses, the simple twisted pair telephone cable can be used. It will require adjustment of pull-up resistances from 5 kΩ to 1 kΩ. The basic sequence is a reset pulse followed by an 8-bit command, and after it, data can be sent/received in groups of 8-bits. In the case of transmission errors, the weak data protection 8-bit CRC checking procedure can be used. |
{{ en:iot-open:embedded_systems_communication_protocols:1wire_read.png?nolink&450 |}} | |
<caption>1-Wire read timings.</caption> | To find the devices, the enumeration broadcast command must be sent by a master. The slave device responds with all ID bits to the master, and at the end, it returns a 0. |
| |
| Sample 1-Wire timings are present in figures {{ref>1wire1}}, {{ref>1wire2}} and {{ref>1wire3}}. |
| |
| <figure 1wire1> |
| {{ en:iot-open:embeddedcommunicationprotocols2:1wire_reset.png?450 | 1-Wire reset timings}} |
| <caption>1-Wire reset timings</caption> |
</figure> | </figure> |
| |
<figure label> | <figure 1wire2> |
{{ en:iot-open:embedded_systems_communication_protocols:1wire_write.png?nolink&450 |}} | {{ en:iot-open:embeddedcommunicationprotocols2:1wire_read.png?450 | 1-Wire read timings}} |
<caption>1-Wire write timings.</caption> | <caption>1-Wire read timings</caption> |
</figure> | </figure> |
| |
===USB to 1-Wire Master=== | <figure 1wire3> |
The DS9490B is a USB bridge and holder for a single F5-size iButton. The DS9490R is a USB bridge with 1-Wire RJ11 interface to accommodate 1-Wire receptacles and networks. | {{ en:iot-open:embeddedcommunicationprotocols2:1wire_write.png?450 | 1-Wire write timings}} |
<figure label> | <caption>1-Wire write timings</caption> |
{{ :en:iot-open:introduction:ds9490_usb_bridge.png?150 |}}<caption>DS9490R USB Bridge.</caption> | |
</figure> | </figure> |
The bridge is based on the DS2490 chip developed by Dallas company, which allows to interconnect USB interface with 1-Wire bus. This required programming and electrical conversion between two different protocols in bidirectional way. The electrical wiring are present on Figure 9. | |
<figure label> | |
{{ :en:iot-open:introduction:ds9490_schematic.png?600 |}}<caption>DS9490R USB schematic.</caption> | |
</figure> | |
The appropriate 1-Wire cable pinout uses RJ11 telephone connectors. | |
<figure label> | |
{{ :en:iot-open:introduction:ds9490_rj11_pinout.png?300 |}} | |
<caption>DS9490 1-Wire RJ11 SOCKET pinout.</caption> | |
</figure> | |
| |
| |
===1-Wire Products=== | === 1-Wire Products === |
The list of Dallas/Maxim integrated 1-Wire devices contains a wide range of industrial implementations. The 1-Wire sensors and switches devices are very popular in the developer's community due to ease implementation. 1-Wire protocol can be fast implemented into the current IoT boards; most of the manufacturers share the software libraries allowing developers to include them in their projects in C, C++, assembly languages. The 1-Wire sensors (temperature, humidity, pressure, etc.) are factory calibrated and reading the physical measurements follows the International System of Units (SI). 1-Wire products can be grouped as follows: | The Dallas/Maxim integrated 1-Wire devices list contains many implementations. The 1-Wire protocol can be quickly implemented into the current IoT boards; most manufacturers share the software libraries, allowing developers to include them in their projects in C, C++, and assembly languages. The 1-Wire sensors (temperature, humidity, pressure, etc.) are factory-calibrated and read the physical measurements following the International System of Units (SI). 1-Wire products can be grouped as follows: |
* secure authenticators, | * secure authenticators, |
* memory EPROM, EEPROM ROM, | * memory EPROM, EEPROM ROM, |