Another internal clock accuracy question

Dave E

Senior Member
Hello everyone,
The quick question is: Is the internal clock of a PICAXE 28X2 B.3 (using 4MHz external resonator for 16MHz running freq) that is used for the TIMER command the same clock used for PWM output?

I am using an inductive sensor to see 2 pieces of metal that are attached to a belt a certian distance apart. That distance does not change nor does the belt speed (under normal conditions). The normal time between sensor reads of the 2 pins is 60.0 seconds. To verify that things are as accurite as possible, I calculated what the only 2 errors I came up with could be. One source of error could be the placement of the pieces that the sensor reads. They are attached to the belt and are unable to move more than a 64th of an inch once attached. The exact placement can not be exact but once placed they do not move so I can account for that error easily.

The 2nd area of error is where my question comes from. I use one output pin to give me a 1000 Hz 50% PWM signal that I measure with a Fluke 289 and Fluke oscilloscope. I measure 1005.6 Hz and 1005 Hz respectively. This frequency variation (0.5%) should give me a 0.3 second error for a 60 second read time. The problem is, I do not see that error.

After 24 hours of readings, the only error I see is what I calculate to be the error associated with the pin placement inaccuracy. There may be another form of error that exactly cancels this frequency error amount out but I have not found anything else yet. So my question is, is the PWM output error the same error that I would get while using the TIMER command?

Any input would be welcome.

Dave E
 

geoff07

Senior Member
The PIC18F25k22 datasheet has the gen on clock sources. But I don't think there are multiple sources in operation in parallel, just many options for generating the primary clock.

Perhaps I misread your question but it sounds as though your instruments do not agree.
 

Dave E

Senior Member
Thanks for the replies.

I may not have been clear. My 2 Fluke meters were used to verify that the PICAXE PWM was off by about 5 Hertz in a 1000 Hz signal. That is the 0.5% error. I was wondering if the PWM clock that is off by 0.5% is the same clock that generates the timing used with the TIMER command. If it is, then the assumption is that my 1/100 second counts (SETTIMER 64911 @ 16MHz) will also be out by the same 0.5%.

Dave E
 

Goeytex

Senior Member
I suspect that if you test different PWM frequencies that you will find variations in the error percentage. I would not assume a fixed timer error percentage based upon one sample of a single PWM frequency.
 

Dave E

Senior Member
The data sheet shows 0.5%.
I wanted to use the resonator for it's stability verses the on board clock. The amount of error is not as important if it is stable, then I can compensate for it. My problem is that I don't see the timing error caused by the clock/resonator error but I still need to investigate Goeytex's suggestion.

Dave E
 

Dave E

Senior Member
Trying different PWM output frequencys:

1000 Hz = 1005.5 Hz 0.55% error
5000 Hz = 5027.6 Hz 0.552% error
10,000 Hz = 10,055 Hz 0.55% error
50,000 Hz = 50,274 Hz 0.548% error

It does look like different PWM frequencies do have the same frequency error. I will try some non-factor-of-10-and-5 frequencies later to see if that changes anything.

Dave E

P.S.
The manual for my Fluke 289 states for all frequency ranges, the meter error is +-(0.005% + 1 LSD). That is 3.5 Hz out of 50,000.
 

Circuit

Senior Member
The data sheet shows 0.5%.
I wanted to use the resonator for it's stability verses the on board clock. The amount of error is not as important if it is stable, then I can compensate for it. My problem is that I don't see the timing error caused by the clock/resonator error but I still need to investigate Goeytex's suggestion.

Dave E
Remember that you can use an external crystal instead of a resonator if you want to increase the accuracy even further. For most purposes it will have little advantage over a resonator, but if you want the highest precision then an external crystal is easy to hook up to the PICAXE chips.
 

Dave E

Senior Member
Thanks circuit.
The accuracy of the resonator is fine for this application. I just wanted to verify if the accuracy/inaccuracy of the PWM output will be the same as the accuracy/inaccuracy of the clock used for the TIMER command or if there is a better way to acually test the TIMER function for accuracy.

Dave E
 
Last edited:
Top