DigiSpark full 4-channel propo encoder with single-channel, V mix, + inactivity alarm

Single to Multi propo
Post Reply
User avatar
Phil_G
Posts: 311
Joined: 15 Feb 2018, 23:32
Contact:

DigiSpark full 4-channel propo encoder with single-channel, V mix, + inactivity alarm

Post by Phil_G » 23 May 2019, 15:54

Updated 30/8/19.
I've done a full 4-channel propo encoder for the DigiSpark. This is a tiny (3/4" square) cheap & cheerful board that works really well, but only has 5 I/O pins as supplied. Some of the 5 DigiSpark pins have USB circuitry which we need to remove as it affects the linearity when those pins are used for joystick inputs - its just four components - two zener diodes, a pull-up resistor, and an LED ballast resistor (or the led, removing either will do). Since the board is all SMT this is easily done by 'flicking' off the unwanted components with a jewellers screwdriver.
This is all covered in some detail in the DigiSpark thread. It sounds much more fiddly than it actually is - in fact it takes a couple of seconds to remove the four components:



Click to expand:
fully_defluffed.jpg



We need four joystick inputs, a calibrate link or button input, and a PPM output, so having freed up all 5 pins, we need one more. The reset pin P5 has a dual purpose, controlled by an internal 'fuse'. It can be 'reset' as required for programming, or it can be another I/O pin which is what we need. The DigiSpark fuse programmer makes this change easy peasy.

Now we have 6 pins, allocated as follows:
P5 (ADC0) Aileron
P4 (ADC2) Rudder
P3 (ADC3) Throttle
P2 (ADC1) Elevator
P1 Calibrate, S/C Button and buzzer (see below)
P0 PPM output

This is a simple, minimal encoder so it doesnt have a colour telemetry display or anything fancy.
What it does have is:

DigiSpark 4ch features:
Four proportional channels, inbuilt stick calibration,
'Soft' throttle lock (has to be closed before it will open)
Reversing by powering on with the stick held over, saved to flash (throttle is not reversible for safety)
V-tail or Elevon mixer (60:40 ratio)
Single Channel compound escapement emulation mix with kick-up elevator
Inactivity alarm (should you forget & leave it switched on)

We've no pins to dedicate to a buzzer, so for the inactivity warning, we multiplex the SC/Calibrate pin so it performs all three tasks - see the diagram. Please note that he button now has to be a 'break' contact.

Of course the encoder needs mechanical stick trims as theres no provision for subtrim.
Theres no expo and no rates. The V-tail/elevon mixer is permanently enabled and appears on receiver channels 5 & 6.

Quite a few people are using this encoder in their retro 4-channel sets now, if anyone wants a ready-to-fit encoder I can supply them programmed, prewired & heatshrunk. Just one pointer, if the throttle lock holds at the 'open' position (ie at the 2ms end of travel) then the throttle pot outer wires need swapping over, thats the +5 and neg. Its a safety thing for electric flyers.

I've done a few of the DigiSpark 4ch encoders myself, this is one of the testers which for convenience is mounted on a vero backplane, fitted into a Multiplex Pico. I've left the usb tab on this one, normally I saw it off. (It always amuses me to see the tiny 3/4" square board lost inside a transmitter!)


IMG_20190523_144955_647.JPG

attiny85_1.jpg


Cheers
Phil

EDIT:
I really like the elevon mixer idea on the two-plus-one where the mixed channels derived from aileron & elevator are permanently on channels 5 & 6, rather than using an 'enable' switch or link. The aileron and elevator channels remain exactly as they were.

I've added this into the DigiSpark-4 and uploaded the revised code below.
There are no hardware changes, its just the content of receiver channels 5 & 6 that has changed.

Its a 60:40 mix which should be a good compromise for flying wings (very pitch sensitive) and V tailers.
The only disadvantage (if it is one) is that a V tailer or flying wing would need a 6ch receiver.

EDIT 2:
Three times now I've left the DigiAce switched on overnight, luckily the big LiFePo4 battery had enough capacity so it wasnt dead when I found it the following morning... though the Hitec RF module was warm!

Its obvious that for sponge-brains like me an inactivity alarm is essential. We dont have any spare pins for a buzzer, so I've multiplexed the button input, which is now used for calibration, S/C emulation, and the inactivity alarm.

We use the usual 5v DC buzzer with its negative tag (the short leg) to wired to battery negative via the S/C button, and its long leg (pos) wired to P1. Please note that he S/C button now has to be a 'break' contact:


digispark_4ch_button_buzzer.jpg


To convert from the previous arrangement, remove the purple wire from the button 'make' contact, connect purple to the buzzer pos, and connect the buzzer neg back to the button 'break' tag. The button 'common' is the black wire. The buzzer could be soldered directly onto the microswitch tag to save wires.

The diagram makes it clear (I hope!)

If anyone has used the original code, please update as its had a general tidy-up. I know we always say this, but I think thats a wrap, theres only so much you can do with six I/O pins. If the inactivity timer code looks a little convoluted, its necessary because of the multiplexing - the alarm and the S/C button that can cancel the alarm are one & the same thing!
One extra over the usual inactivity warning - if you've inadvertently left the receiver powered up as well as the transmitter, the inactivity alarm also waggles the rudder to let you know. Cool eh? :D

This is the final ( :D ) spec:

Four proportional channels, inbuilt stick calibration,
'Soft' throttle lock (has to be closed before it will open)
Reversing by powering on with the stick held over, saved to flash (throttle is not reversible for safety)
V-tail or Elevon mixer (60:40 ratio)
Single Channel compound escapement emulation mix with kick-up elevator
Inactivity alarm (should you forget & leave it switched on)




.
Attachments
digispark_4ch_sc_v_buz_newmap.ino
(7.48 KiB) Downloaded 8 times
digispark_4ch_propo_sc_v2.pdf
(11.24 MiB) Downloaded 49 times

User avatar
Wayne_H
Posts: 289
Joined: 17 Feb 2018, 05:26
Location: Temora, NSW. Australia
Contact:

Re: DigiSpark full 4-channel encoder with S/C mix

Post by Wayne_H » 23 May 2019, 16:22

Phil,

It looks like another great project, have the candidate tx already picked out. I shall definitely be making 1 (or more 8-) ).

