Interesting Tech Projects
Linux
Convert Any Audio Source Into MP3
Jul 6th
Here is my method that I know works. If you have a better one feel free to post it in the comments section. It may not produce the best quality audio but I’m sure it can be improved.
Obtain a 3.5mm to 3.5mm audio cable, for example this one. Connect one end to the audio source (for example a PC) and the other end to the microphone in on your linux box (I tried line in but that didn’t work for some reason).
Make sure ALSA utilities and ffmpeg are installed (at a console prompt):
$ sudo apt-get install alsa-utils ffpmeg
Start recording with:
$ arecord -f cd -t wav test.wav
Start the audio source and once complete press Ctrl-C to stop recording. Convert to MP3 with:
$ ffmpeg -b 128k -i test.wav test.mp3
I then run the file through MP3Gain as the recordings tend to be a bit quiet and add tags in iTunes.
Graphing Ping Times
Mar 29th
I recently had the need to generate a graph of ping times between my PC and a British Telecom server. After a quick web search the only options I found were commercial programs or free software that was incredibly bloated, complex to configure and with lots of dependencies. There must be a simpler way, and there is. Perl.
Here is my script:
#!/usr/bin/perl
# Converts ping output into a CSV file for graphing
# andy at british ideas dot com - March 29th 2011
# Public Domain
# Run using:
# ping -D 100.101.102.103 | ./pingtocsv.pl > output.csv
# or:
# cat pingdump.txt | ./pingtocsv.pl > output.csv
print "Measurement Time,Ping Time\n";
while (<STDIN>) {
if ($_ =~ m/^\[([0-9\.]+)\].*time\=([0-9\.]+).*/i) {
print "$1,$2\n";
}
}
close(STDIN);
The Progress of Linux
Mar 4th
Back in 1998 I tried installing RedHat 6 on a spare PC. When the desktop loaded it was, ummm, wobbly. I then spent the best part of the next two weeks fighing with X configuration files setting obscure items such as front and back porches in a futile attempt to stabilize the display so it would be usable. I gave up.
Fast forward to March 2011 and Ubuntu 10.10. I’ve used lots of different versions of Ubuntu since 2006 on a variety of machines including for CNC control, but the last time I installed in a dual boot system was two years ago. Ubuntu 10.10 works fine in a virtual machine inside Windows 7 but I wanted to run it at full speed. More >
You Tube, H.264, High Definition and FFmpeg
Jun 3rd
Recently I had the need to take a set of jpeg images and convert them into a high definition time lapse video, then upload to You Tube. Easier said than done…
To get the best quality I wanted to use H.264/MP4, which is also recommended by You Tube. I also wanted 1080P. The problem is that You Tube doesn’t seem to like B-frames in the file, and messes up the start of videos. So here is the solution I found.
Firstly I needed to upgrade my Debian server to Squeeze.
Next I compiled x264 and FFmpeg as described in How To Build FFmpeg on Debian Squeeze.
Finally I ran the following FFmpeg command line to generate a time lapse video at 24 frames per second (-r 24), using 1080P (-s hd1080) with no B-frames (-bf 0):
ffmpeg -r 24 -i %04d.jpg -s hd1080 -vcodec libx264 -vpre hq -bf 0 -crf 16 myfile.mp4
It’s important that the frame rate is specified before the input source in order to make FFmpeg apply the frame rate to the source. Note that trying to use qt-faststart causes You Tube to complain about the audio, even though there isn’t any audio.
Fireball V90 EMC2 Configuration Files
Mar 4th
I am making my configuration files available to help anyone trying to get their Fireball V90 machine working with EMC2. The configuration is for inches, 1/4 microstepping and the HobbyCNC Pro board.
To use these files you will first need to perform the latency test and work out the base period for your PC. Open the Stepconf wizard and choose to update this configuration. Put the latency test results into the Stepconf wizard. Then you must double-check the pin configurations for your board if you are not using the same one I am. These changes are easy to make. I recommend 1/4 microstepping as it gives smooth operation without much reduction in power and speed.
Note that Stepconf will tell you that the INI file has changed since the configuration was generated. I changed the DEFAULT_VELOCITY to 0.9 so the default jogging speed is a bit faster.
Download Fireball V90 EMC2 Configuration Files.
Update: Now with Stepconf generated config files.
Installing Ubuntu Netbook Remix on an Acer Aspire One
Jan 14th
The Acer Aspire One is a pretty nice netbook – for a reasonable price you get 1Gb RAM, 160Gb hard drive, 1024 x 600 screen and 5 1/2 hours of battery life. However it comes with Windows XP or Linpus, which is a customized Linux distribution from Acer. Neither of these options appealed to me. In particular the Aspire One user forums seemed to have a lot of postings on limitations with Linpus.
Enter Ubuntu Netbook Remix (UNR), which is a special version of Ubuntu 8.04 for netbooks. Essentially it is the same as Ubuntu 8.04, but with some additions that make it easier to use on a small screen with limited height. Because netbooks don’t have optical drives it presents a challege to get a new operating system installed. Below is the process I found to work for me. I used Ubuntu on a desktop PC for all the steps.
Firstly note that I tried and failed to get a USB hard drive to work. I partitioned and formatted it every way I could and couldn’t get it to work. I managed to the the UNR installer to boot, but it always failed with “sdb: unknown partition table”. The process only seems to work with USB flash drives. I used a Sandisk Cruzer Micro 4Gb.
1. Download UNR 1.0.1 image from:
http://oem-images.canonical.com/unr/unr-1.0.1.img
2. Plug in USB drive and identify device location. Mine was /dev/sdb mounted to /media/disk.
3. At command prompt:
sudo dd if=./unr-1.0.1.img of=/dev/sdb bs=1024
4. fdisk -l will then show:
Disk /dev/sda: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x88000000
Device Boot Start End Blocks Id System
/dev/sda1 1 8 64228+ de Dell Utility
/dev/sda2 9 1314 10485760 7 HPFS/NTFS
Partition 2 does not end on cylinder boundary.
/dev/sda3 * 1315 7769 51849787+ 7 HPFS/NTFS
/dev/sda4 7770 30394 181735312+ 5 Extended
/dev/sda5 7770 23109 123218518+ 7 HPFS/NTFS
/dev/sda6 23110 29908 54612936 83 Linux
/dev/sda7 29909 30394 3903763+ 82 Linux swap / Solaris
Disk /dev/sdb: 4016 MB, 4016045568 bytes
124 heads, 62 sectors/track, 1020 cylinders
Units = cylinders of 7688 * 512 = 3936256 bytes
Disk identifier: 0x8ef631df
This doesn't look like a partition table
Probably you selected the wrong device.
Device Boot Start End Blocks Id System
/dev/sdb1 ? 274784 529564 979374166 66 Unknown
Partition 1 has different physical/logical beginnings (non-Linux?):
phys=(734, 123, 14) logical=(274783, 70, 21)
Partition 1 has different physical/logical endings:
phys=(120, 143, 6) logical=(529563, 65, 22)
Partition 1 does not end on cylinder boundary.
/dev/sdb2 ? 448668 961719 1972168331 7 HPFS/NTFS
Partition 2 has different physical/logical beginnings (non-Linux?):
phys=(187, 180, 14) logical=(448667, 16, 52)
Partition 2 has different physical/logical endings:
phys=(784, 0, 13) logical=(403059, 76, 1)
Partition 2 does not end on cylinder boundary.
/dev/sdb3 ? 426615 680707 976730017 7d Unknown
Partition 3 has different physical/logical beginnings (non-Linux?):
phys=(252, 59, 46) logical=(426614, 84, 39)
Partition 3 has different physical/logical endings:
phys=(139, 118, 4) logical=(122048, 22, 28)
Partition 3 does not end on cylinder boundary.
/dev/sdb4 ? 36178 37261 4161536 6f Unknown
Partition 4 has different physical/logical beginnings (non-Linux?):
phys=(370, 101, 50) logical=(36177, 96, 57)
Partition 4 has different physical/logical endings:
phys=(10, 114, 13) logical=(37260, 47, 62)
Partition 4 does not end on cylinder boundary.
Partition table entries are not in disk order
Don’t worry about the errors – they don’t seem to be important.
5. Unmount the USB drive by right-clicking on the icon on the desktop.
6. Plug USB drive into Aspire one and boot. At Acer screen press F12 to get to the boot menu.
7. On the boot menu the USB drive will appear twice:
USB Floppy Drive
USB CDROM
This because there is a second hard-coded, read only partition that appears as a CDROM drive. Choose the floppy drive option. Press Enter at the prompt and UNR will now install. Follow the on-screen instructions.
8. At this point you probably want to change the name of the computer. It seems to default to the name of the first user. Go to Administration -> Network, click on “Unlock” and enter your password.
9. Click on the General tab and enter a new name in the Hostname field.
10. Reboot. Clicking on “Quit…” didn’t seem to work. Holding down the power button for a second or so brought up the shutdown options screen. Note that after the reboot the “Quit…” option started working, so I guess the reboot is necessary.
Cleaning Up Your USB Drive
1. Install GParted from Add/Remove…
2. Go to System -> Administration -> Partition Editor
3. Plug in the USB drive and select it from the list at the top right (for example /dev/sdb).
4. Right click on the drive on the desktop and unmount it.
5. Select the partition (there will only be one for some strange reason) and delete it. Click on Apply to confirm.
6. Create a new FAT32 primary partition. Click on Apply.
7. Remove and insert the USB drive to mount it.
Using Inkscape for CNC Designs and DXFs
Sep 4th
Update: see this later post before following the instructions below.
I don’t care for most of the DXF editors available. They seem a bit clunky and not too friendly. But I do like Inkscape. Unfortunately it doesn’t export DXF files.
Here is a way of getting Inkscape 0.46 to export DXF files which can then be processed in a CAM program to generate g-code for a CNC machine.
Firstly install Inkscape 0.46. It must be this version.
Next go to this post on BobandEileen.com, right click on the link to “dxf_templates.py” and save it in C:\Program Files\Inkscape\share\extensions.
Next step is to go to another post on BobandEileen.com, right click on the two .py files (“simpletransform.py” and “better_dxf_outlines.py”) and save in the same place. Then do the same for “better_dxf_outlines.inx”.
Restart Inkscape.
Create a drawing and then move it to the bottom left corner of the page. This corner ends up being the origin. If you want your drawing centered on the origin then center it on the corner of the page.
Go to File -> Save As…
From the list of file types in the save dialog window choose “Better DXF Output (*.dxf)” and save the file.
Now open the DXF file in your favourite CAM program, such as CamBam.
Note that you may need to scale the drawing in your CAM program. Even though I had my drawings correctly sized in Inkscape, they seemed to be quite a bit bigger. If anyone knows how to solve that please post a comment.
Cutting Holes with CNC
Jun 23rd
The next step in testing the CNC machine is to try cutting a hole. For this I needed thinner wood than the scrap pine I’ve been using. Home Depot sells small boards of oak and poplar so I picked up a piece of poplar. It’s 1/4″ thick.
I also needed to raise the sacrificial platform so the tip of the end mill can reach the bottom of the wood. To do that I just cut some more 16″ x 9″ pieces of 1/4″ MDF and stacked them (see the post on fixtures for more information and pictures on what I am talking about).
I used CamBam to draw a 0.5″ x 0.5″ square and then created a profile on the inside using my 1.45mm (0.0571″) end mill. CamBam showed me that I would have slightly rounded corners, but that’s ok. I decided to cut the profile in passes, increasing the depth by 0.05″ each time. This results in five passes to get to the bottom of the wood. Tedious, but better than stressing the end mill and Dremel.
I was afraid that the tip of the end mill might bind in the sticky double-sided carpet tape so I held on to the poplar with one hand and kept my finger on the power button with the other hand just in case. I was also afraid that the cube being cut might fly out as it came free.
It turned out pretty good. No sticky residue on the end mill and no gouging of the sacrifical platform. The cube in the center held in place during cutting and while I lifted the poplar. It came out when I removed the carpet tape.
The cut is nice and clean with no burrs. I guess the carpet tape is a good method to continue using.
First Steps With CNC
Jun 22nd
Today I took my first steps cutting some scrap pine. I started off with a 2″ diameter circle then measured it. This is an acid test to check the CNC machine for accuracy and squareness. I used a 1.45mm four flute carbide end mill, 10″ per minute speed and cutting to 0.05″ deep.
Next I used CamBam to cut my wife’s name. That also went well, however even with the text 1.5″ high I was running into a limitation of the end mill. A small mill would have improved the detail.
Then I downloaded a DXF file of a horse and tried cutting that. Came out very nicely. The thin strip of wood left between the body and mane is thin enough to see light through it.
Here is a video shows the horse being made.
For all these I used the same end mill and cutting depth as I did for the circle.
Measuring CNC Backlash and Software Compensation
Jun 19th
This article describes how I measured the backlash on my CNC machine and then applied software compensation.
To measure backlash I used a Mitutoyo dial indicator with 0.0001″ markings and a full scale of 0.01″. The dial indicator was attached to an adjustable stand so the plunger could be placed against various surfaces on the machine. The stand had a heavy base to ensure the dial indicator and stand didn’t move when pressure was applied to the plunger.
The picture below shows the set up ready to measure the backlash of the X axis.
Here is the method I used:
- Position the plunger on the dial indicator a short distance from a surface that moves in the direction of the axis being measured. The plunger should be perpendicular to the surface.
- Jog 0.001″ along the axis being measured into the plunger, until the needle moves at least 0.001″.
- Note the value shown on the dial indicator. We’ll call this ‘S’ for start.
- Jog the axis 0.001″ seven times into the plunger. Each jog will cause the needle to move. Be careful not to cause the needle to move to the maximum position.
- Jog the axis 0.001″ seven times away from the plunger. The first one, two or three jogs may not cause the needle to move. This is the slack being taken up and hence the backlash.
- Note the value shown on the dial indicator. We’ll call this ‘F’ for finish.
- Calculate the difference between the finish value and the start value (F -S). This is the amount of backlash.
- Jog the axis away from the plunger
- Repeat two more times then work out the average value.
The next picture shows the position of the dial indicator used to measure the Y axis.
The last picture shows the position of the dial indicator used to measure the Z axis.
For my machine I measured the backlash as (averages):
- X = 0.00538″
- Y = 0.00250″
- Z = 0.00030″
EMC2 provides software compensation for backlash. This isn’t as good as using anti-backlash nuts, but I was curious to see how well it would perform. One thing to keep in mind is that over time wear will cause the backlash to change. To configure EMC2 simply add the backlash values to the axis sections of the INI file. Nice and simple. For example:
[AXIS_0]
...
BACKLASH=0.00538
I then remeasured the backlash and obtained the following values (averages):
- X = 0.00073″
- Y = 0.00010″
- Z = 0.00013″
The Y axis saw the greatest improvement (96%) followed by the X axis (86%) and the Z axis (56%). I think this is pretty good.