Home of the ICON - Instrumentation and Control Over Networks Last updated April 1, 2007

 
 
     Main
     ICONIO Board
     1-Wire I/O Devices
 
 

     ICONIO Card Installation
     ICONIO Programming

     Basic 1-Wire Installation

     2 Chan Counter (OWCTR2)

     2 Chan A-D (OWAD2)

     4 Chan A-D (OWAD4)

     1 Chan Pot Out (OWPOT1)

     Dry Contact (OWRELAY4)

     Connections (OWCONNECT)

     Temperature (OWT)

     Relative Humidty (OWTRH)

     Light (OWL)

     Weather Station (OWWEATHER) 

 

 
     
     Phone: (406) 599-1053
 

Programming 1-Wire I/O

Introduction
The 1-wire I/O is programmed within the ICON program as follows:

  • OWconfig instructions are used to create the configuration for each ICONIO card.
  • Modbus instructions are used to send these configurations to each ICONIO card. (After the ICONIO cards are configured they automatically scan their respective 1-wire input devices and put results in their Modbus input registers and send values in their Modbus output registers to their 1-wire output control devices.)
  • Modbus instructions are used to read the ICONIO Modbus registers which contain the results of 1-wire sensors and inputs.
  • Modbus instructions write control values to Modbus output registers on the ICONIO cards. These values are then sent to 1-wire control devices automatically by the ICONIO board.
As Modbus is used for ICON, there is just one data type called a register which is a 16 bit unsigned integer. Therefore all data values are in the range of 0 to 65535. The ICON further defines the value 65535 as a value indicating that operation of that device has failed (this is not a specification of Modbus). The ICON has three types of registers, the configuration registers, the data input registers and the data output registers.

Configuring ICON 1-Wire I/O
The first step is to setup the Modbus configuration registers for the 1-wire devices you are connecting. This requires two ICON instructions, the "OWconfig" instruction sets variable values and the "Modbus" instruction sends these values to the proper ICONIO board configuration registers. Because the ICONIO can receive a maximum of 16, 1-wire device's worth of configuration information at one time, it may be necessary to send all the configuration information in up to four separate Modbus instructions. First configure one OWconfig instruction for each ICONIO board.

  1. Select an "OWconfig" instruction. Set the size to the number of separate 1-wire devices (include all devices on all four 1-wire busses).
  2. Set the "Config" variable to some name such as "ow_config1". You can use "ow_config2" for the second OW_config instruction if you have more than one ICONIO board.
  3. Go to table parameter configuration.
  4. Enter a description for each 1-wire device so you don't forget what's what.
  5. On each 1-wire device is a tag which has the Type, ID Hi and ID Low. Enter these three values into the next three row table entries.  (Note, if you have only one device on a bus you may set ID Hi and ID low to 0.)
  6. Use the drop down list to select which 1-wire bus you connected the device to.
  7. For "Mode", select "Separate power". (In the case of part number OWT, type 0, you must select "1-wire powered".)
  8. Normally pick 15 for "Read Delay uS". But if you have a very long cable (more than 300 feet) you will need to try larger numbers to account for the pulse delay on the cable.
  9. Select 5 for number of "Retries". In very bad electrical noise environments or on very long cables you might have to select 10 or even 15 retries. Set retries to 0 when selecting a "Read Delay uS" value. Then try various values of "Read Delay uS" to minimize the number of errors. When done set "Retries" back to 5 (or higher).
Now insert 1-4  Modbus instructions for each OWconfig instruction. You need 1 modbus instruction if you have 1 to 15 devices, 2 if you have 16 to 31, 3 if you have 32 to 47 and 4 if you have 48 to 64. Configure each Modbus instruction as follows:
  1. You may leave the "Enable" and "Status" variables "Null".
  2. Set the "I/O transfer" variable to the name entered for the "Config" variable when you configured the "OWconfig" instruction above. The Modbus instruction will transfer the values set in the "OWconfig" instruction to the Modbus configuration registers on the ICON.
  3. Select "Com type" as "Serial 2"
  4. The "IP address" and "Port number" are not used so you don't need to change them.
  5. Set the "Unit address" to 255 if you are configuring the first ICON (ICON-LOCAL). Otherwise select the address you set in the switches for the ICON-REMOTE. Generally this will be 1 for the first ICON-REMOTE, 2 for the second, etc.
  6. Set the "Register address" to 4097. This is the starting address for the configuration registers.
  7. Select "Set multiple registers (16)" from the "Command" drop down list.
  8. Set "Timeout (10mS steps)" to 100. This sets a one second timeout.
  9. Set "Retries" to 3.
  10. Do not change any of the table parameters. Leave all the A values at 1 and the B values at 0. Set the length of the table to 4 times the number of entries plus 1. If you have 15 entries set the table length to 4 X 15 + 1 = 61. Each device requires four configuration numbers. The last entry is automatically set by the OWconfig instruction and is set to 65535 which tells the ICON the device configuration list is terminated.
If you have more than 15 1-wire devices, configure as follows. For 16-31 1-wire devices Configure the first Modbus instruction as described above but set the table length to 64. Configure the second Modbus instruction to have the "I/O transfer variable set to ow_config1[64], set the "Register address" to 4161 and set the table length to (Total-16) X 4 + 1.For 32 to 47 devices, set as described in the previous example but make the table length of the second Modbus instruction also be 64. Configure the third Modbus instruction to have the "I/O transfer variable set to ow_config1[128], set the "Register address" to 4225 and set the table length to (Total-32) X 4 + 1.For 38 to 63 devices, set as described in the previous example but make the table length of the third Modbus instruction also be 64. Configure the fourth Modbus instruction to have the "I/O transfer variable set to ow_config1[192], set the "Register address" to 4289 and set the table length to (Total-48) X 4 + 1. If you have exactly 64 devices, set all four table lengths to 64. For this case only, a terminator is not needed. You may not have more than 64 devices.

Read 1-wire Inputs
You may configure your I/O devices on each ICONIO board in any order. However, all the inputs will be grouped together into consecutive registers and all the outputs will be grouped together into a different set of consecutive registers. You may use a maximum of 127 registers for both inputs and outputs. The first input register is reserved for a loop pass counter. Every time all the 1-wire sensors have been read and any outputs updated, the value in the first register is incremented (range is 0-255). The following table shows how many input registers are allocated for each input device:
 
 
Part Number Type Number of Input Modbus Registers
OWT 0 or 5 1
OWTRH 3 4
OWAD2 3 4
OWCTR2 2 2
OWAD4 1 or 4 4
OWDI4 1 4

To read your ICON Modbus register values into your ICON program, configure a Modbus instruction as follows:

  1. You may leave the "Enable" variable "Null".
  2. Set the "Status" variable to a name such as mod_stat1". You will need this value as input to the "Enable" variable of the "Counter" instruction. If the value is greater than 1 the Counter instruction interprets this as a Modbus read failure and won't use erroneous data. You can also use the value on this variable to set status indicating the validity of the other readings. If the value is 1 the input readings are valid (the Modbus instruction correctly read the values from the ICONIO board). Any other values indicate a failure to properly read.
  3. Set the "I/O transfer" variable to the name of an input data array. Choose a name such as mod_data_input1. The Modbus instruction will transfer the Modbus register values on the ICONIO card to this ICON program variable array.
  4. Select "Com type" as "Serial 2"
  5. The "IP address" and "Port number" are not used so you don't need to change them.
  6. Set the "Unit address" as described above.
  7. Set the "Register address" to 1. This is the starting address for the input registers.
  8. Select "Read input registers (4)" from the "Command" drop down list.
  9. Set "Timeout (10mS steps)" to 100.
  10. Set "Retries" to 3.
  11. Set your table length to the number of input registers. The first input register is a loop pass counter. Every time a complete pass is made reading all inputs and setting all outputs, the pass counter increments. This is followed by all the input values. If for example you had 2 OWTs, an OWCTR and an OWAD you could read 1 + (2 X 1) + 2 + 4 = 9 input register values. The first register contains the pass counter value, the second and third registers contain the two temperature readings, the fourth and fifth registers contain the event counts for the two counters and registers six, seven, eight and nine contain the four A-d readings.
  12. You may set your A and B table coefficients to values needed to convert your raw readings to engineering units. It uses the equation converted=Modbus_register_value X A + B.  Leaving A at 1 and B at 0 will pass the raw Modbus register values to the outputs. You must not convert data from the OWCTR counter unit if you will be feeding this data into a "Counter" instruction. (It expects counts from 0 to 65534 with 65535 indicating a sensor failure.)
  13. Note, you can read the values you set in the output registers by using addresses starting at 257. You can read your configuration parameters by using addresses starting at 4097.
It is possible to have over 64 read registers but the ICONIO card supports a maximum of 64 register reads with one instruction. If you have more than 64 registers you must do this with two Modbus reads. The first is set for a table size of 64 and a starting address of 1. The second Modbus read has a table size of (Total_number_of_input_regs-64) and a starting address of 65.

Write 1-Wire Outputs
You may configure your I/O devices on each ICONIO board in any order. However, all the inputs will be grouped together into consecutive registers and all the outputs will be grouped together into a different set of consecutive registers. You may use a maximum of 127 for both inputs and outputs. The following table shows how many output registers are allocated for each output device:
 
 
Part Number Type Number of Output Modbus Registers
OWDO4 128 4
OWRELAY4 128 4
OWPOT1 129 1
To write ICON program values to your ICON Modbus registers for output control, configure a Modbus instruction as follows:

  1. You may leave the "Enable" and "Status" variables "Null".
  2. Set the "I/O transfer" variable to the name of your control value data array. Choose a name such as mod_data_output1. The Modbus instruction will transfer the values from this ICON variable array to the Modbus registers on the ICONIO card. These values will then be sent on to the 1-wire devices.
  3. Select "Com type" as "Serial 2"
  4. The "IP address" and "Port number" are not used so you don't need t change them.
  5. Set the "Unit address" as described above.
  6. Set the "Register address" to 1. This is the starting address for the output registers. Don't worry, these are different registers from the input registers. The program distinguishes by what you select for "Command".
  7. Select "Set multiple registers (16)" from the "Command" drop down list.
  8. Set "Timeout (10mS steps)" to 100.
  9. Set "Retries" to 3.
  10. Set your table length to the number of output registers configured on the ICONIO card.
It is possible to have over 64 write registers but the ICONIO card supports a maximum of 64 register writes with one instruction. If you have more than 64 registers you must do this with two Modbus writes. The first is set for a table size of 64 and a starting address of 1. The second Modbus write has a table size of (Number_of_output_regs-64) and a starting address of 65.

Copyright © 1998-2007