Truncated match.
PICList
Thread
'Drawing Circles & Spirals'
1999\03\17@054949
by
Ravi Pailoor
Hi PICkers,
I have a PIC controlling 2 stepper motors connected to a light source.
I need to move the light source in a circle and a spiral.
Does anyone have PIC / 8031 based algorithm to draw circles ?
Thanks
Pailoor
================================================
For Embedded Controls Solutions and Custom Designs
------------------------------------------------------------------------
CHIP TECHNOLOGIES - Member, Microchip Consultant Program
Bangalore
INDIA
Email : spam_OUTchiptechTakeThisOuT
vsnl.com
Webpage : http://business.vsnl.com/chiptech ( updated 16th Feb 1999 )
================================================
1999\03\17@061201
by
Vincent Deno
|
I'm assuming you have one stepper in for each axis (say X and Y).
A simple way to generate the circle would be to move the light cource to
the position given by:
X=A cos wt
Y=A sin wt
where: A is a constant which controls amplitude of motion
w is a constant wich controls the speed of rotation.
To control the light source, it would be simply a matter of generating
sin and cos waves (or two sine waves 90 degrees out of phase).
Obviously, you can extend this idea to make squares (from square waves)
and other results from other signals.
I've never delt with stepper motors so maybe someone else with more
experience can be of more help. Sorry about the typos, it's late here.
Regards,
Vincent Deno
{Quote hidden}> I have a PIC controlling 2 stepper motors connected to a light source.
>
> I need to move the light source in a circle and a spiral.
>
> Does anyone have PIC / 8031 based algorithm to draw circles ?
>
> Thanks
>
> Pailoor
>
> ================================================
> For Embedded Controls Solutions and Custom Designs
> ------------------------------------------------------------------------
>
> CHIP TECHNOLOGIES - Member, Microchip Consultant Program
> Bangalore
> INDIA
> Email :
.....chiptechKILLspam
@spam@vsnl.com
> Webpage :
http://business.vsnl.com/chiptech ( updated 16th Feb 1999 )
> ================================================
>
--------------
Vincent Deno
Design Engineer
Theta Digital Corp.
http://www.thetadigital.com
denovj
KILLspamemail.uc.edu
_____________
| ____ ____ |
|/| | | | | |\|
| | |/| |\| | |
| | | | | | | |
| |_/ | | \_| |
| | | | | |
|_/ /___\ \_|
1999\03\17@063101
by
g.daniel.invent.design
|
r=(x^2+y^2)^.5
use a table to store x & y values for 0 to 90 degrees in your minimum
step size. if accuracy is important and table size is small then you
must interpolate values inbetween table entries.
use the microchip application notes to do the maths.
quadrants after 0 to 90 degrees can be easily calculated by negating of
y(90 to 180), x and y(180 to 270), x(270 to 360(0)) values.
Alternativly...
connect the servo motors to match the axis used ie rotation servo,
radius servo.
regards,
Graham daniel.
Ravi Pailoor wrote:
{Quote hidden}>
> Hi PICkers,
>
> I have a PIC controlling 2 stepper motors connected to a light source.
>
> I need to move the light source in a circle and a spiral.
>
> Does anyone have PIC / 8031 based algorithm to draw circles ?
>
> Thanks
>
> Pailoor
>
> ================================================
> For Embedded Controls Solutions and Custom Designs
> ------------------------------------------------------------------------
>
> CHIP TECHNOLOGIES - Member, Microchip Consultant Program
> Bangalore
> INDIA
> Email :
.....chiptechKILLspam
.....vsnl.com
> Webpage :
http://business.vsnl.com/chiptech ( updated 16th Feb 1999 )
> ================================================
--
Steam engines may be out of fashion, but when you consider that an
internal combustion engine would require recovery of waste heat by
transfer just before top dead centre then fashion becomes rather
redundant, USE STRATIFIED HEAT EXCHANGERS ! and external combustion.
You heard it first from: Graham Daniel, managing director of Electronic
Product Enhancements.
Phone NZ 04 387 4347, Fax NZ 04 3874348, Cellular NZ 021 954 196.
1999\03\17@071256
by
Pasi T Mustalahti
On Thu, 18 Mar 1999, Graham Daniel wrote:
> r=(x^2+y^2)^.5
>
> use a table to store x & y values for 0 to 90 degrees in your minimum
> step size. if accuracy is important and table size is small then you
> must interpolate values inbetween table entries.
PTM: You don't need y -table at all. Use x table backwards:
sin(x)=cos(90-x) in first quadrant.
--------------------------------------------------------------------------
PTM, EraseMEptmustaspam_OUT
TakeThisOuTutu.fi, http://www.utu.fi/~ptmusta OH1HEK
Lab.ins. (mikrotuki) ATK-keskus/Mat.Luon.Tdk OI7234
Lab.engineer (PC support) Computer Center
Mail: Turun Yliopisto / Fysla, 20014 Turku
Pt 02-3336669, FAX 02-3335632 (Pk 02-2387010, NMT 0400-555577)
--------------------------------------------------------------------------
1999\03\17@071715
by
Peter Williamson
|
Do a web search for Bresenham's algorithm. (I have only got one in C)
Bresenham was responsible for integer line algorithims for plotters. His
techniques were then used to produce integer algorithims for circles.
Theses algorithms are designed for x-y plotters and use no floating
point calculations.
Ravi Pailoor wrote:
{Quote hidden}>
> Hi PICkers,
>
> I have a PIC controlling 2 stepper motors connected to a light source.
>
> I need to move the light source in a circle and a spiral.
>
> Does anyone have PIC / 8031 based algorithm to draw circles ?
>
> Thanks
>
> Pailoor
>
> ================================================
> For Embedded Controls Solutions and Custom Designs
> ------------------------------------------------------------------------
>
> CHIP TECHNOLOGIES - Member, Microchip Consultant Program
> Bangalore
> INDIA
> Email :
chiptech
spam_OUTvsnl.com
> Webpage :
http://business.vsnl.com/chiptech ( updated 16th Feb 1999 )
> ================================================
--
Peter Williamson | Phone: +61 15 898934
Waybeat Pty Ltd | Email: @spam@peterwKILLspam
waybeat.com.au
1999\03\17@074915
by
Ravi Pailoor
Thanks PIClisters, I will try out the suggestions and tell you the result.
Regards
Pailoor
================================================
For Embedded Controls Solutions and Custom Designs
------------------------------------------------------------------------
CHIP TECHNOLOGIES - Member, Microchip Consultant Program
Bangalore
INDIA
Email : KILLspamchiptechKILLspam
vsnl.com
Webpage : http://business.vsnl.com/chiptech ( updated 16th Feb 1999 )
================================================
1999\03\17@091633
by
Mike Keitz
|
On Wed, 17 Mar 1999 06:11:10 -0500 Vincent Deno <RemoveMEdenovjTakeThisOuT
EMAIL.UC.EDU>
writes:
>I'm assuming you have one stepper in for each axis (say X and Y).
>A simple way to generate the circle would be to move the light cource
>to
>the position given by:
>
>X=A cos wt
>Y=A sin wt
Avoid complicated math by essentially calculating the sine and cosine
terms iteratively. Observe that the derivitive of cos(x) is -sin(x) and
the derivative of sin(x) is cos(x). So if you have two numbers that are
the sine and cosine of some angle, you can find the sine and cosine of
some slightly larger angle this way:
S = S + k*C
C = C - k*S
Where k is some constant much smaller than 1 (if the largest values of S
and C are 1).
It can be directly applied to drawing circles. Start with X = r and Y =
0, then use these equations to step around the circle:
Y = Y + k*X
X = X - k*Y
Similar simple equations could be done to make spirals. Will these make
a spiral? I'd have to try it.
X = X - k*Y + j*X
Y = Y + k*X + j*Y
___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]
1999\03\17@092503
by
Vincent Deno
|
Actually, I was simply giving an idea on how one might approach the
problem. To implement this, I might simply use a lookup table to find the
appropriate value (for the given time). And yes, the same lookup table
could (and should) be used to get values for both sin and cos functions.
Making the spiral is easy from the given info... simply decrease the
amplitude with time.
Regards,
Vincent Deno
> On Wed, 17 Mar 1999 06:11:10
-0500 Vincent Deno <spamBeGonedenovjspamBeGone
EMAIL.UC.EDU> > writes:
{Quote hidden}> >I'm assuming you have one stepper in for each axis (say X and Y).
> >A simple way to generate the circle would be to move the light cource
> >to
> >the position given by:
> >
> >X=A cos wt
> >Y=A sin wt
>
> Avoid complicated math by essentially calculating the sine and cosine
> terms iteratively. Observe that the derivitive of cos(x) is -sin(x) and
> the derivative of sin(x) is cos(x). So if you have two numbers that are
> the sine and cosine of some angle, you can find the sine and cosine of
> some slightly larger angle this way:
>
> S = S + k*C
> C = C - k*S
>
> Where k is some constant much smaller than 1 (if the largest values of S
> and C are 1).
>
> It can be directly applied to drawing circles. Start with X = r and Y =
> 0, then use these equations to step around the circle:
>
> Y = Y + k*X
> X = X - k*Y
>
> Similar simple equations could be done to make spirals. Will these make
> a spiral? I'd have to try it.
>
> X = X - k*Y + j*X
> Y = Y + k*X + j*Y
>
>
> ___________________________________________________________________
> You don't need to buy Internet access to use free Internet e-mail.
> Get completely free e-mail from Juno at
http://www.juno.com/getjuno.html
> or call Juno at (800) 654-JUNO [654-5866]
>
--------------
Vincent Deno
Design Engineer
Theta Digital Corp.
http://www.thetadigital.com
TakeThisOuTdenovjEraseME
spam_OUTemail.uc.edu
_____________
| ____ ____ |
|/| | | | | |\|
| | |/| |\| | |
| | | | | | | |
| |_/ | | \_| |
| | | | | |
|_/ /___\ \_|
1999\03\17@121158
by
Gerhard Fiedler
At 16:22 03/17/99 +0530, Ravi Pailoor wrote:
>I have a PIC controlling 2 stepper motors connected to a light source.
>
>I need to move the light source in a circle and a spiral.
>
>Does anyone have PIC / 8031 based algorithm to draw circles ?
i assume you have the step motors controlling the x and y directions
linearily, right? then you need a sine function. scott dattalo has one at
http://www.interstice.com/~sdattalo/technical/software/pic/picsine.html
for a circle, x and y are 90¡ shifted in their phase.
ge
1999\03\17@134756
by
Wagner Lipnharski
|
> At 16:22 03/17/99 +0530, Ravi Pailoor wrote:
> >I have a PIC controlling 2 stepper motors connected to a light source.
> >
> >I need to move the light source in a circle and a spiral.
> >
> >Does anyone have PIC / 8031 based algorithm to draw circles ?
All in the nature tend to a simple solution.
It depends on if you need to move the light source or just the light
beam.
1) Moving the light beam:
Keep the light beam source fixed, projecting the beam over a rotating
mirror, will create a projected circle.
Just use a small mirror attached to the motor shaft. The mirror (1 or 2
inches diameter) needs to be "glued" at 90¡ to the shaft, less the
generated rotational cone angle.
The general formula is:
DPC = DP x TAN(Ax2)
where DPC: Diameter of Projected Circle
DP : Distance from the mirror to the Projection Screen
A : Mirror Angle (from the perpendicular 90¡)
If you glue the mirror at 85¡ at the motor shaft, if the screen is at 30
inches from the mirror, it will project a circle with a diameter: 2 x
30 x Tan((90-85)x2) = 10.57"
I did something like that with laser, and to adjust the mirror angle, I
just used a tick wire (big paper clip) 1/2" long, as an intermediate
connection between the motor shaft and the mirror, so you can bend the
wire with a pliers and adjust it to the correct angle you want,
adjusting the projected circle diameter.
To generate a spiral this mirror need to has a convex surface and the
second motor with another mirror will control the position of the beam
over this convex mirror.
It not only creates a spiral but very interesting effects mixing up with
the motors speed.
2) Moving the light source (lamp).
Forget about to use a x/y positioning table if you want simplicity, just
use a translation system from the first motor, as a mechanical lever
which one side of this arm will be attached to the side of a wheel in
the shaft of this motor (like an old locomotive wheel), while the lamp
will be at the other extreme of this arm (lever). The pivot of this arm
is a movable pin connected to the second motor shaft wheel, in a linear
movement construction. As the second motor moves this pin towards the
lamp, the rotation diameter reduces, as it moves towards the first
motor, it increases, so you can control the spiral this way.
In any case there is no sine calculations to do, just a linear control
over the motor position. Im both cases the second motor will do a
maximum of half rotation to control the spiral, while the first one will
do a full rotation to each lamp apparent rotation. The spiral number of
loops will be some relation between the steps from the first motor to
the second. If you rotate the second motor in complete circles, you
will have spirals going in and out in a endless loop.
In this second case, the lamp needs to have enough movable flex wires,
but the lamp doesn't rotate itself, since it is fixed at the end of the
arm.
If you want challenge, for for the x-y encoding table. Remember that
you have several ways to build that.
Wagner
1999\03\17@155323
by
Scott Dattalo
|
Ravi Pailoor wrote:
>
> Does anyone have PIC / 8031 based algorithm to draw circles ?
and then Gerhard Fiedler replied:
>
> i assume you have the step motors controlling the x and y directions
> linearily, right? then you need a sine function. scott dattalo has one at
> www.interstice.com/~sdattalo/technical/software/pic/picsine.html
>
> for a circle, x and y are 90¡ shifted in their phase.
thanks for the plug, but then Peter Williamson suggested:
> Do a web search for Bresenham's algorithm.
So I did and found this:
http://www.robots.ox.ac.uk/~awf/graphics/bres-ellipse.html
Bresenham's algorithm would be the preferred method for 'drawing
circles' in most systems. (This was discussed not too long ago, BTW.
However, I couldn't find the thread in the archives). However, if you
use mine or Eric Smith's sine tables, I think you'll find that it's
faster to generate circles using sines and cosines (especially for unity
radius :]) on a pic. I'm not sure if there is even a Bresenham algorithm
for spirals...
The equations for a circle, ellipse, or spiral can all be expressed
similarly:
x = r1(t) * cos(w*t)
y = r2(t) * sin(w*t)
for a circle, r1 = r2 and are constant.
for an ellipse, r1 != r2, but both are constant.
for a spiral, r1 = r2 and are functions of time.
You can also get elliptical spirals by making r1 != r2.
If you wanted a circular spiral that spiraled inward:
r1 = r2 = R_max - k*t for k*t < R_max
You can make logarithmic spirals by varying r1 and r2 exponentially (or
logarithmically).
It wouldn't be too hard to extend these concepts to generate lissajous
patterns or cycloids (e.g. spiral-graph).
Scott
1999\03\18@021218
by
Ravi Pailoor
Hi PICkers,
The light source is fixed, Wagner. I have a mirror fixed to a stepper
motor
M1. The other stepper motor M2 moves M1.
I have received more than 8 suggestions which I need to consolidate.
I have to convert all the formule to PIC code and come up with the best
solution. Once I am successful ( if I am ) , I will post the code for
others to
use.
Thanks a lot PICkers.
Regards
Pailoor
================================================
For Embedded Controls Solutions and Custom Designs
------------------------------------------------------------------------
CHIP TECHNOLOGIES - Member, Microchip Consultant Program
Bangalore
INDIA
Email : RemoveMEchiptech
TakeThisOuTvsnl.com
Webpage : http://business.vsnl.com/chiptech ( updated 16th Feb 1999 )
================================================
1999\03\19@124119
by
John Payson
|
|Bresenham's algorithm would be the preferred method for 'drawing
|circles' in most systems. (This was discussed not too long ago, BTW.
|However, I couldn't find the thread in the archives). However, if you
|use mine or Eric Smith's sine tables, I think you'll find that it's
|faster to generate circles using sines and cosines (especially for unity
|radius :]) on a pic. I'm not sure if there is even a Bresenham algorithm
|for spirals...
Actually, if you have a sine/cosine function/table you can generate
variable-sized circles without any multiplication:
just plot (for variable t and fixed Q)
x=cos(t)+cos(t+Q)
y=sin(t)+sin(t+Q)
If Q increases or decreases while you're running the plots, you'll get
shapes that spiral in and out. If you want to be able to get a specific
radius of circle, you'll need a table to translate the desired radius
into the Q value. Note that the function for converting Q into radius
is:
radius = sqrt ((1+cos(Q))^2 + sin(Q)^2)
= sqrt (1 + 2cos(Q) + cos(Q)^2 + sin(Q)^2)
= sqrt (2 + 2cos(Q))
so it's probably easiest just to use an R->Q table.
More... (looser matching)
- Last day of these posts
- In 1999
, 2000 only
- Today
- New search...