Page 1 of 1

How does maghold work ?

Posted: Sun Sep 07, 2014 7:29 pm
by Kayle
Hello all,

i try to understand how maghold works. I don´t use Arduino IDE for Programming. I use Bascom on an Atxmega. My MAG is a CMPS10 I2C and i gives me values between 0 and 360.

My Question is:

For example the desired degrees are 0°. How does multiwii code prevent that the actual degrees jump to 360° ? My code use a PID to adjust a PWM. There is no Problem if the desired degrees are for example 100°. But if the desired degrees are 0° the PID Controller adjust the PWM so far that the actual degrees become for a little moment 360 - 355 °. So the Servo ( PWM ) turns on full rotation until the degrees are nearly 0°.

How Multiwii handles this ?

Kind Regards
Kay

Re: How does maghold work ?

Posted: Sun Sep 07, 2014 8:23 pm
by Plüschi
You subtract actual direction and wanted direction. Then you norm this to -180 to +180 by subtracting or adding 360. Aint too diffcult.

Nice sensor. Tilt compensated ...

Posted: Sun Sep 07, 2014 8:40 pm
by Kayle
Thanks for your fast reply. I will Test it tomorrow.

Posted: Mon Sep 08, 2014 8:16 pm
by Kayle
It works. Thank you Plüschi.