Any Arduino Gyro Projects

Any old or new electronic projects on the go
Post Reply
Martin
Posts: 419
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Any Arduino Gyro Projects

Post by Martin » 31 Jul 2020, 14:05

Well it seems to work, and I've updated the sketch which you can download from here:

viewtopic.php?f=42&t=1018&start=10#p8534



Pete, remember that the available gain ranges are now considerably higher than before - so back off your gain setting on your transmitter to perhaps 25%, and then gradually creep it back up again till you get the response you want.

If you're using a digital tail servo, remember that you can edit config.h to give faster frame rates, and you should also set the servo end travel limits in config.h so that the tail slider never binds, regardless of control inputs or gyro corrections. Easiest way I know to find the limits is to use a servo tester and jot down the minimum and maximum microsecond readings when the servo is just about to hit the end stops. Some modern transmitters also display microsecond readings - but if you want to use that feature, it's best to bypass the gyro and plug the tail servo straight into the receiver while finding the limits.

As with many commercial HH gyros, you get rid of the rudder trim offset between heading hold and rate modes by trimming in HH mode and then mechanically adjusting the servo position / linkage in rate mode. With modern transmitters that support it, it's easier to configure two flight modes for HH and rate - and set those flight modes so that they each remember their own trim position.

I've not implemented the 'drift compensation' feature yet - the one I mentioned that would derive its time correction from the (hopefully constant) received frame rates. Maybe it won't be necessary anyhow, but I didn't want to add too much complication, and possible source of new bugs, in one release.

Pchristy
Posts: 173
Joined: 16 Feb 2018, 13:57
Location: South Devon, UK

Re: Any Arduino Gyro Projects

Post by Pchristy » 31 Jul 2020, 17:03

Downloaded and programmed in!

Hopefully test sometime over the weekend!

My son is coming down to visit next week, so if all goes well, we may put it in my Hirobo SDX and give it a real work-out!

:lol:

--
Pete

Pchristy
Posts: 173
Joined: 16 Feb 2018, 13:57
Location: South Devon, UK

Re: Any Arduino Gyro Projects

Post by Pchristy » 02 Aug 2020, 15:06

Hi Martin,

Test flown successfully today! I flew circuits in both normal and HH with no problems. My son is coming down this week, so I'll get him to give an opinion too. He'll probably be a bit more aggressive than me - better reactions and eyesight! ;)

I ended up with 50% gain in "Normal" mode and 35% in HH - any higher, and you started to see signs of wagging. No wagging whilst flying around gentle circuits though, so its pretty good for an early prototype.

Nitpicking: It would be nice to get the gains between the two modes closer matched. It would also be nice if you could split the difference between the present gain sensitivity and what you had in the previous version. Ideally, I would like to see the tail stable at around 60-70% on this model. That should allow enough for adjustment on any model. I don't know if this is possible or not, like I say, nit-picking!

So, a successful sortie! Well done! I'll leave the gyro in the Voyager for the moment, until Mark has had a play with it. Then I'll try it in my Hirobo SDX, which is a much more lively machine!

Cheers,

--
Pete

bluejets
Posts: 94
Joined: 19 Jun 2019, 04:09

Re: Any Arduino Gyro Projects

Post by bluejets » 03 Aug 2020, 00:35

Hi Pete,
I've been away from this for a while and need to do some reading to catch up.
Where do you set these gain values, in the program or via the original external pot..??

Just seems that 50% would be easy to judge on the pot knob but 35% is getting a bit precise for the same.
Especially given it is half travel each way for heading hold versus rate.

Should have that little HK450 $15.00 kit I bought up and going in a week or so.
Never again, too small and fiddley.
M2 screws on the floor every time. :ugeek: :ugeek:

Pchristy
Posts: 173
Joined: 16 Feb 2018, 13:57
Location: South Devon, UK

Re: Any Arduino Gyro Projects

Post by Pchristy » 03 Aug 2020, 09:57

A little background is necessary to answer! This is quite an old heli! It was originally designed to fly on Nicads with a brushed motor. I converted it to brushless and LiPo power at the dawn of the electric era, and it flies quite nicely like that. It has an old Spektrum 6-channel DSM-2 receiver, and is programmed into my JR DSX-9 Tx. Yes, I could update it to use my FrSky gear, but it has been in the attic in storage for years, and was dragged out of retirement as a suitable test-bed for this gyro. If it ain't broke, don't fix it! :)

The gyro gain is controlled by the "gear" channel (5), on a 2-position switch. The switch is calibrated by the travel adjust setting in the Tx and can go from +150% to -150% with 0 being in the middle. 0 corresponds to 1.5mS, and 100% either side corresponds to 1.1 to 1.9mS.

In my case, I got optimum results at +50% (normal) and -35% (HH).

In contrast, FrSky gear works the other way around, with max travel being reached at the default 100% input - corresponding to approximately 0.9mS to 2.1mS. To use a FrSky Tx with a model previously set up on JR or Spektrum gear, it is necessary to set the inputs to around 80% of their normal, full travel.

It is quite normal on any gyro equipped heli to set the rudder travel to the maximum the Tx will allow (150% in this case). This will overdrive the servo on the ground, but in the air the gyro will restrict the travel due to its "negative feedback" effect in opposing the control input. This gives you good control authority, but equally good gyro damping of the tail. If it feels twitchy around neutral, up 30% expo is not unusual.

