Following my last update, we decided to use TinyG to do motion control for our Pick-n-Place machine. The BeagleBone Black needs to send the appropriate g-code over the serial port to tell the TinyG what movements to make. One of our team members, Ed Bennett, had the idea of using the mouse to control the PnP machine while we continue to develop it. For now, we need "exercise" the X-Y gantry to see how well it works before mounting Ed's vacuum nozzle head which has Z-axis and alpha-axis (rotation).
Porting PyQt demo
Ed developed a PyQt demo for mouse control of PnP gantry on his Linux laptop. Bonnie King and I then worked on getting Ed's program working on the BBB. It turned out to be an issue that the code seems to use Qt3 classes. It worked on Bonnie's Fedora laptop with Qt3 installed. However, neither Angstrom, Debian 7 (www.armhf.com) or Ubuntu 13 (www.armhf.com) had Qt3 available in their repos.
We ended up rewriting the program for Qt4 based on various PyQt for Qt4 examples (using Debian 7 as it was last distro we tried when still search for Qt3):
https://github.com/pdp7/bbqt/blob/master/pnpcntrl.py
The code is messy right now, but it will writes g-code to the serial port (via PySerial) per mouse movement. At first I thought there was a problem, as it was really slow, but I realized after awhile it was because I running it remotely via X. I put my 4.3" LCD touchscreen cape on the BBB and installed LXDE desktop env into Debian on the BBB. It then drew at a normal speed no problem - d'oh I could also draw using my finger on the touchscreen. The photo attached looks crude as I was drawing points with a large pen at that point before going to drawing lines with a finer pen.
Software Setup:
Here is the process I followed to setup my BeagleBone Black to run the demo:
1) Download Debian 7.0 image from armhf.com and burn to microSD:
http://www.armhf.com/index.php/boards/beaglebone-black/#wheezy
2) Boot off microSD card and then copy to eMMC (so microSD card won't be needed anymore at bootup; based on armhf.com instructions)
a) Boot off of Debian SD card by holding down the boot button
b) copy the image file to the BBB from your computer (for example, filename debian-wheezy-7.0.0-armhf-3.8.13-bone20.img.xz).
c) the .img.xz can be directly applied to the Bone’s internal eMMC while booted from the external microSD card:
xz -cd debian-wheezy-7.0.0-armhf-3.8.13-bone20.img.xz > /dev/mmcblk1
d) power down and remove the microSD card
e) power on the BBB and you'll now enjoy a nice photo of Tux on the bootscreen
3) Install required packages:
sudo apt-get update
sudo apt-get install lxde git python-sip python-qt4 python-setuptools python-pip python-serial minicom
4) Clone my bbqt GitHub repo:
debian@debian-armhf:~$ git clone git@github.com:pdp7/bbqt.git
Cloning into 'bbqt'...
remote: Counting objects: 31, done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 31 (delta 12), reused 30 (delta 11)
Receiving objects: 100% (31/31), 10.01 KiB, done.
Resolving deltas: 100% (12/12), done.
5) Connect TinyG mini-USB port to the BBB's USB 2.0 host port & verify serial port exists
debian@debian-armhf:~$ ls /dev/ttyUSB0
#it could potentially be ttyUSB1, ttyUSB2, so check those if ttyUSB0 not present
6) Run pnpcntrl.py script in the bbqt repo (edit the path for serial port if not /dev/ttyUSB0)
debian@debian-armhf:~/bbqt$ sudo python ./pnpcntrl.py
Live Testing:
Here's a video of the gantry running under mouse control. We taped a marker to the head and used a pizza box to simulate the PCB to determine if the machine's X & Y were calibrated properly:
Here's a still photo from the process:
We learned we needed to adjust the size of the canvas in Qt and also scale the mouse coordinates to the dimensions of our machine (about 10" travel on both the X & Y). Luckily, I was able to use the LCD4 cape directly to edit the (tiny) Python code:
Ed B (right) and Dan D (left) decided it would be better if we tried to draw a square exactly:
We wrote exact g-code for a square instead of using the mouse and it worked well:
We were very proud to see our little PnP bot's artistic taste move from abstract to realism
Coming Soon...
Our next big task is a mechanical one: mounting Ed's Z-axis + alpha-axis head onto the PnP gantry.
In my next post, I'll describe the process Ed went through in design the Z-axis and alpha-axis and how he machined the parts in the device
Reference:
- Ongoing collection of photos and videos I shot:
- Read all "Hackerspace challenge: PS1 PnP update" posts:
- pnpcntrl.py captured on 2013-07-25 and pasted into a Gist so I can embed it here: