Hello Guest it is November 21, 2019, 06:43:35 PM

Author Topic: Export coordinates with machining time in .txt file  (Read 11076 times)

0 Members and 1 Guest are viewing this topic.

Export coordinates with machining time in .txt file
« on: May 16, 2008, 07:49:07 AM »
Dear, Everybody

I saw values of x,y,z coodinates displayed on DROs when the program runs. How can i export all of these values with machining time. Anybody know which function and its using can do that, please tell me. Thank you very much
Best regards.
« Last Edit: May 16, 2008, 07:54:43 AM by vansyle »

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Export coordinates with machining time in .txt file
« Reply #1 on: May 16, 2008, 10:04:22 AM »
If you trying to send the DRO's position values to a file "On the Fly" (while the machine is running), I suspect you would need to do a C++ plug in.
The VB would just not be fast enough, not even close. Also, you would have a HUGE .txt file  since every change of each DRO would be recorded. and written.
I suspect you would need a very fast Computer as well.

scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: Export coordinates with machining time in .txt file
« Reply #2 on: May 16, 2008, 11:18:11 AM »
Thanks for your reply.

My model is very simple (100x100x30mm), and my program includes 30 commandlines. I don't know how to use C++ . I am trying make small program after reading Help.

Sub Main ()

Open "c:\TESTFILE.txt" For Output As #1 ' Open to write file.

 While IsMoving ()

    x = GetOEMDRO (800)
    y = GetOEMDRO (801)
    z = GetOEMDRO (802)
   
    Write #1, x , y, z
 Wend
Close #1
End Sub

And i received x,y,z coordinates but they are repeated many times.
60.263,-66.377,-1
60.263,-66.377,-1
60.263,-66.377,-1
60.263,-66.377,-1
60.263,-66.377,-1
....,....,....
60.064,-66.445,-1
60.064,-66.445,-1
60.064,-66.445,-1
60.064,-66.445,-1
60.064,-66.445,-1
...,....,....
59.856,-66.516,-1
59.856,-66.516,-1
59.856,-66.516,-1
59.856,-66.516,-1
59.856,-66.516,-1
................

Could you help me?     

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Export coordinates with machining time in .txt file
« Reply #3 on: May 16, 2008, 11:34:21 AM »
As I said, your not going to be able to do it in VB, it just runs to slow in mach, Mach only services the VB "updates" once every 1/10th of a second.
Further those DROs are constantly changing since they are tied to the Engine, your Engine is gonna be Running Much, much, much faster than the DRO's can react. Again, the DROs are also updated via Mach3's App loop.

If you want real time, your gonna have to do it in C++, in where you can capture the Axis position as it is written and that loading out to a file. Note, even at 25k, your gonna get a HUGE amound of positional data even for short runs.

Better options might be to take "Snap Shots" in where you have a timer that will capture a "Picture" of Machs current location at a set interval.
If that would be acceptable, then you could probably send out a "Snap Shot" of current movements in a set time frame, if that time frame is = to, or more than Machs Scan time for the VB scripter.

