ATtiny85 GG decoder - DIY thread

Waggly tails
Martin
Posts: 744
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

ATtiny85 GG decoder - DIY thread

Post by Martin »

This is the thread for home-brew versions of the ATtiny85 Galloping Ghost driver. As you can see in the video, all you really need is the bare ATtiny85 chip, and a resistor. An alternative would be to use one of the small ATtiny85 boards for sale on Ebay for a few pounds that have a built-in USB port for programming - something like this:

Image

Disclaimer: I've not tried running my sketch on one of these boards yet. I think it will work, but it would be nice if someone could try it to see if there are any issues with the USB bootloader or the on-board LED (if there's one fitted). It's unlikely there will be any problems, and if there are any they can probably be fixed by a small change to the sketch.

You'll most likely want to add a H-bridge driver, and again these can be had on Ebay for a pound or so. There are several types available. Here's a typical cheap Ebay version.

Image

Or the Pololu 2135, available from Pololu and various resellers, is a little more compact and with a better chip, though it does cost slightly more.

Image

Attachments
pulserATtiny85potVersion.zip
Version that uses a preset pot rather than an auxiliary channel to control drive power. See post 10 in this thread
(3.84 KiB) Downloaded 216 times
pulserATtiny85.zip
Altered default drive when AUX not connected to more closely match Phil's decoder.
(3.87 KiB) Downloaded 217 times
Last edited by Martin on 22 Mar 2019, 19:26, edited 3 times in total.
Stewart
Posts: 37
Joined: 17 Feb 2018, 04:57

Re: ATtiny85 GG decoder - DIY thread

Post by Stewart »

Can also use one of these to program a DIP chip":- https://www.ebay.com/itm/Micro-USB-Mini ... :rk:1:pf:0
Attachments
attiny adapter.jpg
Martin
Posts: 744
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: ATtiny85 GG decoder - DIY thread

Post by Martin »

I got two types of the Digisparks (Chinese clones) surface mount AtTiny85 to test: the one with the micro USB connector and the one with the full-size USB 'edge connector' as part of the PCB. I'm still waiting for the third type (the one with the DIL socket for the ATtiny chip) to arrive.

Findings so far:
  • The bootloader waits for five seconds after power on before executing the sketch - this doesn't matter when switching on the 'galloper', as waiting five seconds is no big deal. It would be bad news if there was a momentary 'brown out' while flying - as you'd then experience five seconds loss of control, but a brown-out shouldn't happen anyway.
  • If you have a USBASP, you can program the chip using that (and overwrite the bootloader to eliminate the start-up delay - and remote chance of the 'brown out problem'). However, you won't then be able to upload via USB unless you use the USBASP to re-install the Digispark bootloader.
  • There are 3.6V zener diodes and in-line 68-ohm resistors on the two I/O that drive the H-bridge, also a 1k5 pull-up resistor on one of them (these are the two pins used for USB programming in the Digispark system). I don't think this will affect the operation of most H-bridges, but I've not tested all types.
  • Pin 1 (used for elevator input by my sketch) drives an on-board LED (to ground) via a 1k resistor. I don't think this will be a problem - radio receivers are easily capable of driving into a 1k load.
  • On the 'clone' chips, P5 (unused by my sketch) is bought out to a pin but can't be used as it's left enabled as a reset pin. On the official Digispark, a fuse is set that allows this pin to be used as an extra I/O. As my sketch doesn't use this pin it makes no difference. If you want to enable the pin to gain an extra I/O line you can do it by setting a fuse using a USBASP programmer - then you can still upload by using USB. If you want to revert to not using the USB bootloader you then need a high-voltage (12V) programmer to reset the fuse - you can't reset the fuse using a USBASP. and you can't program the chip (AFAIK) with a USBASP until the fuse is reset.
I'm currently making a home-brew magnetic actuator so I can test the sketch with that as well as the motorized galloping ghost.
User avatar
Mike_K
Posts: 669
Joined: 16 Feb 2018, 06:35
Location: Hertfordshire

Re: ATtiny85 GG decoder - DIY thread

Post by Mike_K »

Hi Martin

What ATtiny core and bootloader are you using? It makes a big difference, as an example, Arduino Nano's come with the original Arduino bootloader and show similarly slow boot times, but if you flash them with the Opti bootloader, the boot time is <0.5secs. The Opti bootloader also has the advantage that it only takes 512 bytes the original bootloader 2K. Why any Arduino's are still shipped with the original bootloader defies logic. At least the Uno ships with Opti.

I don't know what ATtiny core you are using with the Arduino IDE and hence which bootloader. You should be able to tell which bootloader is being used from ATtiny85 section of the boards.txt file. As a quick check, you could just compile a program/sketch and see how much flash is reported as being usable. The original Arduino bootloader takes 2K so it would report maximum 6144 bytes (8192-2048=6144) , the Opti only takes 0.5K so would report 7680 bytes (8192-512=7680).

To use a ATtiny core with the Opti bootloader this is the one I've used in the past, even though it says it's beta, it worked OK for me:

https://github.com/TCWORLD/ATTinyCore

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

Re: ATtiny85 GG decoder - DIY thread

Post by Martin »

Mike, thanks for that info.

The "Digispark" micronucleus bootloader is very different to the AtMega one. The latest ATtiny85 version (2.04) uses 1588 bytes. There is a version that only uses 1418 bytes. The ones I have all display the following information during the upload process:

Code: Select all

> Device has firmware version 1.6
> Available space for user applications: 6012 bytes
So it looks like they're using this old 1.06 version that uses 2180 bytes. I know the page says 1.06 and the message says 1.6 but I believe they're the same.

