LibrePilot Forum

General Category => General Discussion => Topic started by: trust on December 23, 2017, 08:18:04 pm

Title: Axis Hold / Rate stabilization
Post by: trust on December 23, 2017, 08:18:04 pm
I'm using a pair of Atom C3CCD controllers in an experimental aircraft, and I need the servo output to hold the deflection required to get to the desired endpoint, rather than just a short deflection. None of the control modes I've tried seem to do this.
Like rate, I should be able to apply a angle change based on the amount of stick movement, and return to center should then have the updated deflection angle change in the servo position until the craft reaches that angle.
For example, with stationary aircraft, short movement of stick, then back to center should move the control surface - and it should stay there until aircraft attitude moves to the updated angle.
Is there a mode for this?
Title: Re: Axis Hold / Rate stabilization
Post by: TheOtherCliff on December 24, 2017, 01:53:33 am
If all you want is servo signal that is proportional to the bank angle, you might look into pretending you are using a camera gimbal and setting that up.

Other than that, you could use Attitude mode and tune the PIDs.  You can get servo signal proportional to bank angle by setting "ID" (of PID) to zero and just adjusting P to what you need.
Title: Re: Axis Hold / Rate stabilization
Post by: trust on December 24, 2017, 03:46:17 am
Thanks for the quick reply. No, attitude is not quite it. I dont want to have to hold the aircraft angle by holding an angle in the sticks. Rate is what SEEMS like it should be what I want - servo will hold whatever angle the aircraft is at when sticks are 0 - and deflections of the stick move that angle. But that's not what I get when I set rate. Servo deflects x amount, then returns to 0 deflection, or whatever offset I have in the sticks. Every pulse of the stick should add a delta to the current angle.
Axis hold doesn't seem to do it either.
Title: Re: Axis Hold / Rate stabilization
Post by: TheOtherCliff on December 24, 2017, 05:42:36 am
Then Rate (or AxisLock), but you will have to adjust the PIDs.  It sounds like you need PD=0 and adjust "I" to suit.  That is what I would play with to start with anyway.
Title: Re: Axis Hold / Rate stabilization
Post by: trust on December 24, 2017, 08:15:55 am
Using rate, Setting PD=0 and adjusting I, I ran I up to 5 and get a deflection, short pause (maybe 0.5s) then it returns to center. 10 or above and it starts oscillating. Axis Lock is similar.
The pause seems like its trending in the right direction, but I can't go anymore and still be stable.
Is there anywhere with a diagram of the process flow for different stabilization cases?
Thanks
Title: Re: Axis Hold / Rate stabilization
Post by: f5soh on December 24, 2017, 11:59:11 am
Using Rate or AxisLock there is no angle involved in stabilization and only Gyro sensors are used.
Rate/AxisLock simply play with angular velocity, middle stick mean 0deg/s rotation and full stick the max rate defined in stabilization bank.
If you apply a brief stick movement and return to 0, rotation will be applied briefly and stops since you go back to 0.

Attitude stabilization will simply stabilize at one bank angle, proportional to the stick deflection (see Attitude response) and you need to maintain the stick position of course.

Seems you need to develop your own stabilization mode, using stick to define a offset angle according to the maximum stick deflection, waiting for stick back to zero and finally applying this offset to a value/setpoint angle used for Attitude stabilization.
Remember the CC3D/Atom will not give a reliable angle/heading in Yaw axis because this board do not use magnetometer and heading is only estimated using Gyros.

Maybe you can explain why the stick deflection need to be applied briefly in your application ?

