Using an ATTiny85 and an Arduino loader I created a simple device for turning on an exhaust fan based on a light sensor. The ATTiny85 turns on the fan after activating a warning light and sounding an alarm. Of course, I use a relay to amplify the signal from the ATTiny85 to switch the AC power to the fan. I’m not using I2C, it is simply an on/off pin command. All well and good.
However, after several weeks of operation the ATTiny85 seems to increase its clock speed. The warning light flashes much faster than it was programmed to and the alarm sounds for a shorter time and at a higher pitch.
digitalWrite(FUNCTION, HIGH); buzzer(1000, 1, 1); delay(700); buzzer(1000, 1, 1); delay(700); buzzer(2000, 1, 1); fan(ON); digitalWrite(FUNCTION, LOW);
Simply rebooting the system solves the problem for a few weeks.
Initially I figured the problem was dirty power. I replaced the 5V transformer running the chip with a 12V transformer and ran the power through a XL4015 Step-Down Buck Converter. When I test the power going to the ATTiny85 from the buck, I get a steady 5.16V as designed. Still, after a few weeks, the ATTiny85 seems to go into hyper-speed.
I have searched along the lines of “ATTiny85 clock speed” and have found nothing that approximates my problem. The code is a fairly simple loop and the integers passed to the "buzzer" routine should produce a constant time period, I would think.
Assuming the code is not at fault, are there ways that the ATTiny85’s clock speed can be altered by external events? Power spikes? phases of the moon? ;-)...
I wanted to ask this question, before I go wading-in looking for a silly software bug! Which is likely the problem!
Awjlogan and SamGibson - Thanks for your prompt reply and suggestions. Your initial comments about Protection Circuitry and Vdd ramp-up “inspired” me to look at:
EEVblog #859 - Bypass Capacitor Tutorial https://www.youtube.com/watch?v=BcJ6UdDx1vg
When I built this little project I had just gotten a new cable crimper. A PA-09 and it works great for making custom Dupont connectors. After going thru Dave’s blog I suspect I over did it. The leads are at least 150 mm long. More than enough to cause problems. I’m betting that these long connectors and NO Bypass Caps are the reason I’m having problems! Naively, I thought that the XL4015 Step-Down Buck Converter would have taken care of this. But based on what I’ve learned the length of the connectors are probably the source of the problem.
I’ll update this post when I’ve confirmed or denied this assessment.
Thanks for your input!