Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 08:11:49 AM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  General Mach Discussion
| | |-+  machine running irregular on button script
Pages: 1 2 3 4 5 »   Go Down
Print
Author Topic: machine running irregular on button script  (Read 1714 times)
0 Members and 1 Guest are viewing this topic.
zone023
Active Member

Offline Offline

Posts: 37


View Profile
« on: December 13, 2010, 03:49:30 PM »

Hi All,

I am encountering a problem when running a button script.

It is a fairly simple probing script, for measuring flatness of a surface.
There are a few dro's involved for surface size, grid size, etc.
The script uses some Do Until...Loops to scan a surface for flatness in a regular grid.
Scanned XYZ values are written to a textfile.

For instance, on a surface of 270 x 400 mm with a 20mm measuring grid about 300 points are beeing probed.
This takes about 10 minutes.

During this scan my machine sometimes acts strange, it looses steps and is running irregular.

Also, when the probe hits the surface "G4 P.25" is used, a pause to allow for writing values to the textfile.
About 1 in every 100 times the pause is skipped, the probe backs off immediately to go to the next piont.
XYZ Values are written okay though..


Is there some explanation for this strange behaviour?

I never loose steps when running g-code.
I can run complex programs without a problem.

So, is there a way to scan with a g-code file?
Can XYZ values  be written to a textfile while using g-code?
I mean g-code in a .NC-file, not g-gode in a button script.

Thanks for helping!

Rich
  
  
 
 

 
Logged
Graham Waterworth
Administrator
*
Offline Offline

Posts: 1,665


West Yorkshire, England



View Profile WWW
« Reply #1 on: December 13, 2010, 04:22:09 PM »

You can run a g-code G31 loop using a sub and some # variables then jump into a custom macro to write the data to a file, that way the moves are all native g-code.

Graham
Logged

G-Code is on the cutting edge

Autovalues Engineering, CNC machining specialists, Bradford, England
zone023
Active Member

Offline Offline

Posts: 37


View Profile
« Reply #2 on: December 13, 2010, 06:50:04 PM »

Hi Graham,

I have no idea how to do what you say.
I will have to find out how to use # variables...
Are there enough variables available to store 300 to 500 xyz values?   (thus 1500 values)
Some searching and reading will help, I guess... Huh

Is it normal that g-code in a button scrip is executed like described, with irregularities?
Does this happen because the VB-script is interrupted by windows, or something like that?

 
Thanks for helping!

Rich


Logged
rrc1962
Active Member

Offline Offline

Posts: 434


View Profile
« Reply #3 on: December 13, 2010, 07:09:58 PM »

I would write each coordinate to an array, then when the process finishes, write the array to the file.  Updating an array is much faster than writing to file.  Just write the file once. 

FWIW...I've seen the same issue with G4 pause commands being skipped and it wasn't from a button script.  It is while running a g-code program.  It's usually the first one in the program.  No idea what causes it, but it hasn't been enough of an issue to spend a whole lot of time on.
Logged
zone023
Active Member

Offline Offline

Posts: 37


View Profile
« Reply #4 on: December 13, 2010, 08:05:12 PM »

Hi,

Missing the pause isn't the real problem...
It just also happens on an irregular basis.

The real problem is missing the steps...
When I scan say 300 points on a surface, in my opinion the machine should make a repeated regluar sound... probe and step to the next piont.....probe and step to the next point....probe and step to the next point....etc...
But the sound is not regular, like it hessitates sometimes...or sometimes it seems to react faster, skip a pause..

As said, the machine normally never looses steps when running a .NC-file.
Loosing steps while probing from a vb (button) script only occurs on the y-axis.
The y-axis is driven on both sides. It has dual motors, master and slave setup.

My guess for now is that, because of the irregularity, master-y and slave-y are not receiving their commands simultaneous.  
Thus tension builds up in the y-axis and steps are lost... ( I hear a "bang" when loosing steps...)

