northwest_trail
Member
Hello, I'm brand new to Modbus. I've been trying to get the syntax correct for reading/writing data from a M340 over Modbus TCP (from the processor) and am amazed by the lack of resources.
I'm ultimately trying to send commands to a slave device that allows the reading of process values and writing of parameters via Modbus.
First of all, should I be using READ_VAR and WRITE_VAR? That's what I'm trying to work with. I found an example in the help file that seemed to specify the below syntax:
Addr_Array := ADDM('Ethernet_1{192.168.1.100}');
WRITE_VAR (
ADR := Addr_Array,
OBJ := '%MW',
NUM := 1,
NB := 2,
EMIS := Value_Array,
GEST := %MW200:4
);
Where Ethernet_1 is the Ethernet network interface for the M340, connected to a device with address 192.168.1.100. '%MW' is the type of object (internal word), 1 is the address of the first object to write, 2 is the number of consecutive objects to write, Value_Array is an integer array of size 2, and %MW200:4 should be an INT table of size 4.
First off, is this syntax correct? I haven't yet been able to get it to work.
Second off, I get errors:
{Main : [MAST]} : (l: 5, c: 5) E1208 usage of dynamic arrays is disabled
{Main : [MAST]} : (l: 9, c: 5) E1208 usage of dynamic arrays is disabled
{Main : [MAST]} : (l: 10, c: 5) E1208 usage of dynamic arrays is disabled
{Main : [MAST]} : (l: 10, c: 20) E1200 usage of directly represented array variables is disabled
I know I can get rid of these errors by changing the preferences.. but what gives? What am I supposed to be doing to address things correctly if neither of these formats works? Any information about this would be very much appreciated.
Thank you in advance.
I'm ultimately trying to send commands to a slave device that allows the reading of process values and writing of parameters via Modbus.
First of all, should I be using READ_VAR and WRITE_VAR? That's what I'm trying to work with. I found an example in the help file that seemed to specify the below syntax:
Addr_Array := ADDM('Ethernet_1{192.168.1.100}');
WRITE_VAR (
ADR := Addr_Array,
OBJ := '%MW',
NUM := 1,
NB := 2,
EMIS := Value_Array,
GEST := %MW200:4
);
Where Ethernet_1 is the Ethernet network interface for the M340, connected to a device with address 192.168.1.100. '%MW' is the type of object (internal word), 1 is the address of the first object to write, 2 is the number of consecutive objects to write, Value_Array is an integer array of size 2, and %MW200:4 should be an INT table of size 4.
First off, is this syntax correct? I haven't yet been able to get it to work.
Second off, I get errors:
{Main : [MAST]} : (l: 5, c: 5) E1208 usage of dynamic arrays is disabled
{Main : [MAST]} : (l: 9, c: 5) E1208 usage of dynamic arrays is disabled
{Main : [MAST]} : (l: 10, c: 5) E1208 usage of dynamic arrays is disabled
{Main : [MAST]} : (l: 10, c: 20) E1200 usage of directly represented array variables is disabled
I know I can get rid of these errors by changing the preferences.. but what gives? What am I supposed to be doing to address things correctly if neither of these formats works? Any information about this would be very much appreciated.
Thank you in advance.