Fighting with computers

Computers are not always friendly.

Thursday, April 29, 2010

Animate the drawing of a SVG file

Several times I've blogged about Inkscape vector drawing software and its many uses. Being free software there is nothing to lose if you want to try it out. I use it on Windows, Linux and OSX happily.

For a new project I wanted to get a given drawing animated and maybe with a soundtrack. My goal was to use this for explaining some topics of my lessons.

Long ago I saw LectureScribe and I liked it. But it was not exactly what I was looking for, though you might want to give it a try too.

What I am showing you below is a rough demo (no music so I won't get any damn DMCA notice; yes I know there are copyright free music). I've used a Python script by Ed Halley to get a sequence of photograms. Next I've used mencoder to combine them to create a video I later uploaded to youtube.

It's a drawing of an stepper motor interface.

In case you wonder, I captured this drawing using a Genius G-note board.

Tuesday, April 20, 2010

I lost my parallel programmer

A while ago I wired a 25-pin parallel port socket with three resistors to build a parallel programmer for burning Arduino bootloader on brand-new chips. I used several times and it was great. However I do have the need to use it now and I cannot find it.

I've bought an ATMega328 as a drop-in replacement to have more memory available for a project involving the Ethernet shield and UDP networking. Unfortunately, Arduino Mega does not have the proper pinout for the Ethernet shield, so the ATmega328 is my best choice. But the new chip I've bought was empty and I need to burn the booloader.

I do keep my old PC available just in case, but my new iMac does not have a parallel port either. So I remembered that there was another way of burning the bootloader with some extra wiring on a Diecimila board.

And the wires go to the ICSP header ...

This way the FTDI serial chip can be used to burn the bootloader in the flash memory of the ATmega. However, it is not as easy if you are not using Windows. The problem is that in order to use this method, changes to avrdude program and FTDI driver are needed in OS X and Linux. The process is well documented but it is time consuming.

For those not interested on compiling away I'd recommend you to use a Windows virtual machine to make the process faster and easier. That's what I did and it worked nicely with vmplayer on Linux.

Saturday, April 10, 2010

MicroRGB: A LED with a brain

A recent project required to create a matrix of RGB leds. First prototype was set to a 5x5 matrix. For quite some time I've been thinking on the cheapest and more powerful way of doing this. Other people already answered the question in different ways. Either they put a micro controller on board, like BlinkM or they use a PWM shift register like ShiftBrite.

A while ago I learned of a website with several PIC-based projects in the same line, one of them it was a serial addressable RGB led controller.

One of the factors I was taking into account was cost. When you are using a large amount of units the unit cost becomes important if your budget is limited. I decided I wanted to create my own device. Should I chose a Microchip micro controller I could use the software mentioned above. My fist take was to use a 12F675 8-pin micro controller I found for $1 each on eBay. Unfortunately it seems too limited for the task of handling 3 PWM channels and serial communications as it lacks of a UART. Next stop was 16F628A that has more memory, timers and a hardware UART (and some code I can use is available too).

Next stop was to decide the format of the device: I was thinking of a small board that would hold a Superflex RGB led, the micro controller plus a programming interface (using SMD parts you program by soldering some temporary wires to the programmer is something I do not want to do very often). This way I am able to change the firmware to fit different applications.

Ok, so I have to create my own PCB for SMD parts. Well ... I've never done this before for SMD parts. After checking several software packages I settled with the free version of Eagle CAD that works happily with my Mac and Linux computers.

After some browsing I learned that Futurelc was making prototype PCBs at affordable prices. I sent them my Eagle files as they accepted that format too. Unfortunately something went wrong in the process as they remained unresponsive for two weeks. After that period of time waiting for them to ask me to pay for my order I decided I no longer wanted to deal with a company that treats you like this before getting your money (discovering this after you'd paid puts you in an even more difficult situation). I cancelled my order and I searched for another company. This time I selected PCBCART that also had good comments online and though more expensive than Futurlec hopefully would deliver my boards. Process run smoothly, they also accepted Eagle CAD files and a few days later I received the boards from China by Fedex. Please note that in order to keep my costs low I ordered a single-side board with no solder mask nor labeling. Therefore I cannot comment on how well they work in multilayer designs.

If you do not factor in your time, I'd say this thing can be built for less than $3 per unit. A typical setup just needs three wires (VCC, GND, TX) connected in parallel to all the units. TX line can be driven from a PC or an Arduino controller.

For programming the finished devices I used an old TE20X, which is based on the JDM programming interface for Microchip processors. The only problem is that you need a real RS-232 port on your computer (a USB adapter won't work).

Both schematic and board are available. And you can use Pete's firmware too.

Saturday, April 03, 2010

Yet another laser cutter

When my EPSON 830U decided not to work for me anymore (printing heads clogged) I thought I could make some use of the still working mechanics of the printer. It's based on a couple of stepper motors for both axis of motion (print head and paper feed).

So I replaced the original power supply and drive electronics for an arduino board and an stepper motor driver from Adafruit industries. Now I could move the printhead anywhere on a page. Next step was to add a laser on the printhead and to control it using a PWM output from arduino (so laser power could be modulated from the computer).

Though it only cut thin back color cardboard, it has may uses. I wrote a C program for arduino to control the stepper motors and laser. It receives data from the computer and interfaces with the old printer guts.

Data format is very simple: each line contains a sequence of integer numbers separated by blank space. Each pair of numbers represents one XY coordinate. Line ends with a CR (0x0d) character (that also shuts down the laser to stop cutting). First coordinate of a line sets the starting point (before reaching that location the laser is off).

I wrote some software running on my iMac that reads a Inkscape SVG file (only straight lines are supported though, use Flatten Bezier on curves to get a sequence of straight line segments) and translates it to the desired data format for arduino and it shows a preview on the screen. Data is sent through a USB port to the arduino. iMac code was written using Processing language (Java-based) so it can run on Windows or Linux too.

If you have an old EPSON printer, you may want to give it a second thought before putting it to the trash.

Video was shot by taping an iPod to the printer's head. That's why it looks laser is static and only cardboard moves.

Update: After I published the above version of software, I kept working on the next one. Now flow control works ok and the Processing code shows a red dot over the drawing while cutting. One click is needed to start cutting once the SVG file is shown and some minor changes make the code a bit better (SVG parsing code is very lame and failure prone, only straight lines are understood). SVG filename is still hardcoded in the Processing file.