If your just capturing locations out to a file, REMOVE the "While isMoving", I would drop a custom LED that when it is turned on, and you push your "capture coordinates" button, you macro from the button would run, as long as the LED is on (with a Do While UserLED(*********x) .

scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: Export coordinates with machining time in .txt file
« Reply #4 on: May 16, 2008, 10:27:29 PM »
Can you tell us what you are trying to do? Why do you want to save the values, they are already in the gcode that is running.
Re: Export coordinates with machining time in .txt file
« Reply #5 on: May 17, 2008, 04:33:22 PM »
Thanks for your reply,

I want to save these coordinates as input datum of Malab to simulate cutting process. Exactly, I don't need all of coordinates, i only need to "snap" coordinates in interval as Scott said. My Matlab program can make smoothly toolpath from the saved coordinates.

Following Scott, I made a Userled and use pressing button to turn on/off this led as:

test = GetUserLED (1005)
If (test = false) Then
  Call SetUserLED (1005, 1)
Else
   Call SetUserLED (1005, 0)
End If 

And VB Script to save coordinates as:

Sub Main ()
 
Open "c:\TESTFILE.txt" For Output As #1 ' Open to write file.

Do While GetUserLED (1005)

    x = GetOEMDRO (800)
    y = GetOEMDRO (801)
    z = GetOEMDRO (802)     
    Write #1, x , y, z
   
Loop
Close #1
End Sub

The results are similar to previous one. could you help me ?
 

Re: Export coordinates with machining time in .txt file
« Reply #6 on: May 17, 2008, 06:49:57 PM »
OK, now I agree with Scott, you cant do what you want with VB. For that matter, I dont think you can di it with a plug-in either.The problem is that the VB loop is not synchronized with the motor movements. Remember a kind of 'time sharing' is going on here, VB only runs when mach is not busy calculating the trajectory.

When VB gets its time slot to run  it grabs several DRO values in your Do loop, but the number of values is not related to any movements, just whatever happens to be in a DRO at that milisecond. Then, when VB is not running other values pass by that you wont capture.

But Mach is never generating moves that are not driven by the Gcode. So why do you need to grab the DRO values? Just read the Gcode and you will know all the start-end points.

Or are you trying to collect data to see the acceleration along the path?

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Export coordinates with machining time in .txt file
« Reply #7 on: May 17, 2008, 07:10:59 PM »
Ok, I found a way to do it, it is NOT perfect but it may do.

You will need to drop TWO User LEDs on your screen sets One that I called 2101 is the one that is turned off and on, for recording (you called it 1005).  Also as a diagnostic Drop another LED called 2102 this is your Time Capture LED.

This thing runs with two things, ONE is a brain that when you turn on LED 2101 (the record LED), it goes through a timer, the timer pulses at "On" for 0.01 Seconds, and is "Off" for 0.10 seconds. (you can adjust these values to your situation).

Once you hit your Record button, the brain pulses the LED as above, during its short "On" phaze, it will write the data to your file, and in the OFF it will not write the data, BUT note your Macro is running in the background as long as that Record light is on.

Here is the VB Code:

Sub Main ()

Open "c:\TESTFILE.txt" For Output As #1 ' Open to write file.

Do While GetUserLED (2101)
  If GetUserLED(2102) Then     
    x = GetOEMDRO (800)
    y = GetOEMDRO (801)
    z = GetOEMDRO (802)     
    Write #1, x , y, z
  End If
Loop
Close #1
End Sub


THE BRAIN is attached below,

Let me know how it works for you

NOTE: When you open the file, use the slider to see the changes, even though the Pulse ON time is so low, it still writes many rows of identical data, DRAG the slider down, after you run it about 5-6 seconds.
The other LED blinks at the Pulse rate, you have choosen in the Brain ,while the record light is ON. It tells you that your Brain is running as well.

Scott
« Last Edit: May 17, 2008, 07:25:05 PM by poppabear »
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: Export coordinates with machining time in .txt file
« Reply #8 on: May 18, 2008, 05:21:08 AM »
@Scott:
Thanks for your help. I trying with your way but coordinates are still repeated as old one. I tried to increase/decrease Pulse time B / Delay till Repeat C through vaules 1, 0.1, 0.01 / 0.1, 0.001, 2 and run program. The results seem to be influenced by changing these values.

@RonGinger
these values in G-Code are not interpreted by my program. For example: G03 X1.Y2 I2.J3 only expresses  start-end and center points of circular arc, it not expresses the coordinates which tool is going pass on this circle. I want to grab these coordinates in interval and reconstruct circle by my Matlab. Matlab can    make smoothly from received coordinates. Thus, I only need grab interval of coordinates.
Do you know which tool can convert G-Code into coordinate values of X,Y,Z?

Thanks   

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Export coordinates with machining time in .txt file
« Reply #9 on: May 18, 2008, 10:06:32 AM »
If you look at my last post, you will note, that I told you, it still repeat several rows of coordinated until the next change. If you use the "Slider" on the Text file it creates you will see the coordinates change as you scroll down.

This is the Best your gonna get out of VB.  The Engine is running at 25K, (unless your running faster). That is one change per 0.00004 second. When the Brain Pulses (and as far as I am aware the best resoulution your gonna get on timers in Brians is 0.1 seconds, since mach only services the change of I/O from Brains in its normal 10hrtz loop. So during that Pulse ON time, Machs Engine will have changed states (pulse out to Axis) 2,500 times. This means depending on your steps per unit, that it will move some amount. But at any rate, the DROs that report its position are updated only 10hrtz. So the number of indentical "line of Data" repeats, will equal the number of times your computer can do the Write to file function. Note since the Dros only update at 10hrtz, The capture function will be ON for 0.1 second, no matter if you set the Pulse of the Brain less. since even it the setting of the timer was less. The I/O will only change state and Be Read/write ONCE per scan.

So again, if you want better resoultion than that, you will need to do a C++ plug in, The Plug-ins are faster than the "Interpreted" VB. Bottom line though, is the Plug-ins are also only serviced with Machs update loop of 10htz.

You Might be MUCH better off Talking to Brian, OR, looking at the C++ documentation, to see if you can get "Hooks" into the Tool Path display. You could have the Tool path display export out its path to your software. That would indeed show the path of the tool graphically.

Scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/