Digispark kickstarter ATtiny85 & ICSP programming adapter

Digispark kickstarter ATtiny85 & ICSP programming adapter

Postby Phil_G » Thu May 25, 2017 12:42 pm

Frank & I have been using this cheap & dependable ATtiny85 board for some time in various R/C projects, and as the Pro-Mini ICSP adapter was popular I thought I'd post my ATtiny85 adapter.

I've switched to this board where previously I've used the ICP07 Pic board, for the simple reason that the manufacturer
has hiked the ICP07 price - they now cost three times as much as when I started using them in the RDT encoder, Tiny-6, Codamac, etc.

The ATtiny85 board comes with an inbuilt but unshrouded USB plug for simple USB programming via a special USB bootloader.
This is bad with a capital B - the bootloader delay in this case is five full seconds! They come with 'blink' loaded (theres an LED on P1),
and with the fuses set for 16mhz, but on power up, five seconds elapse (an eternity!) before blinking commences.
In any case theres little room in a Tiny85 to waste on unnecessary bootloaders!

I remove the redundant USB connector with a junior hacksaw, a couple of strokes of the permagrit block gets the edge of the
board smooth, and then its programmed as usual using a USBASP via SPI.
Heres a before & after shot, with a PP3 for size reference - after the mod, they're really small, less than 3/4" square:

attiny85_1.jpg


Heres the programming adapter - just two headers on a length of vero for the chip and the usual 6-pin USBASP header:

attiny85_0.jpg


I later added an extra header pin on the neg rail, so my PPM tester plugs onto neg & port P0 (ppm), and also a resistive ground-lead
for testing button inputs. This means the programming adapter doubles as a simple tester:

attiny85_2.jpg


The board is a loose fit over the headers of course so a small sponge block under the top-left corner wedges the board at an angle and
secures the connections.

attiny85_3.jpg


One thing I have noticed is that although the clock speed is stable, its not precisely the same from one chip to another,
at a nominal 16mhz some are very slightly over, some are very slightly under, but that hasnt been a problem as the variation is minimal
and for anything 'timing critical' the clock can be tweaked in the software. Its because the RC clock is actually 4mhz multiplied up with a PLL
so any slight variations are multiplied four times.

Heres an RDT encoder made with this board (Remote Dethermalizer) for free-flight models, with a Futaba-style OrangeRx module for size:

IMG_20170525_152537.jpg


Veroboard layout. Note that the USBASP header has cuts between adjacent holes, as does the 5v and 0v connector for the Attiny.
The short blue link (negative) on the right and short red link (pos) on the far left can both be just a solder blob.

attiny85_kickstarter_icsp_adapter.jpg


Cheers
Phil
User avatar
Phil_G
 
Posts: 1919
Joined: Fri Mar 14, 2014 1:41 am

Re: Digispark kickstarter ATtiny85 ICSP programming adapter

Postby ceptimus » Thu May 25, 2017 5:56 pm

