Hello Guest it is April 16, 2024, 05:39:58 AM

Author Topic: Macro or script for A axis  (Read 774 times)

0 Members and 1 Guest are viewing this topic.

Macro or script for A axis
« on: September 08, 2021, 02:25:14 PM »
I would like to make a macro or script to put into Mach 4 latest version , to activate my rotary axis and have it turn constant . I want it to act like a lathe , and be able to run a g code file separately while it is turning . I want it to act like the spindle , push a button on the mach 4 screen to start it turning and push button to stop rotation . I can put in the feed rates for A axis , the reason i want it to run constant is , otherwise i would have to change the length or the work piece in the routine . I want to turn table leg profiles .

    Thank you

      Ed

Online Graham Waterworth

*
  • *
  •  2,671 2,671
  • Yorkshire Dales, England
    • View Profile
Re: Macro or script for A axis
« Reply #1 on: September 08, 2021, 06:22:25 PM »
That is not possible unless you run the 4th axis with a pulse generator and use Mach to switch it on and off, an Arduino would work to drive the 4th axis and signals for stop and start and also rotation speed.
Without engineers the world stops
Re: Macro or script for A axis
« Reply #2 on: September 09, 2021, 03:16:34 AM »
Could an OB axis be used for this? Just set it to jog and then run a gcode?

Offline smurph

*
  • *
  •  1,546 1,546
  • "That there... that's an RV."
    • View Profile
Re: Macro or script for A axis
« Reply #3 on: September 09, 2021, 06:41:42 PM »
Could an OB axis be used for this? Just set it to jog and then run a gcode?
SwiftyJ is on a roll!  It could be possible, but not simple or easy, if all of the requirements line up.  First, your motion controller will have to support the use of out of band axes.  Not all do.  Then you would have to use the motor mapping API calls and unmap the motor from the A axis and map it to an out of band (OB) axis.  But you would have to set the feed rate for the OB axis with the API, meaning you can't set it with the F word in G code.  And you will have to manually set the machine up in the screen load script so that the machine starts up with a known motor configuration, as changing the motors on the fly will play havoc at shutdown or if some external plugin or script saves the Mach settings. 

Here are the API calls that would need to be used, at a minimum.  (remember to check your API function return codes)

mc.mcAxisUnmapMotors(inst, axis)
mc.mcAxisMapMotor(inst, axis, motor)
mc.mcMotionSync(inst) -- to be used when the motor is mapped BACK to the A axis.
mc.mcJogSetFeedRate(inst, axis, unitsPerMin)
mc.mcJogVelocityStart(inst, axis, dir)
mc.mcJogVelocityStop(inst, axis)

Steve