Hello Guest it is April 26, 2024, 12:29:13 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - matt_l

Pages: 1
1
VB and the development of wizards / File I/O being called out of order
« on: April 25, 2014, 02:10:14 PM »
First off I am not using the Mach3 to cut things, I am using it to interact with a device and looking at response from the Mach3 stimuli in real time, so what I am trying to do will sound a bit odd.
I am trying to move the robot and at certain locations to have certain scripts called by the Mach3 and run file commands.  I have attached a screen shot of my current settings.

Below are some subs I will use to try to illustrate my issues.

Sub test1
Dim temp As Double
code "g01 x 10 f 40"
While IsMoving()
sleep(10)
Wend
Shell("notepad.exe")
code "g01 x 0 f 40"
temp = FileLen("c:\temp\test.txt")
Print temp
End Sub


Sub test2
Dim temp As Double
code "g01 x 20 f 40"
Shell("notepad.exe")
code "g01 x 0 f 40"
temp = FileLen("c:\temp\test.txt")
Print temp
End Sub


Sub test3
code "g01 x 20 f 40"
sleep(5000)
code "g01 x 0 f 40"
End Sub

When I run “test2” as soon as the robot starts to move I get notepad opening as well as mach3 opening a dialog box displaying the length of “c:\temp\test.txt”. It just executes all of the non-movement commands as it is executing the movement commands.  I am trying to look at the file length at specific parts of the robots motion, so I need to be able to specify when to read the file length.  In “test1” I am able to prevent the execution of the non-movement commands by using a while loop that exits when the first movement stops, but during the second movement all of the non-movement commands are called.  However I need to perform a movement then run a script, and ten seconds after the first script is finished run a second script, then allow movement once the second script has finished, since there is no movement occurring during the first script I have no way to time between the first and second script correctly or the ability to prevent movement until all scripts are completed.  In “test3” the sleep command has no effect since the first movement takes longer to complete than the sleep time, I have noticed that if sleep commands are put sequentially it does delay for each one separately. 

All of my issues seem to boil down to one question.
How do I enable a “wait until line is finished” type of logic into movement and non-movement commands?


Pages: 1