Machsupport Forum

General CNC Chat => Show"N"Tell ( What you have made with your CNC machine.) => Topic started by: Tweakie.CNC on November 14, 2012, 07:55:50 AM

Title: Isolation Routing PCB's and Local System Rotate.
Post by: Tweakie.CNC on November 14, 2012, 07:55:50 AM
When Isolation Routing double sided PCB’s I drill two holes in the PCB blank (one is the datum and one the reference) to locate the work on two pins in the spoil board on the machine. This method enables good location of the tracks when machining each side and also for hole drilling etc. (always using the same datum point for X zero /  Y zero).

After reading this post and watching the video http://www.machsupport.com/forum/index.php/topic,22555.0.html  I thought I would try visual location of the datum and reference holes (using my cross hair pointer) and use ‘Local System Rotate’ just to see if it was an easier method.

Then using 3 CB buttons (at the bottom of my Mach screen) it is as easy as ABC. Well it’s almost that easy.  :)
Obviously this was only experimental so it is bit of a ‘quick & dirty’ solution and it needs work to tidy up the user interface side of things but it works.

Basically…

Button A turns on the cross hair pointer, sets slow jogging and brings up the status message ‘Locate Datum then click Button B’

Button B resets X and Y axis DRO’s to zero and brings up the status message ‘Locate Reference then click Button C’

Button C is where the calculation takes place – the current X and Y axis position (reference) is used to calculate ArcTan of the angle which is then used to set the Local System Rotate. The offset between the cross hair pointer position and the spindle position is factored in and the X and Y axis moved to bring the spindle to the datum position. Jog speed is reset to normal etc. and the status message ‘Complete’ is displayed.

As it turns out this method works very well and in operation is an equivalent to the system used in the aforementioned video. It can handle any rotation or position of the work (within + / - 90 degrees).
Although the accuracy I achieved is acceptable it could definitely be much improved by using a webcam for the hole location and Klaus’s video window (camera plugin). http://www.kd-dietz.com/klausphp/pages/ger/plugins/webcam/description/wcam_description.html

It is not a quicker method than my existing system of using the two dowel pins but it may have advantages with odd shaped circuit boards and possibly alteration of existing boards so definitely warrants further investigation.

My next step – fit a webcam to the Z axis.   ;D ;D

A short video of the result  http://tweakie.byethost10.com/rotate1.wmv

Tweakie.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Chaoticone on November 14, 2012, 02:13:57 PM
Very Good Tweakie!

Brett
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Sam on November 15, 2012, 12:06:53 AM
Pretty cool, Tweaks. Looks like you've got it figured out pretty good. Amazes me how you are able to do all the things you do. I can't even get the necessities done! "Limit switches you say? Pfffffttt... it can wait." I read about this in the digital sample issue of Digital Machinist. They have a really nice writeup on Mach 3 "How Mach 3 Continues To Amaze Me". It's a really good read, very informative. Even gives ya the VB code for several routines.
http://digital.turn-page.com/issue/17465 (http://digital.turn-page.com/issue/17465) If your interested.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Tweakie.CNC on November 15, 2012, 12:11:06 PM
Thanks for the info Sam, much appreciated.

A Question...

Is there any way to increase the resolution (currently 0.1 degrees) of the Mach3 ' Local System Rotated' DRO as this appears to be my major stumbling block (as far as accuracy is concerned) ??

Tweakie.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: BR549 on November 15, 2012, 05:08:09 PM
Tweakie you can change the resolution of the dro with MachScreen. I have mine set to

0.0000 degs

(;-) TP
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Tweakie.CNC on November 15, 2012, 06:26:11 PM
Many thanks Terry, I will give that a try.  8)

Tweakie.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: patter on November 17, 2012, 12:23:09 PM
Great work Tweakie....thank you.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Tweakie.CNC on November 24, 2012, 12:13:35 PM
WELL - fitting a USB webcam to use with the on-screen video window could be considered akin to playing the lottery – you pay your money and take your chance. I had to smile when one member commented that ‘plug and play’ should be renamed ‘plug and pray’.

As the saying goes ‘third time lucky’. After two unsuccessful attempts the third ‘plug and play’ webcam works perfectly on both my desk PC and machine PC with either Brian’s or Klaus’s video window. So now, still using the same 3 buttons, Button A opens the video window and prompts for the Datum to be located, Button B prompts for the Reference to be located and Button C closes the video window, performs the calculation, sets the Local System Rotated and moves the spindle / tool to the Datum position.

This has proved much easier and quicker than using the cross-hair pointer so I now have some more work to make this a permanent addition to my machine.

(Incidentally the cross-hairs in the video window were in the process of refresh at the instant the first snapshot was taken which is the reason they are not actually showing in the pic.).

