Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: doy on March 17, 2020, 04:58:28 AM

Title: How to use MODBUS RTU in MACRO
Post by: doy on March 17, 2020, 04:58:28 AM
Hello!
How to use MODBUS RTU in MACRO

The source is:

'------------------------------------------------------
rem M403 modebus test

Dim a1,a2,a3

'a1 = FillFromInput(1,1020, 2)
a1 = FillFromHolding(1,1020,8)

a2 = GetModWord(0)
a3 = GetInput(0)

Message "M403 Test End! = " &  GetUserDRO(1000) & " , " & a1  & " , " & a2  & " , " & a3   
'------------------------------------------------------------

result
[ M403 Test End! = 1691574, -1 , -1 , 0 ]

The '1691574' value obtained from GetUserDRO (1000) is the result of normal communication in the brain.

Manual instructions should be 1. However, -1 is output.

a1 = FillFromHolding(1,1020,8)

I would appreciate it if you let me know what needs to be fixed in the above line.