Hello Guest it is August 16, 2022, 08:25:47 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 - smurph

Mach4 General Discussion / Re: Initiating values from "ini file"
« on: March 31, 2022, 07:43:48 PM »
... so I put this code at the end of the Screen Load Script:

The screen load script is run when the screen is first loaded.  Meaning the screen hasn't yet loaded.  So you will never be able to do it this way.

You could probably use the PLC script and scr.IsLoaded() in combination with a flag to only allow the code to run once.

But the better way, as others have mentioned, is to use the register plugin to create a persistent register.  Then point a DRO (Register Property) to that register in the screen editor. 


It does both by default.  Why would you want to prevent it?  Just use the machine coordinates.


Mach4 General Discussion / Re: Mach4, Pandant xhc HB04B wireless help
« on: March 20, 2022, 02:19:00 AM »
The plugin I wrote will handle the newer wired or wireless WHB04B-4/6 pendants.  But unfortunately not your older HB04B pendant.


Mach4 General Discussion / Re: New to forum, I have mach4 issues
« on: February 17, 2022, 04:55:06 PM »
I have no idea, unfortunately.  I'm not familiar enough with sheetcam or the warprunner to comment.  But maybe someone will come a long though. 


Mach4 General Discussion / Re: Spindle Speed Lua Script..
« on: February 16, 2022, 03:38:07 PM »
Where are you running that code?  In just a file?  Mach won't ever run a random file.  So yes, you will HAVE to put your code into the screen load and PLC script.  I don't know how any of this worked with 4300, as it was no different than the current build in this regard.  It didn't load random files either. 

To implement this as a PLC script, then:

1. Put your ReadRegister() and SetSpindleSpeed() scripts in the screen load scrip.
2. You don't need a FireCount register.  You just need a global variable defined in the screen load script.  e.g. a line with "countVal = 0" in it.
3. Put your "main code" in the screen PLC script.  But modify it to not look at the FireCount register.  Take out your local countVal = 0 line and just reference the global countVal variable. 

In the screen load script:
Code: [Select]
-- global countVal
countVal = 0

--Function to read value from Pokeys57CNC controller analog register (Pin41)
function ReadRegister(i,device, analogPin)
         --i = Instance
         --device= the name of the PoKeys controller
         --pin = the Pokeys pin to read
        local hreg = mc.mcRegGetHandle(i, string.format("%s/Analog input %s",
                          device, analogPin))
         local val =  mc.mcRegGetValue(hreg)
         return val
--Function to set active spindle speed
function SetSpindleSpeed(i, regValue, maxspeed, tweak)
                --i = Instance
                --regValue = number between 0-1 representing the
                --                 voltage read from controller pin41
                --                 where 0 represents 0 RPM, and 1.0 represents 24000 RPM
                --maxspeed = maximum speed of the spindle (24000 RPM)
                --tweak = fudge factor to correct RFI generated error on pin 41 reading
                local speed = regValue * maxspeed * tweak --RegValue 0-1.0V
                if(regValue<=0.15) then -- If the register is under .15V then just set
                                                     -- the speed to 0 rpm

                local rc = mc.mcSpindleSetSensorRPM(i,speed)
                --local rspeed=mc.mcSpindleGetSensorRPM(i)  DEBUG to Verify SPINRPM "set"

And in the screen PLC script:
Code: [Select]

-- local inst = mc.mcGetInstance() -- this is probably already defined at the beginning of the PLC script.

local device = "PoKeys_*********X"  -- The name of my controller
local analogPin = "41"              -- Analog input pin number
local MAXSPEED=24000           -- Maximum spindle speed (RPM)
local TWEAK=.985144              -- Adjustment factor to correct for EMI on P41 reading
local mVal=countVal%10                  -- get the modulo remainder
--mVal=0 -- Debug Code to fire every time (remove for operations)
if (mVal==0) then  --Execution only runs every 10th execution of main
    analogVal = ReadRegister(inst, device, analogPin) --get P41 Value
    SetSpindleSpeed(inst, analogVal, MAXSPEED, TWEAK) -- Set SindleSpeed

