Hello Guest it is March 28, 2024, 03:13:13 PM

Author Topic: Arduino to read spindle speed via modbus  (Read 2136 times)

0 Members and 1 Guest are viewing this topic.

Arduino to read spindle speed via modbus
« on: January 03, 2022, 07:24:48 AM »
Hello all, may I ask other members experineced in MODBUS if it's possible to read spindle speed set via S command by Arduino via modbus? I am building a custom VFD controller and 0-10V is not a way here. All I need to do is to read the speed that is set in Mach3 either manually or in gcode so I can interpret the information further.
Thanks in advance!
Re: Arduino to read spindle speed via modbus
« Reply #1 on: January 18, 2022, 10:20:59 PM »
*** Oops! I missed the part about you using Mach3 but the idea is the same ***

You mean write to the Arduino hosted holding register? Arduino's can't read but Mach4 ModBus plugin can write the value to the Arduino.

All I know is Mach4 and Lua. Which is nothing more than the following;

Code: [Select]
local inst = mc.mcGetInstance()
local hreg = mc.mcRegGetHandle(inst, "MBUS/hr0")
mc.mcRegSetValue(hreg, spindleSpeed)

You would have to look up the call to get the spindle speed but writing to a ModBus holding register is as simple as writing to any other register in Mach4.

Hope that helps.
« Last Edit: January 18, 2022, 10:23:13 PM by subnoize »