Hello Guest it is April 26, 2024, 10:13:21 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

71
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
end
 
--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
                                speed=0
                end

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

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
end

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. 

Steve


72
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.

Steve

73
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. 

Steve

74
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. 

Steve

75
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.  :( 


76
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. 

Steve

77
Mach4 General Discussion / Re: G4 P10 not work always
« on: October 08, 2021, 02:06:13 AM »
If you want an exact stop with no CV rounding, call out a G09 on the line you want a sharp corner with.  Faster than G04.  :)

Steve

78
Mach4 Plugins / Re: XHC WB04 plugin
« on: October 02, 2021, 05:16:04 AM »
Hmm...  It may depend on the resolution of your machine.  I'm getting increments will .0001" without issue.  But I have 12570 counts per inch, so the resolution of the encoder is greater than .0001" (10000 counts).

Steve

79
Mach4 General Discussion / Re: Mach3 script conversion into macros for Mach4
« on: September 30, 2021, 05:02:46 PM »
Setting up the tool table requires no scripting.  So why do you think you have to have a script or do scripting if you are using a manual tool change?  Unless I'm misunderstanding you. 

Why don't you post the script that you wanted to "convert" to Mach 4 and let us see what is does.  It may be that Mach 4 doesn't even require a script where Mach 3 did. 

Steve

80
Mach4 General Discussion / Re: Mach3 script conversion into macros for Mach4
« on: September 30, 2021, 03:52:31 PM »
I try to formulate the question differently ..
in MTC mode is it possible to have a master tool as an initial reference?
so that each subsequent tool references the first tool by updating the part zero?

If I understand you correctly, that depends entirely on how you setup your tool table.  No scripting required.  If every tool is an offset of tool #1, then that is what you get.  Even in manual tool change mode.  Remember, you still have to call out G43 after the tool change though. 

Steve