countVal=countVal+1                     -- pop the counter up 1

That will integrate your code into the Mach processes for your current screen set.  However, I would implement it as a module and "require" the module in the screen load script and run a module function from the PLC script.  It will make updating to a new build of Mach or a new screen set MUCH easier.  So read up on LUA modules a bit. 

Also, you can use the Mach spindle setup tab in the configuration dialog to implement ramp up and ramp down times.  This is the standard way of implementing a spindle that has no RPM feedback.  There is no need to modify your G code for a delay. 

When you do get your feedback going, you can use the ISIG_SPINDLE_AT_SPEED and ISIG_SPINDLE_AT_ZERO to tell mach the status of the spindle and remove the ramp times. 

If this help you, please close your support ticket.  Because this is way beyond what our support people would be able to do for a hobby license as it is not a bug, but an implementation of a custom feature.  Even Industrial license customers would have to pay for machine integration support. 


Mach4 General Discussion / Re: Best way work with Modbus
« on: February 16, 2022, 02:15:13 PM »
To me, the overhead of opening and closing the com ports will consume far more processor power than just leaving the connection open.  You can then determine and/or vary the interval to poll the devices to save CPU if needed.  If you have com failures, just close and reopen the port.  However, you should NOT have com failures.  If you do, then you have to fix that problem first.


Mach4 General Discussion / Re: Spindle Speed Lua Script..
« on: February 15, 2022, 03:29:01 PM »
mc.mcSpindleSetSensorRPM(m_inst, currRpm) works for me.  It is what Sim uses to simulate a spindle as well.  Perhaps you can post the code that you are using?  Maybe something else is setting the spindle speed with mcSpindleSetSensorRPM(m_inst, currRpm) and there is a conflict. 


Mach4 General Discussion / Re: Rotary axis overshoot
« on: October 16, 2021, 05:10:03 PM »
In a couple of words, "constant velocity".  If acceleration changes the outcome, always suspect constant velocity.  Try running in exact stop mode.  But while in CV mode, the higher the acceleration, the closer the cut will be to the actual tool path.  So if you machine can handle it, turn the acceleration up more. 


Mach4 Plugins / Re: XHC WB04 plugin
« on: October 16, 2021, 05:02:15 PM »
I've been using the pendant for real work over the last few days. The limits issue is very strange...

On several occasions I've seen a refusal to jog below WORK position 0. Mach tells me the jog would violate the soft-min of the axis. But i am way down the axis. Jogging the other way and then coming back fixes it.
That was a general MPG (wireless or not) issue that has been fixed in the later dev builds.  We were trying to support lower resolution machine better and that bug crept in there.  (Wishing everyone would use higher resolution machines these days...)

Also, START doesn't resume after a tool change. This could be Avid's customizations. I see the START button in the gui toggle, but nothing happens.
Start certainly works in the stock Mach config.  So I be you are onto something here.

And, just once, immediately after powering on, and homing, a single jog in Y sent the gantry off to the back of the machine at high speed. I had to jump on the estop to catch it. *Be alert*.
This sounds like a soft limit configuration issue if soft limits are enabled after the home.

Still, i am really enjoying the new pendant despite these teething troubles.
I'd really love to blame everything on the pendant because I'm not to happy with the XHC company not writing their own Mach 4 plugin and leaving lots of Mach 3 users wanting to upgrade hanging.  But no.  LOL  The initial jog thing was definitely a Mach bug that I introduced.  :( 

Mach4 General Discussion / Re: Gage Block DRO
« on: October 08, 2021, 02:10:17 AM »
Craig, are there any update or modify scripts with that DRO?  If so, look at the screen manual about the update and modify scripts needing to return a value to update the DRO.  4162 did not require this but newer build will.