stepper motor code +cnc plotter code

hi, i recently got 2 old scanners ,im planning to use there moving axis to make a pencil plotter like here:http://www.instructables.com/id/Low-Cost-Hobby-Servo-XY-Table/. ive made everything but how should i write an arduino code to control the stepper telling it to move at a certain point on its axis,im using an uln2003a for control.for example to move 10cm or 20cm etc.the stepper is unipolar 5wire,7.5degree per pulse

thanks for the reply, i ve seen that tutorial and i have used it to control the stepper motor ,but its just randomly moving i ,want to write the code to tell the stepper to move the stepper head to the furthermost point of its axis,to the middle point etc.should i calculate the number of pulses it requires to move to the furthermost point ??

thanks again for your reply, im sorry i didnt say it clearly ,by randomly i meant that its moving on the axis but i cant control it with my current code ie move 10cm 20cm etc.But the second part of your answer is very helpful . can u please elaborate ,i have two micro switches which i can put on both sides, but how should i make the code now,should i send a loop of pulses which should stop when the switch gets pressed? and then count how many pulses ,then this would serve as the maximum point and the rest can be calculated???

You need to think how you are going to send commands to make it draw. A popular code for CNC machines is Gcode but plotters use HPGL, you need to write an interpreter for the language you want to use.
s to how to get a motor to plot a straight diagonal line, one way is with Bresenham line algorithm Bresenham's line algorithm - Wikipedia

An example of my Gcode project is here:-
http://www.thebox.myzen.co.uk/Hardware/CNC_Conversion.html

and there is an open source Gcode interpreter for the Arduino at:-
http://dank.bengler.no/-/page/show/5470_grbl?ref=mst

this sounds very difficult . cant i just calculate e.g. that if 200 steps move 50cm, 100 steps move 25cm ,then write a big code to draw smthing??

then write a big code to draw smthing??

Doing this you will always have to write code to draw anything. Most likely you will want to draw something you want, not just random lines. This means the code is even more involved with lots of things to go wrong. Also one downloaded sketch will draw one thing, an making changes to that code to draw just a little bit will be almost impossible.
You want to swap short term gain for long term pain. That's not smart.

oh! thanks, now i understand, i was experimenting with a normal arduino program on a single axis and i see ur point now,straight horizontal and vertical lines will be easy ,but drawing cirlces and other complex things will be very difficult and time consuming, so please can you elaborate a bit, so i would have to download a Gcode interpreter then design a code.
thanks!!!

so i would have to download a Gcode interpreter then design a code.

Yes that is probably the easiest route to go.

thankyou Grumpy mike you have been very helpful
please tell me ,is g code easy to use with the arduino ,to u know of any tutorial that might help me to get started. and can i use gcode with uln2003a???

Well you don't use it with the arduino, you use a text editor to create a Gcode file and then some program to sent it to the arduino.
There are programs like inkscape that will allow you to draw stuff on the screen and output a Gcode file ready for your system. So you don't have to actually touch the Gcode.
However you can google for Gcode tutorials if you want.

Well look at:-

http://cnc-club.ru/forum/viewtopic.php?f=33&t=35

Touch OSC and Gcode viewer
http://www.thebox.myzen.co.uk/Mac_Apps/Processing.html

thanks but this is for the future . i first have to understand how to use gcode with the arduino , and can i use it with uln2003a
also does grbl have its own hardware?

to use gcode to i need to buy its own hardware or can i use uln2003a IC's????????????????????

please can someone post a step by step guide on how to install and use gcode

Sorry no it is not like that. It is not something you install. You have to make a program to drive your own stepping motors from Gcode instructions. I have already posted the Gcode for arduino link, that is what you incorporate into your own program. Or my own work that is Gcode CNC controller along with Gcode readers.
This is not something that is a beginners project, it involves a modicum of gumption. Unless you are willing to put in effort and try to understand things you will get nowhere.

You are probably not at the stage where you can benefit from this. I would suggest that you do a few more tutorials with motors and get the feel of both them and how to write code. Then when you know more come back to this project.

Of course im willing to make an effort i made the plotter, so im not going to stop here,
ok so im getting started with gcode if i dont understand something ill ask u,im just writing down what i understood please see if this is correct: