Inconsistent timing on ATTiny85 between boards

Hi, I've been prototyping with the ATTiny85 in a DIP package. It is used as part of a larger board for a very basic application. Basically its primary purpose is to act as an LED driver. If it sees a 3V signal on a particular pin it will turn on one LED, wait 80ms, turn on the second LED, wait another 80ms etc. So that the LEDs "shoot up" rather than all turn on at once.

I have been using an arduino Uno as an ISP programmer to program my ATTinies with arduino. The code is very simple. I initially just use the delay() function (even though people advise against it) since it was a very basic piece of code. Here's where the confusing stuff happens. I have 4 ATTiny85, and I programmed them one after the other with the exact same code, and swapped them into the same exact board each time. Of the 4 that I have, only one of them gets the timing right on the delay() function, the other 3 will have the timing 10x longer than what I have programmed. So if my delay was meant to be 80ms, it ends up being 800ms.

I thought maybe delay was not a good idea to use. So I tried doing it the proper way by using the millis() function and checking when I am over 80ms to have an LED on. Same problem, the timing was 10x what it was meant to be.

Thanks in advance to anyone who has had experience dealing with this and might know why this is happening

Internal oscillator? External resonator? External crystal?

I have no idea but I suspect that small variations in the attiny might cause this.

A schematic might be useful.

sterretje:
I have no idea but I suspect that small variations in the attiny might cause this.

Small variations will not cause a 10x change.

I suspect the slow ones are not 10x slower but 8x. Did you burn bootloader onto all of the ATTinys? One of the fuses that is set by defauly on new chips is CLKDIV8, which does eactly what its name implies, divides the clock frequency by 8. You think you're running off the 8 MHz internal oscillator, but the chip's actually clocking along at 1 MHz, slowing everything down. The Burn Bootloader command in the IDE also sets the fuses to what they're supposed to be, which usually means disabling this fuse.

Jiggy-Ninja:
Small variations will not cause a 10x change.

I suspect the slow ones are not 10x slower but 8x. Did you burn bootloader onto all of the ATTinys? One of the fuses that is set by defauly on new chips is CLKDIV8, which does eactly what its name implies, divides the clock frequency by 8. You think you're running off the 8 MHz internal oscillator, but the chip's actually clocking along at 1 MHz, slowing everything down. The Burn Bootloader command in the IDE also sets the fuses to what they're supposed to be, which usually means disabling this fuse.

Yes, this was the issue, thank you so much.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.