The easiest way to tweak the timing of the oscillator for any programs that require more accurate timing (and most don't) is to write to the OSCCAL register. The initial value of OSCCAL, and the value you need to offset it by to tweak the oscillator to exactly 16MHz varies from one chip to another so once you've worked out the correct OSCCAL offset value for a particular chip, you can either code that value as a constant into the sketch for that chip or you could store it in EEPROM if you're making many devices and want to keep the same sketch for all of them.
ceptimus
 
Posts: 461
Joined: Mon Aug 03, 2015 5:54 pm
Location: Warwickshire

Re: Digispark kickstarter ATtiny85 ICSP programming adapter

Postby FBMinis » Thu May 25, 2017 6:27 pm

Thank you for the tutorial, Phil. I have one of these but not being as straight forward to use as the Arduino Pro Mini or the Nano always put me off.
FBMinis
 
Posts: 48
Joined: Wed Feb 24, 2016 11:38 pm

Re: Digispark kickstarter ATtiny85 ICSP programming adapter

Postby Phil_G » Thu May 25, 2017 6:55 pm

Hi Francesco, once you have the Tiny85 extensions added to your Arduino environment, its just a case of choosing the board,
setting the processor type to Tiny85, the clock speed, programmer to 'usbasp' and away you go as usual:

tiny85.jpg


Brand new Tiny85's run at 1mhz and need to be coaxed up to 16mhz but the kickstarters on ebay have the fuses already configured for 16mhz.
The easiest method of 'coaxing' is to temporarily upload the Tiny85 bootloader, which as a by-product sets the clock fuses for 16mhz.
The clock fuse settings are retained even after you subsequently overwrite the bootloader with your sketch via the USBASP.

'Blink' is always a good place to start - as you can see, other than the LED pin its the same as always!

Code: Select all
// Blink for Kickstarter ATtiny85
#define blinkPin 1
void setup()
{
  pinMode(blinkPin, OUTPUT);
}

void loop()
{
  digitalWrite(blinkPin, HIGH);
  delay(500);
  digitalWrite(blinkPin, LOW);
  delay(500);
}
User avatar
Phil_G
 
Posts: 1919
Joined: Fri Mar 14, 2014 1:41 am

Re: Digispark kickstarter ATtiny85 ICSP programming adapter

Postby Phil_G » Sun Jun 04, 2017 8:43 pm

Some more info gleaned after completing several projects using the DigiSpark Kickstarter Attiny85 board:

The internal pull-up resistors which are enabled when ports are configured using pinMode(buttonPin,INPUT_PULLUP); for example
have quite a high resistance compared to other chips (about 25k ohms) only so are only very weak pull-ups.
In the case of the Digispark board, D3 and D4 are the USB data connections, and both have some protection circuitry in the form of
resistors & 3v6 zener diodes which the 25k internal pull-up cannot overcome. The result is that if D4 is configured as an input using say:
pinMode(4,INPUT_PULLUP);, when open-circuit, D4 will always read as a zero.
This affects only D4, D3 has an additional on-board pull-up resistor of 1.5k and so behaves as expected.

A further effect of this is that when used as analogue inputs, D3 and D4 are restricted to 3.6v max by the zener clamping diodes - and the additional 1k pullup on D3 affects its linearity as an analogue input - see diagram.
In the bottom two photos you can see how the unwanted protection circuitry can easily be removed, if required - for D3 remove the diode,
and for D4 lightly ream either TPH hole of the doggy-bone where D4 connects to the underside of the board, as in the last couple of photos.
The diode can be removed with fine pliers, and the D4 PTH use a small (say 2mm) drill twisted in your fingers - so theres no soldering.
This will remove all the USB protection circuitry around D3 and D4 and revert them to 'normal' ATTiny85 behaviour.

EDIT: I've since found that you can easily remove diode D3 with your thumb-nail, and D4 by pressing it sideways with a watchmakers screwdriver. The lead-free solder is very soft and they both break away quite easily with no need to cut tracks or drill PTH holes!

D1 has an on-board LED with a 1k resistor and whilst this doesnt affect its operation as an output, when configured as an input, obviously
the resistor and led combination are working in opposition to the 25k pull-up and so needs to be taken into account. Its like the Nano's D13.

D5 is by default the chip reset input and needs a fuse reprogramming to change it to a digital I/O pin, after which, since its no longer a reset pin,
the USBASP wont work and a high voltage programmer is subsequently necessary. So unless you're very keen, ignore D5 completely.

D0, D1 & D2 behave normally!

This is a great board, very handy for less complex projects, really cheap and so very small after sawing off the USB tab.
It seems that some 'best practise' things are surfacing, these are just my own observations:

1) D0, D1 & D2 behave just as you would expect. D1 has the inbuilt LED so is handy as an indicator output like D13 on a larger Arduino.
If used as an input, the source should be low enough Z to overcome the LED/resistor combination.
2) D3 has an on-board 1.5k pull-up regardless of the pinMode setting you give it. Bear this in mind, its ideal as a 'button' input for example.
3) D4 will appear to ignore 'input_pullup' configuration and should be driven from a relatively strong source (Z less than say 10k) or used as an output
4) D5 is the reset pin, its not generally available as an I/O pin unless you do a fuse change and have a high-voltage programmer.
5) the USB bootloader is very clever but wastes 25% of the memory unnecessarily and takes a full 5 seconds before running your program. Ditch it!
6) ICSP works great with a USBASP using the adapter shown a few posts up, removes the troublesome bootloader and as you are not using
the USB tab it can be chopped off, leaving the board just under 3/4" square.
7) if the D3 & D4 weirdness is a concern, it can easily be resolved with a small mod as described above.

attiny85_1.jpg


digispark_schematic.jpg


digispark_board.jpg


digispark_d3d4_problem_fix.jpg
User avatar
Phil_G
 
Posts: 1919
Joined: Fri Mar 14, 2014 1:41 am

Re: Digispark kickstarter ATtiny85 ICSP programming adapter

Postby ceptimus » Sun Jun 04, 2017 10:37 pm

Have you tried a beetle board Phil? Similar form factor but with the more capable ATMega 32U4 chip

http://www.ebay.co.uk/itm/Arduino-Beetl ... 2150557985

£4.28 each on Ebay
ceptimus
 
Posts: 461
Joined: Mon Aug 03, 2015 5:54 pm
Location: Warwickshire

Re: Digispark kickstarter ATtiny85 ICSP programming adapter

Postby Phil_G » Sun Jun 04, 2017 11:58 pm

Thats interesting Martin, I wasnt aware of that one.
I like the extra I/O, memory and the proper clock. I've ordered a couple to try Image
But one of the attractions of the Digispark is they're only a quid each!
Cheers
Phil
User avatar
Phil_G
 
Posts: 1919
Joined: Fri Mar 14, 2014 1:41 am

Re: Digispark kickstarter ATtiny85 & ICSP programming adapte

Postby Phil_G » Tue Jul 18, 2017 1:01 pm

Well, I ordered a couple of beatle boards, I'm sure they arrived ok a few weeks ago, however I've lost them,
turned everything upside down but no joy. Its an age thing - yes, another age thing...
Cheers
Phil
User avatar
Phil_G
 
Posts: 1919
Joined: Fri Mar 14, 2014 1:41 am

Re: Digispark kickstarter ATtiny85 & ICSP programming adapte

Postby Phil_G » Thu Jul 20, 2017 10:35 pm

Update - those unwanted diodes pull off easily, no need to drill any lands.
The one at the edge of the PCB comes off easily with your thumbnail. The one between the two chips needs a little more care, just gently push it one way then the other with a flat jewellers screwdriver& it will drop off!
Removing the two diodes removes all the weirdness around D3 & D4, allowing them to behave normally.

no_diodes1.jpg


no_diodes.jpg
User avatar
Phil_G
 
Posts: 1919
Joined: Fri Mar 14, 2014 1:41 am


Return to Projects

Who is online

Users browsing this forum: No registered users and 1 guest