21
Mach4 General Discussion / Re: Read droGageBlockT
« on: May 25, 2019, 11:05:55 AM »
--To my understanding your trying to use these two Probing Screens Dro's
--Make sure you have created registers GageBlock and GageBlockT before you can write and read them.
local GageBlock = scr.GetProperty("droGageBlock", "Value")
local GageBlockT = scr.GetProperty("droGageBlockT", "Value")
WriteReg('iRegs0/GageBlock',tonumber(GageBlock));
WriteReg('iRegs0/GageBlockT',tonumber(GageBlockT));
--Never tried to share the same named variable but worth a test
--if not just change them. (more of a scripting timing and use issue id expect)
--Just have to make sure any changes to the Dro's get reread and rewritten to the registers
--I do remember if you try to read the registers to soon after writing to them they are not available.
--so a dwell might need to be used if in the same script
--But in most cases registers are updated in the PLC or button script and then used in the M code.
local GageBlock = ReadReg("iRegs0/GageBlock");
local GageBlockT = ReadReg("iRegs0/GageBlockT");
--Make sure you have created registers GageBlock and GageBlockT before you can write and read them.
local GageBlock = scr.GetProperty("droGageBlock", "Value")
local GageBlockT = scr.GetProperty("droGageBlockT", "Value")
WriteReg('iRegs0/GageBlock',tonumber(GageBlock));
WriteReg('iRegs0/GageBlockT',tonumber(GageBlockT));
--Never tried to share the same named variable but worth a test
--if not just change them. (more of a scripting timing and use issue id expect)
--Just have to make sure any changes to the Dro's get reread and rewritten to the registers
--I do remember if you try to read the registers to soon after writing to them they are not available.
--so a dwell might need to be used if in the same script
--But in most cases registers are updated in the PLC or button script and then used in the M code.
local GageBlock = ReadReg("iRegs0/GageBlock");
local GageBlockT = ReadReg("iRegs0/GageBlockT");