Machsupport Forum

Third party software and hardware support forums. => Modbus => Topic started by: Aral on August 19, 2019, 05:46:20 AM

Title: Arduino and Modbus Help
Post by: Aral on August 19, 2019, 05:46:20 AM
Hi

I am totally new to Mach4 and I am struggling with Lua. I connected a Arduino Uno through the Modbus to Mach4. The communication between the Arduino and Mach is ok. On the A0 analog pin is a LM35 Temp sensor. I want to show the temp reading in a text box. In the PLC script I Put the following lines:

-- Temp LM35
inst = mc.mcGetInstance()
hreg = mc.mcRegGetHandle (inst,"Arduino/LM35")
local TempVar = mc.mcRegGetValueString(hreg)
local TempValue = tonumber(TempVar)*500/1023

How do I get the Tempvalue in the textbox register?

Sorry if it is a dumb question.

Thanks

Johan