Arduino + NES + 3 Axis = Pure Awesomeness! 02/23/2010
After a few hours of work tonight, I managed to mate the NES controller with my mill. Seems to be a match made in heaven. The video is below for proof and the code is below that if you want to try this out for yourself (it's very easy). I'm planning to make this a permanent feature of my mill. In order to give it a cleaner appearance (instead of just shoving wires into the controller), I've ordered a set of NES controller sockets from parallax which I will be mounting in my case. A couple of notes: 1.) The code is terrible, I will try to clean it up and re-post sometime soon. 2.) This is a very easy project, If you're trying to interface your easydrivers with a 3 axis mill, a homemade bot, or anything else and want to add NES controller pad capabilities, give this a look. You'll be surprised. 3.)The X axis on my machine is terribly loud. I need to fix that it....
02/24/2010 - EDIT: An updated version of the code used to drive 3 Easy Drivers via and Arduino and a classic NES controller. Not a whole lot of changes to the original, just a little bit cleaner, more concise, and thoroughly commented.
Turns out, it's not so bad after all! 02/19/2010
As mentioned yesterday, driving the mill with an N64 controller seems like an awesome idea. Today, I set to work trying to figure that out. I was almost immediately sidetracked As luck would have it, my stash of NES controllers (qty: 2) were in the same location as my stash or N64 controllers! I couldn't resist. Shapeoko needs a "joystick". All CNC machines have one. They are either software controlled (buttons on screen) or hardware. They are necessary to move the gantry out of the way and to "home" your machine to the material. I have an old joystick from an arcade I build a few years ago that I have been planning to use. However, one of the problems using a traditional joystick is that it takes up one port for each direction you are trying to capture. So in our case we would want: Forward, Back (Xaxis), Left, Right (Yaxis), Up, Down (Zaxis). That's 6 inputs we would need! The NES controller doesn't need one output for each button because it's digital. What's that mean? Good question. Here is how I understand the NES controller to work: The chip inside the controller is polling the status of the buttons at a rapid rate. When the buttons are not being pressed, the result of the poll looks like "11111111" (one bit for each button). After the controller is done polling, it sends that string to the console (in our case the Arduino) which is then interpretted by the program into whatever the button are mapped for. If you press a button then the string changes to reflect it. For instance if you press the select button the string changes to 11011111. The cool part about this is the arduino need only use 3 ports to interface with all 8 buttons! The three ports are for "Clock", "Latch", and of course data. The data wire is where all the action is! Clock and latch are there to keep the timing correct. To be honest I don't completely understand how it works, but I figured it out enough to capture the inputs with the Arduino and light up the corresponding LEDs! I would like to say, as a side note, working with a "digital" also prevents you from having to debounce the button pushes. Because that debounce logic is already in the chip that's doing a2d inside the controller! we're just taking the "clean" data :) Here's a quick video of the setup in action. The code is below if you want it. Now that the buttons are mapped and I feel pretty confident about capturing button presses, I am going to get to work on writing the code to control the step/dir functions of the easy drivers.
Let's parse some gcode! (Shapeoko + Grbl) 02/05/2010
Here's a video of shapeoko + grbl parsing gcode being streamed from my Dell Mini9. (You can download the gcode below.) Clearly something is not right. However, the job will run identically, which makes me think that it's a simple software tweak as opposed to something more devistating like a hardware problem. Another positive sign is the fact that the z-axis height seems to be working just fine. This particular g-code calls for a clearance height of 6.25mm and a target depth of -1mm. Both of which seemed to be consistent throughout the job.
Mill Progress....an update. 12/27/2009
I have managed to find some time during the holiday season to work on the mill. Here's a recap:
Update: Overall Progress 12/01/2009
There's something wrong with the X axis. Unlike the Y, it's very difficult to move. Well, not very difficult but more difficult than the Y. I think there may be a bit of a design flaw... stupid designer. From what I can tell, there is some friction between the X-axis-rail-mount-plates (the ones slotted end to end) and the X-axis-cross-plate (the one that the X-axis acme nut mounts to). I'll try taking some sandpaper to it and if that doesn't work, perhaps the dremel? Someone also suggested I use wax.. i don't even know where I'd find wax though. Also, I should have boxed in the X-axis cross plates because there is flex when the nut is being driven. I'm going to move forward and continue with the current iteration. After the new power supply is delivered and the EasyDrivers are installed, I'll see where we're at. But, I'm afraid I'll have to make some changes to the design and re-order all of the parts from ponoko. It's not the end of the world but I hate the fact that I didn't get it perfect the first time... Though, I should be used to that by now. On a different note: When I started this project I was certain that a computer would be running the machine. However, I've been using the arduino to test the motors and when I get the 2 additional EasyDrivers I'm planning to run them through their paces with the arduino as well. I keep thinking how awesome it would be to use the arduino permanently as the controller. Yes, replace a full PC with a tiny arduino! My machine has a very small footprint to begin with, and I keep thinking how cool it would be house *all* of the controls in a tiny matching box! I don't even know if that's possible, but wouldn't it be sweet! I'm imagining something like this: Obviously, do the CAD/CAM on a workstation but save the G-code to an SD card. Then, insert the SD card into the arduino, turn the arduino on, it would then look for a specific text file. Parse the file and run the machine! I know it's a lot harder than that and I'm doubting there would be enough room on the arduino to store the code to both control the reading of the SD card and parse the file and run the machine. Either way, a guy can dream right? X axis, Z axis: First movements! 11/28/2009
Just one short day after figuring out the Y-axis, the X and Z are both moving! I decided to stop by Radio Shack and pickup some DB9 connectors (1 male, 3 females) to make switching between motors easier. Although soldering all those pins on (24 total) wasn't much fun, it was totally worth it. In addition to making it easier switching between X,Y,andZ, the connectors also cleaned up a lot of the wiring. I also soldered headers onto the easy driver so I could actually mount it on the breadboard instead of just setting it there! Worked like a charm. As for the power supply, i switched from the ATX PS which was pushing 12v, to an old Dell Inspiron 20V 90W power supply. I'm not certain on this, but I'm pretty sure the extra power has really added to how smooth the motors run. I'm not even sure if that's possible, but it seems like it to me. Here are some video of the other two axis' running. The Z looks especially smooth, which i'll say is from the fact that the acme rod is short which pretty much eliminates the chance of it being bent (as I suspect is the case on the Y axis). The X axis is coming along but there seems to be some friction somewhere along the path which is causing it to hang up and stall the motor (even with the ramp up / ramp down code) I ordered two more Easy Drivers from Sparkfun yesterday, they should be here early next week. At which time I'll try hacking together something that runs all 3 axis in an indefinite "test" pattern. Pretty exciting stuff here! The Sparkfun forum guys really helped me out. After getting the Y-axis stepper up and running with the Arduino, there were some issues. Mostly it was loosing steps in a bad way. Plus, the vibration threatened to tear my machine apart! OK, that last bit was an exaggeration, but the vibration was pretty bad. The guys on the forum pointed out that you cant just start a stepper at full speed, you have to "ramp up". Which after thinking about it, makes perfect sense. At this point in time, i've learned enough to know that in most cases, "it's already been done". Meaning, there was no need for me to write new code to "ramp up" the arduino. I mean, there are tons and tons and tons of stepper based arduino projects on the web, surely someone must have written some good code..... The short answer: Yes, it's out there . But, the really surprising part is, that link is the only one i found where the steppers were "ramped up". Now, don't get me wrong, it WORKED! Check the video for proof of that. The difference with a smooth start is night and day compared to just the standard method. BTW: the standard method is: Start a loop, Pull step pin HIGH, put step pin back to LOW, delay for a set amount of time, loop. Most people just set the delay to something that won't stall their motor. This varies greatly depending on the specs, but for the most part people are between 200 and 400ms. I guess I'm wondering why more people don't start smooth? maybe it's just easier to set the delay and forget it... who knows. Either way, I'm really happy with the progress so far. Things are starting to come along. Update: Y-Axis Movements! 11/25/2009
The guys in the Sparkfun forum are really helping me get this thing going! Right now I'm working one axis at a time. Here is my attempt to move the Y-Axis with a 60oz/in stepper and the EasyDriver from Sparkfun. If you have a listen, it starts out pretty well and then makes this terrible grinding/vibrating noise. I found out that is the motor stalling and/or loosing steps, It's could be from a variety of things, all of which sound pretty managable. I'll try to get it smoother and more consistent. Although it's not perfect, I'm fully confident this solution is going to work. Update: Mill Electronics 11/24/2009
Have a look at the mill page for a peak at my first schematic! I posted a question yesterday to the sparkfun project forum asking how to connect an 8 wire stepper motor to their Easy Driver stepper motor controller. After a few hours and some really helpful replies, I had my answer! I wanted to try it last night, but ran out of time. Hopefully I can test it out tonight and report back tomorrow on two things: 1.) If it works! 2.) If the motor is strong enough to move the Z axis :) Thanks again to the guys in the forum for their help! Also, I used a program called "Project Draw" from the Autodesk Labs website to draw the schematic. Although I'm more comfortable drawing things in Illustrator, Project Draw works really well. I'm by no means a professional electrical schematic drawer, so I can't attest to how great it is at that, but as far as an easy cloud based way to make a line drawing. It works just fine and has plenty of built in symbols to use. So check it out if you get a minute, you might find it useful as well. Update: Mill 11/23/2009
There is a point in every project’s build cycle that puts you face to face with the details you have procrastinated. This is the time that you need to focus, keep scope, budget, and timeframe in mind, and make some tough decisions. For me, this time came over the weekend. From the time I received the first nest from Ponoko, I started thinking about points of failure and then possible design changes. I plugged away, carefully assembling what I could without fully committing myself. In retrospect, I was just buying time I think, time to convince myself that I should change the design, that I should fix some inconsequential mistakes, that I should start over. Then I glued the main box together, it scared the crap out of me clamping the pieces together and waiting for it to dry. One thing i really liked about the designed made from steel was the fact that you can unbolt them! With glue... well it's sort of permanent. Everything worked out just fine. So I glued the uprights in place, then I glued the cross supports in place. Then there was only one item left to glue, and I glued it. Now I'm on to the hard part: The electronics. It's so frustrating/exciting to dive into something you know so little about, it's difficult to know where to start. However, working through the reference material I'm reminded of why I like projects so much: Learning! | |||||||||
