ProtoVoltaics RTD Shield with RS232 and RS485 Transceivers  Version 8
 All Classes Functions Variables Pages
ProtoVoltaics Multi-Channel RTD Arduino Shield with RS232 and RS485 Transceivers

Introduction

Thanks for taking a look at our shield! We value your feedback and contributions. Contact us at support@protovoltaics.com if you find any errors.

This Arduino shield has multiple channels to read Resistance Temperature Detectors as well as transceivers to communicate with RS232 and RS485 devices. The Arduino communicates with the shield over the I2C (Wire) pins, so the RS232 (3-wire RS232) and RS485 transceivers don't connect to the Arduino's serial ports. The shield can also connect to the Arduino's D2, D3, D4, and D5 pins to alert the Arduino of various conditions such as new data from the shield's RS232 or RS485 ports or if an RTD reading meets some criteria.

If you are looking for details on all of the commands you can give the RTD shield, click on the "Classes" link in the menubar at the top of the page. To dive straight in you can click here.

Quick Start

  1. Download and extract the interface library for communicating with the shield. Download link for Arduino RTD interface library.
  2. Install the library. Instructions for installing an Arduino library.
  3. Create a new Arduino sketch.
  4. Add the RTD library to the sketch: Sketch | Import Library... | PV_RTD_RS232_RS485_Shield
  5. Create a minimal program to read your RTDs: Download the code below
    #include <Wire.h>
    #include <PV_RTD_RS232_RS485_Shield.h>
    // Create an object to talk to the RTD shield.
    // 82 is the I2C (Wire) interface address.
    // 100.0 is the type of RTD sensor being used (100.0 for Pt-100)
    // (Replace the 100.0 below with 1000.0 if you are using a Pt-1000 RTD)
    PV_RTD_RS232_RS485 my_rtds( 82, 100.0 );
    void setup() {
    Serial.begin( 115200 );
    Serial.println( "Starting up..." );
    // This calls Wire1.begin() for Due and Wire.begin() for other Arduinos
    I2C_RTD_PORTNAME.begin();
    // This will put us in a "fresh" state at startup, though you probably
    // wouldn't want to do a factory reset every time you power up.
    my_rtds.Factory_Reset();
    // Next, we enable the channels which we want to read
    my_rtds.Disable_All_RTD_Channels();
    my_rtds.Enable_RTD_Channel( 3, 1 );
    // Now, the next three commands configure the shield to maximize stability
    // The following settings are particular to 3-wire Pt-100 RTDs. If you
    // are using different RTDs contact us for the best settings
    // (support@protovoltaics.com)
    // Slow the shield down to 20 samples-per-second. The shield automatically
    // takes 16 samples at this rate then stores the median value for reporting
    // to the Arduino. This also enables the 50Hz/60Hz rejection filters,
    // which are only enabled for speeds at or below 20 samples-per-second.
    // You can reduce this value to as low as 5, but you will have to wait
    // about 6.6 seconds for each new reading. The slower you go, the less
    // noise there will be in the measurements.
    my_rtds.Set_RTD_SPS( 20 );
    // Set the RTD drive current to 250uA. This is typically the best setting.
    // Higher settings will provide common-mode errors to the shield. Lower
    // values will be more susceptible to noise.
    my_rtds.Set_RTD_Idac( 3, 1, 0.000250 );
    // Set the programmable gain amplifier to 64. This will limit readings to
    // 89.1 deg C (192.4 deg F).
    // A PGA value of 32 will allow measurements up to 463.5 deg C (866.3 deg F)
    // but the noise rejection is not as good as it is at 64.
    // A PGA value of 16 will allow measurements up to the limit of the RTD
    // sensor but the noise rejection is not as good as it is at 64 or 32.
    my_rtds.Set_RTD_PGA( 3, 1, 64 );
    // A short delay so that the first reading can be taken. If you request
    // a reading before the shield has taken its first reading you will get a
    // bogus number. The shield also performs a self-calibration that we have
    // to allow to complete.
    // Set this delay to 10000 if using 5 samples-per-second above.
    delay( 3000 );
    }
    void loop() {
    // Read the temperature and display the results
    float t = my_rtds.Get_RTD_Temperature_degC( 3, 1 );
    Serial.print( "The three-wire RTD on channel 1 is reading " );
    Serial.print( t, 6 );
    Serial.println( " degrees Celsius" );
    // Add a delay to allow the shield to take a new measurement.
    // Set this delay to 6600 if using 5 samples-per-second
    delay( 1600 );
    }
  6. Set the jumpers on top of the shield.
    If you have any 2-wire RTDs then you should place a jumper on the header labeled "2W". If you do not have any 2-wire RTDs, then it's better to remove the jumper from the header labeled "2W". Remember, 2-wire RTDs can not give you an accurate temperature reading and you should expect to be off about +/- 1 degree Celsius for each inch of wire between a 2-wire RTD and the shield. There is no way to physically compensate for the resistance loss in the wires of a 2-wire RTD, so you should always use a 3-wire or 4-wire connection.
    The "LAST RTD PIN" should be set for the type of RTD being connected to the last screw terminal. If you are connecting a 3-wire RTD to channel 4 (that's 3-wire channel 4) on the shield put a jumper connecting the "3W" pin to the center pin on the "LAST RTD PIN" header. If you are connecting a 4-wire RTD to channel 3 (that's 4-wire channel 3) of the shield put a jumper connecting the "4W" pin to the center pin on the "LAST RTD PIN" header.
    If you want the shield to send the Arduino alerts when the RTD readings meet a criteria that you set, then add the jumpers desired on the "IRQ D2" through "IRQ D5" headers. If you are using those pins for other purposes just remove the jumpers.
  7. Connect your RTD sensors to the shield's screw terminals.
    For a 3-wire RTD, two of the wires will have very little (nearly 0) resistance between them and these should go in to the "-" terminals. The other wire should have more resistance (about 110-ohms for a Pt-100 RTD or 1100-ohms for a Pt-1000 RTD) and should go in to the "+" terminal. For a 4-wire RTD, you will have two groups of wires with very little (nearly 0) resistance between them. One group goes to the termials labeled "+" and the other group to the terminals labeled "-".
  8. Run your code.
  9. Throw your arms up in 'V' and chant "victorious".

Resistance Temperature Detectors Overview

RTDs have better linearity and accuracy compared to other temperature measurement technologies such as thermocouples. However RTDs are typically limited to measurements less than 600 degrees Celsius.

Changes in temperature cause a change the resistance of the RTD. The shield is actually just measuring the resistance on its terminals, so it's really just a very accurate ohm-meter. Since the temperature changes cause only slight changes in the sensor's resistance, very accurate measurements must be made.

Hardware Overview

The shield has a 12-pin screw terminal for connecting RTDs (or other resistance based sensors), a 3-pin terminal for RS232 communication, and a 2-pin terminal for RS485 communication. The RS232 and RS485 terminals are wired to transceivers that perform voltage level shifting for UARTs on a microcontroller that manages the shield. The RTD terminals are wired to a 24-bit analog-to-digital converter (ADC) which also provides excitation for the RTDs. A precision current source is used to excite the RTDs. The voltage across the RTD is then measured and the resistance is calculated based on the voltage and current values.

RTD Channels

The shield can connect to seven two-wire RTDs, four three-wire RTDs, three four-wire RTDs, or certain combinations of various RTDs. The "or" in the previous sentence is an exclusive-or: meaning you can't connect seven two-wire RTDs, "and" four three-wire RTDs, "and" three four-wire RTDs. If a channel is used to connect to a three-wire RTD then the pins used for that channel cannot be used to connect to a two-wire or four-wire RTD.

The RTD channels are labeled in numeric order starting from the RS232 port down to the RS485 port. Meaning channel 1 is the closest to the RS232 port, channel 2 is next, and so on. The last channel is channel 7 for the two-wire ports, channel 4 for the three-wire ports, and channel 3 for the four-wire ports.

RTD Connections

Two-Wire RTDs

Directly behind the screw-terminals for the RTDs on the shield is the labeling diagram for making two-wire connections. Two-wire RTDs have two wires. One wire must go into a numbered terminal, which are labeled 1 through 7. The other wire must go into a terminal labeled 'C'. The 'C' stands for "common". It doesn't matter which 'C' pin is used and a 'C' pin can be used to connect to more than one two-wire RTD. The RTD is not polarized, so either wire can go in the numbered terminal and either wire can go in the 'C' terminal.

If two-wire RTDs are used, the jumper terminal labeled "2W" must have a jumper installed on it.

If two-wire RTDs are used, then the pin labeled '7' can only be used for two-wire RTDs. You cannot use the pin labeled '7' for three-wire or four-wire RTDs when a jumper is installed in the jumper terminal labeled "2W".

Three-Wire RTDs

Three-wire RTDs have three wires, obviously. Two of the wires are connected together at the tip of the sensor. If you measure the resistance with an ohm-meter you will see zero or almost zero. The two wires that have nearly zero resistance go into the terminals labeled '-'. The other wire, which will have a measurable resistance much larger than zero (it depends on the RTD type, but 110 ohms or 1100 ohms are typical values), should go into the terminal labeled '+'.

If three-wire channel 4 is going to be used to measure a three-wire RTD then the jumper terminal labeled 'LAST RTD PIN' must have a jumper installed between the middle pin and the pin labeled '3W'.

Four-Wire RTDs

Four-wire RTDs are the most accurate type of RTDs. Two wires are connected to each side of the RTD element at the tip of the sensor. The wires in a pair will have zero or nearly zero resistance between them. One of the pairs gets installed in the terminals labeled '+' and the other pair gets installed in the terminals labeled '-'.

If four-wire channel 3 is going to be used to measure a four-wire RTD then the jumper terminal labeled 'LAST RTD PIN' must have a jumper installed between the middle pin and the pin labeled '4W'.

RTD Commands

The general process for reading a temperature measurement is the following:

  1. Include the appropriate header libraries
    #include <Wire.h>
    #include <PV_RTD_RS232_RS485_Shield.h>

  2. Create the PV_RTD_RS232_RS485 object
    // Use I2C address 82 for the shield.
    // Tell the shield we are using Pt-100 RTDs (by sending the 100.0).
    PV_RTD_RS232_RS485 my_rtds( 82, 100.0 );

  3. Initialize the Wire library by calling Wire library's begin() function
    I2C_RTD_PORTNAME.begin();
    The above (I2C_RTD_PORTNAME.begin()) will work for all Arduinos. If you have an Arduino Due you could call Wire1.begin() instead. If you have any other type of Arduino you could call Wire.begin() instead. I2C_RTD_PORTNAME is defined in the PV_RTD_RS232_RS485_Shield.h file.

  4. Enable the desired RTD channel via PV_RTD_RS232_RS485::Enable_RTD_Channel()
    my_rtds.Enable_RTD_Channel( 3, 1 ); // Tell the shield a 3-wire RTD is on channel 1.

  5. Read the temperature via PV_RTD_RS232_RS485::Get_RTD_Temperature_degC() or similar function
    float the_temperature = my_rtds.Get_RTD_Temperature_degC();

RTD Repeatability

Since the shield is really just a precision ohmmeter, the performance of the shield can be verified by connecting a precision resistor of known accuracy to the shield and taking multiple readings. The factors that will impact the quality of your measurements the most are the speed ( PV_RTD_RS232_RS485::Set_RTD_SPS() ), gain ( PV_RTD_RS232_RS485::Set_RTD_PGA() ), and drive current ( PV_RTD_RS232_RS485::Set_RTD_Idac() ) settings. The graph below shows how the speed settings impacts readings.

sps_comparison.png

As you can see slower speeds provide less variation when the input is fixed. However, at a speed of 5 samples-per-second the shield only updates the temperature measurement about once every 6.6 seconds. The 6.6 second time is due to the speed setting, time for internal calibration, and sampling of multiple readings done internally by the shield.

The settings for PGA and Idac depend on the maximum temperature you need to measure and the type of sensor you are using. Our team can provide you with these values based on your application.

The following graph shows a histogram of readings made a precision 100 ohm resistor using a four-wire connection. Typical Pt100 RTDs have a resistance of 100 ohms at 0 degrees Celsius.

four_wire_rtd_v8.gif

The graph above gives an indication of how repeatable the shield is. The spread between the maximum and minimum reading for this test was 0.007675 ohms, which corresponds to 0.020 degrees Celsius or 0.035 degrees Fahrenheit. This data was collected at 160 samples-per-second.

The following graph shows histogram data for a fixed resistor connected in a 3-wire configuration: a jumper wire connected between the two "-" terminals.

three_wire_rtd_v8.gif

This time the spread between minimum and maximum readings was 0.00975 ohms, 0.025 degrees Celsius, or 0.045 degrees Fahrenheit. This data was collected at 160 samples-per-second.

A two-wire connection is almost never used. This is because the two-wire connection has no compensation for wire length, which will have a dramatic impact on measured values. Do not use two-wire RTDs unless you are an expert.

two_wire_rtd_v8.gif

This time the spread between minimum and maximum readings was 0.007531 ohms, 0.019 degrees Celsius, or 0.035 degrees Fahrenheit. The results demonstrate good repeatability, but the accuracy of the measurements will decrease with every millimeter of distance from the shield's screw terminals to the active part of the RTD sensor. This data was collected at 160 samples-per-second.

RTD Measurement Range

The maximum measurable resistance value is controlled by the programmable gain amplifier (PGA), which is controlled with the PV_RTD_RS232_RS485::Set_RTD_PGA() method. Using a larger gain gives better resolution but reduces the maximum measurable resistance, which reduces the maximum measurable temperature. Lower gain values reduce the resolution in the readings, but allow larger resistances to be measured.

