Pages: [1]   Go Down
Author Topic: PID SOS  (Read 376 times)
0 Members and 1 Guest are viewing this topic.
Dallas, TX
Offline Offline
Full Member
***
Karma: 0
Posts: 170
Check out my blog on your smartphone!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged

Dallas, TX
Offline Offline
Full Member
***
Karma: 0
Posts: 170
Check out my blog on your smartphone!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

anybody? Please, any information will help.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11164
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1]   Go Up
Jump to: