Escolar Documentos
Profissional Documentos
Cultura Documentos
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
20th October A Raspberry Pi controlled mini CNC Laser engraver [last update
Dec 18, 2013]
I recently made a mini CNC laser engraver using two DVD drives salvaged from old computers and <$10 extra parts bought on
eBay. The controller of the CNC machine is a Raspberry Pi, a $35 credit card size computer. The engraver turns out to be pretty
successful. So I am sharing it with everyone.
There have been a lot of examples people using Arduino to control CNCs. And you can probably can find tons of C programs
available that can run directly on Arduino to process G code. A famous one is grbl. Like this on by Groover in instructable
[http://www.instructables.com/id/Pocket-laser-engraver/] A Chinese translation can be found here [http://www.guokr.com/article/18616/] .
Also there are available CNC controller like MATH3 on the market that can be controlled by serial.
I am taking a different approach by using a RPi (http://www.raspberrypi.org/)
[https://lh5.googleusercontent.com/-gZxCHkodIg/UmQ7E0MNe3I/AAAAAAAABlo/j4Xc11Na9Zk/s640/blogger-image-1777046652.jpg]
A Raspberry Pi mini computer
The reason why I choose Raspberry Pi is: it is a much more powerful device than Arduino; it has a complete OS; the GPIO pins
can be controlled by python, a more intuitive and simpler language than C (the disadvantage of python would be the slow speed); I
don't have to buy a separate controller for this project--I can use a single Raspberry Pi to do a lot of different things without
reloading firmware. Most importantly, I have a Raspberry Pi but don't have an Arduino right now!
Also, there are projects people running LinuxCNC on Raspberry Pi and use an external PIC 32 board to control CNC. It's a great
idea but I want to limit my cost to be minimum. Instead, I wrote my own python interpreter to execute G code or process jpg
image directly. For 2D CNC laser engraver, it is actually very easy to control and don't require high-level program techniques.
I will keep updating this post. And hopefully this post will eventually cover everything including the python code.
First, some pictures.
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
1/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
[https://lh3.googleusercontent.com/NhET35e5HHE/UmQ6XNquFGI/AAAAAAAABlY/1h6hy94DCJ4/s640/blogger-image-1422023181.jpg]
Laser engraver is work ing
[https://lh4.googleusercontent.com/-9WzCIW9OWPY/Umrz8fhsEdI/AAAAAAAABqM/mGzgnLCfkuc/s640/blogger-image1868552292.jpg]
A coin size university icon on a plastic board
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
2/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
[https://lh4.googleusercontent.com/--Uz2gPIMjGE/UmQ6VzgbuI/AAAAAAAABlI/T7Md51ZZ9wE/s640/blogger-image-1452605621.jpg]
I messed up the direction for this one...
[https://lh4.googleusercontent.com/X5Fff2_epwM/UmQ6WXvi99I/AAAAAAAABlQ/znB88dNArXc/s640/blogger-image-1347168473.jpg]
Some words..
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
3/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
[https://lh3.googleusercontent.com/TO6rmzfeHiE/Umsa8Qr6DFI/AAAAAAAABqs/Xuf_pwW9_mY/s640/blogger-image-954034757.jpg]
The machine is not pack aged yet. You can find: machine (top middle), controlling circuit (top left) and RPi (lower right)
[https://lh4.googleusercontent.com/O_1FzA6BDMg/UmsbKBSgJyI/AAAAAAAABq8/gfj1FxDT4BU/s640/blogger-image-1433608126.jpg]
The controller and wires in a perfect chaos
Must read!!!
This post has drawn considerable attention in the past several weeks. Sorry that I still haven't been able to finalize it yet.. But
everything needed to make a RPi mini laser engraver is already here. Once all parts are ready, it shouldn't take more than a
weekend to finish the project.
Now, as everyone does, I feel crazy about laser. But it is extremely important to keep in mind that the laser used in this project
could burn human eye retina in millisec before eyeball is capable to react. Even a random reflection beam during engraving could
be >50 mW (for comparison, a regular laser pointer is 1 mW), and make permanent damage to your eyes, kids' eyes, or pets'
eyes. ALWAYS WARE A LASER SAFE GOGLE when you are close to the working engraver. A suitable one for 650 nm laser
should be green color. MAKE SURE THE ENGRAVER IS NOT ACCESSIBLE TO KIDS OR PETS. I would suggest everyone
planning to build this should enclose the whole thing inside a large box or cover (however, mounting a little computer fan on the
box would be nice).
AGAIN, think TWICE before you make it.
4/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
You can make your own H bridges by using 4 NPN and 4 PNP transistors and probably TTL converters (RPi's GPIO pin are 3.3V
so logic TTL chips might be required). Or you can simply buy them. There are a lot of integrated H bridge circuits available in the
market, such as L298. The ones I use are L9110s Dual H Bridge purchased on Ebay (like this one:
http://www.ebay.com/itm/350877288713?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649). They are low cost (~$2
each), compact (.8"x1") and are powerful enough (~800mA). However, if you buy from a Chinese seller, shipping can cost 3
weeks.
L9110s is also known as HG7881.
Regarding the H bridge, you need to make sure that the continuous current limit of the circuit is greater than 500mA. Usually the
stepper motor in a DVD drive is rated at 5V and each coil has a resistance of 10ohm. So the current through each coil would be
500mA!
5. a LM317 regulator, a power NPN bipolar transistor (like E3055, should be able to handle continuous 200mA at least), some
resistors, capacitors and a bundle of jumpers.
The LM317 is for the laser driver. The power NPN is for making a switch for the laser. My lab has tons of these components so I
don't have buy them. If you don't want to solder a driver by your own, you can surely buy a laser driver for <$5. The laser driver
need to be able to output at least 200mA at 2V and have the function of enable/disable.
6. a solder gun, screw driver and some basic hard wares.
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
5/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
[https://lh3.googleusercontent.com/A8TCx9psJ1k/Umf7nko9YsI/AAAAAAAABnE/E92lJZWfB7Q/s640/blogger-image--865966619.jpg]
Two DVD found in E-waste
[https://lh6.googleusercontent.com/AqE0_gUYNTM/Umf7m607nCI/AAAAAAAABm8/Kq3PtUQ0-B8/s640/blogger-image--1290820048.jpg]
They are rewritable
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
6/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
[https://lh5.googleusercontent.com/-uShfewz1fs/UmSPqMT8zZI/AAAAAAAABmA/ttZV2bW4imM/s640/blogger-image-675544038.jpg]
tearing down a DVD
[https://lh6.googleusercontent.com/U9SHrrvyYjM/UmSTtTAAo7I/AAAAAAAABmc/G2nZTaapCEE/s640/blogger-image-1858542639.jpg]
Two 5.6mm laser diodes (infrared and 650nm red)
compared with a USB connector.
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
7/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
[https://lh5.googleusercontent.com/KdkGOs7eL30/UmSPtdBrOpI/AAAAAAAABmI/lpZfL5FjOXI/s640/blogger-image-1710620668.jpg]
Stepper motor (right) and linear slider.
I soldered four wires on the stepper motor.
There are other good things you can salvage from the DVD drive and keep for future projects, such as a 9 V dc motor near the
gate, a brushless motor that spins the DVDs, some shock reducers and some miniature lens and optic parts. You can also find
four strong magnets near the laser diode. Don't throw them away. They will turn out to be useful later.
[http://2.bp.blogspot.com/XSMh79o74FQ/UmgAjAM49fI/AAAAAAAABnU/KkE5DPnQ1us/s1600/untitled.bmp]
The laser diode housing
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
8/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
[http://1.bp.blogspot.com/-nrlB5I5__xA/UmgB5GeydNI/AAAAAAAABng/baeZmj4pIIA/s1600/laser.jpg]
[https://lh4.googleusercontent.com/nhuXe5WT5pE/UmoYwpU_1oI/AAAAAAAABpU/YKjhDO8bskw/s640/blogger-image--801909403.jpg]
Laser diode (middle left) and laser housing
[http://1.bp.blogspot.com/-nrlB5I5__xA/UmgB5GeydNI/AAAAAAAABng/baeZmj4pIIA/s1600/laser.jpg]
[https://lh4.googleusercontent.com/-V4anUZswBHM/UmoYvGexB-I/AAAAAAAABpM/sddluZksTXs/s640/blogger-image400252594.jpg]
[https://lh4.googleusercontent.com/DA0TsV2dvrQ/UmoYrxJq4xI/AAAAAAAABo0/GgB7EFyrV2A/s640/blogger-image-1938372409.jpg]
Pushing the diode into the housing head
[https://lh4.googleusercontent.com/-V4anUZswBHM/UmoYvGexB-I/AAAAAAAABpM/sddluZksTXs/s640/blogger-image400252594.jpg]
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
9/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
[https://lh6.googleusercontent.com/I2tiD3hpFGw/UmoYmgVRJZI/AAAAAAAABoc/zch9WYhH0Lo/s640/blogger-image-482774664.jpg]
Solder two wires on the diode
[https://lh6.googleusercontent.com/-w6lrjFmfVAQ/Umi5pGhVmaI/AAAAAAAABoA/hyWFvHhWFpU/s640/blogger-image--1656642207.jpg]
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
10/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
[https://lh5.googleusercontent.com/EELclxxwmHI/UmoYn1OjXoI/AAAAAAAABok/CTrNSCnXdjM/s640/blogger-image-1314658176.jpg]
Use some heat shrink to increase the strength
[https://lh3.googleusercontent.com/fL2kWXPADlY/UmoYpBnIc4I/AAAAAAAABos/8SUVecbUQGQ/s640/blogger-image-1947563989.jpg]
Getting there
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
11/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
[https://lh4.googleusercontent.com/zmVUvqNTwBU/UmoYsqg_vGI/AAAAAAAABo8/KkzCpx0A8oo/s640/blogger-image--227150302.jpg]
Done!
Carefully put the laser diode into the head of the laser housing. You can use the laser housing body to help knock against the
diode and push the diode into the housing head. The diode should fit perfectly into the head. Make sure the pins are still fine. Then
solder two wires to the electrodes and assemble the housing together.
STEP 3: Make laser driver and enabler and test the laser
A laser diode is like a photodiode but equipped with a resonant cavity. Laser diode is a huge current sink. Once the
diode conducts, it generates a lot of heat, and the heat further lowers the diode impedance. So it is a unstable positive
feedback system. If you simply put a 1.5 V battery across the diode, you will either get the diode burn or battery
drained right away. We need a laser driver that can output a constant current to the diode.
There are numerous way to do this. One of the most popular and least frustrating way is to use a DC current regulator. LM317 is a
good choice. By adding a resister R across the adjust pin and output pin, LM317 can output a constant current of ~1.25V/R.
[In fact, LM317 is mostly used as a voltage regulator. It maintains a 1.25V across the output pin (pin 2) and the adj pin (pin 1).
Meanwhile, it controls the current output from the adj pin to be very low (usually <100 uA). Therefore by adding a resistor R across
pin 2 and 3, we can have 1.25V/R current output from pin 2 to pin 1. We then add the laser diode across pin 1 and GND. Since
pin 1 is forbidden to sink current, all the 1.25V/R current outputted by pin 2 will flow through R and laser diode to GND. The official
datasheet of LM317 can be download here . [http://www.fairchildsemi.com/ds/LM/LM317.pdf]
A good instruction can be found here LM317 Laser Driver [http://www.rog8811.com/laserdriver.htm]
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
12/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
In my case, I replace the two parallel 10 ohm resistors by two .5 Watt 12 ohm resistors. The max current I am going to run
through the diode is 200mA.
Make sure you don't mess up the adjust pin and the output pin. A heat sink would be necessary on the LM317.
You also need a switch that can be controlled by RPi. I used a power NPN E3055 transistor. You can choose what every you
want, just make sure that the transistor can support continuous CE current >300mA and also put a heat sink on it.
[http://1.bp.blogspot.com/-ewI7TGlE0q8/UmvuF9vmrSI/AAAAAAAABrM/pn0yN2P9Vpo/s1600/laser_driver.png]
Schematics of the laser driver and the switch. Laser is on only when "Laser switch" port is logic high (>3V). Mak e sure you don't
mess up the pin order of LM317
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
13/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
[https://lh4.googleusercontent.com/-0HWB1UT3Ccc/Umrz5RUEyMI/AAAAAAAABp8/lGNwa25KNG4/s640/bloggerimage--1341492090.jpg]
[https://lh5.googleusercontent.com/kvgU8nHr7YY/Umrz7LGSVVI/AAAAAAAABqE/P6rKSIUDIPg/s640/blogger-image--482078108.jpg]
Laser driver (top) and the E3055 power NPN (bottom)
14/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
attached to x-axis so it only moves in x direction. The laser is attached to y axis so it only moves in y direction. This configuration
minimizes the weight on each of the axes.
[https://lh5.googleusercontent.com/Mr32O1BsXxA/UmoYt96zZDI/AAAAAAAABpE/RByzrEnqT80/s640/blogger-image-1694152089.jpg]
Laser engraver I made
[https://lh5.googleusercontent.com/-nysEOwGE4tc/Umi5n4pVAyI/AAAAAAAABn4/aMFNAwYovCM/s640/bloggerimage-1285557579.jpg]
I cut a 2"x2" steel board out of the DVD case and glued it to the x-axis stage as the sample support base. Since the DVD case is
made from iron, you can use the strong magnets salvaged from the laser optical system to help you stabilize the engraving
sample on the base.
The laser diode will generate a lot of heat . And it is important to dissipate this heat. Otherwise the diode will die fast. I cut a
1inch cube heat sink from an old computer CPU heat sink and drilled a hole though it. The hole is perfectly large to hold the laser.
I glue the heat sink on the y axis stages.
The most important issue is the x axis, y axis and body of laser have to be perpendicular to each other.
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
15/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
[https://lh5.googleusercontent.com/-9yw5RESL_ow/UmvurjhTtSI/AAAAAAAABrU/8u5BnERSTbo/s640/blogger-image975699712.jpg]
Four connect pins on a 4-wire-2-phase stepper motor. They are usually arranged in the following order: a1,a2,b1,b2. (a1 and a2
are the two leads of coil a; b1 and b2 are the two leads of coil b). Using a multimeter will help to verify this.
The stepper motor in DVD is a 4-wire 2-phase bipolar motor. There are two independent coils inside. Each coil has a
10 Ohm resistance. Usually the DVD stepper motors are rated at 5V. Therefor the rated current through each coil is
500mA! The RPi GPIO pins can only output less than 20mA so RPi cannot control a stepper directly. H bridges are
required.
Here
is
very
good
tutorial
on
Bipolar
stepper
motor
Bipolar
Tutorial
[http://www.stepperworld.com/Tutorials/pgBipolarTutorial.htm]
Seems I am using different names for pins of stepper motor. In most people's writeup I can find online, they define
coil 1 and coil 2 and name 1a, 1b as the two leads of coil 1, and 2a, 2b as the two leads of coil 2. It doesn't matter, as
long as we know what we are doing. At least in this post I will keep the terminology thing consistent.
The central spinner of the bipolar stepper motor can be regarded as a bar magnet (actually it is circular). Obviously from the figure
above that if we successively conduct current in coil a1, b2, a2 and b1, the spinner will spin in the desired sequence. To do this,
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
16/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
we can apply a voltage sequence to a1, b2, a2, b1 as:1) high, low, low, low. So only a1 and a2 are activated. Since a1 a2 have
same polarity (or opposite depending on how you define it), the spinner is pointing to a1
2)low, high, low, low. So only b2 and b1 are activated. Spinner is pointing to b2
3)low, low, high, low. So only a2 and a2 are activated. Spinner points to a2
4)low, low, low, high. Spinner points to b1.
go to 1).
Denote high as 1 and low as 0. The sequence can be written as 1000,0100,0010,0001
The advantage of this configuration is that it is very easy to understand and usually the stepper motor moves very precisely.
However, since in each step only one pair of coils is activated, the torque applied on the spinner is not very great.
To achieve high torque, a more popular way is to apply the following sequence: 1100,0110,0011,1001. And the spinner will be
pointing to middle of a1 and b2, middle of b2 and a2, middle of a2 and b1, middle of b1 and a1 consequentially. And the torque is
doubled. This is called full-step mode or high torque mode or two phase mode.. and is usually the mode used.
If the torque won't be a problem then we can use a 8-step sequence: 1000,1100,0100,0110,0010,0011,0001,1001. The spinner will
turn 8 steps instead of 4 steps to turn same angle. This doubles the resolution. And the cost is the non-uniform torque being
applied on the stepper motor. This is called half-step mode.
Usually for DVDs, the linear sliders moves about 0.15mm every full step stepper motor turn, corresponding to a resolution of
~170dpi. Good enough for home-made projects. If 8-step mode is implemented, then the resolution is 0.075mm/step or 340dp,
similar to regular printer.
For laser engraver, there isn't any serious load on the stepper motor so I choose the half-step mode or 8-step mode.
As mentioned, RPi cannot drive the stepper motor directly because of the current limit. Actually, besides powering low power
LEDs, the GPIO pins of a RPi usually serves as logic switches. In output mode, they are either logical High (3V) or logic low
(<0.7V). A H bridges is a "translator" that translates these logic High or Low into power source that has high voltage or low
voltage.
[http://2.bp.blogspot.com/fV0rZGpTArw/UnFHMel0eFI/AAAAAAAABsM/i01kBInTTZ8/s1600/Hbridge.bmp]
A very very simplified conceptual schematics of NPN PNP H bridges. NEVER build an H bridge based on this graph. You
will probably burn the transistors or even the Pi. A practical H bridge requires current limiting resistors, reverse diodes and logic
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
17/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
TTL chips. Please consult more from other sources if you would lik e to build a work ing H bridge from scratch.
When A is logic low (0V) and B is logic high(+V), then transistor 1 and 4 are conducting while 2 and 3 are open; when A is logic
high (+V) and B is logic low (0V), then transistor 1 and 4 are oepn while 2 and 3 are conducting. When both A and B are logic
high, 2 and 4 are conducting, 1 and 3 are open, the motor stalls; when both A and B are low, 1 and 3 are conducting, 2 and 4 are
open, the motor stalls.
Therefore by setting A and B high or low, we can control the current direction through a load. For each 4 wire 2 phase stepper
motor, there are two independent coils we need to control. So a total of 4 H bridges are required to control the two stepper motors.
There are a lot of integrated H bridge available on the market. For my case, I need 500mA through each H bridge so L9110S
suffices (L9110S can afford 800mA through each H bridge). Each L9110S contain two H bridge so two of them is enough. There
are L9110S module for <$2 each on the market. Very convenient!
I am not exactly sure but I think sometimes people call it L9110 sometimes L9110S.. Datasheet can be found here
[http://nvhs.files.wordpress.com/2013/02/datasheet-l9110.pdf] .
Also, L9110S has internal clamp diodes to conduct the reverse current generated by the sudden stop of the stepper motors. This
protects the circuit. L9110S is TTL/CMOS output level compatible so it can be directly connected to RPi.
[https://lh5.googleusercontent.com/-ZJCKmxDARE/Umrz90EnW3I/AAAAAAAABqU/twC9EEK2yCk/s640/blogger-image--1562055245.jpg]
Two L9110 dual H bridges (also k nown as HG7881). They are 0.8" by 1" big
Each dual bridges control a stepper motors. On the right hand side, there are a1, a2, b1, b2 connectors to the stepper motors
(top to bottom). On the left hand side, there are logic control pins for a1, a2, b1, b2 (actually they are named as A-IA, A-IB, BIA, B-IB) and VCC and GND.
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
18/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
[https://lh5.googleusercontent.com/_u3tXFcXriI/Umrz_CHi1AI/AAAAAAAABqc/QtZBxTCYqSM/s640/blogger-image--492549739.jpg]
When powered, the chips light up (The big circular thing is my ring. I don't have a big finger..)
The most challenging part is how to control more than one stepper motor simultaneously. The idea is actually very simple and
can be extended to any number of motors. We already know how to control one motor. Now suppose we have two motors: MX
and MY, and we want to turn MX 12 steps and MY 15 steps simultaneously in 6 seconds. First find the least common multiplier
(LCM) of 12 and 15, which is 60. Now divide 6 seconds by 60 we get dt=0.1sec. Set 60 loops. Before the end of each loop, we
use time.sleep(0.1) commands. So it takes 6 sec to finish the loop. And we move MX one step every 5 loops and move MY one
step every 4 loops. After 60 loops, MX moves 60/5=12 steps and MY moves 60/4=15 steps. And both MX and MY moved at
constant speeds.
00001 [tel:0000100001] 00001 [tel:0000100001] 00001 [tel:0000100001] 00001 [tel:0000100001] 00001 [tel:0000100001] 00001
[tel:0000100001] 00001
[tel:0000100001] 00001
[tel:0000100001]
0001 [tel:0001000100] 0001 [tel:0001000100] 00 [tel:0001000100] 01 [tel:0100010001] 0001 [tel:0100010001] 0001 [tel:0100010001]
0001 [tel:0001000100] 0001 [tel:0001000100] 00 [tel:0001000100] 01 [tel:0100010001] 0001 [tel:0100010001] 0001 [tel:0100010001]
0001 [tel:0001000100] 0001 [tel:0001000100] 00 [tel:0001000100] 01 [tel:0100010001] 0001 [tel:0100010001] 0001 [tel:0100010001] (60
digits, 15 ones)
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
19/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
For more than two stepper motors, just find the LCM of all the steps (ignore 0).
You
can
download
all
the
python
code
here
My
RPi
CNC
Laser
Engraver
Code
[http://hostcode.sourceforge.net/p/raspberrypi-cnc-laser-engraver] :
Project: raspberrypi-cnc-laser-engraver
Code
Bipolar_Stepper_Motor_Class.py
[http://hostcode.sourceforge.net/view/1084]
Motor_control.py [http://hostcode.sourceforge.net/view/1085]
Gcode_executer.py
[http://hostcode.sourceforge.net/view/1086]
spiral.nc
[http://hostcode.sourceforge.net/view/1126]
grid.nc [http://hostcode.sourceforge.net/view/1127]
Uploaded
by
Date
Xiang Zhai
October 25,
11:34 pm
2013,
Xiang Zhai
October 25,
11:38 pm
2013,
Xiang Zhai
October 25,
11:39 pm
2013,
Language
Xiang
Zhai
text
Xiang
Zhai
text
python
python
python
Motor_control.py [http://hostcode.sourceforge.net/view/1085] defines a set of functions such as LCM (for calculating the lcm of
two integers) and Motor_Step (for controlling two motors simultaneously). Usually you don't need to modify anything.
Gcode_executer.py [http://hostcode.sourceforge.net/view/1086]
This is the main program. You need to modify line 25 (G code file name), line 29 (pin numbers for stepper motor X), line 31 (pin
numbers for stepper motor Y), line 32 (pin number for laser switch), line 35, 36 (resolution of the machine in unit of mm/step) and
line 38 (engraving speed). The code read and interpret G code, and send corresponding commands to the motor control functions.
spiral.nc [http://hostcode.sourceforge.net/view/1126]
This is a simple G code which plots a small spiral. It can perfectly test whether the machine can process G code,
especially the circular interpolation G02 and G03, correctly.
grid.nc [http://hostcode.sourceforge.net/view/1127]
A simple G code which plots several straight lines to make a grid. Perfect code to test the machine and make a
coordinate system!
Currently the Gcdoe_executer.py only accepts limited number of G commands: G90, G20, G21, M05, M03, M02, G01, G02,
G03.
The code can recognize G1F commands (engraving speed) but simply ignore it. Engraving speed is set by line 38 in unit of
mm/sec.
STEP 7: Engraving!
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
20/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
You need a laser engraving extension to convert vector graph into G codes. There are several different G code extension. The one I
use can be downloaded here Inkscape-Laser-Engraver-Extension [http://www.slackersdelight.com/instructables/laserengraver.zip]
[Note: I wrote my python G code interpreter based on the G code generated by this Inkscape extension. So the code can only
deal with limited numbers of G commands, sufficient for laser engraving though, fortunately. For G codes given by other generator,
my codes might not be able to handle all the commands. You might have to modify the python code on your own.]
Here is the step-by-step instruction on how to generate G code that my python code can process.
[http://3.bp.blogspot.com/-6PnG1Qwpm38/Uq0wtUXP6VI/AAAAAAAABzY/51yUdaDP5qo/s1600/extension.png]
The Laserengraver extension is successfully installed
21/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
You will see the blank page becomes a small square box. Zoom into that box.
[http://4.bp.blogspot.com/-69zIE7HsgJk/Uq0z9arKNmI/AAAAAAAABzk/O846_1rlV9E/s1600/object_to_path.png]
Convert objects to path
[http://3.bp.blogspot.com/-727rmzJ_wu4/Uq011xLIjLI/AAAAAAAABzw/yNxNr4XAEJI/s1600/path_to_nc.png]
Convert the object to G code
22/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
If "Draw additional graphics to debug engraving path" is checked under "Preferences" before clicking "Apply", Inkscape
will plot a lot of arrows on top of the plot, showing the moves given by the generated G code.
[http://4.bp.blogspot.com/-jUHkwHscDLU/Uq014PgIA8I/AAAAAAAABz4/6q_ezL10tpg/s1600/g_cde.png]
G code is successfully generated! A lot of arrows.
Step 7-6: Make necessary modification to the python code and then engrave!
At least you want to change the G code file name in Gcode_executer.py [http://hostcode.sourceforge.net/view/1086] (line
25). Some other changes, say, pin numbers (line 29, 31, 32), resolution (line 35, 36), engraving speed (38), can be
changed if you understand them.
Type "sudo python Gcode_executer.py" in terminal to run the python routines and have fun!
View comments
91 comments
Add a comment
Top comments
23/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
like this
http://www.ebay.com/itm/Laser-Module-Len-TO-5-9mm-Diode-12x30mm-Houseing-U-S-Seller-FastShipping-808-/251345536347?pt=LH_DefaultDomain_0&hash=item3a855c855b
1 Reply
+1
2
1
1 Reply
1 Reply
1 Reply
24/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
+Xiang Zhai
Having a switch on the box opening could make sure the laser will only work when the box is closed.
Xiang Zhai 4 days ago
+James H
great idea!
1 Reply
1 Reply
Translate
25/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
Raspbian-t futtat Raspberry Pi-t, rendelt az eBay-rl kevesebb mint 10 dollrnyi alkatrszt s sszelltott
egy lzergravrozt.
Translate
1 Reply
1 Reply
1 Reply
1 Reply
1 Reply
+2
3
2
1 Reply
26/27
23/12/13
A Raspberry Pi controlled mini CNC Laser engraver [last update Dec 18, 2013]
Joye Lin via Google+ 3 weeks ago - Shared publicly
1
+7
8
7
1 Reply
+1
2
1
1 Reply
Show more
funofdiy.blogspot.co.uk/2013/10/a-raspberry-pi-controlled-mini-laser.html
27/27