Hello Guest it is April 24, 2024, 01:36:21 PM

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 - secretspy711

Pages: « 1 2
11
Mach4 Toolbox / Re: M6: how to add manual spindle RPM with tool change?
« on: October 04, 2018, 01:03:14 AM »
Thanks for that reference.  I'm not trying to pass a parameter, just get normal M3 functionality with the addition of a popup window telling me what RPM to set.

After a couple hours of messing with this, I finally got it.  Here's my M3 script.  This seems so obvious now...  learning a new programming language just takes a little patience I suppose.

Code: [Select]
function m3()
inst = mc.mcGetInstance()
commandrpm = mc.mcSpindleGetCommandRPM(inst)

mc.mcCntlSetLastError(inst, 'SpindleClockwise')
mc.mcSpindleSetDirection(inst, 1)

wx.wxMessageBox("Set spindle RPM to " .. tostring(commandrpm) .. "\nThen press Cycle Start to continue")
mc.mcCntlToolChangeManual(inst, true)

end

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

12
Mach4 Toolbox / Re: M6: how to add manual spindle RPM with tool change?
« on: October 03, 2018, 02:12:54 PM »
I keep learning new stuff...

According to the scripting manual:
https://usermanual.wiki/Pdf/Mach420Scripting20Manual.642363313/html

On page 9/10, the M3 code falls under the category of "if there's no user script, the internal script will be used" which is what's currently happening.  So it looks like I can create my own script as above, but I will have to expand it to actually turn on the spindle.  I think I just found my answer.

13
Mach4 Toolbox / Re: M6: how to add manual spindle RPM with tool change?
« on: October 03, 2018, 12:37:56 PM »
rhtuttle, currently there is no M3 macro in my macros folder.  Wouldn't creating an M3 macro like this work?  I could probably add in some way to store the last spindle speed, and compare it to the one currently being commanded, and if they are the same, then skip this entirely.

Code: [Select]
function m3()
local inst = mc.mcGetInstance()
local spindlerpm = mc.mcSpindleGetCommandRPM(inst)

mc.mcCntlCycleStop(inst)
        wx.wxMessageBox("Set Spindle RPM to" .. tostring(spindlerpm) .. )
mc.mcCntlSetLastError(inst, "Set Spindle RPM to" .. tostring(spindlerpm) ..)
end

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

14
Mach4 Toolbox / Re: M6: how to add manual spindle RPM with tool change?
« on: October 03, 2018, 12:09:07 PM »
your link isn't working...

thank you.  I will play around with both of these options

15
Mach4 Toolbox / Re: M6: how to add manual spindle RPM with tool change?
« on: October 03, 2018, 10:47:54 AM »
I'm at work now so I cant test this, but could I simply add an M3 Macro to my macros folder?

16
Mach4 Toolbox / Re: M6: how to add manual spindle RPM with tool change?
« on: October 03, 2018, 02:23:51 AM »
I also tried this, in the main screen script, but I am getting a compilation error on the messagebox line.

Code: [Select]
-- Spin CW function.
---------------------------------------------------------------
function SpinCW()
    local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
    local sigState = mc.mcSignalGetState(sigh);
    local spindlerpm = mc.mcSpindleGetCommandRPM(inst);
   
    if (sigState == 1) then
        mc.mcSpindleSetDirection(inst, 0);
mc.mcCntlToolChangeManual(inst, true); --This will pause the tool change here and wait for a press of cycle start to continue
wx.wxMessageBox('Set spindle RPM to' .. spindlerpm .. ); --message box with RPM to set
    else
        mc.mcSpindleSetDirection(inst, 1);
mc.mcCntlToolChangeManual(inst, true); --This will pause the tool change here and wait for a press of cycle start to continue
wx.wxMessageBox('Set spindle RPM to' .. spindlerpm .. ); --message box with RPM to set
    end
end

17
Mach4 Toolbox / Re: M6: how to add manual spindle RPM with tool change?
« on: October 03, 2018, 01:00:15 AM »
CNCharly, that's close, but it doesn't consider that the spindle RPM in the Mach4 tool table might be different than the RPM I've set in my Gcode.  I suppose since "T1 M6" is immediately followed by something like "S10000 M3", I could simply look at the Gcode preview window and determine that I need to set it to 10000 RPM... it would just be nice to have it in the same popup window that tells me what tool to change to.

I tried using
Code: [Select]
local spindlerpm = mc.mcSpindleGetCommandRPM
and then
Code: [Select]
wx.wxMessageBox("Set spindle RPM to " .. tostring(spindlerpm) .. "\nThen press Cycle Start" )
and it works except it's telling me to set the spindle RPM to 0...
I assume that's because it hasn't seen the first "S10000 M3" command yet.  How do I get it to look ahead 1 line of gcode and get that number?

18
Daz, I also tried your code and it works great!  However the fact that I have to raise the Z axis manually makes me a little nervous.  I know the popup box tells me to do that, but I could envision a scenario where I'm just not paying close enough attention and forget to do that. 

I inserted a mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 Z0.0") right between the two "end" statements, and now when I hit cycle start, Z goes all the way up before continuing.  Just wanted to throw that out there if anyone is looking to do the same.

19
Mach4 Toolbox / M6: how to add manual spindle RPM with tool change?
« on: October 01, 2018, 12:49:13 PM »
I am using a trim-router as a spindle on my homebuilt machine.  Mach4 controls on/off, but for now, I have to set the speed manually until I get a VFD or SuperPID controller.

I would like to modify my M6 script to get Mach to tell me what RPM to set, in addition to the tool number.  Can someone show me an example script for how to do this?

Pages: « 1 2