Pages: [1] 2   Go Down
Author Topic: stepper motor code +cnc plotter code  (Read 7289 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 203
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 203
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ??
 
« Last Edit: June 07, 2011, 02:14:16 am by adilmalik » Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 203
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-mr-green. 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???
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 635
Posts: 34572
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm

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
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 203
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thankyou for your reply.
this sounds very difficult smiley-eek-blue. cant i just calculate e.g. that if 200 steps move 50cm, 100 steps move 25cm ,then write a big code to draw smthing??
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 635
Posts: 34572
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 203
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!!!
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 635
Posts: 34572
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
so i would have to download a Gcode interpreter then design a code.
Yes that is probably the easiest route to go.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 203
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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???
« Last Edit: June 07, 2011, 12:35:21 pm by adilmalik » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 635
Posts: 34572
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 203
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks again can u please help me out a bit, how do i start ,download smthing?????
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 635
Posts: 34572
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well look at:-
http://www.machsupport.com/forum/index.php?topic=3920.0

http://inkscape.org/

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
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 203
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks but this is for the future smiley-sad . 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?
« Last Edit: June 07, 2011, 01:12:14 pm by adilmalik » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 635
Posts: 34572
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Then look at the previous link about Gcode for the arduino
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 203
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1] 2   Go Up
Jump to: