[HELP] Unity Pro - SEND_REQ

другие контроллеры
RamCUP2000
Posts: 6
Joined: Fri Oct 07, 2011 7:46 am

[HELP] Unity Pro - SEND_REQ

Post by RamCUP2000 »

Does anyone have experience with function SEND_REQ?
I am trying read modbus 3xxxx registers via 04 function.
But response data are incorrect :(

Code: Select all

%MW10 := 16#0004; (* corresponds to the read function of n input words (byte 0 = 16#04, byte 1 = 16#00) *)
%MW11  := 16#0296; (* corresponds to the identification of the Modbus function *)
%MW12 := 0; (* reserved *)
%MW13 := 16#0100; (* address of the first word to read (1) *)
%MW14 := 16#1400; (* number of words to read (20) *)
%MW103  :=10; (* length of the data to be transmitted in bytes *)
SEND_REQ(ADDR('0.0.1.x'),16#9F,%MW10:10,%MW100:4,%MW50:30);
help say: "use ROR1_ARB function for response data..." but is still incorrect

(tyou)
SE_support
Posts: 101
Joined: Thu Aug 29, 2013 4:11 pm

Re: [HELP] Unity Pro - SEND_REQ

Post by SE_support »

Hello RamCUP2000,

why not using READ_VAR to read 3xxx registers? It's much easier!
RamCUP2000
Posts: 6
Joined: Fri Oct 07, 2011 7:46 am

Re: [HELP] Unity Pro - SEND_REQ

Post by RamCUP2000 »

Thank you SE_support

I know function READ_VAR...
it is using for objects '%MW' (4xxxx) or '%M' (0xxxx)
on object type '%IW' (3xxxx) it returns nothing

Code: Select all

READ_VAR(ADDR('0.0.1.x'), '%IW', 0, 10, %MW100:4, %MW50:10);
SE_support
Posts: 101
Joined: Thu Aug 29, 2013 4:11 pm

Re: [HELP] Unity Pro - SEND_REQ

Post by SE_support »

RamCUP2000 wrote:Thank you SE_support

I know function READ_VAR...
it is using for objects '%MW' (4xxxx) or '%M' (0xxxx)
on object type '%IW' (3xxxx) it returns nothing

Code: Select all

READ_VAR(ADDR('0.0.1.x'), '%IW', 0, 10, %MW100:4, %MW50:10);
May be the address %IW0 doesn't exists, normally it starts by %IW1.
Just try to read another range or only 2 values - not 10.

If it doesn't help, use wireshark tool. With wireshark you will see if M340 requests the right values and the answer from your slave.