Quad software from scratch - PID question

Hi folks

I'm programming a quad from scratch (for fun) and have got gyro/accel data and pwm working fine, but I'm strugging on the PID stuff.

I tried tuning a PID with Input = pitch angle, output = motor offset, where:

motor[front].pulse = 1000 + throttle + pidout

motor[back].pulse = 1000 + throttle - pidout

I couldn't get it to stop oscillating and then I read about using PIDs to control the rate (rather than angle).  so I changed my code to:

motor[front].pulse = 1000 + throttle + (pitchRCIN + gyro_x) * Kp

motor[back].pulse = 1000 + throttle - (pitchRCIN - gyro_x) * Kp

but the quad struggles to turn regardless of Kp.  My theory is that as soon as it overshoots the angular rate it applies reverse to slow rate and just oscillates (albeit with small/invisible amplitude) rather than moving.

Can I not use PIDs with angle in and pwm out? Is rate controlled better and daisy chain with angle pid?  Any idea why above rate only isnt working?

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • PS ignore the sign error no pitchRCIN - they're the same sign, minus in my code.  I know it's Proportional only but some have suggested that's sufficient.

  • PS in any case with rate only, as soon as it reaches desired angular rate, then the pid output = 0 so it'll slow down.

This reply was deleted.

Activity

Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21
More…