Introduction: Drawing Robot

Please vote for Drawing Robot on this link.

Thanx in advance

Fixing my drawing incapability with my robotics skills and to me results were not that bad. Now I can at least save my self from humiliation in my drawing class.

This project is good for beginners and gives sufficient exposure to arduino, matlab coding and mechanics. There is not much in the electronics department. The bot is a basic 2DOF arm with a pen manipulator. This project involves application of inverse kinematics and canny edge detection.

Step 1: Parts, Tools and Software Required

Picture of  Parts, Tools and Software Required

1. Mechanical

  • Mechanix kit
  • Nut and bolts
  • Pen Holder (Clothespin)
  • 2X Caster wheels

2. Electronics

  • Arduino uno
  • PCB or Bread board
  • Power Supply (5V adapter with 2A current)
  • USB Cable

3. Servo Motors

4. Tools

  • Soldering Iron
  • Soldering Wire
  • Screw driver
  • Drilling Machine

5. Software

Above links are for India, so you can find this stuff with your local retailer easily.

You can take any servos with torque greater than 7Kg.cm and for bread board users soldering iron and wire are not required.

Step 2: Mechanical Design

Picture of Mechanical Design

From the pictures above you get the idea of what the design is and how you should go about assembling it. It is more like playing with maker kits when you were 5 or 6 years old. So lets start step by step construction.

  1. Drill two holes in each of the horns such that the distance between the two holes is same for all the horns as given in the picture.
  2. Now we have to make a rigid support for one end. Drill four holes at appropriate distances as the screws of the servo and attach the servo to the box. We will use this setup to give a rigid support to the setup.
  3. Join two combinations of aluminium stripes from the kit to any two horns as shown in the picture such that the distance between the two horns should be ~20 cm.
  4. Now attach one horn to the servo with rigid support and one to the other servo and before fixing the horns, calibrate the servos to 90 degrees so that rigid servo is parallel to the stripes and the free end servo is perpendicular to it.
  5. Now take two longest stripes (15 cm) fro the kit and attach them to the lower end of the free end servo parallel with it.
  6. Then attach caster wheels at the bottom of the arm with the pen which we constructed in step 5 for proper balance and support.
  7. The last servo should be attached at the end point of the step 5 with feviquick or glue gun anything that makes it rigid there.
  8. With a stripe of appropriate length and clothespin attach the pen to the servo such that the distance from the free end horn and the pen tip should be ~20cm.

While construction two points should be kept in mind that the distances mentioned above should be 20 cm and calibration should be done properly. Rest of the construction depends on the availability of parts and your wish. For example instead of aluminium stripes from the kit you can use rulers for arms etc.

Step 3: Electronics Part

Picture of Electronics Part

The picture above is self explanatory you can either make a shield for the arduino as I have done or a bread board for the circuit.

Step 4: Coding

Picture of Coding

This part of the project is the most interesting part and the most important as well.

Let me give you a briefing of what is happening.

First we take an image and find its edges with the help of canny edge detection and we are going to draw this image. Drawing the image has two parts

PART 1: First we find the pixel which is 1 as our image is now in the form of 0s and 1s and then check its local pixels if any one of them is also 1 then the pen reaches that pixel and deletes the previous 1. The function repeats it self recursively and creates smooth lines.

PART 2: The second part involves the inverse kinematics part of how to reach that particular pixel. It simply takes in the coordinates of the pixel and calculates the corresponding angles for the pivots, the calculations are shown in the above picture.

The above explanation is not required for the execution of the code it is just for understanding.

Now how to setup Matlab and arduino for the execution of the code.

First install the arduino IO package on matlab (all the instructions are given with the package).

Now replace the arduino.m file with the file the file that I have uploaded with same name.

Download and save finaldraw.m and draw.m in matlab directory.

Upload the adioes.ino file that I have uploaded to the arduino board.

See to which port your arduino is connected and then go to finaldraw.m and change COM3 to your port.

Change the extension of the image which you want to draw to .png. This can be done in any image editor now save this image to the matlab directory. Open the finaldraw.m and change emma.png to your image name with .png extension.Save the finaldraw.m file.

I have uploaded the picture of emma watson as a sample, so you can use it for testing and you can also adjust the parameters of the canny edge detection function according to your need.

We are done now connect the arduino to your PC and switch on the power supply and type finaldraw in matlab command line. HAVE FUN !!!

If you are facing any problems then comment below.

Step 5: Coding Continued..........

Picture of Coding Continued..........

The working of the algorithm is very simple, it is just the matter of visualizing how the bot approaches the image drawing.

This is an elaborate explanation and feel free to skip it.

Firstly, I convert the the image that I want to draw in png format using some image editor, then I save the Image in the matlab directory. Now our algorithm converts this image using canny edge detection as given in the image above. The mysterious part is drawing this image.

What the algo does is it starts checking the pixels of the converted image and when it finds 1 which is indicated as the white pixel in the image above, the pen tip reaches that point (The reaching part is covered in the previous step clearly) and puts the pen down then it checks neighboring 8 pixels, if it finds a 1 it reaches that point without lifting the pen up and deletes the previous pixel to avoid repetition. Now this continues till it finds no 1s in the neighborhood(this is a recursive function) hence it draws smooth line deleting it simultaneously. Then it completes other branches of lines that emerge from the drawn line as it checks every neighboring pixel. This algorithm ultimately creates the whole image. Now watch the video given in the beginning again and try to connect the dots you will surely feel a GEEKY MENTAL ORGASM that I felt when I figured this elegant algorithm after a lot of failed attempts. HOPE YOU LIKED MY INSTRUCTABLE IT WAS MY FIRST SO APOLOGIES FOR A ROUGH TUTORIAL!!!!!!!

Comments

Kirtron made it! (author)2017-01-09

Hello, Lakshay, I need your help. I gathered this project, but accuracy of picture is very far from original image. I ve tried to do it in Matlab 2015a firstly. Then i installed matlab 2012a but it didnt give results. Please, help me, I really want to finish this project.

SaadA83 (author)Kirtron2017-08-08

bro!! please check the co-ordinates. whether both the arm is 20 cm apart. also the shifting of origin should be 4cm. please do check these things. i hope you might get the correct results then

RobotTECH63 (author)2017-06-15

Hello , my error is
Error in finaldraw (line 3)
w=edge(i,'canny',[.05,.20]);

please thank you for replying fast

SuryaK52 (author)2017-03-27

Given matlab code is correct or wrong

khaipham (author)2017-03-16

Give me code with everyone

Allenzenith (author)2017-02-22

The pen holder roate 180 degree and then there is an error in matlab por t and arduino port tell plz send code to my gmail

suraj7 (author)2017-01-22

Hey bro..NYC prjct..My servo holding the pen is rotating 360 degree and making pen move jn circles.how to crct it..And what version of MATLAB is necessary for this project?

suraj7 (author)2017-01-22

My third servo which is holding the pen is rotating 360 degrees and hence it is not able to draw..And also what version of MATLAB is compatible?

IzaR3 (author)2017-01-17

I had no Errors in running the code, and the mechanical design i have done is the same as mentioned, but the servos do crazy things and the drawn picture is comletely wrong.

IzaR3 made it! (author)2016-12-24

here is what i have got. how to proceed now?

PayalM3 (author)2016-10-18

Hey can you send me your email address I have lots of related to this project and I have to complete is soon... Please

BishalK4 (author)2016-09-23

I can not download the io pack . it says the page not found or moved. what shoul i do?

seamster (author)2014-10-10

Very cool! Thanks for sharing this!

lakshay garg (author)seamster2014-10-10

glad you liked it.

BHARATHB15 (author)lakshay garg2016-09-10

BROTHER CAN U PLEASE POST THE WHOLE CODE FOR THIS PROJECT >.

HiritikkK (author)2016-04-24

how much does the aurdino uno

cost

naveen94414 (author)HiritikkK2016-08-16

it is just 6 to 7 bucks

AmikoM (author)HiritikkK2016-04-27

you can get it for 5$
p.s not original, but everything is the same

mal-hd (author)2016-06-04

how have you obtained the inverse kinematics equation from the above 2 equations I tried to solve by hand but I couldn't get the answer correct

DhirenP3 (author)2016-06-03

what should be provided to audrino to start sketching and how the sketch is made....plzzzzz i m willing to make one so can any one guide me plzzzzz

Sembot (author)2016-05-28

Hai,

180° ?????

myprojct (author)2016-04-11

Pls what size of caster wheels should I use

AkhilS9 (author)2016-03-20

can we use 3 kg.cm servos

AkashA26 (author)2016-03-15

getting these errors...

Error using serial/fwrite (line 199)

Unsuccessful write: An error occurred during writing.

Error in arduino/servoRead (line 1109)

fwrite(a.aser,[55 97+pin],'uchar');

