Hello Guest it is December 09, 2021, 09:32:07 AM

Author Topic: Using VB script to wait for an external event and then execute G code  (Read 27003 times)

0 Members and 1 Guest are viewing this topic.

Re: Using VB script to wait for an external event and then execute G code
« Reply #30 on: October 10, 2008, 07:59:28 AM »
I've ordered a dual relay board.  That way I'll be able to turn off the power to the spectrometer _and_ the power to the motor controller card.  I'll report back after it arrives and I've installed/tested.
Re: Using VB script to wait for an external event and then execute G code
« Reply #31 on: October 14, 2008, 06:55:46 PM »
The little breakout relay board arrived today.  It only took a short while to get it wired up.  It worked on the first try.  I have added some buttons to the screen to control the relays manually (even got an LED to turn on and off, which is very basic, I know, but it was pretty advanced for me).  I then added some code to the macropump to turn off the power to the motors (not the controller board) and the laser power once the files have reached 96 (the end) and the probe has returned to the home position.  It took me much longer to do the code because it was pretty much trial and error, but it works.

It all seems to function well.  I may try to add some extra features now such as the option of running two or three plates at one time instead of just one.  Overall the system seems to function quite well and is pretty robust so far.  And now I have saved myself a lot of money because I won't have to replace the laser as soon  :D

Thanks, y'all for your help on this.
Re: Using VB script to wait for an external event and then execute G code
« Reply #32 on: July 06, 2016, 11:47:58 AM »
Hello Octathorpe and Jason,
How and where did you put this code? Did you add it in the macro file? It is an interesting project and I am planning to implement similar system as well.

Jason totally Rocks!

I have added a blerb of script to do the movements, and (amazingly), it worked!

Since this is running as a macropump and goes through and then restarts, it isn't necessary to have logic for stepping through the spots in sequence, all that has to be done is just move X + 9 unless the end of a row has been reached.  This is easly figured out based on the number of files. 

If anyone has comments please let me know, otherwise I'll put it on the actual machine today and see what happens.
----------------------- (code below - I coudn't figure out how to make the 'code' box)

'for all cases not described in select below set move to be X+9

MoveX = GetOemDRO(800) + 9
MoveY = getoemdro(801) + 0

'for the special cases at end of rows override previous settings

Select Case  GetFileCount
  Case 12   
    MoveY = getoemdro(801) - 9
    MoveX = GetOemDRO(800) - 99
  Case 24
    MoveY = getoemdro(801) - 9
    MoveX = GetOemDRO(800) - 99
  Case 36
    MoveY = getoemdro(801) - 9
    MoveX = GetOemDRO(800) - 99
  Case 48
    MoveY = getoemdro(801) - 9
    MoveX = GetOemDRO(800) - 99
  Case 60
    MoveY = getoemdro(801) - 9
    MoveX = GetOemDRO(800) - 99
  Case 72
    MoveY = getoemdro(801) - 9
    MoveX = GetOemDRO(800) - 99
  Case 84
    MoveY = getoemdro(801) - 9
    MoveX = GetOemDRO(800) - 99
  Case 96
    MoveY = getoemdro(801) - 63
    MoveX = GetOemDRO(800) - 99
end select

'Move Y
Code ("G1 Y" & MoveY)
'Move X
Code ("G1 X" & MoveX)