G-Code interpreter for motor shield

by parcanman on Wed Apr 21, 2010 1:57 pm

Hey, I'm working on a plotter using the Adafruit motor shield. I downloaded a copy of the RepRap G-code interpreter, which comes in the form of an Arduino sketch. It looks a lot more complicated than what I need, but I can slim it down. What I'm wondering however is what pins I should set in the configuration file. The part of the configuration file that addresses the pins is right here:

Code: Select all
#define X_STEP_PIN 3
#define X_DIR_PIN 4
#define X_MIN_PIN 5
#define X_MAX_PIN 6
#define X_ENABLE_PIN 15

#define Y_STEP_PIN 7
#define Y_DIR_PIN 8
#define Y_MIN_PIN 9
#define Y_MAX_PIN 10
#define Y_ENABLE_PIN 15


So which of these pins is what on the Adafruit motor shield? I'm using bipolar motors, and there's a motor pin for each wire, but what should these numbers be to drive the shield? I'm assuming that the "ENABLE_PIN" would have nothing to do with the motors since it's default is Analog pin 1. I'm gonna start digging deeper into the firmware sketch to see what I can figure out, but I figured I'd make this post in case anyone has already done this.

Really, I just need the Arduino to interpret G-code and send it out to the motors, it doesn't need to be this particular interpreter, this just seems to be one of the more comprehensive OSS ones already out there. If anyone knows of another one that's designed for a more general purpose that would be helpful since the RepRap one seems to be very purpose-built for their specific machines.

If it comes down to it, I might even just try to build my own interpreter. With the amount of time I just spent building this machine, I'd really just like to get it working as soon as possible, that's why I figured I'd either try to get this one working or see if anyone has any suggestions for a better one for this purpose.

Thanks.
parcanman
 
Posts: 4
Joined: Wed Apr 21, 2010 1:40 pm

Re: G-Code interpreter for motor shield

by adafruit on Wed Apr 21, 2010 5:29 pm

you really should just use the af_motor library. it will take care of the motors, so you just have to do the parsing
User avatar
adafruit
 
Posts: 11509
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: G-Code interpreter for motor shield

by parcanman on Wed Apr 21, 2010 7:39 pm

adafruit wrote:you really should just use the af_motor library. it will take care of the motors, so you just have to do the parsing


Yea, but for that I would have to create my own interpreter, or heavily modify an existing one, all the while my CNC plotter is just sitting there waiting for me to use it. I probably will end up going that route eventually, but I'm just looking for a short-term quick fix to get it running so all the people that keep asking me when they'll be able to use it can finally stop bugging me.
parcanman
 
Posts: 4
Joined: Wed Apr 21, 2010 1:40 pm

Re: G-Code interpreter for motor shield

by adafruit on Wed Apr 21, 2010 9:27 pm

perhaps we are not clear - you cannot 'set the pins' to make the motor shield work with this library. you -must- modify it to work with af_motor, its not really optional!
User avatar
adafruit
 
Posts: 11509
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: G-Code interpreter for motor shield

by parcanman on Wed Apr 21, 2010 10:24 pm

I don't think we're clear either, I'm not hell bent on getting this library to work with the AF motor shield, this is just the one that was reccommended more than any other. What I'm looking for is a way to interpret G-code with the Arduino and have it drive the motors using the AF motor shield. I'm really more of a hardware guy and I haven't been programming for very long, so it seems like a bad idea to set out to reinvent the wheel at this time. What I want to know is if anyone has had any success with using this shield to drive a G-code-based CNC machine, and what the best way to do that would be?
parcanman
 
Posts: 4
Joined: Wed Apr 21, 2010 1:40 pm

Re: G-Code interpreter for motor shield

by adafruit_support_bill on Thu Apr 22, 2010 5:07 am

As a hardware guy, maybe the FAQ will clarify things:http://www.ladyada.net/make/mshield/faq.html

Which pins are connected to the DC/Stepper motors?
The DC/Stepper motors are NOT connected to the Arduino directly. They are connected to the 74HC595 latch which is spoken to by the Arduino. You CANNOT talk directly to the motors, you MUST use the motor shield library


And this link also:http://docs.google.com/View?docid=dgwf6cmm_2fznx7qgr
User avatar
adafruit_support_bill
 
Posts: 25556
Joined: Sat Feb 07, 2009 9:11 am

Re: G-Code interpreter for motor shield

by parcanman on Thu Apr 22, 2010 1:51 pm

Ok thanks, that makes sense, but my question still stands, is there an arduino-based G-code interpreter that is compatible with this shield? I want to know if there's already an open source one available before I dive into trying to create my own.
parcanman
 