Thanks :)
Cheers,

Wayne
Once a Retrobate, always a Retrobate............ :roll:

Mike_K
Posts: 254
Joined: 16 Feb 2018, 06:35

Re: DigiSpark full 4-channel encoder with S/C mix

Post by Mike_K » 23 May 2019, 19:06

Hi Phil

Another great project.

How accurate is the frequency of the ATtiny with the internal RC clock? I tried making an encoder using a bare ATmega328P chip a while back and it was terrible, it was something like 7.45MHz (nearly 7% out) so joystick centre was 1400uS and the ends were something like 930uS and 1860uS. I could have just left it and accepted a different servo neutral, but in the end, I calibrate it using the OSCCAL register to get it anywhere near correct. Then when I test flew it, the model would need re-trimming between sessions on different days (not between flights on the same day) and on checking with a cppm meter on the output, the frequency timing altered day to day, I assume due to temperature? Just wondered if you have had similar issues?

Mike

User avatar
Phil_G
Posts: 311
Joined: 15 Feb 2018, 23:32
Contact:

Re: DigiSpark full 4-channel encoder with S/C mix

Post by Phil_G » 23 May 2019, 19:43

Not really Mike, they seem quite stable at 16mhz, its never going to rival a crystal but all my pic stuff uses the internal osc anyway.
Some DigiSparks are slightly off freq (they tweak them to suit the USB 16.5mhz clock) but after using OSCCAL to get them spot on they dont seem to drift noticably. If you bear in mind that the USB clocking tolerance for full speed data is only 0.25% and yet the DigiSpark USB works fine... though I dont use it :D
I think Martin has found the same with his Tinys, ie fine for normal everyday use. In test gear of course you'd use a crystal.

Either way, they're far, far more accurate and stable than the old half-shot encoders they're replacing,
there was no talk of 'microseconds' back then!
Image

Cheers
Phil

EDIT: Here's the next victim: viewtopic.php?f=27&t=696

User avatar
Wayne_H
Posts: 289
Joined: 17 Feb 2018, 05:26
Location: Temora, NSW. Australia
Contact:

Re: DigiSpark full 4-channel propo encoder with single-channel, V mix, + inactivity alarm

Post by Wayne_H » 11 Jun 2019, 14:22

Phil, your efforts are always appreciated ;)
Cheers,

Wayne
Once a Retrobate, always a Retrobate............ :roll:

User avatar
F2B
Posts: 92
Joined: 16 Feb 2018, 11:23
Location: 20 m NE of Amsterdam

Re: DigiSpark full 4-channel propo encoder with single-channel, V mix, + inactivity alarm

Post by F2B » 12 Jun 2019, 12:49

Wayne_H wrote:
11 Jun 2019, 14:22
Phil, your efforts are always appreciated ;)
Hear, hear....
(as there are no applauding facilities on this forum) :mrgreen:

Cheers,
Bruno
F2B or not to be....

User avatar
Phil_G
Posts: 311
Joined: 15 Feb 2018, 23:32
Contact:

Re: DigiSpark full 4-channel propo encoder with single-channel, V mix, + inactivity alarm

Post by Phil_G » 31 Aug 2019, 23:02

I've updated this sketch after I found that the Waltron pots were very slightly 'off' electrical centre at neutral stick. In all my previous encoder sketches, the calibration routine learns the full throw in either direction, then assumes that neutral is halfway between these values and until the Waltron this method has given spot-on neutrals.

So the new calibration procedure is to switch on with the S/C button pressed, and keeping it held, waggle
the sticks to their extremes but then (and this wasnt necessary before) to centre the sticks including throttle before releasing the button. The highest & lowest values are saved like before, but additionally the centres are now stored and the encoder now uses a separate map for either direction the stick is moved.

This ensures that stick-centre is channel centre whilst full travel is equal in both directions. It works great so I will be incorporating this into the 7ch+sc update too. The updated DigiSpark sketch is in the first post.
I cant update my DigiAce transmitter as the board is soldered up, just as well its sticks are spot on - but I've been using the update in the Multiplex Picoline (which has perfect sticks) and the Waltron (which didnt but does now!) :D

Cheers
Phil

Post Reply