Hello Guest it is April 25, 2024, 06:03:06 PM

Author Topic: How to halt a script halfway & wait for a user entered CR?  (Read 7114 times)

0 Members and 1 Guest are viewing this topic.

How to halt a script halfway & wait for a user entered CR?
« on: November 14, 2011, 06:41:17 PM »
I'm new to all this, presently trying to get my XY cordinates to move between the cutter & the webcam...my end goal is, press a contour shuttle pro button....my script kicks.....

1. Store the present XY coords
2. Goto a known webcam offset (ie locate the webcam immediately above where the tool just was)
3. Jog around a bit (to align webcam crosshair over a pcb index mark)
4. Once I'm happy with the alignment, I then hit carriage return on the PCB keyboard.
5. Use the offsets as per step 2 (but now in reverse) to put the tool where the webcam has just been
6. Restore the XY coords that were stored away in step 1.

The cutting is now exactly over the pcb index mark with the correct XY starting coords.


It the bits in steps 4 that I need a bit of coop ....what's the easiest way to get the VB script to wait until say a CR is pressed on the PC keyboard?

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: How to halt a script halfway & wait for a user entered CR?
« Reply #1 on: November 14, 2011, 07:07:55 PM »
Seems like a lot of useless moving around, when the g-code will do it for yoy.

If you're g-code X and Y zero positions are where the crosshair is, all you need to do is this:

XOffset = 3.5   'X offset from webcam crosshair to spindle
YOffset = 4.0   'Y offset from webcam crosshair to spindle

SetOEMDRO(800,XOffset)
SetOEMDRO(801,YOffset)


This will set your tools 0,0 position where the webcam crosshair is. The g-code should move it into cutting position.

You don't need to wait for the CR. Just jog until the webcam is in position, run the macro, then run your g-code.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: How to halt a script halfway & wait for a user entered CR?
« Reply #2 on: November 14, 2011, 07:22:36 PM »
Thanks...I will certainly use that where the registration mark can be made to be 0.0, but what if the registration mark etched onto the the pcb is not 0,0?

How I envisage this working....

load g-code file
Press run....tool then moves to the first position - the registration mark (could be any coord...not necessarily 0,0)
Stop the cycle
run my macro...present coords get stored, webcam offset kicks in, webcam gets aligned by user ...user then hit cr to return, tool now gets placed where the webcam was, original coords get restored - continue the original run cycle.
« Last Edit: November 14, 2011, 07:24:17 PM by peskywinnets »
Re: How to halt a script halfway & wait for a user entered CR?
« Reply #3 on: November 14, 2011, 07:49:07 PM »
I also want to use this same macro as essentially a 'tool tip' birds eye view utility....at any point during my CNC session (not just a 0,0 position), I can then run a macro & the webcam which will go to where the tool was .....once I've had a peek/confirmation & am happy, hit CR and the tool restores itself to those particular coords.
« Last Edit: November 14, 2011, 07:50:49 PM by peskywinnets »

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: How to halt a script halfway & wait for a user entered CR?
« Reply #4 on: November 14, 2011, 07:59:11 PM »
Quote
Press run....tool then moves to the first position - the registration mark

So the tool starts where you want it, then you want to move the webcam where the tool was, and set an offset so the tool is back where it started from???? either I'm not understanding you, or you're not explaining it right.

OK, I think I figured it out while typing this. Maybe not??

Does the first g-code move have the coordinates of the registration mark? I think it has to for this to work.

If so, I think you might need 2 macros. How about turning on Single Step mode, and running until you get to that point. Run the first macro to store the position in variables. Then, turn off single start mode, jog to position with the webcam, and run the second macro, which can retrieve the position from the variables, change the offsets, and resume cutting. The second macro could even turn off single step for you.

I think it would be far easier to have your registration mark always be 0,0, though.

