# Calculating angles,calculating velocity

1. Aug 29, 2010

hi,
i am trying to calculate angles and velocity.
i believe i have to use PID (never done before)
angles
i have a sensor that is giving a relative angular rotation in degrees per a second
i can sample this a 300htz
but how can i figure out if i have turned xo and i how can i reduce the cumulative error

velocity
i have a sensor that is giving acceleration in g's
i can sample this a 300htz
but how can i figure out if i am moving @ x ms-2 and i how can i reduce the cumulative error

thanks,

if this is in the wrong spot please move it

2. Aug 29, 2010

### Staff: Mentor

Welcome tol the PF, Brad. I went ahead and moved your question to General Engineering for now.

What are the outputs of these sensors like? Are they a byte or two that you are sampling at 300Hz? Or do they offer some sort of pulse outputs or serial data?

Are you familiar with integration in calculus? that's how you go from a rate to a position. In your case, it would be a discrete integration, basically multiplying the rate by the delta time interval to get the quantity. As for minimizing the error, you might want to use the mean value theorem, or maybe some other type of predictive filtering of the data.

What are your thoughts on how to minimize the errors?

3. Aug 29, 2010

the output is a 10bit dac where 0 is -300o/s and 1024 is 300o/s and 512 is 0o/s

the output is a 10bit dac where 0 is -1.5g and 1024 is 1.5g and 512 is 0

i believe that
proportional integral derivative
something along the lines of

where the tuning parameters are:

Proportional gain, Kp

Larger values typically mean faster response since the larger the error, the larger the proportional term compensation. An excessively large proportional gain will lead to process instability and oscillation.

Integral gain, Ki

Larger values imply steady state errors are eliminated more quickly. The trade-off is larger overshoot: any negative error integrated during transient response must be integrated away by positive error before reaching steady state.

Derivative gain, Kd

Larger values decrease overshoot, but slow down transient response and may lead to instability due to signal noise amplification in the differentiation of the error.

Last edited: Aug 30, 2010