Any Arduino Gyro Projects

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

Re: Any Arduino Gyro Projects

Post by Martin »

Thanks! Yes, I'm sure your son would make a good aerobatic gyro test pilot - if we ever get to that stage. :D

If I double the available gain range, you'd just have to adjust your transmitter gain end point to 37% to get the same gain you have now - but it would make more gain available for faster servos. In the past, I've found that the faster the servo, the higher you can set the gain before oscillation sets in - though of course there are lots of other factors like rotor (and tail rotor) rpm, tail rotor blade length, and so on...

I've done the first stage and test flown the 450 in the garden, without a canopy fitted (and with its existing Spartan Quark gyro and Futaba S9650 tail servo). It all went well until the battery fell out! :shock: Luckily, it was in a very low stable hover when it happened so no harm done - the heli just landed. Good job it didn't happen earlier when I was doing gentle lazy 8s or hovering higher up to check the blade tracking (which was out - but it can stay out for now as I've already removed the blades for the next stage of testing).

No more test flying of that helicopter until I've sorted out the gyro program - the whole point of repairing it was to use it as a test-bed. I've got plenty of other helis I can fly for fun - but because they're either the mini ones with integrated gyros, flybarless ones where the tail gyro is part of the flight controller, or bigger noisier glow powered ones, they're not as suitable for gyro testing in the garden, or perhaps even indoors.

Other things I'm thinking of adding:
  • Configurable output pulse rate to suit faster digital servos. At the moment, the output pulse rate is the same as the input pulse rate from the receiver - so probably 50Hz-ish for most receivers. At the moment, my program initializes the gyro to provide only 50 updates per second, so there's no point in driving the servo at a faster frame rate - even if it's capable. But the MPU6050 can be configured to provide much faster updates - and I think the ATtiny could cope with faster frame rates and servo modulation schemes such as the ones that run at 560Hz with a 760 microsecond centre-pulse width.
    .
  • Compensating for any slight clock-drift in the ATtiny85 by using the received pulse rate from the receiver as a reference. The ATtiny85 is running on its internal clock which might drift by 0.5% or so - due mainly to temperature changes.

    Assuming the received frame rate is constant (because the receiver and transmitter probably have crystal controlled microprocessors) then the ATtiny could measure the frame time during the gyro calibration period - say it's 2000 microseconds. If, later the ATtiny thinks the frame rate has changed to 2010 microseconds, it's more likely that the ATtiny's clock has sped up by half a percent - so it could compensate for that by making the same half-percent change to its measured (and output) pulse widths.

    I suppose if someone is flying with a vintage non-microprocessor transmitter and receiver then that would probably drift by more than the ATtiny's clock, so there would be the option to switch clock drift compensation off in the config file.
User avatar
Wayne_H
Posts: 809
Joined: 17 Feb 2018, 05:26
Location: Temora, NSW. Australia
Contact:

Re: Any Arduino Gyro Projects

Post by Wayne_H »

Thanks Martin for the detailed explanations of your problem solving as your gyro project evolves. I've found them interesting & educational (and surprisingly inspirational too :) ).

Please continue 👍👏
Cheers,

Wayne
Once a Retrobate, always a Retrobate............ ;)
Martin
Posts: 744
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Any Arduino Gyro Projects

Post by Martin »

Thanks! :)

Progress with the test stand this morning. It fits the 450 skids, and is the right length to just fit between the skid support arms with the rotation shaft ending up directly underneath the heli's main shaft (which should be roughly the centre of gravity); the height from the skid supports up to the top bearing carrier is to give well-spaced bearings, but still fit under the heli without fouling anything. Seems to work well, and spins freely. The two bearings, shaft and shaft clamp came from an old (crashed when the poorly-designed tail blades pitch slider collar failed) Mikado Logo 10. The shaft is hollow steel 10mm diameter, and the bearings are 10-19-5. I think I over-engineered it, but that's better than under-engineering! :)

testStand.jpg
I'm off out flying again this afternoon, but tonight I may finish designing and printing the bottom part of the stand - that will clamp the shaft to the workbench, with the shaft vertical.

The idea is to sit the heli in the "skid grooves" and fasten it down to the carrier using four tie-wraps.
Martin
Posts: 744
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Any Arduino Gyro Projects

Post by Martin »

Test stand completed at last. I tried it first with the heli's existing Spartan Quark gyro, and then swapped to my own. Verified Pete's findings that heading hold mode is currently unflyable. I'm now working on the fix and hope to post a part 2 video showing the gyro working correctly on the test stand. Then I'll share the modified code and perhaps post a part 3 showing the gyro in flight.