Perhaps someone else has a better idea that I'm not aware of.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: How to halt a script halfway & wait for a user entered CR?
« Reply #5 on: November 14, 2011, 08:14:34 PM »
This is first  stage 1 of an overall endgame...the endgame is to save a whole heap of time meddling about with indexing dowel pins so that my prior etched pcb is aligned accurately & can be depaneled (the inspiration was this video - http://www.youtube.com/watch?v=JJnenOsbCzU&feature=player_embedded - but he's using his own cnc software)

At the minute, here's what I'm doing wrt making pcbs...

Etch a pcb (with known index marks) - drill the index marks out with a 3mm drill (not easy due to human parallax error)
proceed to cnc machine.....load a drill file to drill 3mm holes at the known index marks.
Pop some dowel pins into the drill holes
Now place the pcb over the pins - board is now aligned (maybe - see above re parallax errors!)- pcb board 'outline' cutout can begin

For all it reads quick...it's time consuming!


where I want to get to....

Etch a pcb with known index marks (no need to drill them out)
proceed to cnc machine....clamp board down roughly (ie doesn't need to be accurately aligned)
Run macro - align webcam over 1st index mark (no parallax error)....cnc machine now knows say 0,0  (which your earlier code will do nicely for)

Ok, this is the bit I haven't mentioned but is step 2 (have to nail tha few simpler macros first ...so hence the softly softly approach to this)

Now we have 0,0 sorted ......move to another known coordinate with the webcam - and Mach3 the works out the angle of rotation.
pcb outline cutout can begin.

So I'm eliminating a few time intensive steps (drilling out the pcb, drilling some dowl pin holes, placing in dowel pins, etc) & potential for parallax errors by loosely clamping the pcb & then having a webcam & couple of webcam alignment macros do the legwork.

But like I say, I'm new to VB scripts (and G-Code come to that)...so my initial step is a tool tip view...where I can jump to where the tool was located & back again (with maybe some jogging about to align in between - hence wanting the 'wait until use presses CR' question which started off this thread)
« Last Edit: November 14, 2011, 08:21:30 PM by peskywinnets »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: How to halt a script halfway & wait for a user entered CR?
« Reply #6 on: November 14, 2011, 08:41:57 PM »
There is no macro restart function with CR in Mach CB.

Have you tried the Set Rotation Wizard to align the board??

I think you asked about this before.

(;-) TP

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: How to halt a script halfway & wait for a user entered CR?
« Reply #7 on: November 14, 2011, 08:57:08 PM »
If I were to do this I would first start off by setting up 2 fixture offsets to handle the switching between the camera and the tool.

I would set up say G56 as the camera offset and G55 as the tool offset.

Mount the board, switch to the G56 offset load the set rotation wizard.

Run the routine to set the rotation angle.

Close the wizard

Jog over to the reference point and set the coords X/Y to whatever they are

Next Switch fixture offsets over to the G55 and you are ready to cut.

IF you had a LOT of them to do a dedicated Macro would be best but that will get you going until you can figure out the Macro code you want.

THe CB code to do the Rotation angle is IN the wizard button. You can use it for the hard part(;-).

Just a thought,(;-) TP
Re: How to halt a script halfway & wait for a user entered CR?
« Reply #8 on: November 15, 2011, 03:21:48 AM »
Yes
There is no macro restart function with CR in Mach CB.

Have you tried the Set Rotation Wizard to align the board??

I think you asked about this before.

(;-) TP

Yes, you're right I queried about the rotation wizard earlier ....but that's not what I'm on about here, what I'm on about here is learining a little more about writing my own scripts & getting a tool tip view VB script script going down.

I guess I could use a dummy text entry....ie where Mach3 prompts a user for input text entry then just discard the entry?

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: How to halt a script halfway & wait for a user entered CR?
« Reply #9 on: November 15, 2011, 10:41:41 AM »
One problem with that is when you open the CB querry window you are locked out from MACH3 and most time cannot jog or do anything in Mach3 until you have release the querry window by answering the question (Catch22).

There IS a way to stop mid prgrom and then return but it involves another screen button to release the hold function.  Stirling cam up with it a while back.

(;-) TP