Step 8: Electronics - Arduino

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. Seriously. Actually do this. Nothing will work until you do this. Do it.

Look at this fine guide courtesy of Adafruit for help. Or anywhere on Instructables, or one of the hundreds of Arduino tutorials on the web.

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. Download the file called Polargraph.___.zip.

Unzip the bundle. Inside it is a folder called arduino-source which contains (you guessed it), the source code for the arduino part of the project.

Inside arduino-source there is a folder called libraries. It contains the libraries you need (

Adafruit's AFMotor and Mike McCauley's Accelstepper)

It also contains a folder called polargraph_server_a1. This is the polargraph firmware source code.

Copy the contents of arduino-source/libraries into your Arduino/libraries/ folder.

Copy arduino-source/polargraph_server_a1 into your Arduino/ folder.

You should have created three new folders on your disk:

  • Arduino/polargraph_server_a1/
  • Arduino/libraries/Accelstepper/
  • Arduino/libraries/AFMotor/

Start Arduino IDE.

Go to File->Sketchbook->polargraph_server_a1

Fourteen files will open up and be displayed as tabs in the IDE. This is the source code of the firmware.

Press the "verify" button in the toolbar to try and compile it.

If it compiles, press the "upload" button in the toolbar to upload it.

Of course the source code is also available in the code repository - https://github.com/euphy/polargraph_server_a1 - should you want the very most recent version, but you'll have to figure that one out yourself.

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 last image).