Error in finaldraw (line 29)

E=servoRead(a,9);

Please help me out..

Subha00 (author)2016-02-04

Hi Lakshay. Can you please elaborate on the initial position of the servos and the calibrations required?? Its a brilliant project.Thank you

lingib (author)2016-01-29

Brilliant. Thank you for sharing :)

vinay108 (author)2016-01-04

how to make without MATLAB

myprojct (author)2015-12-09

Hello author.. Can u add comments to the MATLAB code please.. I need it ASAP

Sembot made it! (author)2015-12-01

Hai,

Beautiful project thank you that you want to share this with us

I have a question, can I use Freemat instead of Matlab and how to use

Kind Regards

Motaz Bany-Amer (author)2015-09-25

THE ROBOT IS NOT WORKING!!

I had no Errors in running the code, and the mechanical design i have done is the same as mentioned, but the servos do crazy things and the drawn picture is comletely wrong.

i have checked the servo connections and tested the angels and found it right( i used Emma photo!)

I have tested the robot with another pictures the same problem, nothing drawing right!

a strange thing happend while I'm testing my robot, I have tested the robot with picture have a single line as a test. the robot draw a line; not perfectly straight but its good!

have any idea of the program!?

ТимурУ1 (author)2015-09-18

Attempting connection .............

Analog & Digital I/O + Encoders + Servos (adioes.pde) sketch detected !

Arduino successfully connected !

Matlab stay at this point. Please help. What do i need to do next?

ТимурУ1 (author)2015-09-18

slulu226 (author)2015-08-05

Guys,you can search a 4 in 1 drawing robot kit named mDrawbot from MakeBlock! it can be assembled into 4 different configuration drawing robots: mScara, mSpider, mEggBot and mCar.

http://www.makeblock.cc/mdrawbot-kit/

DashS1 (author)2015-07-29

could you elaborate on the inverse kinematics equations? I built an arm with slightly different setup and I'm trying to figure out how to adapt your code to work with it, but I don't really get where the 800 in the code comes from or the other numbers

mnaung (author)2014-11-21

??? Undefined variable "vision" or class "vision.CascadeObjectDetector".

Error in ==> FINAL at 5

EyeDetect = vision.CascadeObjectDetector('EyePairBig');

how to fix it

go for matlab R2013a . ..

MahmoudTolba (author)mnaung2015-01-13

I have the same error, Did you find a solution to fix it ?

ademyanenko (author)2015-07-08

Great project. Cheap and cheerful.

Chandandeep (author)2015-05-23

I just cannot interface arduino with matlab. checked all ports , everyhing.. did all you said but it just doesn't work... help me please

hay budy can you found a way to solve this problem

mechagical (author)2015-03-16

Hi, the face detection is amazing, but i'm having errors while trying to execute finaldraw. It seems there's something wrong with the servo angle?

Error using arduino/servoWrite (line 1149)

Unallowed value for angle, the value must be an integer going from 0 to 180

Error in draw>servoAngle (line 66)

servoWrite(a,p,E-i+n);

Error in draw>reach (line 26)

servoAngle(a,9,180-p);

Error in draw (line 3)

reach(a,m,n,size(I));

Error in finaldraw (line 36)

I=draw(a,I,p,t);

lakshay garg (author)mechagical2015-03-27

you have to replace the arduino.m file in your matlab directory with the one I have uploaded and upload the sketch adioes.ino THAT I HAVE UPLOADED. then it will not give that error.

hay can you help me to get out of following problems please.....

(1)Matlab Error in draw.m is

Error in ==> draw at 2

if

I(m-1,n-1)==1||I(m,n-1)==1||I(m-1,n)==1||I(m+1,n-1)==1||I(m-1,n+1)==1||I(m,n+1)==1||I(m+1,n)==1||I(m+1,n+1)==1

(2)error in finaldraw is

Error in ==> FINAL at 5

EyeDetect = vision.CascadeObjectDetector('EyePairBig');

Chandandeep (author)2015-05-23

TheL1 (author)2015-04-13

I'm a drawing master lol

ArachnoKing (author)2015-04-11

i already draw good

akash.parida.54 (author)2015-03-19

hello friends , can we use a normal servo having torque 7 kg.cm instead of a dual ball bearing servo ???? plzz answer soon...

yes you can

akash.parida.54 (author)2015-03-22

where are you admin??? plzz do reply soon...

aravindd (author)2015-02-08

About This Instructable

142,556views

799favorites

License:

Add instructable to: