CNC machine v2.1 - aka "Valkyrie Reloaded"
| Attachment | Size |
|---|---|
| tiny2313_stepper.brd | 22.52 KB |
| tiny2313_stepper.sch | 336.57 KB |
| serial_gcode.py_.txt | 730 bytes |
Pictures:
- the front

- the back

- left

- right

- the power unit

- and some closeups here and there





Description:
This is the second third version of a homemade CNC machine build using mostly off the shelve parts.
The first one aka "The beast" had a lot of precision issues due to play in most parts which in turn was caused by mostly bad cutting. Also one of the biggest problems was that when I have build it I did not think to allow later adjustments to be done.
So this time almost every part of it allows for some adjustments. It is also easier to build due to the different design.
Purpose:
I have been asked many times over why I did this below are a few possible answers:
- because I wanted to see if I can
- because I like doing this kind of stuff
- because I think such a machine is useful
- because I want to use it to mill PCB's, I'm tired of messy etching, bad exposure, bad transfers ... etc
- because I also want to build some other stuff and I need precision
- because I learned a lot building it
- because maybe I can make some money out of it in the end
- etc, etc ...
Technical details:
- 250 by 160 265 by 225 mm maximum work area
- 50 by 35 by 35 cm machine size (could sit on my desktop :))
- with the material I have tested (laminate wood pretty tough material) it can cut at around 80 to 100 100 - ? (must still find out maybe as high as 400) mm per minute
Construction materials:
The main material used is 16 mm MDF - I used about a square meter all together.
The rails are 10 by 20 mm aluminum corners used for ... I don't know for what but the margins are slanted at an angle - I used 3 meters of it.
The lead screws are standard M8 type threaded, nothing fancy - 3 meters.
The bearings used are two types because I did not have enough of them, but you can get away with ABEC7 bearings - 16 for the X-axis + 8 for Y-axis + 8 for Z-axis + 8 for the lead screws = 40 bearings.
The motors I used are 7.5 degrees per step, 24 volt, canstack stepper motors, the kind you should find in almost all older printers.
The electronics used are all home build. The brain of the machine is an Arduino (the single sided version), and the motor drivers are created around Attiny 2313 paired with an l298.
The wires used are CAT 5 pairs used for power, and pairs from an old SCSI flat cable for data.
The screws used in the construction are standard M8 of different lengths and M6 screws to fix the rails.
Mechanics:
A. Lead screws
The design is as simple as it gets, it is all based on lead screw transmission.
I chose to use this kind of transmission because it has three advantages:
1. Force ratio is high - to move the nut along the screw the rotational force applied is low compared to the output. That allows the use of those small motors
2. Precision - even with the large step angles provided by the motors I still get pretty good sub millimeter precision: 76,8 steps/mm - good enough for my requirements for now at least.
3. Ease of implementation - you only need two bearings at the ends of the screw, two normal nuts to hold it in place, one long nut to move around.
The linear rail system allows the axes to move freely along their axis and ensure there is no side load on the lead screws.
B. Rail system
On this machine the linear rails are using a different system as on the first version, inspired by the new version of the CNC machines created by the guy here. Obviously the new system is a lot easier to implement than the one before due to it's simplicity. The only drawback is that it requires a strange type of bearing called a V-groove bearing which comes with a V shaped groove along the center of the other housing. I could not find any of those, so I used a pair of normal bearings put side by side to create a small groove in the center.
Electronics:
The electronics of this thing are composed of two parts: the Arduino board and the motor boards.
The Arduino is just a standard single side board, not much to say about it, if you want to build your own see here.
The motor boards I designed myself, they are based on an Attiny 2313 and l298. You can find the schematics below.
I have built my own controller because I did not want to have a mess of wires around the machine from the Arduino to the drivers. This way I can control all 3 axis by using just two wires trough the I2C protocol.
Software:
The software is divided in three parts:
- pc side
- Arduino side
- motor controller side
On the pc side I'm using the excellent Inkscape to draw the shapes, and a plugin to convert them to G-Code coordonates. Then I'm using a simple python script to send the G-Code to the Arduino, over the serial link.
On the Arduino I have a modified version of the code from the RepRap project (www.reprap.org), adapted to use I2C to command the motors instead of driving pins directly.
On the motor controller side the software takes different commands trough I2C and executes them.
Open source:
All code and driver schematics are available here:
http://github.com/TinHead/Valkyrie-CNC-source-code
Please ask for more info, I will add it, I do not have anything more on my mind now.
Update 15-Aug-2009 - hit a wall ...
I clearly remember updating this page about 2 -3 weeks ago but I must have been drunk ... O.o
I was saying back then that I still have an issue, that sometimes the I2C bus seems to bail out causing the machine to stop working.
I was finally able to do some testing last night and I managed to replicate this "bug" and the conclusion is that it only happens when the machine is under load, i.e. cutting something.
The question remaining is: Why? Is it a power issue? Wiring issue ?
No idea ... currently it uses a single 12 V rail from the ATX power source, I'm thinking on rewiring this fellows power lines to use one rail for each motor.
Ideas anyone?
Update 18-Aug-2009 - Here comes the source code
As promised I have made the source code available to the world. I do not like the way Drupal handles attachments (does not accept archives), so I decided to upload the code on GitHub.
Git (http://git-scm.com/) on which GitHub is based is a very nice version control system and pretty easy to use.
I have created a GitHub account, you can find my page here:
http://github.com/TinHead/Valkyrie-CNC-source-code/tree/master
To download the source code as a ZIP or TAR archive you can click on the "Download" button :)
For hardcore geeks install git and clone the code with:
git clone git://github.com/TinHead/Valkyrie-CNC-source-code.git
Have fun with it, clone it, fork it, patch it, optimize it ... eh write it in assembly if you wish.
Update 28-Sep-2009 - Some revelations
Lately I spent my time trying to understand the timers of the Attiny 2313.
While playing around with different PWM setups and frequencies I found out two things:
1. timers are not easy, but they are very useful beasts
2. why I could not get microstepping to work on the Valkyrie
While 1 is pretty obvious, 2 requires some explanations:
- microstepping requires that you adjust the power on the motor windings in such a way that a full step (say 100% an winding A and 100% in B) may be divided in multiple smaller steps.
- to achieve the above PWM has to be employed on the H-Bridge enable pins
- if PWM is employed and you drive the motors at their nominal voltage you loose torque so microstepping is a no go, the stepper might microstep without load but not under load (the PWM frequency plays an important role here, higher frequencies tend to amplyfy the problem)
- so the solution to be able to microstep is to have the motors powered at a (much?) higher voltage than the nominal voltage and apply PWM with the right frequency (which sadly varies from motor to motor) to control the power.
In my case the motors have an assumed nominal voltage of 12v (based on datasheets of similar motors) and I'm driving them with 12v -> no microstepping possible.
I have two options now:
- change the motors with 5v motors
- redesign the controllers to allow higher voltage input, the caps have to be replaced.
PS: I know this stuff is nothing new, I'm practically reinventing the wheel, but this is what it takes for me to really "get it" :)
Update 25-Nov-2009 - All work and no play makes TH a dull boy
Long time no update, sorry got lost in todo stuff and never finished the todo stuff ... bah.
Things I managed to do:
1. Redesigned the motor driver with the following things in mind:
- used a ground plane to reduce some noise
- linked all inputs of the L298 to PWM capable pins on the Attiny 2313
- moved the enable inputs to non PWM pins because of the above
- the driver is designed with two layers now ... looks nicer but it is also harder to build
- replaced power and motor pins with screw connectors so it is easier to connect the wires
- motor power is now independently routed so the driver has one power input with a voltage regulator for the logic and a separate one for the motor - on the logic power input you can use up to 12v (to be safe because the caps are 16V) on the motor up to around 40v.
- fixed a problem with the reset button in the schematic, now the reset works as it is supposed to. Before it would actually create a short, it worked but not really as it should have been.
- changed the diodes to schottky type, SB560 (not sure if they changed anything yet, but they do recommend them in the l298 datasheet)
- rearranged stuff around, I tried to follow the advices of B0SC0 on this, thanks B0SC0 :)
2. On the software side:
- found the problem with the Arduino code limiting the speed of movement (actually John_NY lead me up to this, thanks John)
- implemented full torque halfstepping on the driver trough PWM (still testing that)
Things I did not managed to do (in random order):
- really get into XK-1 to use it instead of Arduino for the XMOS challenge - needs lots of work I only got to blink a LED on it for now
- implement microstepping ... the short version is that it kind of works but totally unusable I think the torque loss is just to great or something, or a problem with my code.
- create two more new drivers to put them on the Valkyrie
- implement home sensors on the axes to home the machine
- work on the plastic extruder - still just an unclear recurring idea in my head
- squash the I2C lockup bug - but I have some ideas now
- other random stuff not related to Valkyrie
I will update the git repository with the new stuff soon, and also add the v1 controller re-designs by B0SC0 and John_NY in there.
Update 06-Dec-2009 - Bigger motors => bigger problems
So I finally got my hands on bigger motors with the kind help of a friend.
These guys are bipolar 1 Amp per coil 200 steps per revolution motors. Very cool Japanese motors.
But there of course to use them I have to recreate the motor holders 'cause those ones have a very different mount...
Also driving two of them with one driver for the X-axis... seems risky to say the least, an early test proves that they can easily blow up my driver and melt the hell out of CAT5 type wires because of current draw. I'm now considering trying to use a really big radiator on the Xaxis driver, and if that fails building a special driver for the Xaxis with two L298's on it.
Looks like I will never get to finish porting the code to the XK-1 this year ....
Update 20-Dec-2009 - Moving forwards to 2.1 (?)
So bigger motors are here (yey!) but not in use yet ... as usual I got side tracked with other stuff ...
The new ones need other mounts, and I just can't find an easy way to adapt the current mount for them. So I decided to delay mounting them, and go on using the old motors until I have a working machine which can do the mounts for me :)
Had it too long on my TODO list: New Z axis, to really take advantage of the Y axis length. As it was it "eat" about 100 mm usable workarea, just by the sheer size of it so I was pondering for a long time to fix that. This actually happened this weekend because I broke the old axis. So I had to rebuild, and I gained the missing mm on the Y axis :D
Also on my TODO was having some kind of home/eol sensors to make it easy to home the machine and stop it before destroying itself while trying to go further then possible. The drivers were designed with this in mind but I never got to try/test it. So today I finally got the drivers to respond back over I2C so they can yell "Hey I'm home already !" back to the Arduino. Which is very cool :D I'm going to implement this in the code ASAP.
One other thing waiting in my TODO is to try making an thermal plastic extruder as they have on the RepRap machine as a second tool for the Valkyrie, I was finally able to take a few steps in that direction. I played with a thermistor for the first time, and got it to show the room temperature properly, but not higher temperatures yet... I have no comparison to check it against.
And finally it looks like I'm going to hit the limits of the Arduino pretty soon with this project, I think reimplementing the extruder and the end stops will fill the rest of it up ... so I have to start working on the XMOS or get an Atmega 368 ... which I cannot seem to find locally ...
That's it for now, stay tuned ..
Update 21-Dec-2009 - Pythons
There have been several requests for the python script I use to send the g-code over to the Arduino trough the serial connection. It requires python and pyserial installed to work.
Here we go:
<code>
import serial,sys,time
serial = serial.Serial('/dev/ttyS0', 19200, timeout=1)
def check_conn():
serial.write("G21\n")
if serial.readline().strip()=="ok":
print "Connected"
else:
sys.exit("Serial connection could not be established")
def send_line(line):
print "Sending "+line
serial.write(line)
response = serial.readline()
while not response:
time.sleep(1)
response = serial.readline()
def main():
try:
filename = sys.argv[1]
except IndexError:
print "Usage: serial_gcode filename"
sys.exit
try:
g_code = open(filename, 'r').readlines()
except IOError:
print "An error occured opening the file "+filename
check_conn()
for line in g_code:
send_line(line)
if __name__ == "__main__":
main()
</code>
And attached above http://letsmakerobots.com/files/serial_gcode.py_.txt, please remove the .txt ending.
Have fun !
Update - 04 Jan 2010 -Valkyrie Reloaded
The last two days I worked on and off on the Valkyrie slowly putting it back together.
I mounted the new Z, got the motors mounted. I got the drivers checked, fixed and running.
I'm running the motors at around 30V now (give or take 5V) and with the help of the redesigned drivers, I'm running them in a so called "full torque half stepping" mode (at least it seems to work) see here for info on that:
http://www.piclist.com/tecHREF/io/stepper/linistep/halfstep.htm
I still have to re adjust the axis, right now I have problems with both X and Y, Z seems fine, I will do that tomorrow with a fresh mind.
I moved the drivers off of the machine to avoid EMF as much as possible, will run tests ASAP to see if I still get lockups on the I2C bus.
So basically I have the machine back online, I hope I will be able to start doing useful stuff with it soon.
12 - January - 2010 - 2.1 is here aka "Valkyrie Reloaded"
Check out the new video for now, I will update the rest in the
following days.
19 - Jan - 2010 - Video for Oddbot
Hi all,
Since China gouvernment seems to protect it's people form bad things like youtube, OddBot is unable to see any of my youtube videos.
So here you go Oddbot a download link:
http://www.4shared.com/file/200950593/5bfc7e36/valkyrie21avi.html
Let me know if it works.


