Instructables

Step 8: Electronics - Arduino

Picture of Electronics - Arduino
path-afmotor-library.jpg
serial-port-monitor-ready.jpg

You need an Arduino UNO board, I used a Seeeduino v2.21 here - it did the job very nicely back in the day, but a couple of new features have been added to the code and so it doesn't fit on anymore. Genuine UNOs have very slightly more space for programs.

Upload the source code to the arduino. Look at this fine guide courtesy of Adafruit for help.

Because it changes regularly, I have not attached a copy of the code itself to this step, but the very most recent version can be downloaded in a bundle from the polargraph code repository.

You should save the code file into a new folder inside your arduino sketch folder. Give the new folder the same name as the source code file. So if the file is called polargraph_server_a1.ino, you should create a new folder called polargraph_server_a1 and save the file into it.

It also uses Adafruit's AFMotor library and Mike McCauley's Accelstepper libraries. Please use the copy of Accelstepper that is in the zip file - the newest versions of it have a few fixes in them that the polargraph code isn't yet updated for.

The AFMotor library files should be put into a folder called AFMotor inside your Arduino/libraries/ folder.

The Accelstepper library files should be put into a folder called AccelStepper inside your Arduino/libraries/ folder.

Once they are moved, your arduino installation directory should look something like the second image on this page.

Of course the source code is also available in the code repository - https://github.com/euphy - should you want the very most recent version.

Once you do that, you should confirm that it is working properly - use the serial monitor on the board, set to 57600 baud to make sure that it is issuing "READY" every couple of seconds (see the third image).

 
Remove these adsRemove these ads by Signing Up
hey sandy i am a bit confused with the files yu hav added in yur recent polargraph code repository -polargraph1.2.4 !
i hav unzipped it and hav 4 folders out of wich application.windows32/application.macosx contains the polargraph controller. Polargraph Arduino code contains d code to be frst saved in the arduino sketch folder as yu hav said above n libraries to be saved in arduino library.
am i correct with this ?
also i aint able to understand the use of Processing libraries ?
what is to b done with this folder ?
Euphy (author)  sweta_rocks1 year ago
Forgot to mention - the new download is http://code.google.com/p/polargraph/downloads/detail?name=Polargraph1.2.5.zip
Euphy (author)  sweta_rocks1 year ago
Hi Sweta, I've actually just uploaded a new zip file that includes a couple of fixes.

The folders called "application. ..." are the ones that have the precompiled controller app inside them - different version for different operating systems. Use the version that matches the kind of computer you have. You don't need to install any libraries if you are just going to use the precompiled applications.

Inside the arduino-source folder is all the source code that you'd open up in the Arduino IDE and upload to your arduino board. There is a libraries folder inside that that should be copied into your arduino sketchbook folder.

Inside the polargraph-source folder is all the source code for the controller app. If you want to run this you will need to add the two libraries that are in the libraries folder there too. Just put them in your libraries folder in your processing sketchbook folder.

Good luck!
SnyperBob2 years ago
Hi! I really like your project and am planning on building my own using your Instructable. I'm only in the planning stage now to try to figure out how much this will cost and whatnot. Do you have any stepper motors still for sale?

Can you update this step as well with more recent info about what code is needed? Step 8 of this Instructable. The link for 'polargraph code repository' is broken.

Is this the main sketch for your machine: polargraphcontroller_zoom.pde ??

I'm going to try to hammer out all the software details before I jump in and start buying all the bits to make this work. I really appreciate how much time and effort you have put into refining this project. Thanks for sharing it with us!

I have a cheap/generic motor shield I got thru eBay, I wonder if AdaFruit's libraries will still work with it. I'll have to try it out I suppose, unless you know if it will work?

There's a lot to digest here, and especially with all of the code files

How do I use all of the PDE files? I thought you can only upload one PDE to the Arduino at a time. Looking at the code, most of them say that they are part of the Polargraph Controller, and have classes and all kinds of other stuff in them. Can you give any quick tips to help me understand how all these files work in the big picture?

Thanks again!
I'm trying to work out where and how to set the pins for my motor driver. I actually have some L293D chips, which is what your adafruit driver uses anyway. Looking at AFMotor.h and AccelStepper.h it looks like it can be set for pretty much any control mode I could want to use. If you have any ideas about where to look to set the output pins, or just see what they are set to, it could help me out. Thanks.
Euphy (author)  PaulMakesThings2 years ago
Hey Paul, if you aren't using the motorshield, then the AFMotor library isn't used, you can use the AccelStepper library on it's own. Means you won't get the interleaved step style that adafruit provide, but depending on the motor you're using you might find yourself with enough resolution without it.

It's been a while since I used the accelstepper drivers on their own, but if I remember right you declare it something like

AccelStepper motorA = new AccelStepper(4, 4,5,6,7);

to specify that you're controlling your stepper hardware with four wires, on arduino pins 4,5,6 and 7.

I did this with another project (http://www.flickr.com/photos/euphy/5942249105/in/set-72157625241383012 - my linear clock that is also on instructables) so it can't be hard if I could figure it out :) The circuit in that picture is two instances of Tom Igoe's stepper driver circuit (http://www.tigoe.net/pcomp/code/circuits/motors/stepper-motors). He uses SN754410s in his diagram, but the pinout is the same on L293Ds. It's not that important which arduino pins you use. The motorshield uses the PWM pins, but that's just for the clever microstepping. If you aren't microstepping, you can use any pin.
It appears that the shield just has a shift register, two L293D driver chips and the appropriate resistors and caps to support it. What I find a bit odd is that the code seems to be outputting the combination of pins needed to go straight to the chips, but using a shift register seems to imply they are using serial communication and that shift register should be what outputs the paired on/off signals to control the H bridges.

Anyway, it seems like the code for the adafruit motor driver doesn't add much, still, if I wanted to take advantage of it, I think I can make my device work the same way.
Actually they have a schematic so I could probably just wire it exactly the same way since I have the chips. It's more a matter of not wanting to wait for the order than cheapness:
http://www.ladyada.net/images/mshield/mshieldv1-schem.png