|
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.
- Select an "OWconfig" instruction.
Set the size to the number of separate 1-wire devices (include
all devices on all four 1-wire busses).
- 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.
- Go to table parameter configuration.
- Enter a description for each
1-wire device so you don't forget what's what.
- 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.)
- Use the drop down list to
select which 1-wire bus you connected the device to.
- For "Mode", select "Separate
power". (In the case of part number OWT, type 0, you must
select "1-wire powered".)
- 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.
- 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:
- You may leave the "Enable"
and "Status" variables "Null".
- 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.
- Select "Com type" as "Serial
2"
- The "IP address" and "Port
number" are not used so you don't need to change them.
- 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.
- Set the "Register address"
to 4097. This is the starting address for the configuration
registers.
- Select "Set multiple registers
(16)" from the "Command" drop down list.
- Set "Timeout (10mS steps)"
to 100. This sets a one second timeout.
- Set "Retries" to 3.
- 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:
To read your ICON Modbus register
values into your ICON program, configure a Modbus instruction
as follows:
- You may leave the "Enable"
variable "Null".
- 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.
- 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.
- Select "Com type" as "Serial
2"
- The "IP address" and "Port
number" are not used so you don't need to change them.
- Set the "Unit address" as
described above.
- Set the "Register address"
to 1. This is the starting address for the input registers.
- Select "Read input registers
(4)" from the "Command" drop down list.
- Set "Timeout (10mS steps)"
to 100.
- Set "Retries" to 3.
- 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.
- 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.)
- 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:
To write ICON program values to
your ICON Modbus registers for output control, configure a Modbus
instruction as follows:
- You may leave the "Enable"
and "Status" variables "Null".
- 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.
- Select "Com type" as "Serial
2"
- The "IP address" and "Port
number" are not used so you don't need t change them.
- Set the "Unit address" as
described above.
- 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".
- Select "Set multiple registers
(16)" from the "Command" drop down list.
- Set "Timeout (10mS steps)"
to 100.
- Set "Retries" to 3.
- 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. |