thanks for your responses. I like the pid controller thing, the "PID
without a PhD" is quite straightforward and i think it could be of use for
my cause
Reply by Tim Wescott●May 15, 20062006-05-15
zyd wrote:
> hi everyone i'm gonna build a car that moves according to a light, ig the
> light is getting close the car moves backwards, if the light is going away
> the car follow it. The speed of the car will depend of the rate of change
> of the light's intensity. If the light intensity is changing slowly the
> car will move slow if the light is changing fast the car will move fast.
> I understand that for the rate of change of the light i need to use a
> derivative. i'm going to use a microcontroller to implement this project
> but i don't know how to calculate the derivative, somebodytold me that i
> needed to use a "discrete-time filter" and i started to investigate, and
> everything points to the use od the z transform, but i don't get yet why i
> need to use the z transform, i have less than 2 weeks to finish this
> project which is about electronics, so i cannot invest so much time in
> maths investigation. so i need a little help.
> could somebody tell me in which way the z tranform is of use for me?
> thanks in advance
>
>
>
http://www.wescottdesign.com/articles/zTransform/z-transforms.html
should be a quick read.
As Rick pointed out you can get away without using z transforms. If you
want to actually analyze the system behavior first, however, you'll need
them.
Once you get past differentiation you may also want to read the article
pointed to by http://www.wescottdesign.com/articles/pidwophd.html --
it'll tell you how to actually write your controller.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
Posting from Google? See http://cfaj.freeshell.org/google/
"Applied Control Theory for Embedded Systems" came out in April.
See details at http://www.wescottdesign.com/actfes/actfes.html
Reply by Rick Lyons●May 15, 20062006-05-15
On Mon, 15 May 2006 07:43:16 -0500, "zyd" <lr3web@hotmail.com> wrote:
>hi everyone i'm gonna build a car that moves according to a light, ig the
>light is getting close the car moves backwards, if the light is going away
>the car follow it. The speed of the car will depend of the rate of change
>of the light's intensity. If the light intensity is changing slowly the
>car will move slow if the light is changing fast the car will move fast.
>I understand that for the rate of change of the light i need to use a
>derivative. i'm going to use a microcontroller to implement this project
>but i don't know how to calculate the derivative, somebodytold me that i
>needed to use a "discrete-time filter" and i started to investigate, and
>everything points to the use od the z transform, but i don't get yet why i
>need to use the z transform, i have less than 2 weeks to finish this
>project which is about electronics, so i cannot invest so much time in
>maths investigation. so i need a little help.
>could somebody tell me in which way the z tranform is of use for me?
>thanks in advance
Hi zyd,
without going into all the math, I suggest you
use one of the following:
y(n) = x(n) - x(n-1) [1]
or
y(n) = [x(n) - x(n-2)]/2 [2]
[Sequence y(n) is the approx derivative of
sequence x(n).]
Method [2] will have reduced high-frequency
noise in y(n) compared to method [1].
Both methods [1] & [2] *only* provide accurate
results if your x(n) signal has a positive-freq
bandwidth of no greater than 1/10 of the Fs
signal sample rate. (That's because these differentiators
are so computationally simple.
If ya need to differentiate a signal whose one-sided
bandwidth is wider than Fs/10, then you'll need someone
to design a "tapped-delay line" differentiator
that will require 10-20 (maybe more depending on signal
bandwidth) taps.
You can search the Internet for "FIR differentiators"
to learn more. Your problem is fairly simple
to solve, so if ya' need more help, ask more questions.
Good Luck,
[-Rick-]
Reply by Noway2●May 15, 20062006-05-15
zyd wrote:
> hi everyone i'm gonna build a car that moves according to a light, ig the
> light is getting close the car moves backwards, if the light is going away
> the car follow it. The speed of the car will depend of the rate of change
> of the light's intensity. If the light intensity is changing slowly the
> car will move slow if the light is changing fast the car will move fast.
> I understand that for the rate of change of the light i need to use a
> derivative. i'm going to use a microcontroller to implement this project
> but i don't know how to calculate the derivative, somebodytold me that i
> needed to use a "discrete-time filter" and i started to investigate, and
> everything points to the use od the z transform, but i don't get yet why i
> need to use the z transform, i have less than 2 weeks to finish this
> project which is about electronics, so i cannot invest so much time in
> maths investigation. so i need a little help.
> could somebody tell me in which way the z tranform is of use for me?
> thanks in advance
Calculations of the derivative involve the use of forward and or
backward differences, which is the difference between to successive
samples. These differences can also be expressed in terms of the Z
transform since z^-1 is an operator that represents a delay of one and
z^1 is an advance of one. The accuracy of the calculated derivative
is related to the order of the model. In this instance a first order
would be the difference of two samples and second order would incorpate
the difference of the first differences, and so on. Of course, the
higher the order the more involved calculations become. In a real time
system with some form of feedback the control loop will usually
counteract the error in the math so that it isn't ncessary to use high
order calculations.
I would highly suggest the book Math toolkit for real time programming
by Jack Crenshaw for you. In this book, he develops the mathematics
necessary for calculating various functions, inlcuding derivates and
relates them to the Z transform. The book also provides example code
in C that demonstrates these principles. The code is very concise and
easilly adapted to an application. If you can't find the book or
obtain it in time, I would suggest trying to find some of his articles
on line as there is likely one that deals with calculating the
derivative.
The end of the book also deals with close loop control systems in real
time, based upon the techniques described in the rest of the book. I
mention this because it may be very applicable to your design.
Reply by zyd●May 15, 20062006-05-15
hi everyone i'm gonna build a car that moves according to a light, ig the
light is getting close the car moves backwards, if the light is going away
the car follow it. The speed of the car will depend of the rate of change
of the light's intensity. If the light intensity is changing slowly the
car will move slow if the light is changing fast the car will move fast.
I understand that for the rate of change of the light i need to use a
derivative. i'm going to use a microcontroller to implement this project
but i don't know how to calculate the derivative, somebodytold me that i
needed to use a "discrete-time filter" and i started to investigate, and
everything points to the use od the z transform, but i don't get yet why i
need to use the z transform, i have less than 2 weeks to finish this
project which is about electronics, so i cannot invest so much time in
maths investigation. so i need a little help.
could somebody tell me in which way the z tranform is of use for me?
thanks in advance