Temperature Sensor ADT7420 Pmod Controller (VHDL)

Logic Home

Code Downloads

Temperature Sensor Pmod Controller (top-level file): pmod_temp_sensor_adt7420.vhd (10.4 KB)

I2C Master (must also be included in the project): i2c_master.vhd (14.1 KB)

Features

  • VHDL source code of a streamlined interface to Digilent’s Pmod TMP2, Rev. B (Pmod for Analog Devices ADT7420 Temperature Sensor)
  • Continually outputs latest temperature data on a parallel interface
  • Handles I2C communication and all data retrieval from the Temperature Sensor Pmod
  • Handles configuration of the temperature sensor’s resolution
  • Configurable system clock rate

Introduction

This details a VHDL component that handles interfacing to Digilent’s Temperature Sensor ADT7420 Pmod, shown in Figure 1. Figure 2 illustrates a typical example of this Temperature Sensor Pmod Controller integrated into a system. As shown, this Temp Sensor Pmod Controller connects to the Pmod ports and executes transactions to configure the temperature sensor and gather data. The data is continually updated and presented on a simple parallel interface which can be connected to user logic or to output ports on the FPGA.

pmod_tmp2
Figure 1. Digilent Temperature Sensor ADT4720 Pmod


Figure 2. Example Implementation

Background

The Analog Devices ADT7420 is a high accuracy digital temperature sensor, capable of 0.0078°C resolution when set to its full 16 bits (as done in this design).

Theory of Operation

The Temperature Sensor Pmod Controller consists primarily of a state machine and an I2C Master component.

State Machine

The design uses the state machine depicted in Figure 3 to implement its operation. Upon start-up the component immediately enters the start state. It remains in this state for 100ms to ensure the Pmod has ample time to power-up. It then proceeds to the set_resolution state, where it configures the temperature sensor’s resolution to 16 bits. The pause state inserts a 1.3us “Bus-Free Time” between I2C transactions as required in the ADT7420 datasheet. In the following read_data state, it gathers the most recent temperature data from the Pmod’s temperature sensor. Finally, it outputs the temperature in the output_result state. It then continuously cycles between the pause, read_data, and output_result states to keep the temperature data regularly updated. Although not shown, resetting the component at any time returns it to the start state.


Figure 3. State Diagram

I2C Master

During the set_resolution and read_data states, the state machine controls an I2C Master component to communicate with the temperature sensor on the Pmod. Documentation for the I2C Master is available here.

Configuring the Temp Sensor Pmod Controller

The Temp Sensor Pmod Controller is configured by setting the generic parameters in the entity.

System Clock Frequency

The generic parameter sys_clk_freq must be set to the frequency of the system clock provided to the Temp Sensor Pmod Controller on its clk port.

Pmod I2C Address

The Temp Sensor Pmod Controller must have the Pmod’s 7-bit I2C address to communicate. The 5 most significant bits are “10010” and the following 2 bits are set by the Pmod’s jumper blocks JP2 and JP1, respectively. An open jumper sets the bit to ‘1’, and a closed jumper sets the bit to ‘0’.

The generic parameter temp_sensor_addr must be set to this address. The default value “1001011” corresponds to both jumpers being left open (pulled up to VCC). (Note: there is an error in Digilent’s reference manual which mistakenly inserts an extra ‘0’ into this address.)

I2C Pull-Up Resistors

Unlike most of Digilent’s Pmod boards, the I2C pull-up resistors shown in Figure 2 above are not included on the Pmod TMP2. The I2C bus will not operate correctly without them.

The user can solve this problem by wiring 2.2 kΩ resistors into the circuit as shown.

Port Descriptions

Table 1 describes the Temp Sensor Pmod Controller’s ports.

Table 1. Port Descriptions

Connections

This Pmod has an 8-pin connector. Table 2 provides the pinout for this connector. The Temp Sensor Pmod Controller’s ports need to be assigned to the FPGA pins that are routed to this connector as listed. The two rows of the J1 connector are tied together on the Pmod board, so only one side needs to be connected to the FPGA.

Table 2. Temp Sensor Pmod Pinout and Connections to Temp Sensor Pmod Controller

The Pmod also has 2 jumpers. JP1 and JP2 set the I2C address of the Pmod. See the Pmod I2C Address section above for details.

Reset

The reset_n input port must have a logic high for the Temperature Sensor Pmod Controller component to operate. A low logic level on this port asynchronously resets the component. During reset, the component aborts the current transaction with the Pmod and clears the temperature data output and the i2c_ack_err output. Once released from reset, the Temperature Sensor Pmod Controller restarts its operation. It reconfigures the temperature sensor and resumes collecting and outputting temperature data.

Conclusion

This Temperature Sensor ADT7420 Pmod Controller is a programmable logic component that interfaces to Digilent’s PmodTMP2 (Temperature Sensor ADT7420 Pmod). It handles all communication with this Pmod to configure the Pmod’s temperature sensor and provide a continual stream of updated temperature data on a parallel output.

Additional Information

ADT7420 datasheet.pdf (5.7 MB)

Related Topics

I2C Master (VHDL)

1 Like