Both sides previous revisionPrevious revisionNext revision | Previous revision |
en:iot-open:introduction:introduction_to_iot_communication_and_protocols [2018/09/20 08:16] – Agrisnik | en:iot-open:introduction:introduction_to_iot_communication_and_protocols [2020/07/20 09:00] (current) – external edit 127.0.0.1 |
---|
| ===== ===== |
| <box #5374d5></box> |
| <box #5374d5></box> |
===== Embedded Systems Communication Protocols ===== | ===== Embedded Systems Communication Protocols ===== |
Understanding the principals of the communication are essential for further reading on hardware and programming. Most microcontrollers (including SoCs) can communicate in the protocols juxtaposed below right "out of the box". Interfaces can be implemented in hardware or (recently) in software. Some microcontrollers may require an external, dedicated protocol converter (a chip or a module). | <box #5374d5></box> |
| <box #5374d5></box> |
| |
| Understanding the principals of communication are essential for further reading on hardware and programming. Most microcontrollers (including SoCs) can communicate in the protocols juxtaposed below right "out of the box". Interfaces can be implemented in hardware or (recently) in software. Some microcontrollers may require an external, dedicated protocol converter (a chip or a module). |
| |
IoT systems are typically structured into three basic layers ((Internet of Things: Security Vulnerabilities and Challenges Ioannis Andrea, Chrysostomos Chrysostomou, George Hadjichristofi, The 3rd IEEE ISCC 2015 International Workshop on Smart City and Ubiquitous Computing Applications, https://doi.org/10.1109/ISCC.2015.7405513)). The lowest layer is the Perception (physical, acquisition) Layer, the intermediate is the Network Layer, and the higher is the Application Layer. | IoT systems are typically structured into three basic layers ((Internet of Things: Security Vulnerabilities and Challenges Ioannis Andrea, Chrysostomos Chrysostomou, George Hadjichristofi, The 3rd IEEE ISCC 2015 International Workshop on Smart City and Ubiquitous Computing Applications, https://doi.org/10.1109/ISCC.2015.7405513)). The lowest layer is the Perception (physical, acquisition) Layer, the intermediate is the Network Layer, and the higher is the Application Layer. |
The function of the perception layer is to keep the contact with the physical environment. Devices working in this layer are designed as embedded systems. They include the microprocessor or microcontroller, memory, communication unit and interfaces - sensors or actuators. | The function of the perception layer is to keep contact with the physical environment. Devices working in this layer are designed as embedded systems. They include the microprocessor or microcontroller, memory, communication unit, and interfaces – sensors or actuators. |
Sensors are elements that convert a value of some physical parameter into an electrical signal, while actuators are elements that control environment parameters. | Sensors are elements that convert a value of some physical parameter into an electrical signal, while actuators are elements that control environment parameters. |
Sensors and actuators are interfaced with the microcontroller using different connection types. This chapter describes some internal protocols used to communicate between microcontrollers and other electronic elements that can be named “embedded protocols”. Description of the protocols used for wire and wireless transmission between the perception layer and higher layers is present in [[en:iot-open:communications_and_communicating_sut]] | Sensors and actuators are interfaced with the microcontroller using different connection types. This chapter describes some internal protocols used to communicate between microcontrollers and other electronic elements that can be named “embedded protocols”. Description of the protocols used for wire and wireless transmission between the perception layer and higher layers is present in [[en:iot-open:communications_and_communicating_sut]] |
| |
====Digital==== | ====Digital==== |
Dummy, true/false information can be processed via digital I/O. Most devices use positive logic, where i.e. +5V (TTL) or +3.3V (those are most popular yet there do exist other voltage standards) presents a logical one, while 0V presents logical zero. In real systems this bounding is fuzzy and brings some tolerance, simplifying i.e. communication from 3.3V output to 5V input, without a need of the conversion (note, opposite conversion is usually not so straightforward, as 3.3V inputs driven by 5V output may burn easily). A sample of the sensor providing binary data is a button (On/Off). | Dummy, true/false information can be processed via digital I/O. Most devices use positive logic, where, i.e. +5 V (TTL) or +3.3 V (those are the most popular, yet there do exist other voltage standards) presents a logical one, while 0V presents logical zero. In real systems this bounding is fuzzy and brings some tolerance, simplifying, i.e. communication from 3.3 V output to 5 V input, without a need of the conversion (note, the reverse conversion is usually not so straightforward, as 3.3 V inputs driven by 5V output may burn easily). A sample of the sensor providing binary data is a button (On/Off). |
| |
====SPI==== | ====SPI==== |
One of the most popular interfaces to connect the sensor is SPI (Serial Peripheral Interface). It is a synchronous serial interface and protocol that can transmit data with speed up to 20Mbps. SPI is used to communicate microcontrollers with one or more peripheral devices over short distances – usually internally in the device. In SPI connection there is always one master device, in most cases the microcontroller (uC) that controls the transmission, and one or more slave devices - peripherals. To communicate SPI uses three lines common to all of the connected devices, and one enabling line for every slave element. | One of the most popular interfaces to connect the sensor is SPI (Serial Peripheral Interface). It is a synchronous serial interface and protocol that can transmit data with speed up to 20 Mbps. SPI is used to communicate microcontrollers with one or more peripheral devices over short distances – usually internally in the device. In SPI connection there is always one master device, in most cases the microcontroller (μC) that controls the transmission, and one or more slave devices – peripherals. To communicate SPI uses three lines common to all of the connected devices, and one enabling line for every slave element. |
<table Ref.Tab.1> | <table Ref.Tab.1> |
<caption>SPI lines</caption> | <caption>SPI Lines</caption> |
^ Line ^ description ^ direction ^ | ^ <fs xx-small>Line</fs> ^ <fs xx-small>Description</fs> ^ <fs xx-small>Direction</fs> ^ |
| MISO | Master In Slave Out | peripheral -> uC | | | <fs xx-small>MISO</fs> | <fs xx-small>Master In Slave Out</fs> | <fs xx-small>peripheral -> μC</fs> | |
| MOSI | Master Out Slave In | uC -> peripheral | | | <fs xx-small>MOSI</fs> | <fs xx-small>Master Out Slave In</fs> | <fs xx-small>μC -> peripheral</fs> | |
| SCK | Serial Clock | uC -> peripheral | | | <fs xx-small>SCK</fs> | <fs xx-small>Serial Clock</fs> | <fs xx-small>μC -> peripheral</fs> | |
| SS | Slave Select | uC -> peripheral | | | <fs xx-small>SS</fs> | <fs xx-small>Slave Select</fs> | <fs xx-small>μC -> peripheral</fs> | |
</table> | </table> |
MISO is intended to send bits from slave to master, MOSI transmits data from master to slave. SCK line is used for sending clock pulses which synchronize data transmission. The clock signal is always generated by the master device. | MISO is intended to send bits from slave to master, MOSI transmits data from master to slave. SCK line is used for sending clock pulses which synchronize data transmission. The clock signal is always generated by the master device. |
Every SPI compatible device has the SS (Slave Select) input that enables communication in this specific device. Master is responsible to generate this enable signal – separately for every slave in the system. | Every SPI compatible device has the SS (Slave Select) input that enables communication in this specific device. Master is responsible to generate this enable signal – separately for every slave in the system. |
<figure Ref.Pic.1> | <figure Ref.Pic.1> |
{{ :en:iot-open:embedded_systems_communication_protocols:spi_three_slaves.svg.png?nolink&300 | SPI connections }} | {{ :en:iot-open:embedded_systems_communication_protocols:spi_diagram.png?nolink&500 | SPI connections }} |
<caption align = "center">Sample SPI connection((https://en.wikipedia.org/wiki/File:SPI_three_slaves.svg))</caption> | <caption>Sample SPI connection.</caption> |
</figure> | </figure> |
| |
| SPI is used in many electronic elements like analogue to digital converters (ADC), real-time clocks (RTC), EEPROMs, LCD displays, communication interfaces (e.g. Ethernet, WiFi) and many others. |
| |
| |
SPI is used in many electronic elements like analog to digital converters (ADC), real time clocks (RTC), EEPROMs, LCD displays, communication interfaces (eg. Ethernet, WiFi) and many others. | |
Due to different hardware implementations, there are four modes of operation of the SPI protocol. The mode used in master must fit the mode that is implemented in the slave device. | Due to different hardware implementations, there are four modes of operation of the SPI protocol. The mode used in master must fit the mode that is implemented in the slave device. |
<table Ref.Tab.2> | <table Ref.Tab.2> |
<caption>SPI modes</caption> | <caption>SPI Modes</caption> |
^ Mode ^ Clock polarity ^ Clock phase ^ Idle state ^ Active state ^ Output edge ^ Data capture ^ | ^ <fs xx-small>Mode</fs> ^ <fs xx-small>Clock polarity</fs> ^ <fs xx-small>Clock phase</fs> ^ <fs xx-small>Idle state</fs> ^ <fs xx-small>Active state</fs> ^ <fs xx-small>Output edge</fs> ^ <fs xx-small>Data capture</fs> ^ |
| mode 0 | 0 | 0 | 0 | 1 | falling | rising | | | <fs xx-small>mode 0</fs> | <fs xx-small>0</fs> | <fs xx-small>0</fs> | <fs xx-small>0</fs> | <fs xx-small>1</fs> | <fs xx-small>falling</fs> | <fs xx-small>rising</fs> | |
| mode 1 | 0 | 1 | 0 | 1 | rising | falling | | | <fs xx-small>mode 1</fs> | <fs xx-small>0</fs> | <fs xx-small>1</fs> | <fs xx-small>0</fs> | <fs xx-small>1</fs> | <fs xx-small>rising</fs> | <fs xx-small>falling</fs> | |
| mode 2 | 1 | 0 | 1 | 0 | rising | falling | | | <fs xx-small>mode 2</fs> | <fs xx-small>1</fs> | <fs xx-small>0</fs> | <fs xx-small>1</fs> | <fs xx-small>0</fs> | <fs xx-small>rising</fs> | <fs xx-small>falling</fs> | |
| mode 3 | 1 | 1 | 1 | 0 | falling | rising | | | <fs xx-small>mode 3</fs> | <fs xx-small>1</fs> | <fs xx-small>1</fs> | <fs xx-small>1</fs> | <fs xx-small>0</fs> | <fs xx-small>falling</fs> | <fs xx-small>rising</fs> | |
</table> | </table> |
This results in different timings of the clock signal concerning the data sent. Clock polarity = 0 means that the idle state of the SCK is 0 so every data bit is synchronised with the pulse of logic 1. Clock polarity = 1 reverses these states. Output edge (rising/falling) says at which edge of active SCK signal sender puts a bit on the data line. Data capture edge says at what edge of SCK signal data should be captured by the receiver. | |
| It results in different timings of the clock signal concerning the data sent. Clock polarity = 0 means that the idle state of the SCK is 0, so every data bit is synchronised with the pulse of logic 1. Clock polarity = 1 reverses these states. Output edge (rising/falling) says at which edge of active SCK signal sender puts a bit on the data line. Data capture edge says at what edge of SCK signal data should be captured by the receiver. |
====TWI (I2C)==== | ====TWI (I2C)==== |
TWI (Two WIre Interface) is one of the most popular communication protocol used in embedded systems. It has been designed by Philips as I2C (Inter Integrated Circuit) for using in the audio-video appliances controlled by microprocessor. There are many chips that can be connected to the processor with this interface including: | TWI (Two Wire Interface) is one of the most popular communication protocol used in embedded systems. It has been designed by Philips as I2C (Inter-Integrated Circuit) for using in the audio-video appliances controlled by the microprocessor. There are many chips that can be connected to the processor with this interface, including: |
- EEPROM memory chips | * EEPROM memory chips, |
- RAM memory chips | * RAM memory chips, |
- AD/DA converters | * AD/DA converters, |
- Real time clocks | * real-time clocks, |
- Sensors (temperature, pressure, gas, air pollution) | * sensors (temperature, pressure, gas, air pollution), |
- Port extenders | * port extenders, |
- Displays | * displays, |
- Specialized AV circuits | * specialised AV circuits. |
TWI as the name says uses two wires for communication. One is the data line (SDA) second is the clock line (SCL). Both lines are common to all circuits connected to the one TWI bus. The method of the communication of TWI is the master-slave synchronous serial transmission. It means that data is sent bit after bit synchronized with the clock signal. SCL line is always controlled by the master unit (usually the processor), signal on the SDA line is generated by master or one of the slaves – depending on the direction of communication. The frequency rate of the communication is up to 100kHz for most of the chips, for some can be higher – up to 400kHz. New implementation allows even higher frequency rate reaching 5MHz. | TWI, as the name says, uses two wires for communication. One is the data line (SDA); the second is the clock line (SCL). Both lines are common to all circuits connected to the one TWI bus. The method of the communication of TWI is the master-slave synchronous serial transmission. It means that data is sent bit after bit synchronised with the clock signal. SCL line is always controlled by the master unit (usually the processor), the signal on the SDA line is generated by the master or one of the slaves – depending on the direction of communication. The frequency rate of the communication is up to 100 kHz for most of the chips, for some can be higher – up to 400 kHz. The new implementation allows even higher frequency rate is reaching 5 MHz. |
At the output side of units the lines have the open-collector or open-drain circuit. It means that there are external pull-up resistors needed to ensure proper operation of the TWI bus. Value of these resistors depends on the number of connected elements, speed of transmission and the power supply voltage and can be calculated with the formulas presented in Texas Instrument Application Report((Rajan Arora, I2C Bus Pullup Resistor Calculation, Texas Instruments Application Report)). Usually it is assumed between 1 kOhm and 4,7 kOhm. | At the output side of units, the lines have the open-collector or open-drain circuit. It means that there are external pull-up resistors needed to ensure proper operation of the TWI bus. Value of these resistors depends on the number of connected elements, speed of transmission and the power supply voltage and can be calculated with the formulas presented in Texas Instrument Application Report ((Rajan Arora, I2C Bus Pullup Resistor Calculation, Texas Instruments Application Report)). Usually, it is assumed between 1 kΩ and 4.7 kΩ. |
| |
<figure Ref.Pic.2> | <figure Ref.Pic.2> |
{{ :en:iot-open:embedded_systems_communication_protocols:1000px-i2c.svg.png?nolink&400 | TWI bus connection}} | {{ :en:iot-open:embedded_systems_communication_protocols:twi_diagram.png?nolink&500 | TWI bus connection}} |
<caption>Sample TWI connection((https://en.wikipedia.org/wiki/I%C2%B2C#/media/File:I2C.svg))</caption> | <caption>Sample TWI connection.</caption> |
</figure> | </figure> |
| |
The data is sent using frames of bytes. Every frame begins with the sequence of signals that is called start condition. This sequence is detected by slaves and causes them to collect next eight bits that forms the address byte – unique for every circuit on the bus. If one of the slaves recognizes its address remains active till the end of the communication frame, others become inactive. To inform master that some unit has been properly addressed slave responses with the acknowledge bit – it generates one bit of low level on the SDA line (clock pulse is generated by master). After sending proper address data bytes are sent. The direction of the data bytes is controlled by last bit of the address, for 0 data is sent by master (Write), for 1 data is sent by slave (Read). Every full byte (eight bits) must be acknowledged by the receiving unit. There is no limitation on the number of data bytes in the frame, for example samples from the AD converter can be read continuously byte after byte. At the end of the frame another special sequence is sent by master – stop condition. It is also possible to generate another start condition without the stop condition. It is called repeated start condition. | The data is sent using frames of bytes. Every frame begins with the sequence of signals that is called the start condition. This sequence is detected by slaves and causes them to collect the next eight bits that form the address byte – unique for every circuit on the bus. If one of the slaves recognises its address remains active until the end of the communication frame, others become inactive. To inform the master that some unit has been appropriately addressed slave responses with the acknowledge bit – it generates one bit of low level on the SDA line (the master generates clock pulse). After sending the proper address, data bytes are sent. The direction of the data bytes is controlled by the last bit of the address, for 0 data is transmitted by the master (Write), for 1 data is sent by the slave (Read). The receiving unit must acknowledge every full byte (eight bits). There is no limitation on the number of data bytes in the frame, for example, samples from the AD converter can be read byte continuously after byte. At the end of the frame, another special sequence is sent by the master – stop condition. It is also possible to generate another start condition without the stop condition. It is called a repeated start condition. |
| |
<figure Ref.Pic.3> | <figure Ref.Pic.3> |
{{ :en:iot-open:embedded_systems_communication_protocols:1000px-i2c_data_transfer.svg.png?nolink&800 | TWI frame}} | {{ :en:iot-open:embedded_systems_communication_protocols:twi_timing.png?nolink&600 | TWI frame}} |
<caption>TWI frame((https://en.wikipedia.org/wiki/I%C2%B2C#/media/File:I2C_data_transfer.svg))</caption> | <caption>TWI frame.</caption> |
</figure> | </figure> |
| |
Address byte activates one chip on the bus only, so every unit must have unique physical address. This byte consists usually of three elements: 4-bit field fixed by the producer, 3-bit field that can be set by connecting three pins of the chip to 0 (ground) or 1 (positive supply line), 1-bit field for setting the direction of communication (R/#W). Some elements (eg. EEPROM memory chips) uses the 3-bit field for internal addressing so there can be only one such circuit connected to one bus. | Address byte activates one chip on the bus only, so every unit must have a unique physical address. This byte usually consists of three elements: 4-bit field fixed by the producer, 3-bit field that can be set by connecting three pins of the chip to 0 (ground) or 1 (positive supply line), 1-bit field for setting the direction of communication (R/#W). Some elements (e.g. EEPROM memory chips) uses the 3-bit field for internal addressing so there can be only one such circuit connected to one bus. |
There are no special rules for the data bytes. First data byte sent by master can be used for configuration of the slave chip. In memory units it is used for setting the internal address of the memory for writing or reading. In multi-channel AD converters to choose the analog input. The detailed information of meaning of every bit of the transmission is present in the documentation of the specific integrated circuit. | There are no special rules for the data bytes. First data byte sent by the master can be used for configuration of the slave chip. In memory units, it is used for setting the internal address of the memory for writing or reading, in multi-channel AD converters to choose the analogue input. The detailed information on the meaning of every bit of the transmission is present in the documentation of the specific integrated circuit. |
I2C standard defines also the multi master mode but in most of the small projects there is one master device only. | The I2C standard also defines the multi-master mode, but in most of the small projects, there is one master device only. |
| |
| |
====1-Wire==== | ====1-Wire==== |
1-Wire is a device communications bus system designed by Dallas Semiconductor Corp((https://www.maximintegrated.com/en/products/digital/one-wire.html)). that provides low-speed data, signalling, and power over a single signal. 1-Wire is similar in concept to I²C, but with lower data rates and longer range. It is typically used to communicate with small, inexpensive devices such as digital thermometers and weather instruments. A network of 1-Wire devices with an associated master device is called a MicroLAN. 1-Wire devices may be one of many components on a circuit board within a product, could be a single component within a device such as a temperature probe, or may be attached to a device being monitored. Some laboratory systems and other data acquisition and control systems connect to 1-Wire devices using cables with modular connectors or with CAT-5 cable, with the devices themselves, mounted in a socket, incorporated in a small PCB, or attached to the object being monitored. In such systems, RJ11 (6P2C or 6P4C modular plugs, commonly used for telephones) are popular. | 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. |
Systems of sensors and actuators can be built by wiring together 1-Wire components. Each component contains all of the logic needed to operate on the 1-Wire bus. Examples include temperature loggers, timers, voltage and current sensors, battery monitors, and memory. These can be connected to a PC using a bus converter. USB, RS-232 serial, and parallel port interfaces are popular solutions for connecting the MicroLAN to the host PC. 1-Wire devices can also be interfaced directly to microcontrollers from various vendors. | 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 Protocol Description=== |
| 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. |
| |
| 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. |
| |
| 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 label> |
| {{ en:iot-open:embedded_systems_communication_protocols:1wire_reset.png?nolink&450 |}} |
| <caption>1-Wire reset timings.</caption> |
| </figure> |
| |
| <figure label> |
| {{ en:iot-open:embedded_systems_communication_protocols:1wire_read.png?nolink&450 |}} |
| <caption>1-Wire read timings.</caption> |
| </figure> |
| |
===1-Wire protocol description=== | |
In any MicroLAN, there is always one master in overall charge, which may be a PC or a microcontroller. The master initiates activity on the bus, simplifying the avoidance of collisions on the bus. Protocols are built into the software to detect collisions. After a collision, the master retries the required communication. Many devices can share the same bus. Each device on the bus has a unique 64-bit serial number. The least significant byte of the serial number is an 8-bit number that tells the type of the device. The most significant byte is a standard (for the 1-wire bus) 8-bit CRC. There are several standard broadcast commands, as well as commands used to address a particular device. The master can send a selection command, then the address of a particular device. The next command is executed only by the addressed device. The 1-wire bus enumeration protocol (described later), like other singulation protocols, is an algorithm the master uses to read the address of every device on the bus. Since the address includes the device type and a CRC, recovering the address roster also produces a reliable inventory of the devices on the bus. The 64-bit address space is searched as a binary tree, allowing up to 75 devices to be found per second. The Dallas 1-Wire network is physically implemented as an open drain master device connected to one or more open drain slaves. A single pull-up resistor is common to all devices and acts to pull the bus up to 3 or 5 volts and may provide power to the slave devices. Communication occurs when a master or slave asserts the bus low, i.e. connects the pull-up resistor to ground through its output MOSFET. Specific 1-Wire driver and bridge chips are also available. Data rates of 16.3 kbit/s can be achieved. There is also an overdrive mode which speeds up the communication by a factor of 10. The master starts a transmission with a reset pulse, which pulls the wire to 0 volts for at least 480 µs. It resets every slave device on the bus. After that, any slave device, if present, shows that it exists with a "presence" pulse: it holds the bus low for at least 60 µs after the master releases the bus. To send a "1", the bus master sends a very brief (1–15 µs) low pulse. To send a "0", the master sends a 60 µs low pulse. The falling (negative) edge of the pulse is used to start a monostable multivibrator in the slave device. The multivibrator in the slave clocks to read the data line about 30 µs after the falling edge. The slave's multivibrator unavoidably has analogue tolerances that affect its timing accuracy, which is why the "0" pulses have to be 60 µs long, and the "1" pulses can't be longer than 15 µs. When a dedicated 1-Wire interface peripheral is not available, a UART can be used to implement a 1-wire bus master. Serial or USB "bridge" chips are also available that handle the timing and waveform requirements of the 1-Wire bus, and are particularly useful in utilising long (greater than 100 m) cables effectively. Up to 300 meter long buses consisting of simple twisted pair telephone cable has been tested by the manufacturer. It will, however, require adjustment of pull-up resistances from 5 to 1 kΩ. When receiving data, the master sends a 1–15-µs 0-volt pulse to start each bit. If the transmitting slave unit wants to send a "1", it does nothing, and the bus goes to the pulled-up voltage. If the transmitting slave wants to send a "0", it pulls the data line to ground for 60 µs. The basic sequence is a reset pulse followed by an 8-bit command, and then data is sent or received in groups of 8-bits. When a sequence of data is being transferred, errors can be detected with an 8-bit CRC (weak data protection). To find the devices, the master broadcasts an enumeration command, and then an address, "listening" after each bit of an address. If a slave has all the address bits so far, it returns a 0. The master uses this simple behaviour to search systematically for valid sequences of address bits. The process is much faster than a brute force search of all possible 64-bit numbers because as soon as an invalid bit is detected, all subsequent address bits are known to be invalid. An enumeration of 10 to 15 devices finishes very quickly. The location of devices on the bus is sometimes significant. For these situations, the manufacturer has a special device that either passes through the bus or switches it off. | |
<figure label> | <figure label> |
{{ :en:iot-open:introduction:1-wire_timing.png |}}<caption>1-Wire reset, write and read timings</caption> | {{ en:iot-open:embedded_systems_communication_protocols:1wire_write.png?nolink&450 |}} |
| <caption>1-Wire write timings.</caption> |
</figure> | </figure> |
| |
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. | 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. |
<figure label> | <figure label> |
{{ :en:iot-open:introduction:ds9490_usb_bridge.png?300 |}}<caption>DS9490R USB Bridge</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 3. | 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> | <figure label> |
{{ :en:iot-open:introduction:ds9490_schematic.png?600 |}}<caption>DS9490R USB schematic</caption> | {{ :en:iot-open:introduction:ds9490_schematic.png?600 |}}<caption>DS9490R USB schematic.</caption> |
</figure> | </figure> |
The appropriate 1-Wire cable pinout uses RJ11 telephone connectors. | The appropriate 1-Wire cable pinout uses RJ11 telephone connectors. |
<figure label> | <figure label> |
{{ :en:iot-open:introduction:ds9490_rj11_pinout.png |}}<caption>DS9490 1-Wire RJ11 SOCKET pinout</caption> | {{ :en:iot-open:introduction:ds9490_rj11_pinout.png?300 |}} |
| <caption>DS9490 1-Wire RJ11 SOCKET pinout.</caption> |
</figure> | </figure> |
| |
| |
===1-Wire Products=== | ===1-Wire Products=== |
The list of Dallas/Maximintegrated 1-Wire devices contains a wide range of the industrial implementations. The 1-Wire sensors and switches devices are viral in developers entity because of ease of implementation. 1-Wire protocol can be easy and 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 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: |
- Secure Authenticators, | * secure authenticators, |
- Memory EPROM, EEPROM ROM, | * memory EPROM, EEPROM ROM, |
- Temperature Sensors and Temperature Switches, | * temperature sensors and temperature switches, |
- Data Loggers, | * data loggers, |
- 1-Wire Interface Products, | * 1-Wire interface products, |
- Battery Monitors, Protectors and Selectors, | * battery monitors, protectors, and selectors, |
- Battery ID and Authentication, | * battery ID and authentication, |
- Timekeeping and Real-Time Clocks. | * timekeeping and real-time clocks. |