Hello Guest it is September 28, 2023, 06:07:54 PM

Author Topic: Arduino and Modbus Help  (Read 5050 times)

0 Members and 1 Guest are viewing this topic.

Arduino and Modbus Help
« on: August 19, 2019, 05:46:20 AM »

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.