Home
Downloads
Mach3
Plugins
CAM Post Processors
Screensets
Purchase
Support
Forum
Tutorial Videos
Documentation
Yahoo Group
Mach Wiki
Resources
Contact Us
Links
CNCZone
German Forum
Italian Forum
Korean Forum
Portugese (Brazil) Forum
Russian Forum (RSK CNCROUTER)
Thai Forum
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 25, 2012, 07:40:15 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Select from and to languages
Chinese-simp to English
Chinese-trad to English
English to Chinese-simp
English to Chinese-trad
English to Dutch
English to French
English to German
English to Greek
English to Italian
English to Japanese
English to Korean
English to Portuguese
English to Russian
English to Spanish
Dutch to English
Dutch to French
French to English
French to German
French to Greek
French to Italian
French to Portuguese
French to Dutch
French to Spanish
German to English
German to French
Greek to English
Greek to French
Italian to English
Italian to French
Japanese to English
Korean to English
Portuguese to English
Portuguese to French
Russian to English
Spanish to English
Spanish to French
Machsupport Forum
Mach Discussion
VB and the development of wizards
Help with loop for writing succesive DRO values to .txt
Pages:
1
2
»
Go Down
« previous
next »
Author
Topic: Help with loop for writing succesive DRO values to .txt (Read 978 times)
0 Members and 1 Guest are viewing this topic.
cheech
Active Member
Offline
Posts: 7
Help with loop for writing succesive DRO values to .txt
«
on:
September 05, 2009, 03:33:52 AM »
hello
I'm almost crawling with VB programming. I'd like to create a code that gets the press of a button and writes the DRO's to a file and keeps appending the values as you keep hitting the button.
I did a bit of a search in the forum and read a bit of the "C. Enable" manual. And so far this is what I've got:
Dim fileData As Integer
Dim fileName As String
Dim place As String
fileData = FreeFile
fileName = InputBox("Part file name:", "please name the file...", "", 350,400)
place = "c:\" + fileName + ".txt"
Open place For Output As #fileData
Xcoord = getoemdro(800) 'gets the X axis DRO value, which is motorized
Ycoord = getoemdro(171) 'gets the value of encoder #2 DRO, Y axis carried by hand for measuring rig
Zcoord = getoemdro(172) 'gets the value of encoder #3 DRO, Z axis carried by hand for measuring rig
Print #fileData, "X= ", Xcoord
Print #fileData, "Y= ", Ycoord
Print #fileData, "Z= ", Zcoord
Close #fileData
Can I get a little help with how to create a loop for repeating the getoemdro() method every time the "append" button is pressed? Also is it possible/needed to create a second button that closes the file?, In case I want to create a new file/session.
thanks
cheech
«
Last Edit: September 05, 2009, 04:48:32 AM by cheech
»
Logged
poppabear
S S SYSTEMS, LLC
Global Moderator
Offline
Posts: 1,707
Briceville, TN, USA
Re: Help with loop for writing succesive DRO values to .txt
«
Reply #1 on:
September 05, 2009, 08:06:16 AM »
Here is one I posted up a long while back, it saves both DRO and LED states to a file, you can Modify it for your purposes.
'M1001.m1s Save User DROs and LEDs to file and/or this can run in your macro pump.
UserDROs = 1000
UserLEDs = 1000
'Optional, you can have a Brain using a timer
'that for every 5 minutes or so this file will run again, updating the status.
'OR you can have a SAVE user DROs/LEDs button that will activate this, you would need
'to put this code in your MacroPump for the AutoSave and manual Save to work.
'If GetUserLED(2100) Then 'Optional code see above.
Open "UserDROStates.txt" For Output As #1 ' Open to write file.
For x = 1000 To 2255
DROState = GetUserDRO(UserDROs)
Write #1, DROState
UserDROs =(UserDROs + 1)
Next x
Close #1
Open "UserLEDStates.txt" For Output As #2 ' Open to write file.
For y = 1000 To 2255
LEDState = GetUserLED(UserLEDs)
Write #2, LEDState
UserLEDs = (UserLEDs + 1)
Next y
Close #2
'End If 'optional from the if above for auto save functions
'Enjoy Scott
Logged
Commercial Mach3: Screens (regular and flash), Wizards, Plug-ins, Brains, PLCs, Macros, ATC's, machine build, retrofit and Prototyping
http://sites.google.com/site/volunteerfablab/
cheech
Active Member
Offline
Posts: 7
Re: Help with loop for writing succesive DRO values to .txt
«
Reply #2 on:
September 05, 2009, 07:43:48 PM »
Thanks Scott for the code! I'm having a bit of a hard time to understand it but as I said, I'm not even scratching the surface with programming. I feel dumb actually. But wont give up,
I'm trying to get a bit of a help from a friend to do this, I'll post results
thanks
F.
Logged
cheech
Active Member
Offline
Posts: 7
Re: Help with loop for writing succesive DRO values to .txt
«
Reply #3 on:
December 02, 2011, 05:25:43 AM »
HI, after a looong time, I am back trying to make that code work...
can someone please tell me why this snippet gives a compiler error???
Sub Main
Dim TriggerLED As Integer
TriggerLED = 1005
TriggerLEDState = GetUserLED(TriggerLED)
If (TriggerLEDState = 1)
SetUserLED(TriggerLED,0)
End If
SetUserLED(Trigger LED,1)
Sleep 1000
SetUserLED(TriggerLED,0)
End Sub
What i am trying to do is, with the push of a button, check the state of UserLED(1005) and make sure it is off. Set it to on for half second and set it off..
Basically, I want to toggle the state of the UserLED On/off, for a short period of time.... that so I can use it as a trigger for DRO capture, for probing....
thanks all,
cheech
Logged
BR549
Active Member
Offline
Posts: 2,550
Re: Help with loop for writing succesive DRO values to .txt
«
Reply #4 on:
December 02, 2011, 11:04:12 AM »
WHy not write the dro values directly to the file from the button press?? Press the button and it appends the values to the file
You do know that mach3 already has a POINT file that will run automatically to record your probed points OR are you doing something different
Just a thought, (;-)TP
Logged
cheech
Active Member
Offline
Posts: 7
Re: Help with loop for writing succesive DRO values to .txt
«
Reply #5 on:
December 02, 2011, 06:34:30 PM »
Quote from: BR549 on December 02, 2011, 11:04:12 AM
WHy not write the dro values directly to the file from the button press?? Press the button and it appends the values to the file
You do know that mach3 already has a POINT file that will run automatically to record your probed points OR are you doing something different
Just a thought, (;-)TP
TP I got the idea from monitoring the led from a snippet by popabear, if i remember right. I am not sure how to do it with a button toggle only!??? also, it will be good to see the led flashing for 1/2 sec., the plan it to assign the toggle to the probe, later.
i didn't know about the point file, how doesit work? thanks!
c.
Logged
poppabear
S S SYSTEMS, LLC
Global Moderator
Offline
Posts: 1,707
Briceville, TN, USA
Re: Help with loop for writing succesive DRO values to .txt
«
Reply #6 on:
December 02, 2011, 07:20:13 PM »
see here:
Sub Main
Dim TriggerLED As Integer
TriggerLED = 1005
TriggerLEDState = GetUserLED(TriggerLED)
If (TriggerLEDState = 1)
Then
'you forgot the "then"
SetUserLED(TriggerLED,0)
End If
SetUserLED(TriggerLED,1) 'you had this "Trigger LED" notice space between trigger and LED
Sleep 1000
SetUserLED(TriggerLED,0)
End Sub
'scott
Logged
Commercial Mach3: Screens (regular and flash), Wizards, Plug-ins, Brains, PLCs, Macros, ATC's, machine build, retrofit and Prototyping
http://sites.google.com/site/volunteerfablab/
BR549
Active Member
Offline
Posts: 2,550
Re: Help with loop for writing succesive DRO values to .txt
«
Reply #7 on:
December 02, 2011, 07:47:24 PM »
Issue a M40 that will open and allow you to name the point file.
After the M40 is called any time you call a G31 probe routine the trip points are written to the file.
When you are finished issue a M41 and it closes and saves the point file.
(;-) TP
Logged
cheech
Active Member
Offline
Posts: 7
Re: Help with loop for writing succesive DRO values to .txt
«
Reply #8 on:
December 03, 2011, 04:43:11 AM »
Quote from: poppabear on December 02, 2011, 07:20:13 PM
see here:
Sub Main
Dim TriggerLED As Integer
TriggerLED = 1005
TriggerLEDState = GetUserLED(TriggerLED)
If (TriggerLEDState = 1)
Then
'you forgot the "then"
SetUserLED(TriggerLED,0)
End If
SetUserLED(TriggerLED,1) 'you had this "Trigger LED" notice space between trigger and LED
Sleep 1000
SetUserLED(TriggerLED,0)
End Sub
'scott
thanks scott, bad syntax error. it works!!!!!!!! feels good.
Logged
cheech
Active Member
Offline
Posts: 7
Re: Help with loop for writing succesive DRO values to .txt
«
Reply #9 on:
December 03, 2011, 05:11:32 AM »
Quote from: BR549 on December 02, 2011, 07:47:24 PM
Issue a M40 that will open and allow you to name the point file.
After the M40 is called any time you call a G31 probe routine the trip points are written to the file.
When you are finished issue a M41 and it closes and saves the point file.
(;-) TP
TP, this sounds v. interesting. I need to find out more, mind if i ask questions?
-where do I store the routine? is it a vb file, and can I assign it to a button?
-does mach compensates for the probe tip?
I want to scan 3d surfaces, big objects like surfboards. 100% curves. But I don't need to scan the whole surface ... I only need to scan the the profile, outline and the slices. For the profile and outline I need to sample every 30mm or so, x wise. And for the slices, every 5mm, y wise .
regards, cheech
Logged
Pages:
1
2
»
Go Up
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Mach Discussion
-----------------------------
=> General Mach Discussion
=> Mach3 under Vista
=> Quantum
=> Mach SDK plugin questions and answers.
===> Finished Plugins for Download
=> VB and the development of wizards
=> Brains Development
=> Video P*r*o*b*i*n*g
=> Mach Screens
===> Screen designer tips and tutorials
===> Works in progress
===> Finished Screens
===> Flash Screens
===> JetCam screen designer
===> Machscreen Screen Designer
===> CVI MachStdMill (MSM)
=> Feature Requests
=> Non English Forums
===> Italian
===> French
===> Spanish
===> Chinese
===> German
===> Russian
===> Romanian
===> Japanese
===> Vietnamese
=> FAQs
-----------------------------
*****VIDEOS*****
-----------------------------
=> *****VIDEOS*****
-----------------------------
General CNC Chat
-----------------------------
=> Share Your GCode
=> Show"N"Tell ( What you have made with your CNC machine.)
=> Building or Buying a Wood routing table.. Beginnners guide..
=> Show"N"Tell ( Your Machines)
-----------------------------
G-Code, CAD, and CAM
-----------------------------
=> G-Code, CAD, and CAM discussions
=> LazyCam (Beta)
-----------------------------
Third party software and hardware support forums.
-----------------------------
=> LazyTurn
=> GearoticMotion Preliminary testing
=> Tempest Trajectory Planner
=> Contec
=> dspMC/IP Motion Controller
=> HiCON Motion Controller
=> Third party software and hardware support forums.
=> Galil
=> Newfangled Solutions Wizards
=> Mach3 and G-Rex
=> Mesa
=> Modbus
=> NC Pod
=> PoKeys
=> SmoothStepper USB
=> Sieg Machines
=> Promote and discuss your product
-----------------------------
Tangent Corner
-----------------------------
=> Tangent Corner
=> Competitions
=> Polls
=> Bargain Basement
-----------------------------
Support
-----------------------------
=> Downloads
===> XML files
===> Post Processors
===> Macros
===> Tutorials
===> Others
===> Beta Brains
===> Screen Sets
===> Documents
===> MACH TOOL BOX
=> One on one phone support.
=> Forum suggestions and report forum problems.
-----------------------------
Mach4
-----------------------------
=> Mach4 pre-Alpha Testing
Loading...