[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Drawing arcs with stepper motors.
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /diy/ - Do It yourself

Thread replies: 13
Thread images: 2
File: descarga.jpg (4 KB, 275x183) Image search: [Google]
descarga.jpg
4 KB, 275x183
Hi diy,
im trying to draw arcs with 2 stepper motors attached to an X and Y axis, the arc must be drawn from point A to B in a cartesian plane, given the starting and endpoint point coordinates.

The problem is that i cant figure out how to tell the motors how to get the arc divided in lots of steps. (im using an arduino)

help this peasant diy. :l
>>
>>991979
Was it really too much effort to check if your old thread still existed?
>>990730
>>
I'm not sure I understand your goal. Are you using 2 stepper motors to move a point in a Cartesian plane from a given starting and to a given ending point?

Adafruit has a motor shield and library for controlling steppers that you could use. You really don't even need that though if you understand how steppers work and can get an H-bridge (L293 I believe is a good general purpose one).
>>
File: midpoint.gif (6 KB, 360x255) Image search: [Google]
midpoint.gif
6 KB, 360x255
>>991979
>>991979
First thing that comes to mind is that two points do not make an arc on a plane. You need three points at least.

Take a look at the attached image, that's called midpoint integration. It does something different, but it gives you a nice set of vertical and horizontal lines that approximate the curve. The denser the rectangles, the closer the approximation of the curve. When they get really dense it'll stop looking like a bunch of corners and start looking like a line.
Now say that for the first 5 steps on x we need to go 7 steps on y. Assume you need both of these to happen in a given timeframe, e.g. one second. This gives you different step frequencies for the next second for axes x and y (in this example it's 5 Hz for x and 7 Hz for y). Feed that to the driver, run the motors at those freqs for one second and then recalculate for the next second and so forth. Perhaps if your resolution isn't shit it might work.
>>
>>991979
I have no idea what you are doing. But anyway....

What you might do is go look up the old-style circle and oval drawing methods for DOS PC games.

At one point in time there was very limited built-in functions for drawing stuff; you got a method for setting a single pixel, and usually there was functions to draw straight horizontal or straight vertical lines, and unfilled and filled boxes. And that was it. You had to write your own functions for drawing curved and angled lines.

When drawing curves or angled lines, there won't be a pixel located at the exact point that you want--so you have to search for the nearest pixel (of the four closest to that point) and turn on the one that is closest. The computer maintains the "ideal" position mathematically, and then it finds the nearest position to that point that it can select, given the resolution limits of screen pixels (or stepper motor steps).
>>
>>991979
You don't have enough variables to draw an arc like that, you need A, B and at least one other constraint, be it radius or starting angle or a third arc point.
>>
>>991979
The simple answer? Use an already written library to control your motors.

The do it yourself answer?...
Convert your arc into a bezier curve. Once you have the curve you can aproach the curve programatically by utilizing De Casteljau's algorithm. You can recurse the function enough times that the discrete steps it outputs are within the machine's tolerance limits, or your own defined less-stringent tolerances.
>>
If they're basic arcs, as in a segment of a circle

Just learn how to use sin(x) and cos(x) functions to draw circles and simulate reciprocal motion and such, and that'll give you most of what you need
>>
>>991979
> the arc must be drawn from point A to B in a cartesian plane, given the starting and endpoint point coordinates.
Unless the "arc" is specifically a straight line, then knowing the endpoints isn't enough, you also need all of the points in between.

Essentially what you need is a parametric curve which defines x and y as analytic functions of an independent variable t. E.g. for a circle of radius r centred at x0,y0, you'd have x(t)=r*cos(2*pi*t), y(t)=r*sin(2*pi*t).

Once you have that, you need to compute derivatives, either algebraically (using sum/product/quotient/chain rules) or numerically (x'(t) ~= (x(t+Δt)-x(t))/Δt. At any given point, you determine whether to step left or right and whether to step up or down based upon the signs of the derivatives, and whether to step in the X or Y direction depending upon whether abs(x'(t)) is greater or less than abs(y'(t)).
>>
>>991979

what do you mean by arc

why not just build the thing and then just figure out the rest in software
>>
>>992685
thanks anon this is what i needed.
>>
>>991979
Try H bridge
>>
Look up Bresenham Algorithm.
Thread replies: 13
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.