Hello Guest it is September 17, 2019, 09:16:05 AM

Author Topic: Mach3 VB Script Help  (Read 12573 times)

0 Members and 1 Guest are viewing this topic.

Offline RICH

*
  • *
  •  7,358 7,358
    • View Profile
Re: Mach3 VB Script Help
« Reply #30 on: February 11, 2016, 06:01:37 PM »
Relative to    While Ismoving ()  and Wend        there is a rather long thread / discussion  about it.
Can find my notes on that thread or the thread itself. No I don't remember all the specifics.

BR549, ring any bells???

RICH

Offline BR549

*
  •  6,887 6,887
    • View Profile
Re: Mach3 VB Script Help
« Reply #31 on: February 11, 2016, 06:02:06 PM »
Now another thing Sleep() is NOT just about waiting it also frees up teh CPU during a wait state and can allow OTHER processes to run while the wait is going on OTHERWISE teh wait can HOG all teh CPU resources and nothing else can happen.

(;-) TP

Offline RICH

*
  • *
  •  7,358 7,358
    • View Profile
Re: Mach3 VB Script Help
« Reply #32 on: February 11, 2016, 06:04:12 PM »
Your summarizing nicely Terry........ :-*

RICH

Offline BR549

*
  •  6,887 6,887
    • View Profile
Re: Mach3 VB Script Help
« Reply #33 on: February 11, 2016, 06:16:10 PM »
hIYA RICH. There were MANY discussions on it in past years.  BUT seeing how it will never ever be worked on again I don't see any point in cranking the discussion back up again. (;-)

(;-) TP

Offline RICH

*
  • *
  •  7,358 7,358
    • View Profile
Re: Mach3 VB Script Help
« Reply #34 on: February 11, 2016, 06:26:40 PM »
Understand, don't want a discussion on it, but said differently, If one scripts  the ....following....things will work as intended......well for later versions of Mach anyway.

Carry On, ;)

RICH
Re: Mach3 VB Script Help
« Reply #35 on: February 11, 2016, 06:30:48 PM »
OKAY OKAY So I was wrong my bad. I guess I have alot of reading up to do on this.

So BR549, Are you saying a Sleep() function is better to use than While IsMoving() Wend, because it will allow the Previous lines to finish executing?

Also, Do I need to recall G91 after I call a G0? Or is calling G91 once at the start okay?

Hows this

Code: [Select]
Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G91"
Code "G31 X-7 F8"   
While IsMoving()
Wend                                         
X1 = GetVar(2000)
While IsMoving()
Wend                                   
Code "G0 X" & .98*X1               
Code "G31 X7 F8"
While IsMoving()
Wend
X2 = GetVar(2000)
While IsMoving()
Wend   
Xc = (X1 + X2)/2
Code "G0 X" & XC       'as well is calling a variable in a code line acceptable? Need help with these lines
Code "G31 Y-3 F8"
While IsMoving()
Wend
Y1 = GetVar(2001)
While IsMoving()
Wend
Code "G0 Y" & .98*Y1
Code "G91 G31 Y3 F8"
While IsMoving()
Wend
Y2 = GetVar(2001)
While IsMoving()
Wend   
Yc = (Y1 + Y2)/2
Code "G0 Y" & Yc   
Code "G31 X-7 F30"
While IsMoving()
If X<.95*X1 Then SetFeedRate(F2) 
Wend
X1 = GetVar(2000)
While IsMoving()
Wend
Code "G0 X" & .98*X1   
Code "G31 X7 F30"
While IsMoving()
If X>.95*XMax Then SetFeedRate(F2)
Wend
X2 = GetVar(2000)
While IsMoving()
Wend   
Xc = (X1 + X2)/2
Code "G0 X" & Xc     
ode "G31 Y-3 F30"
While IsMoving()
If Y<.95*YMin Then SetFeedRate(F2)      '<--- Do I need the () of While IsMoving to be around my If Then? Or is just before the Wend okay?
Wend
Y1 = GetVar(2001)
While IsMoving()
Wend
Code "G0 Y" & .98*Y1
Code "G31 Y3 F30"
While IsMoving()
If X>.95*YMax Then SetFeedRate(F2)
Wend
Y2 = GetVar(2001)
While IsMoving()
Wend     
Yc = (Y1 + Y2)/2
Code "G0 Y" & Yc 
SetDro(XaxisDRO,0)
SetDro(YaxisDRO,0)
Code "G0 G53 Z-4" 
Message "Circle Center Found"
« Last Edit: February 11, 2016, 06:47:46 PM by nissan20det »

Offline BR549

*
  •  6,887 6,887
    • View Profile
Re: Mach3 VB Script Help
« Reply #36 on: February 11, 2016, 06:36:31 PM »
Another thing to keep in mind IS Mach3's scripting language is Cypress Basic . It is NOT Visual Basic(VB) 

(;-) TP

Offline RICH

*
  • *
  •  7,358 7,358
    • View Profile
Re: Mach3 VB Script Help
« Reply #37 on: February 11, 2016, 06:38:21 PM »
Nissan......,
Not saying your wrong / whatever.
Rather,
Trying to get some of the knowledge available to you for the script.
You'll be even more dangerous than me in no time at all,  :D

RICH
 
Re: Mach3 VB Script Help
« Reply #38 on: February 11, 2016, 07:07:36 PM »
LOL Rich no offence taken at all bud! Just saying I know my place here... I got alot to learn C++ is way different
Re: Mach3 VB Script Help
« Reply #39 on: February 11, 2016, 07:12:19 PM »
Okay this doesnt work I'm in test phase as we speak.... touches and stops great but the last line doesnt work it just keeps going + forever

Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G91"
Code "G31 X-7 F8"   
While IsMoving()
Wend                                         
X1 = GetVar(2000)
While IsMoving()
Wend                                   
Code "G0 X" & X1*.98

Do I need a X3?

X3 = X1 * .98
then
Code "G0 X" & X3

???



okay this worked

Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G91"
Code "G31 X-7 F8"   
While IsMoving()
Wend                                         
X1 = GetVar(2000)
While IsMoving()
Wend
X3 = X1*.90                                   
Code "G0 X"&X3         
End If

easier way?
« Last Edit: February 11, 2016, 07:20:12 PM by nissan20det »