Skip to main content

Temperature Data Logger Part3

4.3.4 The Timing Diagrams
DS1820 data is read and written through the use of time slots to manipulate bits and a command word to specify the transaction.
Write Time Slots: A write time slot is initiated when the host pulls the data line from a high logic level to a low logic level. There are two types of write time slots: Write ‘1’ time slots and Write ‘0’ time slots as shown in fig 4.9.
Fig 3.6: Master Write pulse for DS1820

Indications
Master Active Low DS1820 Active Low
PIC and DS1820 Low Resistor Pull-Up
Fig 3.7: Master Read pulse for DS1820
Read Time Slots: The master generates read time slots when data is to be read from the DS1820. The data line must remain at a low logic level for a minimum of one µs to initiate read signal; output data from the DS1820 is valid for 15 µs after the falling edge of the read time slot. The master, therefore, must stop driving the I/O pin low in order to read its state 15 µs from the start of the read slot. By the end of the read time slot, the I/O pin will pull back high via the external pull–up resistor. All read time slots must be a minimum of 60 µs in duration. The timing diagram of read ‘0’ and read ‘1’ is as given in fig 4.10.

4.3.5 Cable Properties and Signal Propagation Delays

Capacitance:
Cable capacitance is simply the product of cable length times its unit capacitance. This is roughly about 50pF/m for Category 5 twisted pair cable. Better quality CAT5E or CAT6 cable can have lower numbers. Similarly, line resistance represents cable length multiplied by the specified resistance per meter of a single wire.

Impedance:
The characteristic impedance of a cable is given in its simplified form by:
Zo = √(L/C) ………………………………………………………………………….Eq 4.2

L - Inductance per unit length, and C - Capacitance per unit length.
The NVP, acronym for Nominal Velocity of Propagation, expresses the speed with which electrical signals travel in the cable, relative to the speed of light in space or vacuum. When we measure the time required for a signal to travel the length of the link and back, and we know the NVP of the cable, we can calculate the electrical length of the link. Since the signal has travelled up and down the cable (twice the length), the equation for length is:

Length = (Measured _ Time _ Delay * NVP * Speed _ of _ Light)/2 ………….......Eq 4.3

The speed of light in space (or vacuum) is 300,000,000 meters/second or 0.3 meters per nanosecond. NVP for a Category 5 UTP cable is approximately 69%, which means that electrical signal travel along a Category 5 cable at approximately 0.2 m/nanosecond or 8 inches/nanosecond. The propagation time should also be calculated for long distance communication. The condition for the transition time has to be satisfied. That is if the time is taken for the signal to switch between voltage levels (0V and 5V) called the ‘transition time’ is less than the time it takes for the signal to travel the length of the line and return back only then we say that a transmission line environment exists. This condition is essential for establishing long distant 1-wire communication. For 8 meter length which includes the data line and the return ground line, a Cat5 cable needs 40ns propagation time.

4.3.6 Performance of the DS1820
Typical Error Performance Curve as shown in Fig 4.11. The error rate is found to be below +1/2°C for temperatures between -10°C and 100°C and for temperatures above 100°C the error falls below 0 and decreases For temperatures below -10°C the error curve rises exponentially to around +2.5°C for -55°C.

Fig 3.8: Error Performance curve for IC-DS1820







4. Accessing the Data in the pC

The procedure for logging and accessing the data in the Personal Computer is given below:
1. The test setup consists of powering the PIC microcontroller connected to 1- Wire. More than one DS1820 ICs are connected to this one wire. The test code is written in such a way that first the no. of ICs connected are identified using search from algorithm and then the controller goes into an infinite loop which will address each IC and extract temperature data from each of them.
Fig 4.1: 4- channel data received on HyperTerminal
The above fig shows the 4-DS1820 ICs connected to 1-Wire, which will send the count of DS1820 ICs and its - Address and Temperature data each at a time serially to PC.
2. First, the Hyperterminal port is configured and then temperature values are received and arranged in a proper format in order to ensure that there is no error in data transmission from the PIC microcontroller side.
5. Testing Calibration and Calculation

The procedure for Data Logger hardware module testing is as follows
    1. Connect DS1820 IC to the Data Logger applies 5V to this IC. The output hex values of the PIC are serially transmitted and received in the Computer.
The complete flow chart of the code for the PIC microcontroller is as given below.






Fig 5.1: Flow-Chart of the 5-Channel Data Logger.


5.1 DS1820 Programming and Calculation:
The DS1820 doesn’t require any additional circuit other than the 4.7K pull-up resistor and a 5V DC supply. The main concern in temperature measurement is programming the DS1820 IC; the accuracy involved especially with the timing diagrams for read and write bit sequences. Since 1-wire protocol is used as explained in section 4.3, exact 1micro-second delay programs have to be generated. This is done using and verified using CRO. To begin with DS1820 programming, a good reset pulse obtained on a CRO as shown in fig 6.6
Fig 6.6 Reset pulse obtained in CRO.

The 1820 IC is synchronised by a short low pulse of 5µ second. The reset pulse showed in the figure works as follows:
The wire is held low for 480µsec, and it is then removed and becomes high by the pull-up resistor for 40µsec. DS1820 then understands that a reset has been done and it responds by pulling the wire low for about 120 µsec and later on the pull-up resistor makes it high for 100 µsec. Using the delay code for the reset function the following functions were developed:
void DS1820_DelayUs(int Val),
void DS1820_WriteByte(uint8 val_u8),
uint8 DS1820_ReadByte (void)
void DS1820_Reset()
These functions are building blocks for establishing 1-wire communication with any Dallas 1-wire IC. After reset function was executed the PIC-DS1820 was then programmed for Convert Temperature (44h) and Read Scratchpad (Beh) commands. Next Read Rom Command was done for a single DS1820 IC; using which complete 8byte ROM Address was received. Later the Match from (55h) command was implemented on a single DS1820 IC, after which reading the temperature was done. The success of this program indicated that 1-wire protocol can be implemented without any alteration in the code.
Next two DS1820 ICs were connected on 1-wire and match from along with convert temperature and read temperature was done. Hence, 1-wire implementation was successful using 2 DS1820. This was done by hard coding from addresses of the DS1820 ICs used; wherein the Rom Address was obtained individually by read from command. If any new DS1820 IC had to be replaced for a faulty one, then corresponding change in the source code had to be done. To overcome above problem search from command was implemented. It is placed at the beginning of the code as initialization for scanning every device connected to the one wire. This search ROM is the most critical part of DS1820 programming and it is clearly explained in section 4.3.3.

5.3 Calculation:
The DS1820 outputs the temperature readings in hex decimal format where 0 ºC is represented as 0 ºC (0000 h) and +125 ºC is given as 250 ºC (00FA h) with each increment in hexadecimal signifies 0.5 ºC increase in temperature. As the raw data i.e., hex value is directly sent to the Personal Computer the calculation/conversion involved in PC is as follows.
  1. The least bit being 1 and 0 in binary signifies that the temperature is 0.5 or 0.0 respectively.
  2. The hex value is then right shifted so that the 0.5 increments are eliminated and the resulting value is half the actual value.
  3. This value is converted to decimal and the 0.5 or 0.0 is added to the decimal value depending on the least bit being observed.


Comments

Popular posts from this blog

CAN INTERVIEW QUESTIONS

Qualifiers and Modifier in C

RTOS Real time operating system interview questions

CAN INTERVIEW QUESTIONS 2

What is UDS protocol

Memory mapping in c

TOP IOT PLATFORMS