For version 1 of the shield (that is for shield's with a date stamp prior to "2-MAY-2014") a gain of 1 will allow resistances up to 833 ohms to be measured for two-wire and four-wire RTDs and up to 1666 ohms for three-wire RTDs. As the gain is doubled, the maximum measurable resistance is cut in half. The maximum gain of 128 allows readings up to 6.5078125 ohms to be made for two-wire and four-wire RTDs and up to 13.015625 ohms for three-wire RTDs.

For version 2 of the shield (that is for shield's with a date stamp of "2-MAY-2014" and after) a gain of 1 will allow resistance up to 4300 ohms to be measured for two-wire and four-wire RTDs and up to 8600 ohms for three-wire RTDs. As the gain is doubled, the maximum measurable resistance is cut in half. The maximum gain of 128 allows readings up to 33.59375 ohms to be made for two-wire and four-wire RTDs and up to 67.1875 ohms for three-wire RTDs.

The factory reset value for the PGA is 1 for version 2 of the shield. This means that you can measure the full range for Pt-100 and Pt-1000 RTDs without having to make any changes. You may want to change the PGA value to increase your temperature resolution if you will not need to take measurements across the entire temperature range of your sensor. See the details in the description for PV_RTD_RS232_RS485::Set_RTD_PGA().

I2C Communication

Communication between the Arduino and the shield takes place over the I2C pins. The software provided with the shield performs the necessary communication operations, so most users won't need to know about or care how this communication occurs at the low level. For those who are interested, the source code is available to see how this communication is used to control the shield. The registers are enumerated in the PV_RTD_RS232_RS485_Memory_Map.h file if low-level communication is needed.

I2C Address

Solder pads on the top of the shield are used to set the I2C address of the shield. The default value is 82. The only reason you might want to change this is because you need to use multiple RTD shields or if you have another I2C device using address 82. You will have to cut the gold line connecting the center pad before adding a solder jumper to connect it to the other pad.

I2C Pull Ups

The shield has two pull up resistors for the I2C bus. These are 10 kilo-ohm resistors. To disable the pull-ups the solder jumper pads on the top of the shield can be removed with solder wick. The I2C pull up pads are under the pads for setting the I2C address. They are labeled "I2C PU". The pin next to the 'D' is connected to SDA and the pin next to the 'C' is connected to SCL.

Older Arduino Unos

Older Arduino Unos that do not conform to the Arduino R3 specification have their I2C pins in a different location. To enable the shield to communicate to those pins a solder jumper must be installed on the solder jumper ports labeled "UNO SDA" and "UNO SCL"

RS232 Interface

The RS232 screw terminal exposes pins for connecting the Tx (transmit), Rx (receive), and GND (ground) lines. No provision is included for connecting other RS232 control signals such as CTS or RTS. The pins are also labeled for connecting to DB9 connectors: Tx on DB9 pin 2, Tx on DB9 pin 3, and GND on DB9 pin 5.

Data can be written to the shield's RS232 port with Arduino's print() and println() functions if configured. Configuration is done by calling the PV_RTD_RS232_RS485::Connect_Print_To() function.

RS485 Interface

The RS485 screw terminal exposes pins for connecting the A and B lines to an RS485 network. The shield has a 120 ohm termination resistor installed between the A and B terminals. Different hardware will define ports A and B differently. If communication is not working properly, often it is useful to try reversing the pins to see if this solves the problem. Refer to the transceiver's datasheet if necessary. Transceivers from Texas Instruments and Maxim are typically used.

Data can be written to the shield's RS485 port with Arduino's print() and println() functions if configured. Configuration is done by calling the PV_RTD_RS232_RS485::Connect_Print_To() function.

Alarms

The shield has jumpers to connect to pins D2, D3, D4, and D5 on the Arduino. When the jumpers are installed the shield can signal the Arduino when certain events occur. For example, the shield can send an alert when new data arrives on the RS232 port, or on the RS485 port, or when RTD data matches a given criteria.

See PV_RTD_RS232_RS485::Set_Alarm_Source(), PV_RTD_RS232_RS485::Configure_RTD_Alarm(), and PV_RTD_RS232_RS485::Enable_Alarm().

Shield Microcontroller

The shield has a basic microcontroller to perform the functions of the shield. Having a separate microcontroller frees up the Arduino's processor for other tasks.

Microcontroller Memory

Non-volatile EEPROM memory is used on the microcontroller to store all static variables. This means when the shield is powered off and then powered on the shield will go back to processing the same RTD channels and using the same alert configuration that was being used before the power was turned off.

Dynamic variables, such as the last RTD measurements, RS232 buffers, RS485 buffers, and internal ADC registers are not stored in EEPROM and will be erased when the power is turned off. The variables that are retained in non-volatile EEPROM are those with addresses below FIRST_RAM_REGISTER in PV_RTD_RS232_RS485_Memory_Map.h

Microcontroller Firmware

The shield's microcontroller has an ICSP port on the top of the shield. A Microchip programmer, such as the PICkit3 is needed to program the flash memory on the microcontroller. The firmware on the shield's microcontroller cannot be updated directly from the Arduino at this point in time.