Oct 24, 2011

Oscillator Fail

Well, as it turns out even the simple things have to be difficult when you don't know what you are doing. In my first attempt to code a test animation into my four pumpkins, I was able to get them to light up in sequence...for about 20 seconds. The idea was to have each one light up from left to right and then repeat the cycle. Everything seemed to be working great until I walked away and came back about 5 minutes later. Eventually, each pumpkin started to light up out of sequence or with a noticeable delay. As time went on, things only got worse. My first instinct was that it had to do with the inaccuracy of the internal oscillator, which is running at 4 MHz. Based on the data sheet values for the PIC 16F690, the internal oscillator is rated at 1% accuracy, which I know sounds good, but it is actually very poor for a timing device. For reference, that means if you wanted to make a simple clock project where the microcontroller just keeps track of time, your clock would be 15 minutes off the actual time by the end of the day.

I posted my results and my thoughts to the EEVblog forum yesterday afternoon, and the responses have enforced what I believe to be the problem. As you can see in the video below, the initial sequence actually functions very well.



Unfortunately, this is what it looks like about 4 minutes in...............



I have started to think of ways to work around this issue without a lot of extra effort. This problem is by no means insurmountable, but given the time I have and my knowledge of the chip it will be difficult to come up a robust solution before Halloween. My latest thought is to speed up the light triggers and finish the entire show before the oscillators get too far out of sync with each other. After the entire loop has run through once, I think I can enable the chip's reset and start it over with the clocks synced like they are when you first apply power to the circuits. If worse comes to worst, I will let the light show run free and generate what looks like random sequences. Given my high hopes for the project starting out, I really don't want to dumb it down to that level.

0 comments:

Post a Comment