Visual alignment mod for shapeoko

wlanfox
Posts: 74
Joined: Sat Oct 20, 2012 10:49 am

Visual alignment mod for shapeoko

Post by wlanfox » Wed Jan 02, 2013 10:36 pm

Hi,

One of the things I want to do with my ShapeOko is two sided PCBs or even more layers (stacking 1mm or 0.5 mm PCBs). One of the things I find frustrating is knowing where exactly the tool is specially when dealing with 0.2mm isolation and traces running next to each other if the 0.2mm spacing is not accurate one of the traces can be damage.

To help with this I have added a inexpensive USB microscope to use as an alignment assist, to get the image and cross-hair I used python and OpenCV libs (I want to do more, thus why creating my own program instead of using somethign off the shelve for image capture). It looks like this:

Image

and it works like this:



Things to note:

1) For alignment purposes and specially when dealing whit 0.2mm you need to have your motors energized ($7=255), I found the magnetic backlash to be 0.3mm on my machine.
2) The knob to focus for these microscopes will move your image changing where the cross-hair is +/- 0.6mm, I used zip ties to hold this tightly in place. I use Z-axis to get closer or away form target, I have it set to 20.0 mm for the focus.
3) once you have attached and tight the USB microscope, measure and find out the true distance from your tool-bit to the center cross-hair, it this end being fractional you could move where the cross-hair center is so it is a more rounded number. For example my offset to target is 51.15 x-axis, 25.55 y-axis.

python code (linux):

Code: Select all

import cv

capture = cv.CaptureFromCAM(0)
cv.WaitKey(200)

frame = cv.QueryFrame(capture)
font = cv.InitFont(cv.CV_FONT_HERSHEY_DUPLEX, 1, 1, 0, 2, 8)

while True:
   frame = cv.QueryFrame(capture)

   cv.PutText(frame, "ShapeOko CAM", (10,460), font, cv.RGB(17, 110, 255))
   cv.Line(frame, (320,0), (320,480) , 255)
   cv.Line(frame, (0,240), (640,240) , 255)
   cv.Circle(frame, (320,240), 100, 255)

   cv.ShowImage("Window",frame)
   c = (cv.WaitKey(16) & 255)

   if c==27: #Break if user enters 'Esc'.
      break
FYI I have these packages installed. (python, python-gtk2, and python-opencv)

Code: Select all

sudo apt-get install python python-gtk2 python-opencv
attaching the gcode for the USB microscope mount rings.


For the future:

By using python and Open Computer Vision Libraries (OpenCV) this opens a opportunity for some automation and computer visual recognition. Imagine being able to select something on the PCB as the target and have the machine align itself every time :D

hope this is useful to some one else :D happy milling.
Attachments
usb-micro-clamp.ngc
(32.32 KiB) Downloaded 255 times

PsyKo
Posts: 430
Joined: Thu Aug 30, 2012 8:42 pm
Location: France

Re: Visual alignment mod for shapeoko

Post by PsyKo » Thu Jan 03, 2013 11:53 pm

Very nice mod.
Do you have homing switch ? I guess they could solve this kind of issues, right ?
Shapeoko #736
Kress 800, Z Axis upgrade, dual Y, 600mm X&Y rails, metal spacers and V Wheels, home switches, 4th axis
Goko - Free CNC Control Software - http://www.shapeoko.com/forum/viewtopic ... 380#p44380

wlanfox
Posts: 74
Joined: Sat Oct 20, 2012 10:49 am

Re: Visual alignment mod for shapeoko

Post by wlanfox » Fri Jan 04, 2013 12:08 am

Yes I do have micros-switches for homing, it does work well most of the time but I has some issues with things getting off by few 10ths of a millimeter say 0.1-0.3mm; not a good thing whit PCBs. I also wanted a more direct visual feel and feedback to be able to inspect the work area under the microscope. Also as mention I want to start experimenting whit computer vision recognition and image processing... as in automating aligning or other jobs.

One extra benefit I got is that I have a microscope on a X,Y,Z axis which is great to inspect PCBs and other things with great control over it...
Last edited by wlanfox on Fri Jan 04, 2013 4:34 am, edited 1 time in total.

levlandau2
Posts: 187
Joined: Tue Apr 17, 2012 1:52 am
Location: Minneapolis, MN, USA

Re: Visual alignment mod for shapeoko

Post by levlandau2 » Fri Jan 04, 2013 3:08 am

Waaah, this is totally awesome!!! I have been thinking of doing a similar mod for a while but you beat me to it. Where do you find the time to upgrade your tool so much? I am way behind on all of these upgrades :-).

Ok, so a couple of questions.

1) Can you link the camera model you used? Is this the best camera to use?
2) Yes a pattern-rec feature would be awesome. Also I have seen that Mach3 can find two corners of an object by pattern-rec and then correct the rotation offset. So you can place an object to be milled the camera will find the edge of the object, correct the rotation offset, and then we would be all set to mill extremely precisely. This would allow for example precise engraving into a cell phone case...
3) Can you elaborate more about your microscope? Is it something affordable? I have been looking for a microscope for my shop for some time now.
4) What do you think is the minimum resolution of your camera? Can you resolve two lines which are 0.01mm apart?

Great progress, this is awesome stuff. I want this mod!

wlanfox
Posts: 74
Joined: Sat Oct 20, 2012 10:49 am

Re: Visual alignment mod for shapeoko

Post by wlanfox » Fri Jan 04, 2013 4:06 am

levlandau2 wrote:Waaah, this is totally awesome!!! I have been thinking of doing a similar mod for a while but you beat me to it. Where do you find the time to upgrade your tool so much? I am way behind on all of these upgrades :-).

Ok, so a couple of questions.

