In this post you are going to learn how to connect the Dallas temperature sensor to any of our PLCs, read the temperatures from it and store them into an SD card. The code of the temperatures and the SD card is done with the Arduino Software and you can see it in the Software section.
In order to work with the Dallas temperature sensor and the SD card, you will need any of our industrial controllers for industrial automation:
One Wire protocol
One of the main advantages of the Dallas sensor (DS18B20) is its 1-Wire communication bus which allows it to communicate with the PLC Arduino using only one data cable. 1-Wire is based on a complex timing system in the signal between the sending and the receiver devices.
The major disadvantage of the 1-Wire system is that it requires a complex code and at the same time it is a big load for the processor to consult the state of the sensors. The total acquisition time of a measurement is 750ms.
1-Wire allows the devices connceted to the bus to get the power supply through the data line. To make this possible, they have a capacitor that stores energy while the data line is in HIGH. This is the "parasite mode". If this mode is not used, the devices will have to be connected to a voltage between 3.0V and 5.5V.
In any of the cases, the 1-Wire bus needs a pull-up resistance of 4k7Ω between VDD (power supply line) and DQ (data line) cables to work properly.
Configuration of the switches:
Most of the inputs and the outputs are connected to the internal Arduino, but in few cases, the user can choose between a special peripheral configuration or a GPIO by changing the position of the Dip Switches.
Each switch can select only one of the two possible configurations at the same time. For example, in this case we are watching the configuration of an M-Duino 58+ Ethernet controlled. If we put the switch to the right position (ON), the input I0.6 will be activated, but if the switch is in the left position (OFF) we will activate Pin 2, which is a digital pin.
Keep in mind that each switch has two different configurations: you must select the right (ON) or the left (OFF) option.
Pin 3, Pin 2 & SD enabled - I0.6, I0.0 & Q2.0 disabled
The connection of the sensor to the PLC has to be the one shown in the One Wire Protocol section.
More than one Dallas temperature sensor:
There can be more than one Dallas sensor connected, using the same data line (DQ). Their connection would be like the following image.
Pull-up resistance: (product web)
The 4k7 Ohm resistance that has been appearing in the hardware assemblies is needed to set the data line (DQ) to HIGH. This allows the sensor to work with the One Wire Arduino library and to operate without an external power supply because it's taken through the 1-Wire pull-up resistance through the DQ pin when the bus is high. The high bus signal also charges an internal capacitor, which supplies power to the device/s when the bus is low. This assembly is known as a "parasite". Its hardware disposition is the following one.
Reading one Dallas sensor located in the digital pin 2:
Reading one Dallas sensor located in the digital pin 2 and datalog into a µSD card:
Finding the direction and reading two Dallas sensors, both located in the digital pin 2:
Reading two Dallas sensors with their direction, both located in the digital pin 2: