Hello Guest it is April 28, 2024, 10:46:40 PM

Author Topic: LUA Macro Spindle Run M3 Help  (Read 212 times)

0 Members and 1 Guest are viewing this topic.

LUA Macro Spindle Run M3 Help
« on: February 17, 2024, 09:29:16 AM »
Hi all, I have a very simple Lua macro I am trying to get working for my avid 6060pro running mach4 on an ESS with a CncDepot RM15 spindle. I have been very successful with all my macros in Lua until this point and hoping someone can tell me where I am going wrong.

All I am trying to do is get my Lua scripted macro to execute "M3 S1000" g-code. My macro has my machine go to a given machine location, perform some movements, and then return. Everything works great until I add into the gcode execute lines for the "M3 S1000" when that is added and I run the macro, Mach4 just sits there and the timer runs but no actions are taken and the spindle does not start. I have also noticed it seems to create something in the background that requires me to exit Mach4, and go into task manager to force end the GUI.

Basically, am I not able to call an M3 to start the spindle within a Lua script?

Thanks for any help you can provide.

Offline cncmagic

*
  •  63 63
  • what me worry? heck...it ain't my machine anyway
    • View Profile
Re: LUA Macro Spindle Run M3 Help
« Reply #1 on: February 18, 2024, 05:12:21 PM »
there are probably some references in the forum.. don't do a loop in the macro waiting for an event.. . if you do you will need task manager to close everything down since the macro won't exit.. that does sound like at least one problem.. I don't do this but I do remember seeing a reference to how the macro can place gcode into the mdi and execute it.. the gcode compiler won't run directly from the macro if I remember correctly. you should be able to find the reference in the forum if you search. At least those two items should get you on your way..
and just for my own interest, why are you doing all this in a macro?  ???
any semblance of information posted to anything remotely  close to accuracy is merely coincidence. Use at you own discretion.. or play the lottery.. same odds
Re: LUA Macro Spindle Run M3 Help
« Reply #2 on: March 11, 2024, 05:05:13 PM »
You can turn the spindle on in a macro and set the rpm
mc.mcSpindleSetCommandRPM(inst, 1000)
mc.mcSpindleSetDirection(inst, 1) --   -1 CCW   0 OFF   1 CW
Chad Byrd