.NC-files, even with repeated operations, never give me this problem... Undecided
 

Thanks again.




 


« Last Edit: December 13, 2010, 08:10:45 PM by zone023 » Logged
zone023
Active Member

Offline Offline

Posts: 37


View Profile
« Reply #5 on: December 13, 2010, 08:19:46 PM »

I thought it might help posting the script... Cheesy

Code:
Option Explicit

Dim POX As Single  '-- probe offset X
Dim POY As Single
Dim TD As Single  '--Tip Diameter
Dim shiftZ As Single

Dim Xwp As Single '-- X work at probe position
Dim Ywp As Single '-- Y work at probe position
Dim Zwp As Single

Dim minX As Single
Dim minY As Single
Dim maxX As Single
Dim maxY As Single

Dim sizeX As Single
Dim sizeY As Single

Dim stepX As Single
Dim stepY As Single

Dim borderX As Single
Dim borderY As Single

Dim ProbeFeed As Single
Dim RapidFeedXY As Single
Dim RapidFeedZ As Single

Dim Datum As String

POX = GetUserDRO(1501)
POY = GetUserDRO(1502)
TD = GetUserDRO(1503)

RapidFeedXY=GetUserDRO(1615)
RapidFeedZ=GetUserDRO(1615)
ProbeFeed = GetUserDRO(1505)

Xwp = GetOemDRO(800) + POX
Ywp = GetOemDRO(801) + POY

sizeX = GetUserDRO(1601)
sizeY = GetUserDRO(1602)

stepX = GetUserDRO(1605)
stepY = GetUserDRO(1606)

borderX = GetUserDRO(1610)
borderY = GetUserDRO(1611)

minX = borderX
minY = borderY

maxX = sizeX - borderX
maxY = sizeY - borderY


Datum = Format(Now, "yyyymmdd")
Datum = Datum & "-" & Format(Time, "hhmm")


If GetOemLed (825)=0 Then

Open "c:\mach3\scan\SCAN-" & Datum & ".txt" For Output As #1 ' Open to write file.


MsgBox ("Probe will move. Make sure work area is clear. Probe-tip must be about 10mm above work!")


Code "G90 G1 X" & minX - POX & " Y" & minY - POY & " F" & RapidFeedXY  'Move to border


Code "G91 G31 Z-15 F" & ProbeFeed
While IsMoving()
Wend
Code "G4 P0.25"

Call SetDro (2, 0 + (0.5 * TD))

Code "G4 P0.5" 'Pause for Dro to update.
Code "G91 G1 Z5 F" & RapidFeedZ  'Probe backs off 5mm
While IsMoving()
Wend

Code "G90"

Code "G4 P0.25"

Code "G91 G31 Z-10 F" & ProbeFeed
While IsMoving()
Wend
Code "G4 P0.25"

shiftZ = GetVar(2002) + (0.5 * TD)


Code "G4 P0.15" 'Pause for Dro to update.
Code "G91 G1 Z5 F" & RapidFeedZ  'Probe backs off 5mm
While IsMoving()
Wend

Code "G90"

Code "G4 P0.25"

Xwp = GetOemDRO(800) + POX
Ywp = GetOemDRO(801) + POY
Zwp = 0

Write #1, Xwp, Ywp, Zwp


If Xwp + stepX < maxX Then
  Code " G91 G1 Y" & stepY & "F" & RapidFeedXY
While IsMoving()
Wend
End If

Xwp = GetOemDRO(800) + POX


Do Until Xwp + stepX > maxX

Code "G4 P0.1"

Code "G91 G31 Z-10 F" & ProbeFeed
While IsMoving()
Wend
Code "G4 P0.05"

Xwp = GetOemDRO(800) + POX
Ywp = GetOemDRO(801) + POY
Zwp = GetVar(2002) - shiftZ + (0.5 * TD)

Write #1, Xwp, Ywp, Zwp

