Frequency meausuring 08M

For demonstrationpurposes I would like to measure the AC frequency. I picked up 50 Hz from the powersupply feeding a transistor. This gives me a nice 50 Hz square.
For now I use the count command for 10 seconds but that gives me only a reading of 50.0 Hz
Any suggestions to boost up the resolution? (such as 50.000 Hz?)
 

BeanieBots

Moderator
Put it in a loop and do it as many times as a word variable will allow summing each time around.
Use a full rectifier to give 100Hz and you will only need to do it half as many times.

Oh, just realised you are using an 08M.
There is no point going to the resolution you suggest because the 08M uses an internal oscillator which has a rather wide tollerance.
To be meaningfull, you would need to use a crystal (resonator at least) for that sort of resolution.

Edited by - beaniebots on 22/03/2007 19:35:08
 

hippy

Ex-Staff (retired)
Ignoring the accuracy issues, an alternative is to use PULSIN to measure the period of the cycle. You can measure a high and a low period, add them together to get a full cycle time.

Then it's some tricky maths to calculate f=1/t

The PICAXE cannot do real/floating numbers, only integers, but you can do f=1000/t and so and then display the value as an integer with the decimal point put in the required place
 
Thanks 4 the replies

Accuracy is no real issue. The project is to show the small changes in our mains frequency. I can compensate the error in sw. but I'm not sure about temp stability of the internal clocksource. Again... not a real issue now.
- About the loop: If I loop for 10 times, it will not give me a higher resolution because the measurements themselfs will be 10 times the same. I will look into the pulsein command Hippy mentioned.
 

manuka

Senior Member
This came up some months back as part of a clever grid demand "load shedding" technique that energy suppliers can use. Have you hence done a past Forum search -I assume you're following the same idea?

But for a quick check of mains freq just wind the leads of a freq. capable DMM around an insulated working mains cord & - et voila! Here in NZ (with a ~US$30 Jaycar Digitech QM1538 datalogging DMM) I could virtually see when it was TV ad break & lunch time etc as the freq altered accordingly. Naturally the freq. is legally required to average 50Hz over 24hrs for clocks etc. Stan
 
Stan, good assumption... I found the UK version on this subject and read they built the device using a Picaxe or something.
Of course I could use a PLL to multiply (prescale) the frequency but I just want to make it without 'descrete' elecronics.

It would fit nice next to the wheather forecast station (and is just as useful)

I'll do a lookup in the forum ...

Thanks,

Erik
 
Top