@ Tue, 2009-07-14 20:40
hooray!
Congrats!
Okay, quick question from me, because it's relevant to my project - how fast can you scan along and engrave ~5cm line?
@ Tue, 2009-07-14 21:19
Thanks
@ Tue, 2009-07-14 21:03
Nice stuff!!
Nice stuff!!
You must make a new sign to your front door with that!
@ Tue, 2009-07-14 21:22
yup
@ Thu, 2009-08-20 20:57
I think a nice sign that
I think a nice sign that says "Hello" will be pretty.
Then they can think about that, them visitors! Hello.
@ Thu, 2009-08-20 21:23
Once I get it to not block up
I will make one "Hello." sign for you and send it to you in Denmark.
@ Tue, 2009-07-14 22:10
Great Job
@ Wed, 2009-07-15 02:24
Wow I`m impressed! Are you
@ Wed, 2009-07-15 06:03
thanks
No, the holes have two roles:
1. delimit the "safe" working area and provide a way to align the material
2. using them makes it easy to secure the material by using small screws
To make a vacuum table you would need a very smooth surface and a powerfull vacuum machine.
@ Thu, 2009-07-30 04:17
3D Printing
@ Thu, 2009-07-30 06:26
Hi, yeah it could
That is not what I had in mind with it though, for a RepStrap it does not need to get very sturdy.
I will do some thermal extruder at some point but the speed of printing leaves much to be desired (i.e. it is slow).
btw .. why 4 stars?
@ Fri, 2009-08-14 21:30
Printed Circuit Boards Look out
Wow this is looking pretty cool now - you leart a lot from the beast :-)
I can really see this a a portable Drill table for mass producing PCBs (custom shaped) ----- i hate drilling holes for ICs anyway.....
@ Sat, 2009-08-15 07:46
Thanks:)
@ Sat, 2009-08-15 15:55
The problem with the I2C bus
@ Mon, 2009-08-17 06:57
power supply
Hi,
Thanks for the reply, but I do not think the motor noise would do that, it would happen constantly.
Each driver runs on 12 V with caps and has it's own 78l05 to power the logic, see the schematic here:
http://letsmakerobots.com/node/6967
@ Fri, 2009-08-21 18:13
Motor noise under load
When the motors are under heavy load, they are eating more current, and you may have more noise on the lines during that time.
This article has a good explaination and some ideas on reducing BOTH lower frequency noise AND higher frequecy noise.
http://www.mabuchi-motor.co.jp/en_US/technic/t_0203.html
@ Fri, 2009-08-21 19:23
I suspect that too
Thanks for the link, it is very usefull.
One thing though, stepper motors do not have brushes, they behave a little different.
I will rewire the thing just to make sure it is not an power vs i2c issue.
@ Sat, 2009-08-15 18:18
I2C issues - a suggestion
Use a multimeter to check the clock and data lines when the I2C "freezes" up.If the data line is held low, you probably have the problem described below.
What can happen a lot is that some noise will get on the clock line, and the slave will get out of sync with the master. When this happens, if the slave is doing an ack, it can end up holding the data line low. In a "worst" case, the slave can be clocking back a bunch of low data (e.g. 0V, not whatever your higher pull up voltage is). When this happens, the master can't create stop (or Start) condition to re-start the communications.
In the systems I've designed, I usually have a "unlock" feature. Where, if the master can't get control of the data line, it clocks the slave until the data line goes high, then it does a stop condition, and then it re-tries the message. Typicaly I'll clock at least 10 cycles to ensure I can get at the bus free.
@ Mon, 2009-08-17 07:02
thanks
@ Sun, 2009-08-16 13:54
It looks nice. How did you
@ Mon, 2009-08-17 07:08
Rubber hose
@ Sun, 2009-08-16 20:16
sorce code
@ Mon, 2009-08-17 07:11
hi!
Here you will find the source code for the drivers:
http://letsmakerobots.com/node/6967
It needs an update but you should get an ideea.
I will post both the Arduino and the updated driver code here too, ASAP.
@ Thu, 2009-08-20 17:12
Inkscape Plugin?
"Inkscape to draw the shapes, and a plugin to convert them to G-Code coordonates."
I can't seem to find the inkscape plugin you mention. May I have a hint?
@ Thu, 2009-08-20 18:06
Sure why not ...
There is the plugin:
http://bitbucket.org/jst/inkscape-gcode/src/tip/dist/
And there are some usage instructions a little outdated:
http://wiki.linuxcnc.org/cgi-bin/emcinfo.pl?InkscapeHowto
btw: google: inskape gcode -> first hit
@ Sun, 2009-09-06 22:35
Are the rails machined in some way?
I like the way you did the bearings, doubling them up and using the groove between them to keep the part on the edge of the rail.
I notice from the high-res photo that the rails appear to have a chamfer on the edge--did you buy them that way, or did you machine the edge on yourself?
The aluminum angle that I've seen at home depot has a 90deg. corner edge, is why I'm asking.
@ Sat, 2009-09-12 18:31
Hello
@ Wed, 2009-09-23 18:01
Also using Home Depot rails
I am using square edged rails with the same double-bearing configuration. To get them to fit I thought I'd need to sand a ~45 degree edge on each side of the rail so the bearings would be easily seated on them. The sanded-down edge was useful for positioning, but I found that after I bolted down the bearings, the steel bearings easily shaped the aluminum.
When you have set up the stage, but before you install the drive screws, tighten the bearings onto the rail and slide it back and forth until the stage travels easily. Some aluminum shavings will be ground off and the resulting edge isn't nice and geometric, but the stage will slide easily while staying on the rail. I'd recommend sanding down the edges of the rail before you screw down the bearings, just to help with the initial positioning and to make sure that the groove ends up at the center of the rail.
my 2¢,
John
@ Tue, 2009-09-08 02:41
Do you think it would be
Do you think it would be faster/easier to modify the reprap code myself for a subractive machine like this, or to modify your code to use the step/dir pins like the original code does?
Is it possible you have an earlier version of your code before you implemented the I2C motor controllers?
Thanks,
Jon
@ Sat, 2009-09-12 18:33
You can use the RepRap code as it is