Open Source XMOS Based CNC Laser Engraver Controller
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.
Buildlog Title: XMOS Controller
Builder: bdring
Member Since: 2009-11-22
Tuesday, March 2nd 2010 - 3:27 PM
- XCore_ProjectOfTheMonth.jpg (4.78 KiB) Viewed 59472 times
.
My engraving controller won the XMOS "Project Of The Month"! The prize is a XK1 development kit. I already have one, but since these controllers are multi-threaded, you can just plug them together and add more processing power.
I have been on vacation, so I have not gotten anything done on this for a while, but the new PCB is in layout and should be on order soon.
add comment in the forum
Monday, February 22nd 2010 - 7:08 PM
I found out there is an error in the XMOS datasheet that says the chip I am using is 5V compatible. I hope I did not damage any of my parts.
This changes the PCB, which was almost ready to order. This is going to set me back about a week.
add comment in the forum
Monday, February 15th 2010 - 2:21 AM
Here is my basic layout of the shield. The shield is just a temporary board that will be very easy to assembly and allow me to continue testing. Only two surface mount parts need to be assembled. They are 24 pin SOICs which are fairly easy to solder. Eventually I might make a single board solution.
The Sparkfun board is on the bottom in red and my shield is above in green. It is quite small at about 2" x 3". I may order a single board from
Sparkfun's Batch PCB for about $20. Or I can get about 14 of them from
Gold Phoenix for about $90. The problem with the shield is you need a $50 Sparkfun board to use it.
.
.
add comment in the forum
Monday, February 15th 2010 - 1:21 AM
I did a little bit of testing with the Sparkfun board that I will use as a base board for my CNC shield.
- I tested the USB to make sure that will do what I need and it worked perfectly
- I tested to make sure the XLINK pins can be used for I/O. They appear to work just fine.
- I did a quick pass through test. This puts the controller in a mode where it reads the parallel port and outputs it back on another connector. This will allow the controller to sit on the cable and allow the PC to control the laser or take control itself. This will allow a lot of options and eliminate cable swapping. It can will also allow a hybrid mode where both the PC parallel port and both control the laser. It worked fine.
Here is a picture of my temporary scatter wire version of the setup. The little green card is a 3.3V-5V translator. Everything seem to be working perfectly. I am going to start the shield card layout this week.
.
add comment in the forum
Friday, February 12th 2010 - 7:34 PM
The Sparkfun XMOS came today. I'll do a little testing and then layout the shield.
.
add comment in the forum
Saturday, February 6th 2010 - 11:17 PM
The source code for the XMOS firmware is located on Github at this URL
http://github.com/bdring/XMOS_ctrl/
- logov3.png (4.98 KiB) Viewed 59773 times
This is my first GitHub project, so I am not real sure how to work with others on this yet.
add comment in the forum
Saturday, February 6th 2010 - 11:07 PM
Here is the current version of the CNC Shield for the Sparkfun XMOS Development board. I am going to have a few people review it before I buy it. I have the Sparkfun board on order and I will do so basic testing with it before I order too. The image below is not very useful. Use the PDF attachment. I just like to have a visual cue on each post so I can find stuff quickly.
Initially the code will be for engraving only. If you want to do G-Code cutting you will use your normal Mach3/EMC parallel port method. This board will connect in between the PC and CNC machine on the parallel port. This will allow you to use it in either mode without any wiring changes.
Basically it will operate in these modes.
- CNC Pass through. The signals just go through the board like it is not there. The XMOS sees all the signals, so it might be able to do some neat tricks even in this mode.
- Engrave mode. The XMOS controller runs via the USB port. The parallel port is still connected, but ignored. It does not have to ignore the parallel port in this mode, so some sort of Mach/EMC plugins could do some things here.
- TBD. There is no reason this could not turn into a junior version of a smoothstepper. It would have less I/O pins than a smoothstepper, but it plenty to control any machine that currently runs off a single parallel port
Edit: made a change to the schematic. Had some voltages wrong on the voltage translators.
Attachements...
- xmos_shield_rev_2.pdf
- Shield Schematic Rev 2
- (103.91 KiB) Downloaded 3249 times
add comment in the forum
Saturday, February 6th 2010 - 7:13 PM
I added code for the Z-axis. It only took me about an hour to code both the XMOS and the PC side and test it all. I didn't need the Z-Axis during development, but now that I am doing a lot more engravings, I wanted to have it. Here is the latest interface.
.
add comment in the forum
Wednesday, February 3rd 2010 - 3:55 AM
I am going to start tracking the progress on my XMOS controller via the buildlog system.
I added a laser pulse feature. I used this as an aiming feature on a recent engrave. I had a piece of paper taped to the bed. I ran the head to the four corners of the work piece and pulsed the laser. I then had four dots on the paper and was able to align the work piece perfectly.
- laser_pulse.JPG (8.35 KiB) Viewed 59819 times
I have been working on a schematic for a shield. I was thinking about using the
Sparkfun board, but
Folknology offered to donate an
Amino board to my project.
.
- amino_sneakpeak.png (54.84 KiB) Viewed 59833 times
add comment in the forum
XMOS Device
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.
- UART. This handles the serial traffic to and from the PC
- commCenter - This coordinates all activity between threads. Is parses the commands from the PC, sends that data to the pulseEngine thread. It also buffers image data and tells the PWM_power thread what PWM duty to set.
- pulseEngine - This is the heart of the motion control. It receives commands from the commCenter. It sends step data back to the commCenter
- PWM_Power - This thread is a simple 50kHz PWM generator with a duty resolution to 2000.
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).
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.
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.
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.
add comments
Comments
I'm not sure you noticed, but this thread is more than five years old. Your only other post to date also responds to a thread from 2009, resurrected briefly more than year ago, and with no response at that time either. Don't feel bad if you get no response here either -- it's rare that people reply to posts on such old threads (mostly because posting on old threads is a thing spammers do).