-- In the Screen Load script, add these globals: millisLast = 0 -- time last number of rotations was copied rotationLast = 0 -- number of spindle rotations at that time -- In the PLC script: --------------------------------------------------------------- -- Measure Spindle RPM function. Added december 2019 --------------------------------------------------------------- local millisNow = mc.mcCntlGetPoundVar(inst, 3001) local interval = millisNow - millisIndexPass -- run this about once per second if (interval > 1000) then -- get new values of rotation and milliseconds local hRot = mc.mcRegGetHandle(inst, "CSMIO-IP/Feedback Ch[5]") local rotationNow = mc.mcRegGetValueLong(hRot) local rotationDelta = rotationNow - rotationLast -- calculate Spindle True RPM, set DRO rc = mc.mcSpindleSetSensorRPM(inst, 60000 * rotationDelta / interval) millisLast = millisNow rotationLast = rotationNow end