Here is a diagram describing how Rate/AxisLock and Attitude works. (https://librepilot.atlassian.net/wiki/spaces/LPDOC/pages/19890317/Attitude+Setup#AttitudeSetup-Controlstructure)
Title: Re: Axis Hold / Rate stabilization
Post by: TheOtherCliff on December 24, 2017, 05:53:58 pm
With PD=0 and I=? you might try increasing System->Settings->StabbilizationSettingsBank1(or 2,3 if you are using those banks instead of the default of 1)->RollRatePID->ILimit

Click red "up arrow" at top of the window to save value.

Also PitchRatePID

Reboot FC afterward to make sure it uses new settings.

Find a good minimum value that works, and don't go too much higher.  Maybe double the good min value.  If I were to guess and without bothering to read the code, this is in degrees of bank angle per second or radians per second, so maybe 30.0 for a test and go from there ??  Depending on speed of servos you have this could even need to be 1000.0
Title: Re: Axis Hold / Rate stabilization
Post by: trust on December 24, 2017, 08:32:56 pm
Fiddling with the rate limit didn't help.
But I went back to an earlier suggestion - using the camera gimbal. I set the inputs to drive the accessory channels, and set the pitch and roll gimbals, and set it to axislock. This is exactly what I'm looking for!
I'm unclear on the input and output angle settings. How do these define the range? I need to be able to set full 360 degree motion for both axis. Usually gimbals have limits, but in my case I don't.
Title: Re: Axis Hold / Rate stabilization
Post by: trust on December 25, 2017, 01:04:39 am
I transferred the hardware from the test rig to the actual aircraft. I only use input 1 and input 5 (even that's not that necessary).
I set channel 1 as accessory 1, and put that as the input to the pitch gimbal.
The stabilization - ie moving the servo in response to the pitch change - works fine.
But I cant get any input control!
I can see the input - its registering in the remote control input properly.
But its not doing anything on the servo!
What am I missing?
Title: Re: Axis Hold / Rate stabilization
Post by: trust on December 25, 2017, 02:07:04 am
OK. I got the input working again, by making sure all the inputs were connected to something (ALARMS went green). Also somehow the output got tuned off - needed to turn that back on.
I had to switch to roll gyro, as the pitch only goes +/-90 degrees, then it flips over!
Changed the input & output ranges to 180 degrees, and turned the inputrate to max 255.
But the rate is too slow and the deflection angles too weak. How can I increase them?
Title: Re: Axis Hold / Rate stabilization
Post by: TheOtherCliff on December 25, 2017, 03:21:33 am
Where is the FC mounted?  It must be mounted on the surface that moves when you "bank" it for any of this to work.

Camera gimbal is basically a hard coded "Attitude mode for camera" that depends only on the FC bank angle and nothing else (i.e. does not depend on RC input), so that won't work.  Sorry about that one.
Title: Re: Axis Hold / Rate stabilization
Post by: trust on December 25, 2017, 06:15:07 am
I have it mounted where it needs to be on the wing, and adjusted position and range using the board rotation. Its doing what I want now, just the rate is too slow and the angle is only marginally good enough.
I've upped the angle by using the servo horn as a lever amplifier. It may be enough to work for testing.
But I'd sure like to increase the rate somehow - it's at 255 and it won't let me set it any higher - can I set it higher in the XML and upload it somehow?. I was hoping I didn't need to dive into code, but *sigh* looks like the only way left.
How do I make sure the modifications stay? I've been making changes using the System list, and hitting the upload button, but when I turn everything off, then on again, my changes aren't always saved in the FC. I've been exporting the list to save it - how do I reload configurations? If I import I get a whole new list of tabs with identical names.
Title: Re: Axis Hold / Rate stabilization
Post by: TheOtherCliff on December 25, 2017, 06:38:34 am
File -> ExportUavFile or Import... to save and restore from a file

255 ... It sounds like the UAVO you are setting is an 8 bit field and it can only store a number from 0 to 255, like 1 bit can only store 0 or 1.
Title: Re: Axis Hold / Rate stabilization
Post by: trust on December 25, 2017, 07:27:52 am
For some reason, the board rotation values are lost every time I power down & back up again. Is there something I'm missing about how to save the current settings so they come up after power down?
Thanks for all the help btw - Happy Holidays to you!
Title: Re: Axis Hold / Rate stabilization
Post by: TheOtherCliff on December 25, 2017, 06:13:15 pm
It must be disarmed to save correctly.

So "Always Armed" is a large pain.
Title: Re: Axis Hold / Rate stabilization
Post by: trust on December 28, 2017, 05:59:53 am
Well, I thought the gimbal stabilization was working - but it seems to be erratic. I have two identical systems on separate parts of the aircraft, and they can move independently. Sometimes it powers up and works. More often not. Sometimes one side (one side much more than the other) sometimes the other - its hard to get them BOTH running at the same time. On a fixed bench more often than not they both work - but in the field its another matter - I can rarely get them to both work. I can't seem to find any reason why. Sometimes they start working after a period of time. But most annoying is even when both working, after some time, for reasons unknown, one or the other stops working. I can move the control inputs, and it will move the servos - that part always works - but the tracking just stops responding. It's like there is some condition(s) necessary for it to work, and if those conditions aren't met, it doesn't work. But what are they?
One of the sides also has a weird tendency to loose the board rotation parameter. Then if I unplug and replug, it will come back correctly.

There is a 3rd FC on the main body of the aircraft, running differential on the motors. That seems to be working fine. Im still tuning the PID, but it seems to power up and down reliably.

?
Title: Re: Axis Hold / Rate stabilization
Post by: TheOtherCliff on December 28, 2017, 09:28:39 am
The gimbal is supposed to only use the current bank angle and not the RC input at all.

Imagine how a gimbal is supposed to work.  It should simply be the opposite of the bank angle so that the camera mounted on it is level.
Title: Re: Axis Hold / Rate stabilization
Post by: trust on December 28, 2017, 08:22:56 pm
Perhaps I wasn't clear. My use of the gimbal is exactly like its use with a camera. I want the "camera" to hold a certain position relative to the horizon. I move a joystick to change that angle - then I expect the gimbal system to send a signal to the servo to move the camera until it gets to that position. If the system moves, it will keep tracking sending a servo signal to move the camera until it gets to my desired position. The change of position happens by incremental movements of the control inputs. A short pulse moves the angle by some delta.
This all works - sometimes. I can use the control inputs to move the camera position - that always works. What doesn't always work is the feedback from the FC to the servo to change position when the FC shifts attitude. Sometimes it does - sometimes it doesn't - and I can't figure out why.
I'm using channel 1, assigned to Accessory 1. 180 degrees input range & speed, roll only, Axislock stabilization mode. pitch & yaw inputs are set to none.
I have limited signals to/from the FC, so I just replicated channel 1 on all the other inputs - throttle, roll, pitch, yaw. It seems to need something on these channels or won't run at all. I have one other input I've been using for mode control on a switch - at some point I'd like to get more control over this function at least with a switch to change modes. But right now it's not doing anything.
Are there some arming conditions that need to be met? I have Always Armed set.
Title: Re: Axis Hold / Rate stabilization
Post by: TheOtherCliff on December 28, 2017, 10:19:33 pm
It's been a while with gimbal for me, but even for Always Armed it must wait for the gyros to init and the default waits for the FC to be PERFECTLY motionless before doing gyro init (calibration).  You generally must leave it setting on a firm surface for gyro init to start.  It does "fast blink" during init.
Title: Re: Axis Hold / Rate stabilization
Post by: trust on December 31, 2017, 07:41:03 pm
Thanks! Yes, that seems to be the issue - one of the FCs takes a long time to init - the way the machine is built its not easy to hold it perfectly still, but applying some props to hold it - eventually it does init, then everything works as expected.
Are there any conditions that would make it stop responding?
Title: Re: Axis Hold / Rate stabilization
Post by: trust on December 31, 2017, 08:19:59 pm
I also found a workaround for the gain on the gimbal mode. I use 180 degrees for input, but output is 45 degrees. In/out = gain.
Now if only I could change these values in the field with Librepilot2go...