Go Down

Topic: PID SOS (Read 505 times) previous topic - next topic

Casey Gross

Hello, I've been working on making my rc plane self-stabilize in mid air using its ailerons. I have a gyro and accelerometer taking readings and outputting a kalman filtered reading from 0 to 359 degrees. What i have done is set my Output limits(Servo limits) to (1000, 2000). In the PID library example it looks like the Input value is an analog vaule from 0, 1023. So, I mapped my filtered angle from (0, 359) to (0, 1023) and made it equal the Input. I made the Setpoint variable equal to 762(~270 degrees) and mapped it as so:
Code: [Select]
AileServo = map(Output, 0, 1024, 1100, 1900);

When I upload the code, the aileron goes in the up position and wont budge, even when I move the plane from side to side. I know im doing something very wrong here. Any help is appreciated.

Casey Gross

anybody? Please, any information will help.

Coding Badly

I have a gyro and accelerometer taking readings and outputting a kalman filtered reading from 0 to 359 degrees.


Does that part work?

"Self-stabilize" is what angle?  Zero degrees?

Quote
In the PID library example it looks like the Input value is an analog vaule from 0, 1023. So, I mapped my filtered angle from (0, 359) to (0, 1023) and made it equal the Input. I made the Setpoint variable equal to 762(~270 degrees) and mapped it as so:
Code: [Select]
AileServo = map(Output, 0, 1024, 1100, 1900);


Stop doing all that scaling.  It's unnecessary.  As long as the Input and Setpoint are in the same units you are fine.

PeterH


I know im doing something very wrong here. Any help is appreciated.


There is probably a mistake in your code - which we can't see.
I only provide help via the forum - please do not contact me for private consultancy.

Go Up