Visual alignment mod for shapeoko

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

Re: Visual alignment mod for shapeoko

Post by xpix » Fri Jan 25, 2013 3:08 pm

The syntax between cv1 and cv2 are bit different :D

I wrote this Camera prg on my Windows machine with Winphyton and OpenCV2:

Code: Select all

import cv2

#capture from camera at location 0
cap = cv2.VideoCapture(1)

while True:
    ret, img = cap.read()
    cv2.putText(img, 'ShapeokoCam',(10,20), cv2.FONT_HERSHEY_PLAIN,1,(17, 110, 255))
    cv2.line(img, (320,0), (320,480) , 255)
    cv2.line(img, (0,240), (640,240) , 255)
    cv2.circle(img, (320,240), 50, 255)
    cv2.circle(img, (320,240), 100, 255)
    cv2.circle(img, (320,240), 150, 255)

    cv2.imshow("input", img)

    key = cv2.waitKey(10)
    if key == 27:
        break


cv2.destroyAllWindows() 
cv2.VideoCapture(0).release()
Have Fun!

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

Re: Visual alignment mod for shapeoko

Post by wlanfox » Thu Feb 21, 2013 1:18 am

Update:

Hi,

I have been working on betters ways an techniques to align the spindle when going from file to file, specially for PCBs where accuracy is very important (the reason of this thread). It occurred to me what I needed is a debugger like tool to allow me to control and adjust ShapeOko while running the program (GCODE) and even modify the GCODE itself; the same way I do for embedded programs and firmware. This tool also provides a platform to play whit visual alignment and OpenCV.

With nothing that I could find, I decided to create such a tool. For the past Month and 3 weeks I have been working on it. I think is ready for general use. Hope it will help others with their CNC alignment.

Note: OpenCV is not required unless you want to play with computer vision.

Note2: you only need gcs.py the rest is just the images sources, but they are embedded with in the python scrip. So you only need the one file "gcs.py" and of course dependencies like python and wx.Python.

Use case: The GCODE file is a drill program for a PCB, gcs will make it possible to set-up a break point right before the tool plunge. At this point with the jogging controls it is possible to lower the tool right before penetrating the surface to verify alignment is adequate. Once this is verify and or adjusted, the program can continue.

https://github.com/duembeg/gcs/tree/v1.0.0

Image

Will Winder
Posts: 435
Joined: Fri Apr 20, 2012 2:40 pm
Location: Hudson, MA
Contact:

Re: Visual alignment mod for shapeoko

Post by Will Winder » Thu Feb 21, 2013 3:27 am

Wow, thats really cool!
ShapeOko #367: Dual-Y drive, Belt on outside, 1000mm Y-Axis, DW660 Spindle, Nema-23 X/Y motors.

Primary developer on Universal Gcode Sender.

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

Re: Visual alignment mod for shapeoko

Post by wlanfox » Thu Feb 21, 2013 4:30 am

Thank you :)

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

Re: Visual alignment mod for shapeoko

Post by xpix » Thu Feb 21, 2013 7:39 am

wlanfox wrote:Update:
Use case: The GCODE file is a drill program for a PCB, gcs will make it possible to set-up a break point right before the tool plunge. At this point with the jogging controls it is possible to lower the tool right before penetrating the surface to verify alignment is adequate. Once this is verify and or adjusted, the program can continue.
Yes, awesome! That is a tool we need, big thank you for this. I want to test and report you!

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

Re: Visual alignment mod for shapeoko

Post by xpix » Thu Feb 21, 2013 8:18 am

So i test your gcs and it looks phantasic. But i found a bug ...

If i call Settings in Menu View then i get a console error:

Code: Select all

