Introduction: Arduino Based Etch a Sketch Laser Cutter.

In this project I take an Arduino Mini Pro connect it to a custom made Etch A Sketch panel and use it to control a Blacknose laser cutter. The result is hours of crazy laser cutting fun, which we will be taking round most of the UK Maker Faires this year for JustAddSharks.co.uk

T
he Etch A Sketch has 2 knobs in the lower corners, one controls movement in the X axis and the other controls movement in the Y Axis. The laser cutter also has an X and a Y axis so each knob is mapped directly to the appropriate axis. The laser is only turned on while the axis are moving which prevents the laser from setting fire to the material it is cutting.


 
The control is all done using the Arduino Mini Pro which shows that small can also be powerful. The lack of processing speed to produce stepper motor pulses is compensated for using the hardware PWM modules in exactly the same ways as described in my previous instructable.

We will be taking this whole project to the UK Maker Faire at the end of April as well as numerous other UK Maker Faires this year so if you're lucky you can come and visit us and give it a try for yourself.

Step 1: Quadrature Inputs

The rotary encoders used in this project produce quadrature output wave signal. 
Quadrature output is sent over two data lines, each line carries a square wave signal but the two lines are 90 degrees out of phase.

By counting the number of pulses on either square wave it is possible to determine how far the encoder has been turned. It is important to know the direction that the knob is turning to decide if the step should be added or taken away from the total count. This is where the second data line can be used.

If you check the state of the 'B' data line as the state of the 'A' line changes you can determine which direction the knob was turning. In the example images I have highlighted the falling edge of the 'A' signal. While the knob is being turned clockwise the 'B' line is high as the 'A' line falls. When the knob is turned anticlockwise the 'B' line is low.

For ultra fast detection of the quadrature input the first data line could easily be connected to an interrupt input and set to detect the signal edge. Each time the interrupt triggers the count can be changed and by checking the second line on a standard input you know to add or subtract from the count.




Step 2: The Etch a Sketch Controller

The Etch A Sketch controller is laser cut from laser plywood. The frame is very simple, the two rotary encoders are held in the corners. The square holes stop the encoders turning in the housing. The shaft of the encoders is D shaped so the holes in the knobs were cut to match. The knobs were glued onto the shafts.

Wires were run from the encoders down to the controller before the frame was closed with additional layers of ply. The red coloured was created with mahogany wood dye. In total there are 6 layers of material in the frame giving it 18mm of thickness, the whole frame is 100mm x 135mm.

I've attached the cutting files in svg and pdf. The files were originally created in Inkscape and saved as svg but I find pdf is much more interchangeable.

Step 3: Arduino Controller Board

This project could be used on any laser cutter that uses the leetro lasercut controller. By using 3.81mm terminal blocks, the same as the existing controller, this board can be plugged in and out of the laser cutter. It can still be used as a functional laser cutter with a moments notice.

The arduino is 'piggybacked' onto a piece of strip board which holds the connectors for the other modules. 

All of the switched inputs use the internal pull ups to stop the possibility of floating digital lines.
The rotary encoders connect using the analogue input pins but these are configured as digital IO.
The stepper motor drivers both connect to the hardware PWM module on Timer 1
The laser driver connects to the hardware PWM module on Timer 3
The laser driver enable line is routed through the lid sensor and the flow switch

Step 4: The Source Code

The source for this project is actually very simple, most of the complicated control is actually handled by the hardware PWM modules. The PWM outputs are setup at the start and they don't change throughout the program.

Each input pulse on the rotary encoder enables the stepper motor outputs and a timer within the code. When the timer times out the pulses to the stepper motor are turned off. This turns a single pulse on the rotary encoder into a series of output pulses that drive the stepper motor several millimetres instead of just 1 step.

The PWM for the laser driver is set at the beginning of the code. The control is done by using the digital enable line, this simply turns the laser on and off in the appropriate places. This data line is routed through the flow sensor and the Lid sensor so it is impossible to accidentally activate the laser when it might be dangerous to do so.

When either the X or Y axis is moving the laser tube is turned on. Only cutting when the axis are moving prevents the laser from being on while stationary so chances of fire are greatly diminished.