Hello Guest it is March 28, 2024, 09:02:39 AM

Author Topic: Writing coordinates to a file  (Read 7863 times)

0 Members and 1 Guest are viewing this topic.

Writing coordinates to a file
« on: May 05, 2008, 12:45:24 AM »
Ok, so I got Mach3 setup to my mill table, and use a ModIO which I hooked up a laser displacement sensor mapped through an analog input to a DRO (haven't figured out which one yet, so just using the manual feed override DRO as instructed in the tutorial videos.

I'm just stuck ion two more points and was wondering if anyone could offer any advice.

First off.......Can I map an analog input to a DRO such as my A-axis readout on the main screen?? 

Second.......is there a tutorial around that demonstrates how to take the X, Y and Laser displacement value and write them to a file??    I'm a VB.net guy, so the legacy vb is a bit rough for me, but I'm looking for something very similar to the digitizing wizard, but instead of the Z value, it would record the analog input.

Any advice?? 

Thanks a lot, this program is killer and I plan on making my purchase soon!


Dan

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Writing coordinates to a file
« Reply #1 on: May 05, 2008, 12:53:41 AM »
Quote
First off.......Can I map an analog input to a DRO such as my A-axis readout on the main screen?? 

I think you could do this with a brain. There are videos in the video section about brains.

Brett
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Writing coordinates to a file
« Reply #2 on: May 05, 2008, 08:21:32 AM »
Ok, I do see this with assigning the termination to a DRO.   Is there any function of BRAINS to do writing to a file, or is that only done with VB script??  I did find the syntax for creating a writing a file, but in the videos it says BRAINS are much faster, but if that's not an option, I'll go ahead and do the VB script for the file operation.

Thanks for the heads up!



Dan

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Writing coordinates to a file
« Reply #3 on: May 05, 2008, 09:38:18 AM »
I'm not sure so you may want to wait on someone who is. I think to write to a file you'll have to do that in VB or maybe flash.

Brett
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Writing coordinates to a file
« Reply #4 on: May 05, 2008, 07:43:45 PM »
File I/O is pretty basic in VB, to make a bad pun. Something like:

open "filename.txt" For Output as #1
Write #1 "some junk in the file"
Write #1 Xval, Yval
Close #1

There is a complete Basic manual on this site under the documents section.
Re: Writing coordinates to a file
« Reply #5 on: May 08, 2008, 10:24:09 AM »
Ok, well I was able to get the laser sensor reading my distance with surprisingly good accuracy to a DRO on the main screen.  I still haven't figured out how to override the z-axis  value since my z-axis isn't really moving, but I went ahead and made the z-axis scale DRO as my measurement in mm.

So after looking at the digitize wizard, I've noticed the following:

- I could modify the script to take out the z-axis plunging.
- Since there is no way to modify the G31 and DigitizeFile settings (or is there?), I remove the digitize open file (M40) code
-With the above in thought, I also remove the G31 code within the macro.
-I make my own M##.m1s file that I can call from within the g-code
-In this macro, it opens the file for appending.........and adding the x, y and z coordinates, then closes the file.
-GCode moves my laser to the next coordinate.
-My custom M##.m1s file is run again

and so on


I would LOVE to test this, but I'm at work.    Is there anyone that can confirm this for me just from experience?  I've a serious CNC noob, but actually a software developer by trade, so I'm constantly thinking of this.  I'm having to learn vb-script as it's a bit different from vb.net, but it's not too bad.

Thanks again for the help.

Dan
Re: Writing coordinates to a file
« Reply #6 on: May 08, 2008, 11:34:20 AM »
Ok, well I tried running an M-code macro from within the g-code and it just stops and I have to hit "Cycle Start" again to get it to move to the next coordinate.

is it better to run a vb macro from gcode?

Or is it better to run G-Code from a vb script?
Re: Writing coordinates to a file
« Reply #7 on: May 09, 2008, 08:38:38 PM »
Any macro can be a VB function and it should run fine. It should not require a Cycle Start unless something in the macro causes a stop.

It is fine to run gcode form VB scripts, many wizards do that.

What is not allowed is for a VB macro to call another VB macro. I think that causes strange hang conditions.

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Writing coordinates to a file
« Reply #8 on: May 22, 2008, 10:53:09 AM »
Here is a Coordinate capture Macro I just helped a guy with.

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

oldX = GetOEMDRO (800)
oldY = GetOEMDRO (801)
oldZ = GetOEMDRO (802)

Write #1, oldX , oldY, oldZ
While GetUserLED (1005)

     newx = GetOEMDRO (800)
    newy = GetOEMDRO (801)
     newz = GetOEMDRO (802)     

if oldX <> newX or oldY <> newY or oldZ <> newZ Then
  oldX = newX
  oldY = newY
  oldZ = newZ
  Write #1, oldX , oldY, oldZ
 
     End If
Wend
Close #1
End Sub

Here is the "Brain" that goes with it.

What it does, is the Brain "Strobes" and LED at a set interval (you can modify the timer in it for your situation), when it goes to ON, the Write coordinates will execute. (NOTE you have to have another on/off button with a Control LED, that you use as your Record Function.

The code it self will compare, coordinates and only update changed coordinates in the file.

In your Case you can ADD or Change the Z value to "GetUserDRO(*********x)" that is the DRO where you are dropping your Analog value.

Further:  You can have that Analog value dynamically control the Z axis hiegth, through Brains as well. (If you need to do that). You would "0" your Z axis to some minimum hiegth. Then the Analog value Range would scale through a formula in brains and that result would goto another Terminator UserDRO. This would be units, above your "0" point.  Then I would in the Macro pump, put in a statement to grab this dro and put those units into a movement Code for your Z. (I would probably put another Control LED in there that would allow me to turn on and off that ability).  Since it would be running in the Macro pump it would execute anywhere from 4-10 hrts frequency (depending on your comps speed, and if you already have other Macropump overhead issues.

Scott
fun times
Re: Writing coordinates to a file
« Reply #9 on: June 01, 2013, 12:09:55 AM »
phnxgold30,

Have you made any further progress with this matter? I am trying to develop and create my own laser digitizing system and have ran into the same road blocks.