Go Down

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

#### Casey Gross

##### Jan 22, 2013, 01:06 am
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

#1
##### Jan 22, 2013, 06:39 am
anybody? Please, any information will help.

#2
##### Jan 22, 2013, 07:42 am
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

#3
##### Jan 22, 2013, 11:57 am

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.

Go Up