Understanding the Modbus Registers Maps
I'm almost ready in understanding the required basics to start making my first program for the Neuron L503. So one more question regarding the (creation of) channels.
Group1A - "Digital inputs of Group 1" -> Offset "0000 digital inputs of Group 1"
"Digital inputs of Group 2" -> Offset "0064 digital inputs of Group 2"
So to make the link now with the "Modbus Registers Map": Is it the first column that refers to the address: "0 -> 0x00 OR 0000" for DI1 and "100 -> 0x64 OR 0064" for DI2?
What is the length if you add a ModbusChannel? Because it is set at 21 for "Group1A" but shouldn't it just be 1?
What is the difference between "Counter 1" and "Counter 1 Trigger" channels under the "ModbusTCPSlave I/O Mapping" tab because there is only a "Counter 1" under the "Modbus Slave Channel" tab.
Thank you for helping me out on this one.
I'll try to give answers to what I think your questions are.
Firstly an explanation of channels and register mapping.
When a Modbus Channel is configured in CODEYS the length specified is the number of registers to be read or written using a single modbus command. It is more efficient where possible to read multiple registers in one command, this is both runtime efficiency and efficiency of configuration. It is often more efficient to read larger blocks of registers even if you are only interested in a few of the registers. Having configured the channel to read or write the registers, you can then either map all of the registers in one go into an array somewhere in your application, or map just the selected registers that you are interested in.
All of the registers in a Channel are sent in one command. Each register can be mapped separately or all registers in a channel can be mapped as an array.
One the Neuron there registers are defined in groups, and each of the hardware modules on the Neuron has two groups of registers. The channel Group1A reads all 21 registers for Group1 starting at register address 0, these are then mapped into an array inside the Group1 function block. The function block uses the whole block of registers to determine that communications is good, and also to scale analog values etc.
Secondly to deal with the trigger
Most of the time it is preferable to transfer registers on a cyclic basis, however some actions cannot easily be handled on a cyclic basis, for example resetting the counter. On the Neuron you write a 32 bit reset value for the counter, if this was done periodically it would prevent the counter from counting. The solution to this is to use another VAR to trigger the channel to be sent by MODBUS.
CODESYS actually offers three different trigger modes for channels, cyclic (you can choose the rate), trigger (a BOOL value changing from False to True will cause the channel to be sent, or application (The application triggers the channel). Personally, although I have experimented with the application triggering writes, I prefer to use the rising edge trigger).
The image above shows where the channel called counter is configured to be sent on a trigger. If you then look in the mapping tab you can see how there is a trigger mapped to a boolean inside the Group1 function block. There are also two registers mapped to an array inside the Group1 function block that contains the value the counter is to be reset to.
I hope I have correctly understood your questions. If you have more questions please ask. If the questions are more generic to CODESYS rather than specific to the Neuron I will help, but you may get faster support on the CODESYS forums, there is a large helpful community there.
Thank you again for the extensive answer!! It is clear for me (atm ;) )