Tweakie.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Picengraver on November 24, 2012, 04:37:53 PM
Well done, Tweakie.

What web cam did you use?  I will add one to my laser diode machine to locate the edges of material and establish center points for image burning.  No more pencil and scale  :)

Thanks much,
John Champlain
www.picengrave.com 
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Tweakie.CNC on November 25, 2012, 02:09:57 AM
Hi John,

This is the webcam (endoscope) that I finally used. It is from China and available via ebay for < £20 UKP.

Tweakie.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Picengraver on November 25, 2012, 05:30:50 AM
Thanks Tweakie,
Just ordered one.
John
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Ody on November 25, 2012, 11:02:19 PM
Is there a link for the one you bought?
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Picengraver on November 26, 2012, 07:49:18 AM
I purchased from a seller on eBay.  Since I have not received it yet, I am hesitant to post a link to a specific seller as a recommendation.  Just do a search on "endoscope" and lots of choices will be displayed.

Regards,
John Champlain
www.picengrave.com
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Tweakie.CNC on November 26, 2012, 08:31:21 AM
This is the 10mm diameter webcam and home made mounting bracket ready to be fitted to my Z axis.

Tweakie.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Tweakie.CNC on December 01, 2012, 04:24:59 AM
I have just discovered a problem with my particular little webcam – it appears that the guts are assembled to the cable then drawn into the housing and only secured at the cable exit end. When fitted to the machine, if the cable is moved (twisted) the internal image sensor can rotate slightly thus spoiling the accuracy of the positioning / setup.

My solution was to remove (destroy) the front window, apply a couple of spots of adhesive to secure the image sensor PCB to the housing then fit a new window (it was doubtful if the existing window could be removed without damaging it). There is probably a better (easier) way to solve this problem but the image sensor PCB is now secure and all is well again.

Tweakie.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: peskywinnets on December 01, 2012, 07:11:47 AM
...are the LEDs the right brightness level or do they 'white out' your view of the stock? (I've read the some have had real problems getting the correct levels wrt leds & webcams)

Do you have the link to where you bought it from?

Edit: "Seek & ye shall find" as they say...

http://www.ebay.co.uk/itm/2M-Mini-USB-Borescope-Endoscope-Waterproof-Inspection-Snake-Tube-Video-Camera-/180834989844?pt=UK_Computing_Other_Computing_Networking&hash=item2a1a9af714

I see it has an LED brightness control onboard :-)
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Tweakie.CNC on December 09, 2012, 03:35:13 AM
After some experimentation, this is what I have finally ended up with…

The camera can be used for X - Y tool positioning as follows;

By adding two new VB buttons to the Mach3 screen labeled Camera and Home;
Clicking the Camera button opens the video window, sets a slow jog rate and prompts for the Datum to be located.
Clicking the Home button closes the video window, resets the slow jog rate and moves both the X and Y axis (applying the offset) so that the spindle / tool is centered at the datum point.

The VB (Cypress Enable) scripts I have used to achieve this are as follows;

Camera button script;
 
Call SetUserLed(1102,1) 'open Klaus's video window
Call SetOemDRO(3,1) 'set slow jog rate to 1%
Code "(Locate Datum then click HOME)" 'message for status bar

Home button script;
 
SetUserLED(1103,1) 'close Klause’s video window
Call SetOemDRO(3,80) 'reset jog rate to 80%
Xs=GetOemDRO(59) 'read Xscale DRO
Ys=GetOemDRO(60) 'read Yscale DRO
Xmove = 70.850 * 1/Xs 'enter your camera offset here
Ymove = 1.070 * 1/Ys 'enter your camera offset here
Code "G91 G0 X" &Xmove & "Y" &Ymove 'make incremental move
While IsMoving () 'wait while that happens
Wend
Code "G90" 'go back to absolute moves
DoOEMButton (1008) 'zero X axis DRO
DoOEMButton (1009) 'zero Y axis DRO
Code "(Homing to Datum Complete)" 'message for status bar


To take advantage of the Local System Rotate function I have added 3 new VB buttons labeled A, B & C.

Button A opens the video window, sets a slow jog rate and prompts for the Datum to be located.
Button B resets the X an Y axis DRO’s to zero and prompts for the reference to be located.
Button C closes the video window, resets the slow jog rate, performs the calculations and moves the X an Y axis so the spindle / tool position is centered on the Datum location then sets the Local System Rotated DRO to the calculated value. The scripts I have used are as follows;

Button A script;
 
Call SetUserLed(1102,1) 'open Klaus's video window
Call SetOemDRO(118,0) 'reset system rotate DRO
Code "(Locate Datum then click Button B)" 'message for status bar
Call SetOemDRO(3,1) 'set slow jog rate to 1%

Button B script;
 
