Hello Guest it is April 23, 2024, 06:09:13 PM

Author Topic: About a delay routine with G4  (Read 4946 times)

0 Members and 1 Guest are viewing this topic.

About a delay routine with G4
« on: April 11, 2008, 05:39:41 AM »
I have made the following routine:

wait = GetUserDRO (1037) * 770
code ("G4 P" & wait)

But when i set in the 1037 DRO value bigger than 27, the system enters the routine and never stops.
If the value is lower than 27 works fine and by pressing the DoButton(0) escapes the routine.
With 28 even the DoButton(0) does not stop the routine.

I also did the following:

Dim wait As String
The reaction is the same.

Any ideas?

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: About a delay routine with G4
« Reply #1 on: April 11, 2008, 09:58:38 AM »
Hi Giannis

A bit more info would help. When you say "routine" - do you mean just these two lines or is there more?

wait = GetUserDRO (1037) * 770
code ("G4 P" & wait)

The thing is, this routine wouldn't be entered by just entering a value in a DRO and I'm not sure what you mean by "never stops" - do you mean it hangs? or do you mean you don't get the expected delay at the dwell?

Also I'm not sure what you mean by "escapes the routine", there's nothing to escape from. These lines of code will simply pass the command "G4 P?" to the Mach thread and then exit the vb thread. i.e. The VB thread will not remain "alive" for the duration of the dwell unless you follow it with the while isMoving() construct - and you'd only do that if there were more code following.

DoButton(0) is the cycle start button, so I'm a tad lost on why pressing that should stop anything.

Sorry Giannis - can you expand a little?

Thanks

Ian
Re: About a delay routine with G4
« Reply #2 on: April 12, 2008, 02:01:01 AM »
Sorry, i will be more specific.

I want to create a time like "preheat time" for an oxygen torch.
So at the starting point of the shape that i want to cut i put the following code:

  • ActivateSignal(Output 1)
  • wait = (GetUserDRO (1037)*770)
  • code ("G4 P" & wait)
  • followed by the code, eg: G03 X100 Y100 I25 J25

This delay routine works fine (for values from 0 to 27 at the DRO)
and the user can "escape" ( i mean can stop the Dwell) by pressing DoOEMButton(0) or with DoOEMButton(288).

When a value greater than 27 is put, the Output 1 is activated,
but the movement never starts (which shows to me that hangs to the dwell).
At the same time if i press "DoOEMButton(0)" still does not do anything.

Only if i press "stop program" it stops and i can start from the beginning.

So, my problem is why cannot perform Dwell, when 28*770=21560msec and over is set.

Any information would be helpfull...
[/size]
Re: About a delay routine with G4
« Reply #3 on: April 12, 2008, 02:46:17 AM »

Ok, i have some more information.
I changed the multiplier from 770 to 1000:

wait=(GetUserDRO(1037)*1000)

There is the same problem, but now happens at the value of 22 (at the 1037 DRO).

Following, i set the multiplier to 2000 and now happens to 11.

28*770=21560.
22*1000=22000.
11*2000=22000.

So, there is a kind of overflow over 21500, but i don't know where and how. '(while it is not 2 bytes -32768-)

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: About a delay routine with G4
« Reply #4 on: April 12, 2008, 04:32:41 AM »
Hi Gianni

There's a couple of issues here. I'm not entirely sure why there appears to be a limit of around 22000 but for the moment, I'm not sure that is of practical importance - bear with me - it may become irrelevant.

I'm assuming you don't need a delay of 22000 seconds! so you probably have the "G04 dwell in ms" option in Config/general config ticked. If so and you untick it, your delay will be in seconds - so I think your problem will dissappear.

That said, I'm still a little confused as to how you're going about this. If I understand you correctly I think you're intending having all your gcode posted via the "code" sub to Mach from VB. If that is your idea there may be a better way to do it.

If you use the M3 macro to fire your torch (as you would if you were starting a spindle) just add your "wait capture code" prior to DoSpinCW() only use SetVar(1000, wait) instead of your 'code "G4 P" & wait'. Then in your gcode files have G4 P#1000. That way you'll be using a more flexible approach.

So...

In M3.m1s you'll have:

SetVar(1000, GetUserDRO(1037)) 'set gcode var 1000 to delay in SECONDS (no need to go via your wait variable - just wack it straight in there)
DoSpinCW()

In your gcode text files you'll have:

M3
G4 P#1000
G03 X100 Y100 I25 J25
...
...

Cheers

Ian
Re: About a delay routine with G4
« Reply #5 on: April 12, 2008, 05:05:22 AM »

Well, by setting the Dwell in sec (and not in msec) worked!

So easy..

Thanks  Ian.  ;D