31
Mach4 General Discussion / Re: PLC Script not updating all registers?
« on: March 01, 2023, 08:30:43 AM »
Hi, it looks like you are not reading the value of the register before performing calculations. You are performing calculations on the handle of the register which is just a number.. hence why everything executes correctly.
See below
See below
Code: [Select]
---------------------------------------------------------
-- scale VFD readbacks
---------------------------------------------------------
local iVoltsHANDLE=mc.mcRegGetHandle(inst,"MbVFD/R_VFDVolt_V");
local iVolts = mc.mcRegGetValue(inst, iVoltsHANDLE) ----------------Missing this
local hVolts=mc.mcRegGetHandle(inst,"iRegs0/MbVFD/Volts_S");
local readBackVolts=iVolts/10; ---------------- Now calculations will be performed on the value of the register just read
mc.mcRegSetValue(hVolts,readBackVolts);