DoOEMButton (1008) 'zero X axis DRO
DoOEMButton (1009) 'zero Y axis DRO
Code "(Locate Reference then click Button C)" 'message for status bar

Button C script;
 
Sub Main()
Call SetUserLed(1103,1) 'close Klaus's video window
X1pos = GetOemDRO(800) 'read x axis DRO
Y1pos = GetOemDRO(801) 'read y axis DRO
If (Y1pos=0) Then GoTo Label1 'avoid divide by zero error
b = Atn(X1pos/Y1pos)*(180/(4*Atn(1))) 'calculate angle
b = b - (b*2) 'change sign (+/-)
Code "G0 X0 Y0" 'move to datum
While IsMoving () ‘wait for task to be completed
Wend
Xmove = 70.850 'enter your camera offset here
Ymove = 1.070 'enter your camera offset here
Code "G91 G0 X" &Xmove & "Y" &Ymove 'make incremental move
While IsMoving () ‘wait while that happens
Wend
Code "G90" 'go back to absolute moves
Call SetOemDRO(118,b) 'set system rotate DRO
Label1:
DoOEMButton (1008) 'zero X axis DRO
DoOEMButton (1009) 'zero Y axis DRO
Call SetOemDRO(3,80) 'reset jog rate to 80%
Code "(Process complete)" 'message for status bar
End Sub

(With both the Home button and the C button scripts my camera offset should be changed to suit your particular machine).

Obviously, everything is ‘work in progress’ and there will always be room for improvement so please feel free to change these scripts, as necessary, to suit your own particular application. My solution is presented here just as a guide for future development.

One further thought…
 
If, for example, a round circuit board was made and a datum and a reference had been established and the angle calculated (as mentioned above). This angle (angle1) could be stored as a VAR. If the round circuit board was removed from the work table then replaced (at a different angle) then by locating the same datum and reference and again calculating the angle (angle2) by subtracting one from the other the resultant angle when entered into the Local System Rotated DRO would be correct for work to be re-commenced on the circuit board as if it had never been removed and replaced.
 
It would perhaps be quite complicated to perform all the necessary math’s using a calculator but by using a VB script it could not be made more easy.

Tweakie.


Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: BR549 on December 09, 2012, 12:18:19 PM
Tweaks does this assume that the 2 points are inline with the axis when referenced back to the drawing ?  IF not you have to account for that offset as well. 

Just a thought, (;-) TP
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Picengraver on December 09, 2012, 10:46:30 PM
Tweakie,

I mounted my camera today and will install buttons and macros tomorrow.

Perhaps I'm just lucky, or it simply speaks to Chinese quality non-control, but my camera is solidly fixed in its housing and does not move as you described yours.

Thanks for once again developing a project that makes cnc easier.

My Best Regards,
John Champlain
www.picengrave.com
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Ody on December 09, 2012, 11:35:08 PM
I am also lucky as mine is mounted in a solid brass tube. The cable exits the tube and appears CA or something similar was used to secure the cable from twisting.

Very interesting thread. Thanks to Tweakie for his usual good job.

Jack
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Tweakie.CNC on December 10, 2012, 01:42:58 AM
Thanks Guys.

Quote
Tweaks does this assume that the 2 points are inline with the axis when referenced back to the drawing ?  IF not you have to account for that offset as well.  

Just a thought, (;-) TP

Hi Terry,

Yes indeed sir, you are quite correct.

If the Datum and Reference are vertically in-line (the angle is zero) then work re-positioning only takes the one referencing operation.

If the Datum and Reference are not in-line then the angle has to be referenced / calculated at the time of manufacture and stored.
Work repositioning can then be carried out by calculating the new angle, retrieving the original angle, subtracting one from the other then using the result for the Local System Rotate.

Tweakie.

Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: BlackElle170209 on February 01, 2013, 06:24:01 PM
Hi All

I  discovered this post a couple of weeks back and have since implemented the code that Tweekie generously posted. As I already had an endoscope fitted to the Z axis of my small cnc router, it only became a matter of implementing the additional buttons on screen and loading on Klause's video window. I also added a further DRO to indicate on screen the rotate angle and when the G68 is being applied - G68 is totally new to me so for the moment good to see when it is and isn't being applied. I ran some tests using the "rotate" this morning and am most impressed - it really works well and will be of considerable use to me, so many thanks for your efforts Tweekie, they are much appreciated.

I do however have a problem operating Klause's video window.............when ever the window is active, seemingly most of the Mach 3 screen buttons become inactive, also commands from the keyboard cease to operate. On termination of this video window, the screen and keyboard again become functional. To get around this I've been using the Mach3 video window in place of Klause's window - selecting/deselecting the video window manually.
 I've updated Mach3 to the latest lockdown Version, also noted that I'm unable to deactivate the Mach3 video plugin -  don't know why this is. Klause's plug in doesn't seem to affect the Mach3 video.