The size of the bootloader doesn't matter for my Galloping Ghost sketch, as the sketch is tiny. It would be nice to alter the start-up delay, but I doubt if most people using my sketch will bother.

The bootloader source code is available and it's easy to alter the 5-second start-up time. The problem is that to burn a modified bootloader to the chip you need a USBASP or similar programmer, and if you have one of those then you can just upload the sketch using it and eliminate the bootloader entirely.

Tobe suggested this thread for people to use the off-the-shelf ATtiny85 boards in a simple DIY way, and if you buy one of these ATtiny85 Digispark clone boards it will most likely come with the 5-second bootloader - probably the same old 1.06 version of the micronucleus bootloader that my boards came with. Many people building the DIY project won't have a programmer and will just want to plug the board into USB and upload the sketch. Anyone who has a USBASP or other programmer can, of course, use that as an alternative.
Martin
Posts: 744
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: ATtiny85 GG decoder - DIY thread

Post by Martin »

I tried out the little Digispark board with a cheap L9110 H-bridge on a motorized galloping ghost like the one I used in my Pulstar. As expected that worked fine.

So I decided to try a magnetic actuator - I've never done that before. I 3D-printed a 'bobbin' and wound a coil on to it, then 3D-printed a sort of 'frying pan' shape to hold some small strong magnets (the sort we use for retaining canopies and such). The 'frying pan' is glued into the rudder and the coil to the fin, as you can see in the video. I suppose I could make a variant of the design to fit inside the plane in the more usual Adams or Ace actuator manner. As a test-bed, I just fastened it to work a depron rudder on one of those cheap Lidl gliders.



Seems to have plenty of power, so the plan now is to make a second (and maybe third) actuator for the elevator(s). Then I'll stick a little motor on the nose of the Lidl glider, install the gear properly (this was just a test lash-up). I'll try to get some video of the test flight (or crash) whenever that happens.
User avatar
tiptipflyer
Posts: 393
Joined: 16 Feb 2018, 22:49
Location: Germany

Re: ATtiny85 GG decoder - DIY thread

Post by tiptipflyer »

Great Martin,
it seems to have plenty of power and can move the rudder pretty fast. I am very interested, how things move on here. I will keep a close watch on this thread. Thank you Martin for another great project.
Cheers
Frank
User avatar
Wayne_H
Posts: 809
Joined: 17 Feb 2018, 05:26
Location: Temora, NSW. Australia
Contact:

Re: ATtiny85 GG decoder - DIY thread

Post by Wayne_H »

Martin, great result. Like Frank, I'm watching this project closely as I'm very interested :D
Cheers,

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

Re: ATtiny85 GG decoder - DIY thread

Post by Martin »

Stewart wrote: 11 Feb 2019, 13:21 Can also use one of these to program a DIP chip":- https://www.ebay.com/itm/Micro-USB-Mini ... :rk:1:pf:0
Image

Stewart, I ordered one of those boards and a chip to try it out with (selected the 'all above' option from that Ebay seller). The chip didn't come pre-programmed with the Digispark bootloader, though it could still be programmed using a USBASP. This means that anyone who gets the board and chip like I did will find it completely useless unless they already have, or subsequently buy a separate programming device. If you need a programming device the USBASP is cheap and common (just two or three dollars on Ebay). You can also use another Arduino, such as a UNO or NANO as a programming device, but that is more hassle than using a USBASP.

For anyone who's interested here are the details of how to burn the Digispark bootloader to the chip using a USBASP - once that's done the chip can then be programmed via the board's USB connector linked back to a PC without using any other programming device.

The 8-pin (4x2) row of connectors contains at one end the usual 6-pin version of the Arduino ICSP connector - the one that's present on UNO and NANO Arduinos - and you may have a 6-pin connector from your USBASP that will connect to that. But if you want to use it, don't solder in an 4x2 header or the usual connector will foul on the last two pins. Fit a 3x2 header and leave the last two holes (labelled P3 P4) empty - or fit those two pins on the reverse side.

Once you've hooked up your USBASP, this is the command to burn the bootloader and set the fuses. This way doesn't allow you to use P5 (Reset) as an I/O pin. If you want to do that you set the fuses differently - but beware if you do that, you can't undo it (as far as I know) with a USBASP - you need a high voltage programmer. Using the values I give here, you can go back to using the chip without the bootloader, if and when you wish.

Code: Select all

avrdude -c usbasp -p t85 -U flash:w:micronucleus-1.06.hex -U lfuse:w:0xE1:m -U hfuse:w:0xDD:m -U efuse:w:0xFE:m
This uses the older 1.06 (also known as 1.6) version of the bootloader - this is the one that pre-programmed chips tend to come with. You can get a newer 2.04 version - look for micronucleus on github - but, at the time of writing, this isn't compatible with the default Arduino IDE set-up.

I've attached the hex file you need to burn the bootloader as described above.
Attachments
micronucleus-1.06.hex.zip
(2.76 KiB) Downloaded 201 times
Martin
Posts: 744
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: ATtiny85 GG decoder - DIY thread

Post by Martin »

Stewart suggested that some users might not wish to use an auxiliary channel to control the 'drive power' of the actuator, and could a slightly modified sketch use a preset pot into an analog input instead.

So I've done that and attached the alternate version to the opening post.

I shot a short video of it in action, which I'll link here as soon as YouTube has done its magic.

Many many thanks to Tobe for supplying one of his GG-Tobe actuators seen in the video. I'm planning to do a better video showing off the GG-Tobe properly with some good lighting conditions. This was just a quick vid to show Stewart's suggested modification.



Sorry, I screwed up the video settings so everything appears taller and thinner than it really is. I wish I could make myself taller and thinner, but that's not so easy! :lol:
Post Reply