Hello Guest it is March 28, 2024, 08:04:26 AM

Author Topic: Mach4 MPG axis stop after inc steps overflow  (Read 2783 times)

0 Members and 1 Guest are viewing this topic.

Mach4 MPG axis stop after inc steps overflow
« on: February 23, 2019, 05:09:22 PM »
I am using pokeys57E to drive lathe on m4, and it works great. However I can't figure out how to achieve that axis stops after one would stop rotating MPG.
When inc steps are small, it is ok, but when 1mm per step is choosed, inc overlow happens if you turn mpg too fast. So machine wants to execute all commanded steps, and it runs even when mpg is not turned anymore. What I would like is, that when mpg encoder is not turned, motion of axis stops not matter if all steps were not executed.
I assign mpg to axes with mcMpgSetAxis on startup script, and I use fast enc. 1 and fast enc 2 on pokeys, as this is cyclic lathe.
I have looked at function mcJogIncStop and it seems it has something to do with what I want to achive, but if I put it in PLC loop script, it will stop axis right away, but steps aren't working properly, so 0.01mm inc won't actually make machine step 0.01mm etc.. Could someone advise what would be the correct approach to this?
Thanks
Re: Mach4 MPG axis stop after inc steps overflow
« Reply #1 on: February 23, 2019, 08:56:50 PM »
Hi,
there are two jogging modes, Step and Continuous.

What you have described is the behavior of Mach when jogging in Step mode.

Each click of the MPG causes a move instruction to be appended to the motion buffer. Each click will move the current
axis one 'jog increment' whatever the current jog increment is at the current time. If the succession of move instructions
exceeds the jog rate the instructions stack up in the buffer. Even when the MPG is stopped movement will continue until
the buffer is empty. This is normal behavior.

The only way you can stop the motion controller from completing its task is to EStop.

There may be another alternative, I haven't tried it, this API is really meant for probing routines but may none the less offer
you away to 'cheat' Mach4:

Quote
LUA Syntax:
rc = mc.mcMotionClearPlanner(
      number mInst)

Description:
Clears the motion planner of all previously planned moves.

What I am suggesting is that if you had some timer arrangement that detected that the MPG had ceased producing pulses
for say half a second then you could issue a mc.mcMotionClearPlanner instruction.

That may offer a way to prevent overrun in Step jog mode but perhaps you should experiment more with Continuous jog
mode.

This is from "Mill Operations Guide" in your Docs folder, page 23:

Quote
There are 2 basic jog modes which are selectable by pressing the “Jog Mode” button. The current selection will be indicated by an LED. Figure 3-5 shows the continuous mode selected. In continuous mode the machine will move at the specified jog rate as long as a jog button is held down. The jog rate can be changed by moving the slider at the bottom of the jogging tab or by directly typing the desired rate into the DRO in the bottom right corner. The number shown in the DRO is a percentage of the max velocity, or rapid rate, of the machine. Continuous mode is useful for moving the machine relatively large distances and rough positioning. When finding the edge of a work piece, locating a hole, or other precision position is required, step jog is much more accurate. In step jog, the machine moves only by the specified increment amount, regardless of how long the jog button is held down. The jog increment can be changed by pressing the “Cycle Jog Inc” button. This button will change the DRO to the right of it to show the current increment amount. The increment values can be changed on the General tab in the Mach configuration.

Thus in Continuous mode if you release the jog button the axis stops immediately. What happens when supplied by an MPG signal
however? My pendant (VistaCNC P1A) when in Velocity mode (same as Continuous mode) if you turn the MPG wheel fast enough
the axis moves at the current jog rate. If you slow down or stop the axis also stops. I recall when I set it up there was a setting
somewhere that allowed me to program how fast that threshold was.....can't remember where just at the moment.

I believe the same thing happens with an ordinary MPG attached to your motion controller.

Try it out.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach4 MPG axis stop after inc steps overflow
« Reply #2 on: February 23, 2019, 09:01:29 PM »
Hi,
just had the thought if you used the mcMotionClearPlanner() it may be that the DRO would no longer be accurate.

The DRO advances 1mm at each click (assuming the current jog increment is 1mm) and if an extra 20 clicks were in the
buffer when the mcMotionClearPlanner() instruction came along the axis would cease to move but I suspect the DRO would
still show where it was supposed to be....not ideal.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach4 MPG axis stop after inc steps overflow
« Reply #3 on: February 24, 2019, 04:20:44 AM »
Would using mc.mcJogIsJogging to check that the axis is not jogging before issuing additional jog moves help?

Thanks

Offline MN300

*
  •  297 297
    • View Profile
Re: Mach4 MPG axis stop after inc steps overflow
« Reply #4 on: February 24, 2019, 06:38:09 AM »
Two solutions to the problem of the MPG logic storing pulses come to mind.
1) Turn the MPG slowly
2) Change the size of the steps, instead of 0.01, 0.1, 1.0 do something like 0.01, 0.05, 0.25.
Re: Mach4 MPG axis stop after inc steps overflow
« Reply #5 on: February 25, 2019, 11:14:48 AM »
joeaverage and everybody else, thanks for quick reply. MN300 about your first solution, I have to say I admire your simplistic approach :D. Sadly I need something more robust. I touht there is a simple solution to this, as this is how industrial grade controllers work. No matter pulses left in buffer, motion will stop as mpg stops. Otherwise its a crash waiting to happen. About solution to check if mpg is still turning and stopping motion with loop script after some time span, this would work, but it would result in slugish response. What I want is almost instant response.
One solution came to my mind. One could create two registers and feed them with encoder pulses, than map registers to mpgs with MpgSetEncoderReg. This way I could constantly monitor pulserate from mpg, and as soon as it approaches maximum machine speed, I could take over and feed registers with maximum machine speed, ignoring actual encoder pulserate. As soon as encoder pulserate would drop, I could then instantly map it back. This would solve problem with overflow of steps. But I am a bit worried of overall response of mpg. I would like to have less than 60ms response, I use 25ms buffer time on pokeys, and I am worried how much of a delay plc loop would make. For now, I have other things to solve, so I will just go with ugly solution of allowing max step of  0.1mm, and as safety turn it to 0.01mm in startup script.   

Anyway, I have to say I am impressed with M4 compared to M3. I have sucesfully create acceleration ramps for pwm depending on gear lathe is, automatic gear changing with hydraulic solenoid.. The ease of adopting your screen, creating script and screen for carousel type tool changer on machinning centre.. it is absolutly great and a huge step forward compared to M3..
Re: Mach4 MPG axis stop after inc steps overflow
« Reply #6 on: February 25, 2019, 12:09:07 PM »
Hi,
try Continuous mode, that's what its for.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline MN300

*
  •  297 297
    • View Profile
Re: Mach4 MPG axis stop after inc steps overflow
« Reply #7 on: February 25, 2019, 02:38:49 PM »
The Lua script for the MPG defines the connection of the encoder to an axis that is used by the core program.
For example:  mc.mcMpgSetInc(inst, 0, .001)

Encoder steps add distance to the destination register. The whole point of using an encoder rather than a button is so rotating a certain number of steps adds a matching distance to the destination. The problem is that in some cases the stored distance is too much.

A solution would be for NFS were to add an additional parameter to  mc.mcMpgSetInc that limits the maximum number of steps beyond the current position. The MPG script could change it for each increment choice, as the user prefers.
A similar limit could be added to jog commands.
Re: Mach4 MPG axis stop after inc steps overflow
« Reply #8 on: February 26, 2019, 12:12:42 PM »
Craig, Continuous mode has effect only on how jog button behaves, and whether it excecutes one increment or drives machine as long as you hold it. It won't affect behavior of mpg.
MN300 yes, this would be nice addition. Lua function to prevent stacking up increments faster than machine can execute them is what we need.
Re: Mach4 MPG axis stop after inc steps overflow
« Reply #9 on: February 26, 2019, 12:25:21 PM »
Hi,
have you tried it?

On my machine in Velocity mode the axis stops the moment the MPG stops.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'