1) Can you link the camera model you used? Is this the best camera to use?
2) Yes a pattern-rec feature would be awesome. Also I have seen that Mach3 can find two corners of an object by pattern-rec and then correct the rotation offset. So you can place an object to be milled the camera will find the edge of the object, correct the rotation offset, and then we would be all set to mill extremely precisely. This would allow for example precise engraving into a cell phone case...
3) Can you elaborate more about your microscope? Is it something affordable? I have been looking for a microscope for my shop for some time now.
4) What do you think is the minimum resolution of your camera? Can you resolve two lines which are 0.01mm apart?

Great progress, this is awesome stuff. I want this mod!

Yes the time to make the mods is hard to find; I have been working on my mods since I got it, back on June. basically Every weekend and spare time I get and I have many more ideas :D, having tons of fun tough!!!

I had one of this cheap eBay USB microscope ~$40 or less laying around... Mine is white but if I had bought it for this I would of gone with the black. There are many versions the one I have has the on/off switch button for the LEDs. There are many vendors but is the same thing, and yes those images are real you can get that magnification if you get really close to the target. With the end-mill or engraving bit installed that might be hard to do. I guess if your only planning on doing is engraving it would be OK to always be that close, but I mill many things some times 1" thick because of this, I installed mine so the bottom of the microscope is at the same height as the spindle chuck.

http://www.ebay.com/itm/2MP-2-0-Mega-Pi ... 4603c87939

I did just order another one like this one (link below) since they are a lot smaller and i like the metal finish...

http://www.ebay.com/itm/USB-Digital-Vid ... 27ce798a23

not sure on the resolution it says 2MP but I think they are just making it up, and if you read the fine print on some of them it says with software assist... LOL basically not 2MP, on the other hand seem to be a OK resolution not the worst I seen. UVC (http://www.ideasonboard.org/uvc/) can do 1280x1024 with this camera. In the video the hole is a 0.5 mm in diameter and I had the camera set for 640x480... Here is an image using UVC at 1280x1024.

Image

The trace isolation and holes are all 0.5mm.

-wlanfox

wlanfox
Posts: 74
Joined: Sat Oct 20, 2012 10:49 am

Re: Visual alignment mod for shapeoko

Post by wlanfox » Fri Jan 04, 2013 10:51 pm

Quick Update: I did a little more research on the USB microscope I have, it seems the sensor is 1.3MP that correlates with the max resolution for this device in UVC of 1280x1024. Now I got this more then a year ago, so maybe this new ones listed in eBay are really 2MP. The USB-ID for mine is "ID 0c45:62e0 Microdia MSI Starcam Racer"..


some interesting results on a Google search... Also notice this have two focal points to get the maximum optical zoom.

ID 0c45:62e0 Microdia "Advent 1.3MP Interchangeable webcam"

http://www.stealthcopter.com/blog/2010/ ... abilities/
http://www.stealthcopter.com/blog/2010/ ... ntu-linux/
http://www.stealthcopter.com/blog/2010/ ... icroscope/

-wlanfox

PsyKo
Posts: 430
Joined: Thu Aug 30, 2012 8:42 pm
Location: France

Re: Visual alignment mod for shapeoko

Post by PsyKo » Tue Jan 08, 2013 9:56 am

I just ordered an USB 200x microscope to do the same mod :)
This might be interesting. Anyway, a microscope is always useful, especially when working on electronic devices.

I'll let you know, and thanks for the inspiration !
Shapeoko #736
Kress 800, Z Axis upgrade, dual Y, 600mm X&Y rails, metal spacers and V Wheels, home switches, 4th axis
Goko - Free CNC Control Software - http://www.shapeoko.com/forum/viewtopic ... 380#p44380

xpix
Posts: 218
Joined: Thu Sep 06, 2012 6:47 am

Re: Visual alignment mod for shapeoko

Post by xpix » Tue Jan 08, 2013 3:17 pm

awesome! very intresting, i got this model from china last week:

http://www.ebay.de/itm/350660169034?ssP ... 1497.l2649

I think it's possible to place a cross somewhere on the machine and the machine use this as null point?

PsyKo
Posts: 430
Joined: Thu Aug 30, 2012 8:42 pm
Location: France

Re: Visual alignment mod for shapeoko

Post by PsyKo » Tue Jan 08, 2013 4:43 pm

I think it is possible, at least for manual alignement.
Automatic alignement is not harder but implies very accurate cross, the the machine can home precisely ! Beside the cross or any 0,0 pattern would have to be clean of any dust, so the microscope can "see" it clearly. Same goes for the microscope lens.
Shapeoko #736
Kress 800, Z Axis upgrade, dual Y, 600mm X&Y rails, metal spacers and V Wheels, home switches, 4th axis
Goko - Free CNC Control Software - http://www.shapeoko.com/forum/viewtopic ... 380#p44380

wlanfox
Posts: 74
Joined: Sat Oct 20, 2012 10:49 am

Re: Visual alignment mod for shapeoko

Post by wlanfox » Wed Jan 09, 2013 2:01 am

Folks,

Just an FYI, I got of a hold of two other USB microscopes, one is the same body and shape is identical to the white one. But the sensor is NOT. The camera sensor is different and it only supports 640x480. For my experiments (the videos shows a 640x480 res) and my use as of now it seems to be adequate. Just wanted to make sure people will be aware that not because they look the same it means the have the same sensors. See picture below. I am now sticking whit the silver because of size and better simpler mount capability.

Color - Capability - USB ID
White - 1280x1024 - 0c45:62e0 Microdia MSI Starcam Racer
Black - 640x480 - 0ac8:3610 Z-Star Microelectronics Corp.
Silver - 640x480 - 1871:0d02 Aveo Technology Corp.


Image

-wlanfox

Post Reply