Hello Guest it is September 20, 2019, 04:30:20 AM

Author Topic: Probably simple but...(G-Code help)  (Read 11563 times)

0 Members and 1 Guest are viewing this topic.

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Probably simple but...(G-Code help)
« on: January 09, 2016, 04:36:38 PM »
If I have my axes at say X100 and Y100 and in g-code I want to temporarily move to say curretntX+50 currentY+50 , do something then move back to where i was before, how would I code it??

Do i need to be looking at the DRO's etc as variables and adding/subtracting my move ?? or is there a sensible way??

Anyone care to throw an example my way??


:)
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives
Re: Probably simple but...(G-Code help)
« Reply #1 on: January 09, 2016, 05:34:59 PM »
http://machmotion.com/cnc-info/g-code.html
you can give this a shot


G91                       (change to incremental distance mode)
G0 X50 Y50           (move from current position X+50, and Y+50)
>>>> do something
G0 X-50 Y-50         (move from current position back to the original position)
G90                       (change it back to absolute distance mode)
Rob

Albert Einstein ― “If you can't explain it to a six year old, you don't understand it yourself.”

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Probably simple but...(G-Code help)
« Reply #2 on: January 10, 2016, 03:34:40 AM »
Great, thanks,

I wasn't grasping the Incremental/Absolute switch

Should work nicely.
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Probably simple but...(G-Code help)
« Reply #3 on: January 10, 2016, 09:41:26 AM »
Its working nicely thanks, here's the final subroutine code, If there is any surplus code in there please let me know, I have hopefully commented it correctly...
BTW the idea is to use an offset probe as height sensor.

G91 (switch to incremental mode)
G01 X28.00 Y4.00 F6000 (position probe switch)
G04 P0 (wait until the move finishes)
G90 (switch to absolute mode)
#15239=1 (this var is monitored by a brain and triggers the probe cylinder)
G04 P0
G28.1 Z5.000 (probe the surface)
G92 Z0.000 (zero the Z axis DRO)
#15239=0 (raise the probe)
G00 Z#15045 (apply the probe switch offset from settings screen DRO)
G92 Z0.000 (zero the Z axis)
G00 Z5.00 (raise the Z axis for travel)
G91 (switch to incremental mode)
G01 X-28.00 Y-4.00 F6000 (put the axes back to where we came from)
G90 (switch to absolute mode)
M99
%

I'm using G01 moves as the G0 move was a bit vicious.

Queries....

1 - If i remove line 3, it makes the Z motor screech for some reason???

2 - It does not put the axes back where they came from. It varies but is always out by about 0.05mm to 0.15mm every time??

3 - When I press my "set origin" button it makes the Z axis change, this is not wanted, any idea how i fix that??
The button code is...
DoOemButton(1008)
DoOemButton(1009)
DoOemButton(242)
DoOemButton(160)

Many thanks
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline BR549

*
  •  6,895 6,895
    • View Profile
Re: Probably simple but...(G-Code help)
« Reply #4 on: January 10, 2016, 05:11:27 PM »
The G04 P0 is not needed . All you are doing at that point is emptying the buffer.

Define G0 as being vicious. Either the machine can do a G0 move or it cannot Which is it ???

The reason Z is screeching is it is loosing steps  Find out why.

IF the Machine cannot return exactly from where it came from then it is either loosing steps or the Step resolution is course enough to not allow the last step to move precisely and you come up a fraction of a step move short. TO be made up on the next move.

There is nothing in the button code that should effect Z. What it does is

ZeroX
ZeroY
Regen toolpath
Save Corrds to G59.254

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Probably simple but...(G-Code help)
« Reply #5 on: January 11, 2016, 02:27:16 AM »
Hmm,

Without that G04 the Z emits a very short screech, but at a point when the Z should not be moving at all - right at the beginning? I could maybe video this as it is repeatable.

G0 over a sort distance just seemed unnecessarily hard, time saved is nil, so why beat the machine up doing a short pair of rapids when a smooth co-ordinated move is better :)

Can't be losing steps - this is a DRO issue only, not physical, I have not got as far in testing yet to prove lost physical steps, just that the DRO does not always return to zero which seemed odd as that was where it came from :) But if as you say it is made up then no worries at all, even if its not 0.1mm is bugger all in the real world, metal expansion is probably a bigger issue :)

The button changing Z is worrying as Z definitely changes, again, I could video this action.
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives
Re: Probably simple but...(G-Code help)
« Reply #6 on: January 11, 2016, 02:40:43 AM »
Violent implies acceleration is too high as it should accelerate smoothly and quickly up to maximum velocity and back down, over a short distance it should never reach maximum velocity.

Suggestions... Half whatever the present acceleration is and rerun the code with g0 and without the pause, what does it run like (quick check and as your experimenting).

What acceleration and velocity do you have for each axis out of curiosity, plus steps per mm (or inch).
Rob

Albert Einstein ― “If you can't explain it to a six year old, you don't understand it yourself.”

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Probably simple but...(G-Code help)
« Reply #7 on: January 11, 2016, 03:40:43 AM »
Will have a look tonight but this is purely a personal thing i think, i have the accelerations as high as possible as its a plasma table.
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives

Offline Davek0974

*
  •  2,577 2,577
    • View Profile
    • DD Metal Products Ltd
Re: Probably simple but...(G-Code help)
« Reply #8 on: January 11, 2016, 05:28:18 AM »
Slightly more compact subroutine...

G91 (switch to incremental mode)
G01 X28.00 Y4.00 F6000 (position probe switch)
G04 P0 (wait until the move finishes)
G90 (switch to absolute mode)
#15239=1 (this var is monitored by a brain and triggers the probe cylinder)
G04 P0
G28.1 Z5.000 (probe the surface)
G92 Z#15045 (apply the torch height offset from settings screen DRO (currently switch offset))
#15239=0 (raise the probe)
G91 (switch to incremental mode)
G01 X-28.00 Y-4.00 F6000 (put the axes back to where we came from)
G90 (switch to absolute mode)
M99
%

cuts out two z moves and three lines of code, should work ok :)
Bridgeport Mill, Mach3 V062, CSMIO-IP/A controller, AC Servo Drives
Re: Probably simple but...(G-Code help)
« Reply #9 on: January 11, 2016, 05:51:35 AM »
Do you need the double incremental and absolute change?

May not require it.  As the DRO numbers dont change.

With g28.1 why are you setting the DRO with g92?
Curiosity not expert here.
As it will input the numbers shown on the config homing page (do a screenshot tonight, but from memory its the bottom lhd boxes)

You should not need the first g4, and the second g4 probably required more than p0... Like p1

Again I'm new at this and no expert but always learning
Rob

Albert Einstein ― “If you can't explain it to a six year old, you don't understand it yourself.”