BuildLog.Net

Open Source XMOS Based CNC Laser Engraver Controller

XMOS Logo

Project Overview

 

The goal of this project is to create a controller capable of making decent engravings with a homemade CNC laser machine. Software based controllers using the parallel port are just not capable of the fine grained control of power that is required. Off the shelf controllers are very expensive or are of questionable quality.

Typically this is the territory of FPGAs or DSP microcontroller, but they have a steep start-up cost and learning curve and would not be a good choice for an open source project. THe XMOS chip is a better choice. Anyone with any experience in microcontroller programming in C should feel comfortable using it.

I have no plans to sell the completed design as a turn key solution. Everything will be open source and some raw boards may be available for others to play with.

XMOS Device

XMOS XS1-L1

XMOS processors are event driven multi-threaded devices. The events and threading are handled in hardware at up to 400MIPS. Events are typically timing and I/O based events. Programs can be written in XC, C, C++ and assembly. XC is a special C hybrid that has special features for the special features of the XMOS. All my code was written in XC. All development tools are free. The part price is $7.50 at qty 2 and $6.40 at qty 100.

The XMOS is very scaleable. You can get a quad core version and daisy chain multiple boards all running off a single firmware.

add comments

XMOS Firmware

First of all. This is my first XC project. This is my first multi-threaded embedded project. Be kind, contribute, don't criticize or I will laser engrave your retinas. The source code will be posted soon.

The program runs in four threads.

XMOS Threads

pulseEngine

This is based a 32kHz cycle. At each cycle the engine determines how far the motors should have moved. When this adds up to an increment of a step, the I/O is set to command a step from the motor controller. The acceleration and maxSpeed are stored in units relative to the 32kHz cycle, so the math is very simple. At each step the accel value is added to the current speed value and then the current speed is added to the distance. The only other things to deal with, are when to stop accelerating and when to start start decelerating to a smooth stop. These values are calculated before each move to keep the work in the cycles down. Everything is done in 32 bit integers. No floats or long longs are used.

image Buffering

There is a 3000 x 2 array of unsigned char values to store two rows of image pixel data. While the controller is scanning a line it buffers the next line. This currently limits the image resolution to 3000 wide. The engraving can be any resolution.

Power Calculations

At each step the power is recalculated. It uses current speed, image pixel data and desired max and min power data to set the power. The current speed is used so engraving is not heavier at the ends of each as the head is going slower due to accel/decel issues.

PC Software

The controller is interfaced with a Windows based program. It is written in the free version of VB.NET 2008. Right now the interface is step based. This makes it easier for me to debug. Later it will be inch or mm based with a behind the scenes conversion to steps based on the actual machine.

Maybe this could morph into some sort of plugin for another program. (Mach3, CorelDraw, Inkscape, Paint.NET).

PC Controller

 

Test Setup

I purchased an XK-1 development board direct from XMOS. Everything else I had laying around. I used a "Brain Stem" RS232-TTL converter to get serial data into the XMOS from the PC via the serial port. The PC can also send via TCP/IP if that is implemented on the controller. I was using a Lantronix WiPort deveopment board, but that started acting flaky and not accepting connections. The XMOS is 3.3V. All the 5V & 3.3V stuff played well together, but the PWM laser power control would only reach 66% of full scaleI with 3.3V, so I used a Spark Fun level shifter. I used a very old Xylotex 3 axis motor controller to move the motors. The wiring was very easy. It was only about a dozen connections. I used my favorite Sparkfun jumpers connections. The block at the top where the ribbon cable connects is just a 25PIN D breakout board.

 

XMOS XK-1 Brain Stem Sparkfun Level ShifterSpark Fun Jumpers

XMOS Test Setup

Schemtatic

 

Engraving Results

Here is my first test of the controller. This was engraved on a polished granite floor tile. The image resolution was 475 x 600. The engraving is resolution is 667 X 667 lines per inch. The size is about 1.5" wide. The Y stepover is 3 steps ( 0.0044"). Granite is not the best for fine detail because the laser is basically exploding pieces off, but some of the lines on the engraving are less than .005" wide. I think I had the power a little higher than optimal too.

First Laser Engraving

Final Board Design Thoughts

I don't initially plan to have this do any G-Code control for cutting. Things like coordinated arc motion, etc are beyond me right now. Therefore, I think I might put a 25pin D connector pass through circuit on the board. The XMOS could boot into two different modes. One for engraving and one to monitor and echo the signals between the two D connectors. Standard motion controllers like Mach3 and EMC2 would be used in this mode.

I may make a "shield" (Arduino style) for the Sparkfun board. That will eliminate the most difficult soldering.

Spark Fun Board

add comments

 

Comments

About Us | Contact | 2009 BuildLog.Net