DT80 Programming Exercises by hcj

VIEWS: 93 PAGES: 11

									DT80 Range Modbus Programming Exercises 1. DT80 Simple Modbus communications.
1.1. Programming the logger to measure temperature and resistance and view the data on Modbus using the dataTaker default Modbus.
1.1.1. Objective. Configure a DT80 for simple Modbus communications 1.1.2. Items required. Qty Item DT80 1 1 Pot 1 Thermocouple 1 USB to RS232 serial converter DT80 RS232 cable 1 1 Computer with Modbus Poll installed. 1.1.3. Wiring.

In this example we will be using DeLogger 4 connected to the USB Slave and will be monitoring the Modbus communications via the Host serial port. Connect the USB cable between the DT80 and Computer. Connect to the Host serial port with the RS232 cable and serial port. 1.1.4. Prerequisites. Completed day 1 and day 2 of workshop. 1.1.5. dataTaker Code. Profile Initialization
PROFILE"MODBUS_SERVER" "HOST_ADDRESS"="1" SINGLEPUSH

code Page 1
DT80 Modbus Example-Day3-0

BEGIN"ajob" RA1S 1+TK(=1cv) 2R(4W,=2cv) LOGON END

1.1.6. DeLogger 4 Procedure. 1. 2. 3. 4. Open DeLogger 4 and create a new project called Modbus Create a connection named Modbus and connect to the DT80 via a USB connection Open a the text window and connect to the DT80 In the send window enter the command

PROFILE"MODBUS_SERVER","HOST_ADDRESS"="1"

Note: DeLogger 4 will not display any text from the DT80

5. Reset the DT80 by clicking on “dataTaker” and select “Reset” from the drop down menu.

6. Check “Firm RESET” and click OK. This will cause the DT80 to perform a reset and load the new profile setting.

1. Create a DT80 program to read a thermocouple on analog input 1 and a Pot on analog input 2. o Assign the Thermocouple value to 1CV Page 2
DT80 Modbus Example-Day3-0

o Assign the Pot to 2CV 7. Send the program to the DT80 8. To confirm the new profile setting has loaded from the send window send the command
PROFILE"MODBUS_SERVER"

9. Open Modbus Poll program 10. Select “Connection” then click on “Connect”

11. In the connection dialog box select the following settings; Connection = Serial Port. Mode = RTU. Port number is the RS232 serial port number of the USB to serial converter. Baud rate = 19200. Then click OK.

12. Click on “Display” and check “PLC Addresses (Base 1)”

This ensures the register addresses start from number

Page 3
DT80 Modbus Example-Day3-0

13. Change the value of the samples values and observe the returned values for the thermocouple and potentiometer.

DT80 Turn in on an LED via Modbus.
1.2. Writing to the Modbus Coil data type to turn an LED on and off
1.2.1. Objective. In this example we will be using Modbus Poll software to turn an LED on and off, using the Modbus Coil instruction 1.2.2. Items required. Qty Item DT80 1 1 LED (Current limited) 1 USB to RS232 serial converter DT80 RS232 cable 1 Computer with Modbus poll software installed. 1 1.2.3. Wiring.

The RED wire of the LED is connected to the second from left terminal of the battery connector and the Black wire to digital input 1. 1.2.4. Prerequisites. Completed exercise 1.1 of Modbus worked examples. 1.2.5. dataTaker Code.
No dataTaker programming is required

Page 4
DT80 Modbus Example-Day3-0

1.2.6. DeLogger 4 Procedure. 1. Open Modbus Poll program 2. Select “Connection” then click on “Connect”

3. In the connection dialog box select the following settings; Connection = Serial Port. Mode = RTU. Port number is the RS232 serial port number of the USB to serial converter. Baud rate = 19200. Then click OK.

4. Click on “Display” and check “PLC Addresses (Base 1)”

This ensures the register addresses start from number one (1). When using protocol address the numbering starts from zero (0)

Page 5
DT80 Modbus Example-Day3-0

5. Click on “Functions” then click on ”05: Write single coil…”

6. To turn the LED ON Set the slave ID to 1 (The DT80 Modbus address) The Address to 8001 (The Modbus address to write to digital output 1) Set the value to OFF (When the digital is off the input is connected to ground and so current can flow turning the LED ON) Check 05:Write single coil Then click on send. 7. To turn the LED off set the Value to ON and click send.

2. DT80 Simple Modbus communications.
2.1. Demonstrate using non-default Modbus data types.
2.1.1. Objective. Modify the program from exercise 1 to use a signed integer with 1 decimal place for the temperature and 1 long unsigned integer and two decimal places for the resistance. 2.1.2. Items required. Qty Item DT80 Range 1 1 Pot Page 6
DT80 Modbus Example-Day3-0

1 1 1 1 2.1.3. Wiring.

Thermocouple USB to RS232 serial converter DT80 RS232 cable Computer with Modbus Poll installed.

In this example we will be using DeLogger 4 connected to the USB Slave and will be monitoring the Modbus communications via the Host serial port. Connect the USB cable between the DT80 and Computer. Connect to the Host serial port with the RS232 cable and serial port. 2.1.4. Prerequisites. Exercise 1 above. 2.1.5. dataTaker Code. datataker code
BEGIN 1..10CV=0 SETMODBUS 1CV MBI 10 SETMODBUS 3CV MBl 100 'schedule definition RA("B:",ALARMS:OV:100KB,DATA:OV:1MB)1S LOGONA GA 1TK("Temp",=1CV) 2R(4W,"Resist",=3CV) END

2.1.6. DeLogger 4 Procedure. 1. Open the previous project called Modbus 2. Connect to the DT80 Range with the connection previously created. 3. Open a the text window and connect to the DT80

Page 7
DT80 Modbus Example-Day3-0

4. Create a DT80 program to read a thermocouple on analog input 1 and a Pot on analog input 2. o Assign the Thermocouple value to 1CV o Assign the Pot to 3CV 5. Change to the Immediate schedule 6. From the “Signal” column select the “User” channel type

7. Click on … under the Wiring column to open the User dialog box 8. Enter the following dataTaker commands 1..10CV=0 SETMODBUS 1CV MBI 10 SETMODBUS 3CV MBl 100 The line 1..10CV=0 sets the first 10 channel variable to zero. SETMODBUS 1CV MBI 10 sets 1CV as a signed 16 bit integer (MBI) with 1 decimal place (10). SETMODBUS 3CV MBU 100 sets 3 CV as an unsigned 16 bit integer (MBU) with 2 decimal places (100). Note: There is no syntax checking so be careful the commands are correct and there is an carriage return at the end of each line.

Page 8
DT80 Modbus Example-Day3-0

9. Click “Ok “when finished.

14. Send the program to the DT80 10. Open Modbus Poll program 11. Select “Connection” then click on “Connect”

12. In the connection dialog box select the following settings; Connection = Serial Port. Mode = RTU. Port number is the RS232 serial port number of the USB to serial converter. Baud rate = 19200. Then click OK.

13. Click on “Display” and check “PLC Addresses (Base 1)”

This ensures the register addresses start from number

Page 9
DT80 Modbus Example-Day3-0

14. Check that the display is set to Signed

15. Hold the thermocouple so the temperature changes. (Line 1) Note; A Modbus slave does not transmit the decimal place but the Modbus software add it latter. If the pot is changed you will see the value go up to 32,767 then change to a negative number. This is because we are reading the value as a signed number when it is an unsigned value. 16. Change the Display to show unsigned numbers.

Page 10
DT80 Modbus Example-Day3-0

17. Change the position of the pot and observe the reading.

Page 11
DT80 Modbus Example-Day3-0


								
To top