Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 09:54:00 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  General Mach Discussion
| | |-+  Just baffled by G54-56 Offsets
Pages: 1   Go Down
Print
Author Topic: Just baffled by G54-56 Offsets  (Read 275 times)
0 Members and 1 Guest are viewing this topic.
cjmerlin
Active Member

Offline Offline

Posts: 180


View Profile
« on: May 14, 2011, 10:52:01 AM »

Hi, I've been trying to write a macro to set my Z offsets to the same number whether I am using G54 through G59.

See Macro below. I have noticed that without the wait states Mach will not update the Dro's quickly enough and the Z Dro's are still different even with running the macro.

If I single step through the macro, it seems to work as I intended.

Is there another way to achieve the same thing with one command?



* M900.m1s (1.99 KB - downloaded 29 times.)
Logged
BR549
Active Member

Offline Offline

Posts: 2,557


View Profile
« Reply #1 on: May 14, 2011, 04:59:44 PM »

OK to start with the use of Code"G4P2" does not really do anything inside of the macro. It is a Gcode pause not VB.

Use while is moving() or sleep

On some systems (computer) you have to add wait states in order for everything to have time to execute OR mach will skip over things as you have seen.

It is just a matter of getting the wait states correct for YOUR system and it will run.

IF you can step through the code and it functions then it is a matter of timing the VBcode to run correctly.

Just a thought, (;-) TP
Logged
ger21
Global Moderator
*
Offline Offline

Posts: 2,619



View Profile WWW
« Reply #2 on: May 14, 2011, 10:14:07 PM »

I do it like this:


CurrentOffset = GetOEMDRO(46)  ' Get Current Coordinate system 1 = G54, 2 = G55, ....

If CurrentOffset = 1 Then
ZOffset=GetVar(5223)
ElseIf CurrentOffset = 2 Then
ZOffset=GetVar(5243)
ElseIf CurrentOffset = 3 Then
ZOffset=GetVar(5263)
ElseIf CurrentOffset = 4 Then
ZOffset=GetVar(5283)
ElseIf CurrentOffset = 5 Then
ZOffset=GetVar(5303)
ElseIf CurrentOffset = 6 Then
ZOffset=GetVar(5323)
End If

For X = 5223 To 5323 Step 20
SetVar(X, ZOffset)
Next X
Sleep(250)
Logged

cjmerlin
Active Member

Offline Offline

Posts: 180


View Profile
« Reply #3 on: May 15, 2011, 09:40:20 AM »

Thanks guys for the advice, As you can see in my macro I was getting desparate and willing to try anything.

On reflection it seems writing to the Dro's in turn and waiting for them to update is a slow way of doing things. I increased the sleep times to 450 and still had problems with some of the offsets not getting set correctly.

Thanks for the script Gerry, I'll give that a go. Looks very tidy.
Logged
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!