Internet PLC Forum
General => Technical support => Topic started by: taufiqsunar on April 03, 2012, 02:33:31 AM
-
I am sorry, maybe it is basic and fundamental, but because I am a newbie to this protocol, I want to ask a question.
Whether in the Modbus ASCII there are also functions like function 3,4,6,16, etc?
-
Modbus ASCII, RTU and TCP are all the same type of codes. They only differ in the representation of the data. Our PLC support the same functions: 01, 02, 03, 04,05, 06, 16 in all 3 types of Modbus protocols.
[Moderator's note]: We have moved your post from Frequently Asked Questions board to here as the former was meant to be posted by the moderator only.
-
I have Modbus ASCII RS485 slave device with request packet format as picture below.
I have been trying with
DM[101] = READMODBUS(3, 6, &H5030)
but it is error on compiling.
Im also trying
DM[101] = READMODBUS(3, 6, 20528)
there is no response on DM[101].
Im even trying
PRINT #3 "STX06RXP0ETXCRC"
A$ = INPUT$(3)
and still no response.
Previously, I have checked the setting in my slave device and it seem there is nothing strange.
-
Your command format shows that it is NOT a MODBUS ASCII and therefore READMODBUS will not work.
Since your command protocol appears to be proprietary, you may need to use the OUTCOMM 3, c command to send out the ASCII command string byte-by-byte and use INCOMM(3) command to read the data returned from the slave device byte by byte. (You may need to send out the command, wait for a small delay before reading them back from the serial port).
Note: STX is just the binary number 02, not "S", "T", and "X" - so of course your PRINT command will not work.
You can store them inside a range of DM and then use a FOR ... NEXT loop to send them out one byte at a time.
-
I have been able to send the command using FOR ... NEXT loop. But the response message is too long to store it in a DM variable.
Im using DM[111] = INCOMM(3)
and in DM[111] there is -1 in decimal or FFFF in hexadecimal, that indicating if it is overflow.
Can I parsing it in several DM? If it is possible, how to do it?
This is the response format...
-
Yes, you can use a FOR..NEXT loop to store them into DM until -1 and then exit:
E.g. FOR I = 1 to 256
DM[I+200] = INCOMM(3)
IF DM[I+200] = -1 GOTO @10
NEXT
@10
... continue from here. The actual number of data received = I - 1.