I didn't find the RENDER VECTOR command <br>I foud RENDER PIXELS, is it the same ?! And it dosen't function <br>
<p>ok I asume that there is somthing I missed .. </p><p>Reder pixels after I select the area around the vector dosen't function propably </p>
Render pixel and render vector are entirely different and separate.<br><br>To render pixel, you load a bitmap image, and select an area of it.<br><br>To render a vector, you select an area you want to draw in, and &quot;set frame to area&quot;. <br>Then &quot;load vector&quot; and choose your SVG. <br>Then &quot;move vector&quot; and &quot;resize vector&quot; to place your vector artwork.<br>Only the area inside the frame (red crop marks at the corners) will be drawn, or be visible in the preview.<br>Click &quot;Draw vectors&quot; to build the commands to draw the vector.
<p>thanks I followed your instrctions .. </p><p>There is small problem I faced </p><p>The path is not good </p>
<p>hi there !!</p><p>Sorry for distarbance .. but I've no more time to submet my tech.project , and you helped me so mutch &quot;THANK YOU BRO&quot; .. I've just the path of the vectoŕ and how to compelement it or make it the same ?! </p>
<p>Stepper motors keep vibrating, they don't move when I set points. I think I'm doing wrong connections. Can you please tell me how to connect the stepper motors to the motor driver.</p>
<p>If you use adafruit shield you must connect the tearms of each coil within same side example:</p><p>1st chick the motor end tearms by ohm-meter to find where is the ends and the centertaps of the same coil.</p><p>M1 has two input junctions you must put the ends of the same coil in this two junctions</p>
<p>I tried all the permutations to connect the 4 wires coming out of Nema 17 to the motor driver.(24 permutations) No luck till now. For each combination, the stepper motor just vibrates. I have no idea what's wrong. What should I do?</p>
<p>OK!! </p><p>What about : STP-59D3012 /22545 (stepper motor) </p><p>Driver : adfruit shield </p><p>I think it's 12V motor with 6 pins </p><p>Can It be matched to gather?! </p><p>What about the programme ?! </p><p>If you help me I would be great happy with that .. because it's my final project to be graduated .</p><p>Thank you again ?</p>
<p>I think I found my misstake .. also thank you for your help </p><p>Some other quastions : </p><p># how to chose the location of the motor (R, L) m12 , m34 adafruit shield posision.</p><p>#how clearfy the imag and how to use SVG for that </p>
<p>For example, the figure in the file will be able to draw? Roughly A3 size. How long without losing quality.</p>
You'll just have to try it and see!
<p>hi there !!</p><p>The program ( arduino source ) perfictly downloaded ... but my steppers didn't work </p><p>I use 28BYJ-48 with ULN2003 </p><p>The servo perfectly works ..</p><p>I followed all the instructions that I found for definning the pins in configuration part </p><p>What did I miss and how to fix it ?!! </p><p>Thank you !! </p>
Hi sorry, I've never used this motor and driver myself.<br><br>First step: Make sure the steppers, and the stepper drivers work outside of Polargraph.
<p>Hi! There is an idea to upgrade your project. To communicate with the Arduino controller, via USB. I want to consult with you about the SVG format commands, which are transmitted to the line in port of the Arduino controller.</p><p>Question:</p><p>Commands from the SVG file in this format is passed to the controller? (example)</p><p>&lt;path d=&quot;M117.136 51.4184c0.245,0.035 0.4897,0.035 0.7349,0.1225&quot;/&gt;</p><p>&lt;path d=&quot;M117.871 51.5409c0.455,0.5424 0.5777,1.2773 0.4197,1.96&quot;/&gt;</p><p>&lt;path d=&quot;M118.29 53.5009 c-0.5774,2.345 -1.6098,4.6197 -3.1496,6.4923&quot;/&gt;</p><p>Understands the format controller?</p><p>Or they are transmitted in a different format?</p>
<p>Well! I understand that the SVG file can understand your device's firmware. To accomplish this you only need your controller software? Perhaps using another terminal application to transfer a SVG file?</p><p>Thank you!</p>
The controller software can load SVGs and then sends movement commands to the device one by one.<br><br>The communication protocol is a bit like g-code, but it isn't the same.<br><br>There isn't a way to send raw SVG.<br><br>A motor control board with two L293Ds is a good one to use. If it isn't like this one (http://playground.arduino.cc/Main/AdafruitMotorShield), then you will have to define the control pins and do the motor setup in the firmware yourself.<br><br>Good luck!
<p>I admire your project!!! Going to implement it!!! You're cool!!! One more question!. Is it possible to use these components?</p><p>Arduino Uno R3, a Debugging Board for microcontroller atmega328P<br>Motor shield control Board motors [L293D].</p>
<p>Hi! Great project!!! I have a question. You can pass the ready G-code to Arduino via the terminal app? Do not use your software. Will work? If not, then how to do it?</p>
Nope, Polargraph doesn't read g-code sorry.
<p>So I noticed that if the Aruino is not connected and I click &quot;render pixels...&quot; that I get the option for &quot;Spiral&quot;, but once I connect the entire thing and Processing shows the polargraph as connected and ready then I loose the &quot;spiral&quot; option as well as another option... Why might this be? Is the spiral dependant on other factors?</p>
Hi exactly yes, spiral pixel only works on a MEGA-based Polargraph machine, not an UNO-based one unfortunately. There's not enough memory on the UNO for the curve routines!<br><br>The machine tells the controller what kind of machine it is when it connects, and the controller will only show the features that it knows that machine can actually execute.<br><br>sn
<p>When i put in a command for the motors to move they keep moving and wont stop.</p>
<p>You need to upload machine spec, and then &quot;set home&quot;.</p>
<p>Thank you very much i was forgetting the machine spec!</p>
<p>Hi,</p><p>I would like to draw a picture in the style like yours from Marilyn Monroe (http://www.instructables.com/file/FYP17BPGUVTYORL/). My problem is that the generatet path is not locking very nice. There is not really a difference between the black and the white elements.</p><p>My setting:<br>- Machine width = 708<br>- Machine height = 536<br>- NEMA 17<br>- Adafruit Motorshield v2<br>- mm/rev = 126<br>- steps/rev = 200<br>- Step Mulitplier = 16<br>- Drawing Size = DIN A4 (210x297)<br>- Pen size = 0.5</p><p>My process:</p><p>- Start polargraphcontroller<br>- Load image file (jpg)<br>- Resize image<br>- Move image<br>- Set area<br>- Set frame to area<br>- Set Gride size = 10<br>- Set Sample area = 10<br>- Render Pixel: Top-Right; Solid Square Wave<br>- Generate commands<br><br>In the attachment you can see the input picture and my generated path. </p><p>What I am doing wrong? <br></p>
<p>Hi Dominik! I scratched my head at this one, but I spotted the problem:</p><p>&quot;Solid square wave&quot; is exactly that, it's solid and there's no shading. It's always at maximum black. </p><p>All of the others do shading! Marilyn is done with variable frequency square wave.</p><p>sn</p>
<p>Hi, thanks for the fast reply. I have tested it with frequency square wave setting but the result seems similar.</p>
<p>Ok looks completely different to me - I'm not sure what you're expecting to see?</p><p>The preview shows the density of each &quot;pixel&quot; as a circle shaded from deep red (high density) to white (low density). The ones that are over the black areas are red, ie high density. The ones over the white areas are white, ie low density (or empty).</p><p>They are very small, so it's quite difficult to see, I'm not sure why that is, or what controls the size of those indicators.</p><p>What I believe you'll find though, is that your machine is unlikely to be able to render those pixels very well. For such small pixels, you really need a very narrow pen too. If the machine can't fit much shading into a pixel, it tends to either render everything as blank, or everything as solid (there's a bit of a guide to this here: </p><p><a href="https://github.com/euphy/polargraph/wiki/Empty-pixels" rel="nofollow">https://github.com/euphy/polargraph/wiki/Empty-pix...</a> )</p><p>Do you get any error messages in the error log (to the right-hand side of the command queue) when you press &quot;generate commands&quot;? If you don't, then you might be ok!</p><p>sn<br></p>
<p>I thought that the red lines show only the way of the pen. Now I made a test run and it works perfect :) Thank you very much for your support! Great work!</p>
Hello, really nice project.<br>You already answer this was possible wigh a mega 2560 wigh light modifications of the sketch but i owned a mega with a Ramps. Still realizable ?<br><br>Thanks in advance,<br><br>Vivian
<p>Now I think is working, but my stepper motors are making strange noise (squeak and like boiling noise) and got hot very quick. Anyone can help? :) </p>
<p>Use only steppers with lower amp rating. Like 0.4A which is common with 30mm steppers. 1.3A motors can fry the L293D. 2.0A motors will fry it.</p>
<p>What's more I've just noticed is that when I want my gondola to move right it is going down, and when I want it to go left it moves up :(</p>
<p>switch motor cables. left &lt;&gt; right </p><p>OR(!)</p><p>change wire-couples -&gt; if red+blue is on the top connectors and black+green is on the bottom connectors, switch both pairs. Put red+blue down and black+green up.</p>
<p>When I set my 200step motor to 400steps and a multiplier of 1 the movement is totally messed up. Approximately a 1cm move downwards moves the gondolo more like 10cm. </p><p>So I don't understand why you recommend to set the stepper motors to these values (doubled steps) that do not work. And as they don't work for me, they will not work for anybody else. No just kidding. Is there some math behind it or why is this?</p>
<p>nevermind. see this :</p><p>http://www.polargraph.co.uk/forum/polargraphs-group2/troubleshooting-forum5/cant-get-my-settings-calibrated-thread530/</p>
<p>When I move vector it won't release when I click. Weird. </p>
<p>Figured it out. One has to Select Area and Set frame to Area before placing vectors. </p>
<p>Thanks for a great tutorial! More details on </p><p>http://pappmaskin.no/2016/08/pen-plotter-1/</p>
<p>Hello euphy!</p><p>i loved this proyect!</p><p>i have one problem though... in my &quot;powerfull&quot; laptop it works great, everything</p><p>then i try a netbook or basically any other computer and it stays in busy (when trying to upload sizes to the machine) for over one second, even though, if i SET HOME , it doesnt compute, and it doesnt change place, i tried changing the cable, reinstalling arduino, reinstalling java, (i need to try picking another serial library for processing, though my powerfull laptop doesnt have it and still works), i need to check if the arduino co processor requires diferent drivers, great job BTW</p>
<p>Hey Euphy,</p><p>I've build my own polargrpah using Arduino Uno and two steppers( Nema 17) but it seems that something is off. I have checked my measurements and configurations 5 times (step by step with this tutorial) and it all seems correctnut for some reason the machine is still off (doesn't go to where it suppose to, doesn't come back to where it was suppose to and goes off the page).<br>When I upload the machine specs I get this error message:<br>E14:15:00 C25, PGXXABCD,END not recognized.</p><p>this happens every time I try to upload and I couldn't find the reason or meaning of it, could you help me?</p>
The error is nothing to worry about - just an old command that doesn't do anything any more.
<p>The machine is still off. What else can be the problem??</p>
<p>Euphy,</p><p>New Problem. Well two actaully.</p><p>First, when I so a pen tip test it prints out super small not matter how much I change the setting.</p><p>Second, I am assuming also pen size related is that the lines it draws in the on pixel areas are really close together. When is gets to detail areas it just ends up filling in solid because I have not been able to figure out what the right setting are.</p>
Show me a pic of what you mean by super small. Small pixel, or small lines, or small spaces - you need to consider how you might expect me to be able to help based on what you state as the problem.<br><br>&quot;No matter How much you change the setting&quot; - which setting? Does the pixel density (the number of lines) change at all?<br><br>Are you using a very small grid size?<br><br>
<p>Euphy,</p><p>Here it what it looks like when I try to do a pen tip test and my settings. Not sure what I have done wrong.</p>
<p>i have the same problem... if you found the solution can you help?</p>
<p>Did you read my reply below?</p>

About This Instructable




Bio: Like everyone, I like making things. I'm currently a computer programmer by trade, which I adore, but I like building physical things when I ... More »
More by Euphy:Polargraph Drawing Machine Linear Clock Mechanical expanding cardboard lamp - This way up! 
Add instructable to: