Hello Guest it is March 28, 2024, 09:37:09 AM

Author Topic: Switch "direction" of an MPG in a macro?  (Read 4731 times)

0 Members and 1 Guest are viewing this topic.

Switch "direction" of an MPG in a macro?
« on: March 14, 2013, 09:53:34 PM »
I'm just getting a Mach3 driven lathe up and so far its working really well.

I have an MPG mounted on the carriage front and have X and Z labeled switches there also. The switches are setup to run .m1s macros that switch the MPG between the X and Z axises and that is working well.

But since I am sharing the same MPG, right now the X macro works the way I want, clockwise moves the tool towards the part like a normal crosslide handle.

However with it set that way, when I select the Z mode thru the macro, clockwise moves the carriage to the left, opposite the way a normal carriage handle works.

Is there a parameter change I can make in the Z macro that will switch the direction of the MPG moves?

Thanks,

Paul T.
Re: Switch "direction" of an MPG in a macro?
« Reply #1 on: March 14, 2013, 10:24:03 PM »
Hi Paul,
  Could you post your macro ?
Might be a clue there.

Thanks,
Russ
Re: Switch "direction" of an MPG in a macro?
« Reply #2 on: March 14, 2013, 11:27:03 PM »
Hi Russ-

The macro is below. I wrote it almost 10 years ago I think, time flies, that when I was setting up my mill.

It had a workaround for something in Mach that wasn't working correctly back then, perhaps thats fixed now.

Paul T.


Rem Turns on MPG Jog mode, specified axis, specified Jog Increment

ToggleJogMode = 245
SetJogModeStep = 275
SetJogModeContinuous = 276
SetJogModeMPG = 174
ToggleJogOnOff = 103
JogOnLED = 83
SetStepValue1 = 265
SetStepValue2 = 265
SetStepValue3 = 265
SetStepValue4 = 268
SetMPGAxisX = 259
SetMPGAxisY = 260
SetMPGAxisZ = 261
MPGxLed = 1100
MPGyLed = 1101
MPGzLed = 1102
JogContinuousLed = 1103

Axis = SetMPGAxisX

If Not GetOEMLED (JogOnLED) Then
  Call DoOEMButton (ToggleJogOnOff)
End If

Rem 174 is supposed to directly set MPG but broken for now, use hack below
Call DoOEMButton (SetJogModeStep)
Call DoOEMButton (ToggleJogMode)

Call DoOEMButton (Axis)
Call DoOEMButton (SetStepValue1)

SetUserLED(MPGxLed, 1)
SetUserLED(MPGyLed, 0)
SetUserLED(MPGzLed, 0)
SetUserLED(JogContinuousLed, 0)

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Switch "direction" of an MPG in a macro?
« Reply #3 on: March 15, 2013, 03:55:18 AM »
Does the Z DRO count positive when the axis moves towards the chuck?

Hood
Re: Switch "direction" of an MPG in a macro?
« Reply #4 on: March 15, 2013, 11:21:08 AM »
The MPG is currently counting correctly, ie positive counts are increasing both X and Z when they are selected.

However what I'm after is having this apron mounted MPG function in the same manner as the crosslide and carriage handles on the machine.

This will make it nice for quickly "manual" jobs using the MPG instead of these handles.

For this to work I need the MPG in Z control mode to increase the count normally but when controlling X to be reversed. This will cause it to act like a normal cross-slide handle where clockwise turns decrease X.

Last night when I should have been sleeping but was staring as the ceilng instead I realized it might work to in Mach setup a second B MPG but assign the same input pin numbers to it so my single MPG controls both the "Mach" MPGs. Then I can tell Mach to reverse one of them and assign that one to control X.

I'll use my current control buttons with macros to turn on the correct MPG when X or Z is selected.

I'm going to try this now and I'll report back how it works.

Paul T.
Re: Switch "direction" of an MPG in a macro?
« Reply #5 on: March 15, 2013, 07:42:48 PM »
Jeez, so close yet so far.

I thought I had this, making a second MPG with the pin assignments reversed worked.

And I can assign MPG1 directly to control an unused axis so that the "reversed" MPG2 can control the Z axis in the direction I want.

But unfortunately for some reason you don't have direct assignment control over MPG2. You can't assign MPG2 directly to an axis, you can only increment it between axises and it only will switch between live axises so there is no way to shut it off while the "normal" rotation MPG1 controls the X axis.

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Switch "direction" of an MPG in a macro?
« Reply #6 on: March 16, 2013, 07:57:09 AM »
Personally I would just stick with the axis/MPG relation being normal, ie CW moving any axis positive and CCW negative.
I can however see why you want this if you are used to a manual machine. I use both CNC and manual lathes daily, probably manual more than CNC but dont have a problem. Where I do have a problem is when I swap from the big lathe to the small lathe, big lathe has the turret to the rear and the small has a front tool post so MPG is the opposite way in respect to physical X movement ;D Havent used the wee lathe much yet so suppose it will become second nature after a while.

Anyway, maybe a mechanical means would suit, you could have a latching button that works a DPDT relay to invert the MPG's signals, the button could also go to Mach to change between X and Z axis functions via a Brain, I think it should work.

I have a similar kind of setup on my manual lathe, the headstock was noisy as hell so I fitted a servo and bypass the headstock gears. The servo is controlled via 0-10v through a pot. My apron lever controls a relay so that the 0-10v signal gets inverted for Rev spindle, works great.
Hood

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Switch "direction" of an MPG in a macro?
« Reply #7 on: March 16, 2013, 07:21:05 PM »
Try Setting the axis scale to -1. It should reverse the direction of travel.

Just a thought, (;-) TP

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Switch "direction" of an MPG in a macro?
« Reply #8 on: March 16, 2013, 07:27:57 PM »
Good call TP but may need -2 if the lathe is in Dia mode and its the X he is reversing.
Hood