Code "G91 G1 Z5. F" & RapidFeedZ
While IsMoving()
Wend

 
Do Until Ywp + stepY >= maxY

Code "G4 P0.1"

Code " G91 G1 Y" & stepY & "F" & RapidFeedXY
While IsMoving()
Wend

Code "G4 P0.1"

Code "G91 G31 Z-10 F" & ProbeFeed
While IsMoving()
Wend
Code "G4 P0.05"

Xwp = GetOemDRO(800) + POX
Ywp = GetOemDRO(801) + POY
Zwp = GetVar(2002) - shiftZ + (0.5 * TD)

Write #1, Xwp , Ywp, Zwp


Code "G91 G1 Z5. F" & RapidFeedZ
While IsMoving()
Wend


Loop


If Xwp + stepX < maxX Then

Code "G4 P0.1"

Code "G90 G1 X" & Xwp + stepX - POX & "Y" & minY - POY & "F" & RapidFeedXY
While IsMoving()
Wend
Else

Code "G91 G1 Z5. F" & RapidFeedZ
While IsMoving()
Wend


Code "G90 G1 X" & minX - POX & "Y" & minY - POY & "F" & RapidFeedXY
While IsMoving()
Wend

End If


Loop

Code "G90"
Close #1

MsgBox ("Scan File saved as c:\mach3\scan\SCAN-" & Datum & ".txt")


Else
Code "(Probe is active, check setup and try again)"
Exit Sub
End If


                          
« Last Edit: December 13, 2010, 08:21:36 PM by zone023 » Logged
BR549
Active Member

Offline Offline

Posts: 2,555


View Profile
« Reply #6 on: December 13, 2010, 08:58:27 PM »

THere are several thing working aginst you with your approach.

The VB is not in any way synced with the Gcode side so the VB can endrun your Gcode if time is short(and will). and vise versa.

The G4 does not control the wait for the VB side  Sleep() is what you use to control the wait in VB. AND it will be nessesary to use it to help control the flow and wait for updates.

THe G31 is very reliable  and accurate IF used like Graham stated entirley in Gcode.The G31 "does" have a report modual that saves all your points to a file AND is very reliable. (;-) Then that part is control from inside of MACH.

I have probed many 100,000s of points with G31 and the save point files with no errors > Can't say that for the VB side using the G31. Sooner or later something gets out of sync.

Just a thought, (;-) TP
Logged
BR549
Active Member

Offline Offline

Posts: 2,555


View Profile
« Reply #7 on: December 13, 2010, 09:15:13 PM »

Just a note M40 opens the saved points file and G41 closes it when you are all done.
Logged
rrc1962
Active Member

Offline Offline

Posts: 434


View Profile
« Reply #8 on: December 13, 2010, 09:31:37 PM »



The real problem is missing the steps...



You may be missing steps because the PC is busy writing to a file after the G4 finishes.  Mach works best when it is the only thing using PC resources.  In other words, the file write may be taking longer than the G4 is allowing.  You could try increasing the G4 dwell, but personally, I wouldn't be trying to write the file on every G31 move.  Store the coordinates in an array, then when the routine finishes, open the file, dump the array to the file and close the file.
Logged
zone023
Active Member

Offline Offline

Posts: 37


View Profile
« Reply #9 on: December 14, 2010, 06:41:47 AM »

Hi TP and rrc1962,

Thanks for the reply.

I think I am encountering the problems TP describes.
The way the machine acts while running a VB script already gave me the feeling things are not in sync.

As a quick solution I will try writing results to an array while probing and write the array to a text-file when finshed.

But I think probing with .NC g-code will work better after all...
That means I have to learn how to write g-code subs, I guess.
Also writing to variables is new for me... Huh
Of course I will do some searching myself, but is anybody willing to share an example??


Thanks again!

Rich



Logged
Pages: 1 2 3 4 5 »   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!