7 Channel Encoder Mods for a GD-19

Arduino projects on the go
Dave McDDD
Posts: 24
Joined: 28 Apr 2020, 19:37

Re: 7 Channel Encoder Mods for a GD-19

Post by Dave McDDD »

Phil_G wrote: 19 May 2020, 11:45 Hi Dave, nice neat job, pleased to hear its working ok ;)
Expanded scale meter example here: viewtopic.php?f=27&t=902
and theres a general meter thread here:
viewtopic.php?f=62&t=132
Thanks for posting that info! That might be exactly what I need to know to get the original meter working correctly. I think the old GD-19 used the meter as an RF output indicator, but converting it to battery voltage would be more practical for the conversion.
Phil_G wrote: 19 May 2020, 11:45 I would suggest caution with the 100:100 mixer, obviously with the stick in a corner your ppm pulses will be stretched well out of spec. Some modules and some receivers constrain out-of-spec pulse widths which causes dead areas in all the stick corners - and similarly if you constrain in the encoder after the mix, you get dead corners. The ratios are there for a reason :D
Relevant discussion here
I used a constrain for each channel just after the 100:100 elevon mix to limit the pulses between 1000ms and 2000ms, which took care of any possibility of the ppm pulses getting out of spec.

While it's true that moving the elevator stick to the full up (or down) position causes both servos to reach their travel limits, and then moving the aileron stick side to side simply reduces one servo travel without any further increase in the other servo travel, this is actually my preferred elevon setup. In fact, the very first test flight of the Heathkit GD-19 conversion was with an electric elevon plane where the elevons move 45 degrees in each direction. With the 50:50 ratio mixer the elevons only reach 45 degrees of throw with the stick in the corner, and a full elevator or a full aileron stick command only moves the elevons about half the needed amount. While a 50:50 elevon mixer can work great with more gentle control throws, it wasn't practical for my particular situation of needing 45 degrees of throw in each direction for both the elevator and aileron stick commands. In fact, I also used a constrain on each of the dual aileron channels for the flapperon function so a full up (or down) elevator stick command causes the aileron servos to reach their full travel limits.

Don't get me wrong! I understand completely why you setup the elevon mixer with a 50:50 ratio. It's just that in my case, I needed the mixer to work as 100:100 instead.
Built a Heathkit GD-19 in 1969. Been flying RC ever since!
Dave McDDD
Posts: 24
Joined: 28 Apr 2020, 19:37

Re: 7 Channel Encoder Mods for a GD-19

Post by Dave McDDD »

Phil,
I do have a question about the 7 channel encoder sketch, if you don't mind.

The stick calibration routine sets the stickcalHi at 0, the stickcalLo at 1023, and stickcalMid at 512. These values make perfect sense for 1024 resolution.

The full negative deflection of sticks is defined as full_n -400, and the full positive deflection of sticks is defined as full_p +400. This only results in 801 possible positions, assuming these are integer values.

What am I missing here? Why don't the stick deflection values also use 1024 position numbers? I realize that setting these values to -512 and +512 actually results in 1025 positions, but wouldn't that be more accurate than 801 positions?

I know that you put a lot of thought into writing the sketch code, and you didn't do anything without a reason. I'm just trying to understand the reasoning for choosing the -400 and +400 deflection values.
Built a Heathkit GD-19 in 1969. Been flying RC ever since!
User avatar
Phil_G
Posts: 597
Joined: 15 Feb 2018, 23:32
Contact:

Re: 7 Channel Encoder Mods for a GD-19

Post by Phil_G »

Hi Dave, these are two different things.
The analogue-to-digital converter is 10 bit, so its possible return values are 0 to 1023 over the full input range. Initially on an uncalibrated set the stickcal values are preset at the extremes, which the calibration
routine changes to the actual ADC readings at each stick position. The extreme values are simply to stop servos winding to the stops if you try to use an uncalibrated set. Once calibrated, the ranges between stickcalLo and stickcalMid, and also between stickcalMid and stickcalHi are each divided into 400 steps, so 800 stick-steps from Lo to Hi.

Entirely separately from all this the PPM routine uses a timer which free-runs on a 1uS clock. When loaded with the stick position calculated as above, the timer counts this number of 1uS intervals, so +/-400 steps correspond to a +/-400uS channel pulse. This is the standard Spektrum channel width. Whilst the 16-bit timer will accept larger values, your method would result in a non-standard 1024uS width, plus trims of (say) 10% - which is beyond the 'standard' for pulse widths and would only increase the throw, not the resolution, which is fixed by the hardware at 1uS. I used to use +/-500 including trims, but now use +/-400 plus trims, it better suits both mechanical and separate trim options. If you want different deflections, no problem, there are defines provided for that very purpose, but be aware of the implications:
#define full_n -400 // full negative deflection of sticks (excluding trim)
#define full_p +400 // full positive deflection of sticks

You could change the prescaler to get a 0.5uS timer clock and then double all the values, but this would not double the end-to-end resolution as the limiting factor is elsewhere:

Each stage in the overall process has its own resolution. The PPM timer runs at 1Mhz so its resolution is 1uS. The ADC has 10bits so has 1024 steps. However to use all these steps we would have to amplify the stick pot voltages so that they sweep the entire 5v (specifically the ADC reference voltage). If you want to go to that trouble for greater resolution then the encoder caters for that without any software mods. This limitation is common to almost every homebrew encoder and many commercial sets, seldom do designers go to the trouble of amplifying the sticks. Some use multiple read averaging to 'interpolate' resolution. Some use short-throw pots which give a greater voltage swing for a given rotation. It is possible to use a lower ADC reference, but then you need to adjust the physical pots so their range falls within the lower ADC reference voltage. This is beyond the concern of most users and a 5v reference makes it universally simple.

You could also run boost converters to get +/- 12v and adjust each stick feed so the wiper sweeps the full zero to 5v with full deflection+full trim. Personally I dont want the extra complexity, from the outset I've always said this is a simple encoder intended to replace 50-year-old electronics, with a few bells & whistles added for convenience. I think maybe you're expecting too much from a very simple setup made by an old fart in a shed - its not and never will be a Futaba 32MZ, but then it doesnt cost £2600 :lol:

Cheers
Phil
Dave McDDD
Posts: 24
Joined: 28 Apr 2020, 19:37

Re: 7 Channel Encoder Mods for a GD-19

Post by Dave McDDD »

Thank you very much for the detailed reply! Now I understand a lot more about what's going on in the encoder logic, and why you chose -400 and +400 as the default for the deflection values. Your knowledge is greatly appreciated!
Built a Heathkit GD-19 in 1969. Been flying RC ever since!
Post Reply