This is what the test stand components look like drawn in Fusion 360. The Fusion 360 file is attached (as a .zip) if anyone wishes to take a closer look.
testStandDesign.jpg
Attachments
testStand.zip
Fusion 360 test stand design.
(320.55 KiB) Downloaded 144 times
Pchristy
Posts: 413
Joined: 16 Feb 2018, 13:57
Location: South Devon, UK

Re: Any Arduino Gyro Projects

Post by Pchristy »

Well done Martin! My son has a 3D printer - I'll have to get him to run me one off!

I haven't had much time for modelling activities this week - been putting up a tool-shed in the garden, and replacing some shelving in my workshop.

Today it has been pouring with rain, so I took the opportunity to put a faster servo on the tail-rotor of the Voyager-E (JR-810G - a dedicated high-speed t/r servo).

Whilst setting it up, I made an interesting discovery. In HH mode (only!), the throw available on the t/r is proportional to the gain setting! If you reduce the gain, you also reduce the travel - both from the stick input and from the gyro input!

To test, put the gyro in HH mode, and drive the servo to one end. Now reduce the gain, and watch the travel reduce! At 15% gain (which I was using the last time I tried it) the servo barely moves in response to either stick or gyro. Some wires crossed in the software somewhere? Certainly something odd going on.

Hope this helps with the de-bugging!

Cheers,

--
Pete
Pchristy
Posts: 413
Joined: 16 Feb 2018, 13:57
Location: South Devon, UK

Re: Any Arduino Gyro Projects

Post by Pchristy »

Took the Voyager out again today to test the tail response with a high-speed servo. Got the gyro gain to 100% without it wagging, so I think you might have reduced the gain a tad too far, Martin.

I know JR only goes from 1.1 - 1.9mS, but I pushed the gain up to 110% before I got an incipient wag. Bear in mind that this is not a particularly fast or responsive heli. I would imagine a more responsive machine could stand even higher gain.

It was a bit breezy for the poor little thing, so I elected not to fly it around. However I see no reason why it shouldn't behave OK, like it did with the slower servo.

Cheers,

--
Pete
Martin
Posts: 744
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Any Arduino Gyro Projects

Post by Martin »

Thanks Pete.

I've been working on the code for the new heading hold mode for the last few days. It's involved more changes than I originally thought but I think I'm almost there now. I won't post the new code till I've done some more tests. Hopefully that will be tomorrow. I'll double the available gain range in rate mode.

You'll see in the config.h file of the new version (once I post it) that there are a few more things to set up. The values shown below are for my current test bed with a Futaba S9650 servo, but I'll alter them back to 'standard' servo values before posting.

If you have a digital servo that is happy to work with a frame rate faster than your transmitter's frame rate, then you can now set the servo frequency.

It's also worth using a servo tester, or your transmitter if it can do it, to find the maximum throws you want the tail servo to have - so the tail slider doesn't hit the end stops, or even less than that if you prefer - and set these values:

Code: Select all

// servo type selection
// most servos can work at 50Hz - digital servos can often work at higher frequencies which
// results in better performance - but beware that too high a setting may damage your servo
// and possibly result in loss of tail control during flight.  Check the documentation for 
// your servo.
#define SERVO_FREQUENCY 333
// nominal servo centre position (microseconds).  Standard servos use 1500 to 1520 but some
// faster digial servos use 760 or 960 microseconds for their centre position
#define SERVO_CENTRE 1520

// output (rudder servo) travel limits (microseconds)
#define MIN_RUDDER_OUTPUT 1270
#define MAX_RUDDER_OUTPUT 1750

// number of milliseconds to look ahead when operating in heading hold mode
// shorter times can be used for faster servos, and will give a faster response
// but don't set it less than your servo response time, as this will result in 
// unstable (and uncontrollable) operation! 
#define HH_LOOK_AHEAD_MS 150
Pchristy
Posts: 413
Joined: 16 Feb 2018, 13:57
Location: South Devon, UK

Re: Any Arduino Gyro Projects

Post by Pchristy »

Cheers, Martin! Looking forward to the updates!

--
Pete
Pchristy
Posts: 413
Joined: 16 Feb 2018, 13:57
Location: South Devon, UK

Re: Any Arduino Gyro Projects

Post by Pchristy »

Took the Voyager-E out again today, and was a little more adventurous with it. It was still a bit windy for it, but I flew it around a bit to get the feel of it.

The tail has never been very positive on it, but despite having a ground speed of less than the wind speed (ie: flying "backwards" when going downwind), the tail held well, with no sign of wanting to snap round into wind. Its certainly a big improvement over the original gyro fitted to the heli!

Looking forward to trying the HH mode, when you get it sorted!

--
Pete
Martin
Posts: 744
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Any Arduino Gyro Projects

Post by Martin »

Thanks Pete, that sounds promising. :) I've had unexpected visitors today, so I've not made much progress with the heading hold tests. :( Tomorrow now, providing I don't suffer from other visitors.
Post Reply