Most modern gyros have a "travel limit" adjustment of some kind to prevent the linkage binding if full travel is accidentally applied on the ground. This means that it is not unusual for full travel of the servo to be reached well before the Tx stick gets anywhere near full travel.

This can be confusing to someone not familiar with the system, but works well, because once again, in the air, the gyro will oppose the pilot's input, restoring a degree of normality to the airborne control response.

Sorry if I'm teaching grandma to suck eggs, but this is just to clarify for anyone else reading this - and is unfamiliar with gyro setups - what is the normal procedure for setting up a gyro.

One other point to note - and covered by Martin in his instructions - is that it is important to set up the HH "neutral" on the ground first, before flying. I find the best way to do this is to use the sub-trim function (usually a finer adjustment than the normal trim) and adjust it so that the servo does not move in HH mode when stationary on the ground. Adjustment to the "normal" (non-HH) trim is then best done mechanically. If the transmitter supports different trim settings in different flight modes, these can then be used for "fine tuning", but should NOT be used for initial setup!

Hope this helps and clarifies things! Any questions, fire away!

--
Pete

Martin
Posts: 419
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Any Arduino Gyro Projects

Post by Martin » 03 Aug 2020, 11:22

Thanks Pete! Nice to know it flies reasonably okay in both modes now. :D

To adjust the HH gain range to match the rate range, you can edit the 200000L in MPU6050.h It's on line 27, and is used to divide the internal units representing gyro travel, after being multiplied by up to about 500 depending on your AUX channel input, down to microseconds to output to the servo.

The 'L' is just a clue to the compiler that the number is to be treated as a long, so that 32-bit calculations are done rather than 16-bit ones - it's not really necessary here as 200000 is too large to fit in 16 bits anyway. You need to increase the value by your empirically tested ratio of 50/35, so change the 200000L to 285714L (that's just 200000 * 50 / 35).

I'll hold off suggesting any further change to both mode ranges till we see how it performs in your other heli - depending on what servo is fitted, what SERVO_FREQUENCY you choose in config.h and various other factors, you may yet find you need more of the available gain range.

Pchristy
Posts: 173
Joined: 16 Feb 2018, 13:57
Location: South Devon, UK

Re: Any Arduino Gyro Projects

Post by Pchristy » 03 Aug 2020, 11:47

Thanks for the reply, Martin. I may hold off modifying the code until Mark has had a chance to play with it. He's only here for a couple of days, so whether he'll get chance to fly it in the SDX or not, I don't know.

Once he's had a go, I'll have a look at tweaking the code as per your suggestions. Once I have it "balanced", and I'm happy with it, I'll put it in the SDX.

I don't want to rush this, for obvious reasons! One careful step at a time is the best way, I think! ;)

--
Pete

bluejets
Posts: 94
Joined: 19 Jun 2019, 04:09

Re: Any Arduino Gyro Projects

Post by bluejets » 03 Aug 2020, 22:57

Pete,
I can follow the JR setting explanation but cannot see the comparison with Flysky.

To my thinking, a gear switch goes from a 1ms to 2ms at either end and 1.5ms centre no matter what brand of transmitter one chooses to use.

How one sets the end points would be the same on each...no?

Sorry but do not see your "other way around" explanation.

AS for the travel limit adjustment, I wasn't aware of any in this gyro.

Martin
Posts: 419
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Any Arduino Gyro Projects

Post by Martin » 03 Aug 2020, 23:40

Some transmitters have a scale of plus or minus 100% with 0% at centre. Others have a scale of 0% to 100% with 50% at centre. If you use half the available travel, with equal movements either way, then the first transmitter would have end points set at -50% and +50%, while the second one would have 25% and 75% for the same points.

Confusingly, some transmitters try to be helpful by using the 0% to 100% scale for the throttle, but -100% to +100% for the other channels. Some transmitters allow you to choose the scale type for each channel yourself - but many users don't know how to do it, and get confused and annoyed as a result.

Some transmitters also allow the normal range to be extended, by allowing values up to 120% or 150%. Again, some transmitters have these extended ranges as selectable options.

You can set the travel limits for this gyro. You have to edit the config.h file and enter the end points using microseconds as the units - for example you could set the range to 1200us to 1800us and then regardless of stick input or measured yaw rate, the servo output would never go beyond that range.

Pchristy
Posts: 173
Joined: 16 Feb 2018, 13:57
Location: South Devon, UK

Re: Any Arduino Gyro Projects

Post by Pchristy » 04 Aug 2020, 09:08

"The other way around" I was referring to is that JR starts with a "restricted" travel arrangement - 100% = 1.1 - 1.9 mS - and allows you to expand it (travel adjust up to 150%)

FrSky starts off with an expanded travel adjustment - 100% = 0.9 - 2.1 mS, but only allows you to reduce it.

Also, as Martin points out, JR travel adjust is actually +100% to -100% with 0 in the middle (1.5 mS). FrSky's equivalent (weight adjustment) is 0 to 100%, with 50% in the middle. (you can make the weight a negative value, but that has the effect of reversing the control.)

All these things need to be considered when comparing percentages of travel adjust.

Yes, it is confusing, but I hope that clarifies a bit! ;)

--
Pete

Post Reply