Posts: 4
Joined: Wed Apr 21, 2010 1:40 pm

Re: G-Code interpreter for motor shield

by anxion on Thu May 06, 2010 4:21 am

Hello,
Have you tried this code : http://github.com/TinHead/Valkyrie-CNC-source-code ?
anxion
 
Posts: 8
Joined: Fri Apr 09, 2010 4:33 am

Re: G-Code interpreter for motor shield

by lazygeorge on Wed Feb 09, 2011 7:36 pm

Hi,

Done it!

I know this is a little late as the post is now 8 months old+ but having trawled through loads of posts etc, I have put together the plotter code for the adafruit motorshield. The code uses x and y axis steppers and a servo motor for the z axis simultaneously so they can all be powered off the one shield. These are the steps

1. Convert vector drawing in Inkscape using Gcode plugin (must be straight lines only)
2. Use Hydra (Processing software) to feed gcode to Arduino through Serial
3. Adapted Reprap code sorts out the rest - just need motors and servo attached.

Arduino Code was compiled with Arduino 0018, I don't think it will work with newer versions as syntax etc. has changed
Uses libraries - afmotor, accelstepper, and arduino servo/serial libraries. (Make sure you install the libraries first).

It's pretty rough and ready as this is my first Arduino project - but it works! Heres the link:
http://www.maxlivesey.co.uk/maxtest/arduino/gcoder.zip
lazygeorge
 
Posts: 8
Joined: Wed Feb 09, 2011 7:11 pm

Re: G-Code interpreter for motor shield

by amk on Mon Feb 21, 2011 7:22 am

Hi lazygeorge,

I've been planning to do something similar (but I dont have the coding skill) so thanks for this!

I've been trying this out but I'm having some problems connecting to the Uno.
With arduino 0018 there is no available serial port so I can't connect however I can see (in ubuntu linux terminal) that there is a usb connection on /dev/ttyACM0.
With arduino 0021 theres no problem - G-code interpreter2 pde compiles and uploads to the Uno... so thats great!
However where I'm stuck is that I can't connect to the board with Hydra - it doesn't see any serial connections.
I've asked uncle google to help but I'm a bit lost - can anyone help?

cheers,

amk
amk
 
Posts: 1
Joined: Wed Nov 10, 2010 5:09 pm

Re: G-Code interpreter for motor shield

by lazygeorge on Thu Feb 24, 2011 1:59 pm

Hi amk,

Um, sorry about this, but I was a bit premature with the code. There seems to be a problem with the stepper synchronisation so they don't quite step correctly together. I will need to look at it again. Doh!

I will post it back up when I have it figured out.
lazygeorge
 
Posts: 8
Joined: Wed Feb 09, 2011 7:11 pm

Re: G-Code interpreter for motor shield

by Marcus433 on Sun Oct 16, 2011 1:31 pm

I like lazy George's code and I think it would be really cool if we could make a 3d printer with the motor shield. The x and y could be steppers and the z could be a servo. The extruder could be hooked up to other pins on the arduino or even another arduino! Thanks please post back! The extruder could just run on another battery. Please reply adafruit support
Marcus433
 
Posts: 8
Joined: Sun Oct 16, 2011 1:23 pm

Re: G-Code interpreter for motor shield

by adafruit_support_bill on Sun Oct 16, 2011 3:44 pm

@marcus433 - It is certainly possible - although a servo won't give you such great resolution on the z-axis.
User avatar
adafruit_support_bill
 
Posts: 25556
Joined: Sat Feb 07, 2009 9:11 am

Re: G-Code interpreter for motor shield

by Marcus433 on Sun Oct 16, 2011 10:38 pm

Hi adafruit support is their any way of making this possible? I don't need the z axis to be great... Thanks
Marcus reply!!!!!!!!
Marcus433
 
Posts: 8
Joined: Sun Oct 16, 2011 1:23 pm

Re: G-Code interpreter for motor shield

by TeraNamiTeraNami on Fri Sep 28, 2012 10:08 pm

I know it has been more than a year since the last post, but I just want to say thanks to lazygeorge. I recently got Hydra working using NetBeans (had to use a different rxtxSerial.dll for 64-bit) , but having trouble generating code from Inkscape, maybe I am using the wrong plugin. Also just confirming, this program isn’t reading any G02 commands but all linear motion commands only? For adding a one more axis, I was wondering if an array of 8 solid state relays would work on a stepper driver output (4 naturally open and 4 naturally closed) ? Basically opening the circuit for one stepper motor and closing it for the other.
TeraNamiTeraNami
 
Posts: 1
Joined: Fri Sep 28, 2012 8:16 pm