Hello Guest it is July 04, 2020, 08:45:02 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.


Messages - matt_l

Pages: 1
1
VB and the development of wizards / Re: Programing Question
« on: May 08, 2014, 01:09:46 PM »
I ran into an issue where i was slowly losing counts at high speeds (later realized it was too much weight for the stepper motor to go at those speeds) and i got a script to calibrate an offset of the home values so that all of my points would still line up.  My logic was that I know that there is some error in my position relative to home (or is not even homed) and by looking at the home flag variable i was able to home the axies fairly well.  For the homing process i just moved the x axis to the right at 10mm steps till home flag was active then moved to the left by 1mm steps till it was inactive, then moved it to the right at 0.1mm steps till it was active and finally to the left at 0.01mm steps till it was inactive.  Save current position as new_home and then when ever you want to move relative to it you just subtract the new_home position form where you want to go.

Flags for homing, may be different numbers on yours but easy to find.
x-axis GetOEMLED(830)
y-axis GetOEMLED(833)
z-axis GetOEMLED(836)

If you would like i can try and dig up the old code i used ofr this, not sure if i still have it though.

Matt

2
VB and the development of wizards / Re: VB Coding help
« on: May 05, 2014, 08:01:15 PM »
it is a bit of a dry read but thankfully [crtl]-F works in it.
http://www.machsupport.com/wp-content/uploads/2013/02/VBScript_Commands.pdf

Hope fully the comments explain a bit of what is going on here then. A single quote ' is the standard ascii character for comments in mach3 so ill use them for comments.  Hopefully the spaces make it a bit easier to read too.


sub tap(byval zstart as double,byval zend as double,byval zinc as double,byval dwell as double,byval speed as double) ' sub is asking for the start height, end height, the increment distance, dwell time and speed of movement to be given to it.

dim zpos as double ' i am defining a variable called zpos and the current z location so that i do not edit the variable i am given at the start
zpos = zstart ' set zpos to be zstart if zstart is too high up it will take a while so set it close to the material.

while zpos >= zend ' will continue the loop until the desired position is less than or equal to the end position
  code "g01 z " & zpos & " f " & speed ' Gcode to move to current z location at specified speed
  while IsMoving() ' IsMoving() is true while the cnc is in motion, it is needed since your dwell sleep would start as soon the movement starts if this was not blocking
    sleep(10) ' pause for small amount of time, you will acutlaly dwell there for your dwell time and an extra amount of time any where between 0 and 10ms
  wend
  sleep(dwell) ' your dwell time
  if zpos = zend then ' checks to see if it is at the final location, and if so it decrements it one more to make while loop stop
    zpos = zend - 1
  elseif zpos > zend then ' if zpos is still greater than zend
    zpos = zpos - zinc ' change zpos by the defined amount
    if zpos <= zend then ' check to see if zpos was decremented too far and if it was set it to the end value
      zpos = zend
    endif
  endif
wend

end sub

3
Eric-
I have not tried using different sub routines to try to force it to not progress to the next block unless all parts of the subroutine have finished.  The way you have it written with the specified delays between the subroutines assumes that everything will be completed within that amount of time which may not always be true.

Ian-
I had looked at the OLE automation but didn’t realize that this could be done with it. Your method works like a charm.  Just wish i had found it before i wrote a mach3-python timing scheme.

for what is is worth I might at least share the work around i used in case someone else has an issue that this works for.
Start Mach3 running a while true loop and have it look at a file, and when the file says "ready" do nothing but if it says something else copy the line in and execute it as Gcode.  In parallel have a python script running that looks at the same file and if it says "ready" write the next line of Gcode into the file.  Then just build your script to rely on python’s ability to control timing.

objResult = objShell.Run("notepad.exe", 1, True) BLOCKs
objResult = objShell.Run("notepad.exe", 1, False) Does not BLOCK

4
VB and the development of wizards / Re: VB Coding help
« on: April 28, 2014, 03:00:55 PM »
this will do the move and dwell, all in lowercase, but that is just how i prefer to type, note dwell is in ms. there may be soem erros as i hav enot tested this but the logic is there to do it.

sub tap(byval zstart as double,byval zend as double,byval zinc as double,byval dwell as double,byval speed as double)
dim zpos as double
zpos = zstart

while zpos >= zend
code "g01 z " & zpos & " f " & speed
while IsMoving()
sleep(10)
wend
sleep(dwell)
if zpos = zend then
zpos = zend - 1
elseif zpos > zend then
zpos = zpos - zinc
if zpos <= zend then
zpos = zend
endif
endif
wend

5
I was figuring I would have to do something like that or just make a command line interface to use Gcode to resolve the timing issue.  I have searched these forums a fair bit and have never seen a mention of how the Macro language and Gcode interact, is there any documentation on it?

6
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