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

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

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

Post by Phil_G »

See edits!

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 doesn't 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) with alarm if invoked
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) also waggles rudder in case Rx has been left 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 'extra' receiver channels 5 & 6 following on from the usual channels 1 to 4 which are as you'd expect.

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 1:
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

Edit 3:
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 even a slightly non-linear stick pot will map accurately.

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.
Updating the DigiAce transmitter was a messy process as the board is soldered up, and I've been using the update in the Multiplex Picoline (which has perfect sticks) and the Waltron (which didnt but does now!) :D




digispark4encoder_annot.jpg

Cheers
Phil



Edit 4: The 7ch+s/c encoder update is finished and also uses this calibration method: http://mode-zero.uk/viewtopic.php?f=27&t=844

Here is the final ( :D ) spec:

Four proportional channels, inbuilt three-point stick calibration
'Soft' throttle lock (has to be closed before it will open) with alarm if activated
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), also waggles rudder in case Rx has been left on


Edit 5: Tidied up the sketch & doc a bit, no functional code changes.

Edit 6: Added the "Power on with throttle open" warning, which indicates that the soft throttle lock is active - similar to the 7ch encoder.
Attachments
digispark_4ch_propo_sc_v2.ino
(7.9 KiB) Downloaded 357 times
digispark_4ch_propo_sc_v2.pdf
(13.39 MiB) Downloaded 465 times
User avatar
Wayne_H
Posts: 808
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 »

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............ ;)
User avatar
Mike_K
Posts: 669
Joined: 16 Feb 2018, 06:35
Location: Hertfordshire

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

Post by Mike_K »

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: 596
Joined: 15 Feb 2018, 23:32
Contact:

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

Post by Phil_G »

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.

Its just an unfounded opinion but I think the reason I find 16mhz to be so stable and repeatable is because the PLL, whilst locked to the input frequency, has a lock time-constant so it can can free-run over any minor input hiccups or noise, just like any textbook PLL. Also raising the frequency with a PLL doesnt multiply the error like multiplying a fundamental does. Its just an opinion Image

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: 808
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 »

Phil, your efforts are always appreciated ;)
Cheers,

Wayne
Once a Retrobate, always a Retrobate............ ;)
User avatar
F2B
Posts: 200
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 »

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: 596
Joined: 15 Feb 2018, 23:32
Contact:

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

Post by Phil_G »

I thought I'd done a video of the DigiSpark "four channel +s/c mix" encoder but apparently not, so, belatedly, did one today as a few minutes respite from pumping out the drains from storm Ciara. A bit rushed so I may have missed something (in the video, not in the drains, pretty sure i got all that... :D ) but you get the gist. I've edited the video into the first post in this thread and in the Waltron 4 and DigiAce 4 threads. This encoder is proving really popular, loads have gone out, I suspect because it makes a conversion even easier than the more complex encoders here and suits retro 4's like the DigiAce perfectly.
Cheers
Phil
PS as storms go, personally I think Ciara was rubbish, not impressed at all, it was just a bit damp with a bit of a draft... ;)
PPS Dennis and Jorge were also damp squibs after all the media 'Waterworld' frenzy :D
GarydNB
Posts: 282
Joined: 15 Feb 2018, 23:12

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

Post by GarydNB »

That's because you don't live on a boat.........
User avatar
RobertC
Posts: 114
Joined: 04 Sep 2020, 15:13
Location: Grimsby UK

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

Post by RobertC »

Hi Phil
looks a fantastic small, simple install and I reckon could all fit in a fag packet complete , I’ll be in touch , lovely job
User avatar
stuart mackay
Posts: 501
Joined: 01 Mar 2018, 10:38
Location: Swaffham, Norfolk
Contact:

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

Post by stuart mackay »

Built a Digispark driven/ LemonRx DIY module powered RCS Digifour for my old friend John Greenfield, who is loving flying his Junior 81 3/4 around at the Phoenix Club near St Albans next to the M25...John says thanks, Phil!

https://www.ebay.co.uk/itm/133704108565

427939474_2604343753064880_638688461901843791_n.jpg
426642925_2604343863064869_5068380291265337002_n.jpg
Post Reply