I'm hope this is a simple setup problem on my part as I havn't seen any mention of it by anyone else.

 Can anyone help or offer me a solution to try.

Thanks in advance

Richard
   
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Tweakie.CNC on February 02, 2013, 01:51:20 AM
Hi Richard,

In Config / Config Plugins – for the WebCamPlugin click on ‘CONFIG’ and check the ‘Keep focus on Mach’ box.
Then when you open Klause’s window the focus is automatically transferred to the Mach screen and the keyboard jogging is enabled.

Tweakie.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: BlackElle170209 on February 02, 2013, 06:18:36 PM
Hi Tweakie

Thanks for the reply - checked this morning and found that the 'Keep focus on Mach ' was already checked. In fact all the boxes are now checked, but still same result. With everything tried to date am thinking that the plugin hasn't installed correctly. I get the same result when selecting the camera from the top plugin  menue. Video window opens OK, but all jog and other screen functions are inhibited until the video window is terminated. Seems to be quite a fundamental problem and directly related to just the camera module.
 Have run out of ideas for the moment, so am thinking of contacting Klause to see if he can suggest anything. I find it disconcerting when things don't work as I know they should.

 Apart from the  camera window problem, the new Home and Rotate scripts work equally well when using the Mach3 camera plugin. Just means I have to turn the camera off/on myself, but what's a couple of mouse clicks!.

Kind regards
Richard
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: BlackElle170209 on February 02, 2013, 10:35:43 PM
Hi Tweakie

Further (and final) to my last post, in case anyone else has the same problem - I did eventually get Klause's video camera window operating. I found that the frame rate required to be set to it's maximum of 200ms. A pity because the display tends to be a bit "jumpy" when jogging, but it is still very useable and will be fine for my applications.

Regards
Richard

 
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Tweakie.CNC on February 03, 2013, 01:35:58 AM
Hi Richard,

I am pleased that you have managed to resolve the problem.  8)

Tweakie.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: BlackElle170209 on February 15, 2013, 09:42:25 PM
Hi Tweakie
 In case anyone finds it helpful in the future ................Thanks to a discussion going on on the Mach mach2 cnc site, mention was made re the watch dog timer.............thought I'd just check it out on my workshop machine and sure enough found that it had inadvertantly been selected on when updating to the latest mach3 version . Setting it to off.................... and  Klauses's camera now runs fine at the faster frame rates.Working fine at 40ms for me. Should have known it would be 'finger trouble'. It invariably is!.

Regards
Richard   
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Tweakie.CNC on February 16, 2013, 02:24:33 AM
Hi Richard,

Thank you for the information, it is most useful to know what causes and cures problems as this will inevitably be of help to others that follow.

That damn Watchdog - I suppose it is of use to somebody  ;D

Tweakie.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: BR549 on February 16, 2013, 04:29:42 PM
NOT really it was used when Art did testing and was watching for large delays in communication. Just moving from a Wizard to mach3 can trip it at times.

(;-)TP
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: sirma on June 21, 2013, 04:38:27 PM
Hi, I just searched and found this forum quite interesting. The post by Tweakie.CNC about using camera with the CNC machine and to use it for navigation is ingenious, I wonder how I didn’t think of that before. One question though, can we somehow use the camera to actually measure the distance between two points. I know we can measure the angles, just wondering about the distance. Thank you again for sharing the information.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: majorstrain on June 21, 2013, 09:48:13 PM
You certainly can.
The camera plugin (I use WebCamPlugin version 2.12) runs in a separate window and has cross hairs in the center.
All you need to do is centre the start point in the camera view by jogging the mill and the either note down the DRO numbers or zero them. Then jog the mill to the next point and read the DRO's.
You get the X and Y distance. If you want the straight line distance when X and Y both change then you just need to use Pythagoras triangle theory to calculate that distance.

The closer the camera is to the surface the better accuracy you will get.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: airnocker on May 04, 2018, 04:53:26 PM
Well, so I'm late to this party.  Found this topic a week ago and was thrilled that Tweakie.CNC has shared this webcam feature.  I gathered up a USB endoscope, Tweakie's button macros and K.Dietz's webcam driver but was wondering whether in the years that have passed if there is now a more preferred webcam driver available.

Thanks

Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: Tweakie.CNC on May 05, 2018, 02:16:09 AM
Klaus was working on a new version last time I looked, perhaps check out his website http://www.kd-dietz.com/klausphp/pages/ger/plugins/webcam/description/wcam_description.html

Tweakie.
Title: Re: Isolation Routing PCB's and Local System Rotate.
Post by: airnocker on May 05, 2018, 02:25:17 AM
Thanks Tweakie.  Been there and have his latest greatest, so I guess I have the most current.