Hello Guest it is April 27, 2024, 10:42:05 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - brianthechemist

Pages: « 1 2 3 4 5 6 7 »
21
For some reason, I can't get any registers to update (in any of my coding...?)

Here is the problem du jour:

I trigger this function via a SW toggle switch.  The code is running so it is reading the register correctly the first time (I get the "Joystick Jogging Enabled (Toggle)" logging message) but it is not able to read back the register to toggle off.

Is there something strange about 1 and 0, true and false?  Perhaps I am doing my booleans wrong?

Code: [Select]
function JJogEnToggleBrSp()
local inst = mc.mcGetInstance()
local JogEnH=mc.mcRegGetHandle(inst,"iRegs0/JJog/Enable");
local JogEn=mc.mcRegGetValue(inst,JogEnH);
if (JogEn == 0) then
mc.mcRegSetValue(JogEnH, 1);
mc.mcCntlSetLastError(inst, "Joystick Jogging Enabled (Toggle)") -- BS Debug
end
if (JogEn == 1) then
mc.mcRegSetValue(JogEnH, 0);
mc.mcCntlSetLastError(inst, "Joystick Jogging Disabled (Toggle)") -- BS Debug
end

end

22
PoKeys / Re: Pokeys Plugin using excessive CPU
« on: March 06, 2023, 10:42:13 AM »
I may have answered my own question:  I found what may be the issue.  Update rate was set to fast.  I'm not sure how slow medium and slow actually are but setting it to medium brought the CPU down from 49% to 29%


23
PoKeys / Pokeys Plugin using excessive CPU
« on: March 06, 2023, 10:35:46 AM »
Hi everyone,

I just installed a pokeys 57E board into my machine for extra I/O (with a ESS for motion control),

My poor notebook is going insane (50% cpu load and apparently "very high" power usage (ha?) whenever it is enabled.  I don't even have any of the i/o enabled at this point.

I don't see any refresh rate configuration for it like the ESS has, but it appears to be wanting to update constantly (which is not necessary for me as it is just additional I/O)

The computer should have plenty of power to handle this (i7-6500 with 8gb ram)

Is this a known issue?


24
Mach4 General Discussion / Re: Script Debugging
« on: March 05, 2023, 08:45:43 PM »
I managed to get a small M6 macro to work in a sense. I dont understand how the debugger helps me with my mistakes though. A section of this code is working on my machine. Call a toolchange it goes to position. Tool changes. All good.

What doesnt work is the tool will not return to its original position this line:

--mc.mcCntlGcodeExecuteWait (inst, "G90 G53 G0 X"..xstart.. Y"..ystart..") Take the tool back to original position this doesnt seem to work.

My other scripting problem. If the machine is not homed, (obviously) on first attempt my 150kg gantry almost raced right off the machine. E-Stop - pleased I have one of those.

if yhomed = true then = return -- check if y is homed
else mc.mcCntlSetLastError (inst "Please home your Y Axis")
end

I tried debugging but dont know what to do. if someone has time to give me the bits I went wrong on would be appreciated. I know this is a standard M6 thing. But if I can get this sorted I would be able to use the same info for the other bits and pieces I need to program into my machine. Know what I mean? Big thanks in advance. B

Full Code:

function m6()

   local inst = mc.mcGetInstance()
   local selectedTool = mc.mcToolGetSelected(inst)
   selectedTool = math.tointeger(selectedTool)
   local currentTool = mc.mcToolGetCurrent(inst)
   currentTool = math.tointeger(currentTool)
   local ystart = mc.mcAxisGetPos (inst, 1)
   local xstart = mc.mcAxisGetPos (inst, 0)
   local zhomed = mcAxisIsHomed (mInst, Z_AXIS, 2)
   local xhomed = mcAxisIsHomed (mInst, X_AXIS, 0)
   local yhomed = mcAxisIsHomed (mInst, Y_AXIS, 1)
   
if zhomed == true then return -- check if z is homed
else mc.mcCntlSetLastError (inst "Please home your Z Axis")
end

if xhomed == true then return -- check if x is homed
else mc.mcCntlSetLastError (inst "Please home your X Axis")
end

if yhomed == true then return -- check if y is homed
else mc.mcCntlSetLastError (inst "Please home your Y Axis")
end
      
               
if selectedTool == currentTool then
   mc.mcCntlSetLastError(inst, "Current tool == Selected tool so there is nothing to do Dork")
else
      --Remove this line if you would not like the Z axis to move
   mc.mcCntlGcodeExecuteWait (inst, "G90 G53 G0 Z-10");--Move the Z axis all the way up
   mc.mcCntlGcodeExecuteWait (inst, "G90 G53 G0 Y60 X35") -- Move to tool change position
   mc.mcCntlSetLastError(inst, "Change to tool " .. tostring(selectedTool) .. " and press start to continue") --Message at beginning of tool change
   mc.mcCntlToolChangeManual(inst, true) --This will pause the tool change here and wait for a press of cycle start to continue
   --mc.mcCntlGcodeExecuteWait (inst, "G90 G53 G0 X"..xstart.. Y"..ystart..") Take the tool back to original position this doesnt seem to work.
   mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedTool) .. "   Previous Tool == " .. tostring(currentTool)) --Message that shows after Cycle Start
   mc.mcToolSetCurrent(inst, selectedTool)
   end
end

if (mc.mcInEditor() == 1) then
                m6()
end

Try this.  Should be fixed

25
Mach4 General Discussion / Re: Script Debugging
« on: March 05, 2023, 08:43:00 PM »
Shouldn't all of your relational operators be in this format?
Code: [Select]
if (thisThing == thatThing) then 
     doThisotherThing()
end

I think you have a single = sign, which is an assignment not a comparison.

https://www.lua.org/manual/5.1/manual.html#2.5.2

26
Mach4 General Discussion / Re: PLC Script not updating all registers?
« on: March 05, 2023, 04:24:50 PM »
That worked a treat.

One related problem now:  Some of the registers that were created in modbus don't actually exist where they are supposed to be (or anywhere else)

My ini file showing where the registers should exist (take R_VFDalarm and R_VFDfOK for example)
Code: [Select]
[ModbusDevice]
[ModbusDevice/MbVFD]
Type=2
Interval=500
Retry=3
Timeout=100
EnronMode32=0
SwapIntWords=0
SwapFloatWords=0
UseBaseZero=1
InitialState=1
Desc=WJ200 VFD
IPAddr=10.9.9.77
TcpPort=502
Func0=function0
Func1=function1
Func2=function2
Func3=function3
Func4=function4
Func5=function5
Func6=function6
Func7=function7
Func8=function8
Func9=function9
Func10=function10
[ModbusDevice/MbVFD/function0]
Desc=r_Spinspd
Type=4
SlaveAddr=1
MbAddr=1
NbrRegs=1
BitPack=0
Bits=0
ReadAs=1
InitialState=1
ScanDenominator=1
Res0=R_VFDSpd_Hz
[ModbusDevice/MbVFD/function0/R_VFDSpd_Hz]
Desc=Read Spindle Speed (Hz)
Type=128
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function1]
Desc=w_Spinspd
Type=6
SlaveAddr=1
MbAddr=1
NbrRegs=1
BitPack=0
Bits=0
ReadAs=0
InitialState=1
ScanDenominator=1
Res0=W_VFDSpd_Hz
[ModbusDevice/MbVFD/function1/W_VFDSpd_Hz]
Desc=Write Spindle Speed (Hz)
Type=256
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function2]
Desc=r_VFDTemp
Type=4
SlaveAddr=1
MbAddr=4120
NbrRegs=1
BitPack=0
Bits=0
ReadAs=1
InitialState=1
ScanDenominator=5
Res0=R_VFDTemp_C
[ModbusDevice/MbVFD/function2/R_VFDTemp_C]
Desc=Read VFD heatsink temp (dec C *10)
Type=128
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function3]
Desc=r_AL_FR
Type=0
SlaveAddr=1
MbAddr=24
NbrRegs=2
BitPack=0
Bits=0
ReadAs=0
InitialState=1
ScanDenominator=1
Res0=R_VFDalarm
Res1=R_VFDfOK
[ModbusDevice/MbVFD/function3/R_VFDalarm]
Desc=VFD Alarm Signal
Type=1
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function3/R_VFDfOK]
Desc=VFD Setpoint Frequency reached
Type=1
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function4]
Desc=r_tripinfo
Type=4
SlaveAddr=1
MbAddr=17
NbrRegs=1
BitPack=0
Bits=0
ReadAs=1
InitialState=1
ScanDenominator=10
Res0=R_VFDtpInfo
[ModbusDevice/MbVFD/function4/R_VFDtpInfo]
Desc=VFD Trip error "factor"
Type=128
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function5]
Desc=r_OutFreq
Type=4
SlaveAddr=1
MbAddr=4097
NbrRegs=1
BitPack=0
Bits=0
ReadAs=1
InitialState=1
ScanDenominator=1
Res0=R_VFDRPM_Hz
[ModbusDevice/MbVFD/function5/R_VFDRPM_Hz]
Desc=VFD Output Freq (dec Hz *100)
Type=128
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function6]
Desc=r_Etime
Type=4
SlaveAddr=1
MbAddr=4117
NbrRegs=1
BitPack=0
Bits=0
ReadAs=1
InitialState=1
ScanDenominator=20
Res0=R_VFDeTim
[ModbusDevice/MbVFD/function6/R_VFDeTim]
Desc=VFD Total elapsed run time (dec Hours)
Type=128
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function7]
Desc=r_StatusC
Type=0
SlaveAddr=1
MbAddr=14
NbrRegs=5
BitPack=0
Bits=0
ReadAs=1
InitialState=1
ScanDenominator=1
Res0=R_VFDrun
Res1=R_VFDrtDir
Res2=R_VFDready
Res3=R_VFDIGN
Res4=R_VFDtrip
[ModbusDevice/MbVFD/function7/R_VFDrun]
Desc=15: VFD Read Run state
Type=1
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function7/R_VFDrtDir]
Desc=16: VFD Rotation Direction (0 FWD, 1 REV)
Type=1
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function7/R_VFDready]
Desc=17: VFD Ready Status
Type=1
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function7/R_VFDIGN]
Desc=18: ignore
Type=1
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function7/R_VFDtrip]
Desc=19: VFD Trip (0 for trip, 1 normal)
Type=1
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function8]
Desc=r_Mon1
Type=4
SlaveAddr=1
MbAddr=4098
NbrRegs=2
BitPack=0
Bits=0
ReadAs=1
InitialState=1
ScanDenominator=2
Res0=R_VFDcurr_A
Res1=R_VFD_Dir
[ModbusDevice/MbVFD/function8/R_VFDcurr_A]
Desc=4099: VFD Output current (dec A *10)
Type=128
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function8/R_VFD_Dir]
Desc=4010: VFD Act Rot Dir- 0: stop, 1:FWD, 2:REV
Type=128
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function9]
Desc=r_Mon2
Type=4
SlaveAddr=1
MbAddr=4112
NbrRegs=2
BitPack=0
Bits=0
ReadAs=1
InitialState=1
ScanDenominator=2
Res0=R_VFDVolt_V
Res1=R_VFDpwr_KW
[ModbusDevice/MbVFD/function9/R_VFDVolt_V]
Desc=4113: VFD Output Voltage (dec V*10)
Type=128
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function9/R_VFDpwr_KW]
Desc=4114: VFD Power Monitor (dec kW*10)
Type=128
RegIndex=0
BitIndex=0
[ModbusDevice/MbVFD/function10]
Desc=r_trip2
Type=4
SlaveAddr=1
MbAddr=27
NbrRegs=1
BitPack=0
Bits=0
ReadAs=1
InitialState=1
ScanDenominator=10
Res0=R_VFDtpInfo2
[ModbusDevice/MbVFD/function10/R_VFDtpInfo2]
Desc=FD Trip error "factor" for second last trip
Type=128
RegIndex=0
BitIndex=0

As you can see, the Modbus window shows them being updated, however they don't exist in the register diagnostics window (nor in the pull-down menus in the screen editor)

What am I missing here?

Thanks!

27
Mach4 General Discussion / Save resized view of a screenset?
« on: March 01, 2023, 12:06:34 PM »
I'm wondering if it is possible to save/export/etc the resized version of a screenset as a separate screenset of those dimensions?
(for example the 1024x768 screenset wx4 resizes nicely to HD but if you set the screen size to HD in the editor, then it will only occupy a corner of it and you would have to resize every component individually to get the same thing)

28
I fixed this, the registers were 1 off due to not adjusting the addresses after enabling the ‘zero based addressing’

29
Mach4 General Discussion / Re: PLC Script not updating all registers?
« on: March 01, 2023, 10:41:31 AM »
Awesome.  I knew it was something super simple!

Thanks

30
Mach4 General Discussion / PLC Script not updating all registers?
« on: February 28, 2023, 03:21:12 PM »
Hi everyone,

I have a number of registers that I'm reading from my VFD (via modbus) that have some small scaling calculations done to them and eventually become values for a diagnostics tab in my screenset.

For some reason, only some of the code appears to be getting executed (the "Set target ROM and DRO" block).  What am I missing here? 

Code: [Select]
-- ************************* BrSp 02/22/23 **************************************
---------------------------------------------------------
--          set Target RPM and DRO
---------------------------------------------------------