Traceback (most recent call last):
  File "C:\Users\c5125630\Dropbox\Software\Grbl\gcs-1.0.0\gcs.py", line 3028, in OnSettings
    dlg = gcsSettingsDialog(self, self.configData)
  File "C:\Users\c5125630\Dropbox\Software\Grbl\gcs-1.0.0\gcs.py", line 1217, in __init__
    self.InitUI()
  File "C:\Users\c5125630\Dropbox\Software\Grbl\gcs-1.0.0\gcs.py", line 1248, in InitUI
    self.AddCV2Panel(7)
  File "C:\Users\c5125630\Dropbox\Software\Grbl\gcs-1.0.0\gcs.py", line 1310, in AddCV2Panel
    self.CV2Page = gcsCV2SettingsPanel(self.noteBook, self.configData)
  File "C:\Users\c5125630\Dropbox\Software\Grbl\gcs-1.0.0\gcs.py", line 4181, in __init__
    self.InitUI()
  File "C:\Users\c5125630\Dropbox\Software\Grbl\gcs-1.0.0\gcs.py", line 4219, in InitUI
    flag=wx.ALL|wx.LEFT|wx.ALIGN_CENTER_VERTICAL, border=5)
  File "C:\WinPython-32bit-2.7.3.2\python-2.7.3\lib\site-packages\wx-2.9.4-msw\wx\_core.py", line 14469, in Add
    return _core_.Sizer_Add(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "Assert failure" failed at ..\..\src\common\sizer.cpp(1377) in wxGridSizer::DoInsert(): too many items (5 > 2*2) in grid sizer (maybe you should omit the number of either rows or columns?)
I use winphyton with wx-2.9.4 in spyder (IDE for python).

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

Re: Visual alignment mod for shapeoko

Post by wlanfox » Thu Feb 21, 2013 8:46 am

Hi xpix,

Thanks for the feedback, are you in Windows 7, I tried both Ubuntu 12.04 and Windows 7.

On windows I did a quick install since my main OS is Linux... here are the files list I used for setup in in Windows.

python-2.7.3.msi
wxPython2.8-win32-ansi-2.8.12.1-py27.exe
pyserial-2.6.tar.gz

I also went back to the wxWidgets page
Latest Development Release: 2.9.4
Current Stable Release: 2.8.12

Can you try the stable release? I will try the development release see what I find.

if you want to manually configure the port settings, there will be an gcs.ini file in your user directory. look for

[link]
Baud=9600
Port=COM1


Thanks.

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

Re: Visual alignment mod for shapeoko

Post by xpix » Thu Feb 21, 2013 8:57 am

wlanfox wrote:Hi xpix,
Can you try the stable release? I will try the development release see what I find.
Cool, it works with stable Release from wxWindows:
http://downloads.sourceforge.net/wxpyth ... 1-py27.exe

Maybe u plan to make a little video tutorial? I think is better to see the program and the machine ;)

Great Work!

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

Re: Visual alignment mod for shapeoko

Post by wlanfox » Thu Feb 21, 2013 9:27 am

xpix wrote: Maybe u plan to make a little video tutorial? I think is better to see the program and the machine ;)

Great Work!
I am will eventually, waiting for a spindle I got before making the next board. The spindle in questions is "Wolfgang Engineering TB-350 Spindle" Hopefully I can use my 0.3mm end-mill with out braking it.

here is a video some one else made of this same spindle (below), I am anxiously waiting for it :D

About the drill alignment, This is how I usually do this:
  • 1) Setup break point right at plunge.
    2) Using the jogging controls move the tool down just before touching the material.
    3) If no adjustment require just hit run (F5) to continue, you are done and can skip the rest, sit back and watch those perfectly center hole appear before you 8-) .
    4) IMPORTANT :!: before making any other adjustment other then z-motion.
    • a) In the jogging panel make sure to select "use work pos".
      b) Click refresh button, either in the machine tool bar button or the status panel refresh button. (This will update the status and jogging panels at the same time)
      c) Click the job stack memory (+), this will save this position in the jog memory stack.
    5) Adjust spindle XY motion, visually or using your camera (you will need to configure your offsets (to camera) and (to tool from camera) in the settings panel->jogging (any of the custom buttons) to easily move back and forth spindle and the camera)
    6) Make sure to move back to the spindle if using the camera, then pop the saved value from the jog memory stack, and hit the reset to jog, this will SET this as the current values for Grbl.
    7) your done, press (F5) to continue or hit the play button in toolbar.
FYI, if your using pcb2gcode, under the tools menu there are options to convert form inch to mm and form G81 to G01 code.

Last edited by wlanfox on Thu Feb 21, 2013 9:55 am, edited 1 time in total.

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

Re: Visual alignment mod for shapeoko

Post by xpix » Thu Feb 21, 2013 9:48 am

wlanfox wrote:I am will eventually, waiting for a spindle I got before making the next board. The spindle in questions is "Wolfgang Engineering TB-350 Spindle" Hopefully I can use my 0.3mm end-mill with out braking it.
I made very good expiriences with this spindle, maybe a tip for a cheap spindle :)
I got this spindle in ebay/china and make me every day happy:

http://www.shapeoko.com/forum/viewtopic.php?f=21&t=1012
http://www.ebay.com/itm/251201710796

But u need an extra PowerSupply (48V/3A ~30$) and a SpeedController (5$).
But yes, the TB Wolfgang is another league :)

Ok, your prg runs on my Windows7 pc. I will try tutorial at the weekend!

Before i forget: I use pcb-gcode ulp plugin in eagle.

Post Reply