800M AC500 Modbus communication
I have a question on how to read and write bits when using modbus communication between a 800M system (master) and a AC500 system (slave).
The modbus communication is setup and it's working fine. I can read/write integers and single bits between the systems. But I can't figure out how to read/write multiple bits.
In my application I need to be able to read and write 200 bits each. And to this one by one is not an option. I have tought about using the type WORD and then using the WORD on a bit-level. But I havn't got it to work in the 800M. It seems that the 800M only reads/writes integers.
I suspect that my problem is that I don't know how to declare addresses and/or variables correct. I attach the modbus setup of the systems.
Please advice on how to do this.
Voted best answer
You may be need to read %MW0.20 from AC800M as a word, because it is defined in AC500 as a word. For that I'm quite sure.
For 40 bits this have to be 3 consecuent words (%MW0.20; 21 and 22), not completely occupied.
Then you have to un-pack the words in AC800M to bits. Please have in mind Big or Little Endians in AC500 for this un-packing - see for unpacking there:
A. To read words:
In AC800M Start address '%MW10#0' reads MW0.0 from AC500
You also have a possibility to read bit by bit (not only words):
B. To read bits:
In AC800M Start address '%IX10#0' reads MX0.0.0 in AC500
In AC800M Start address '%IX10#1000' reads MX0.125.0 in AC500 (multiple byte x8)
In AC800M Start address '%IX10#2000' reads MX0.250.0 in AC500
Thanks for the fast replies. They are very helpful. And you have put me in the right direction to solving my problem.
I have one more question that I hope you can answer.
I have chosen to group my bits in an ARRAY. This gives my the possibility to transfer as many bits I like (max is 1536, much more than the 200 I need) using only one MBTCPRead or MBTCPWrite.
In the 800M system I have an ARRAY connected to "Rd"-In/Output. And in my AC500 system I have declared 40 testvariables like this:
TCP_Bool0 AT %MX0.0.0: BOOL;
TCP_Bool1 AT %MX0.0.1: BOOL;
TCP_Bool39 AT %MX0.4.7: BOOL;
And this works fine. The 800M system reads these variables from the AC500 system without problem.
I would like to have the variables declared the same way in the AC500. But when I try this I have to declare my ARRAY variable as:
TCP_Read AT %MW0.20: ARRAY[0..39] OF BOOL;
BUT when I do this the 800M system has a problem reading. I don't know if I address the AC500 system wrong (%IX160 on "Startaddr" input) or what.
Hope you can help me with this...