RPM=mc.mcSpindleGetCommandRPM(inst);  -- Use mcSpindleGetCommandRPM
local hRPM=mc.mcRegGetHandle(inst,"iRegs0/MbVFD/SetRPM");
mc.mcRegSetValue(hRPM,RPM);

--Spindle Override Check
local OVRenable=mc.mcSpindleGetOverrideEnable(inst);
  if OVRenable then;
    local OVR=mc.mcSpindleGetOverride(inst);
    RPM=RPM*OVR;
  end;
local range=mc.mcSpindleGetCurrentRange(inst)
if RPM>mc.mcSpindleGetMaxRPM(inst,range) then RPM=mc.mcSpindleGetMaxRPM(inst,range) end;
if RPM<mc.mcSpindleGetMinRPM(inst,range) then RPM=mc.mcSpindleGetMinRPM(inst,range) end;

-- Calc and set the frequency to the VFD
local freq=RPM/6*10;  -- ie 24000 rpm /6 = 400Hz but WJ200VFD wants 4000 as input (no decimals)
local hsetHz=mc.mcRegGetHandle(inst,"iRegs0/MbVFD/SetHz");
mc.mcRegSetValue(hsetHz,freq);
local hfreq=mc.mcRegGetHandle(inst,"MbVFD/W_VFDSpd_Hz");
mc.mcRegSetValue(hfreq,freq);

-- Get the actual RPM from the VFD
local aFreq=mc.mcRegGetHandle(inst,"MbVFD/R_VFDRPM_Hz");
local hActRPM=mc.mcRegGetHandle(inst,"iRegs0/MbVFD/ActRPM");
local readBackRPM=aFreq/10*6;
mc.mcSpindleSetSensorRPM(inst,readBackRPM);
mc.mcRegSetValue(hActRPM,readBackRPM);

---------------------------------------------------------
--          scale VFD readbacks
---------------------------------------------------------

local iVolts=mc.mcRegGetHandle(inst,"MbVFD/R_VFDVolt_V");
local hVolts=mc.mcRegGetHandle(inst,"iRegs0/MbVFD/Volts_S");
local readBackVolts=iVolts/10;
mc.mcRegSetValue(hVolts,readBackVolts);

local iPwr=mc.mcRegGetHandle(inst,"MbVFD/R_VFDpwr_KW");
local hPwr=mc.mcRegGetHandle(inst,"iRegs0/MbVFD/KW_S");
local readBackPwr=iPwr/10;
mc.mcRegSetValue(hPwr,readBackPwr);

local iCur=mc.mcRegGetHandle(inst,"MbVFD/R_VFDcurr_A");
local hCur=mc.mcRegGetHandle(inst,"iRegs0/MbVFD/Curr_S");
local readBackCur=iCur/10;
mc.mcRegSetValue(hCur,readBackCur);

local iTemp=mc.mcRegGetHandle(inst,"MbVFD/R_VFDTemp_C");
local hTemp=mc.mcRegGetHandle(inst,"iRegs0/MbVFD/Temp_S");
local readBackTemp=iTemp/10;
mc.mcRegSetValue(hTemp,readBackTemp);

-- **************************************************************************

The Current value "R_VFDcurr_A" is a perfect example.  The value coming back from the VFD is 0, as is the register it is stored in.  But somehow, the Curr_S register is not being updated.  The script posted above is being executed correctly for the "SetRPM" and "SetHz" values.

Any thoughts?
If I set the initial values for the Curr_S register to a value, that value is quickly overwritten by the value you see and then is static.

Pages: « 1 2 3 4 5 6 7 »