Accessing TMR0 as a counter. (by Henrik Olsson)
Hi,
Is there a way to use TMR0 (16F88) as a highspeed counter?
I have a need to detect the absence/presence of a frequency that can be anywhere from 5kHz to 20kHz. I don't need to measure the actual frequency just checking if it's there or not.
The idea was to let TMR0 count the pulses and, at each cycle, comparing the TMR0 register the value it had the last cycle but I don't see an obvious way to access TMR0.
I'm also thinking if it's possible to it with "ordinary" logic but I'm afraid that, depending on the actual frequency, it might come "in sync" with cycletime and therefor the input will read as high or low every cycle or atleast during several consecutive cycles.
If anyone has any ideas I'm all ears, thanks!
/Henrik.
(no subject) (by Jonathan Westhues)
There's unfortunately no way to use TMR0 (or any other hardware counter) as a high speed counter in LDmicro.
And you are correct that an implementation that sampled the pin every cycle is vulnerable to aliasing--if the input frequency is very close to an integer multiple of the cycle frequency, then the input will appear to stay constant for a long time.
A quick and ugly solution would be to AC-couple the signal into an ordinary digital pin through a peak detector. That's a handful of parts, but it lets you read "frequency present" as a simple digital level. The component values on the schematic will supply a good logic high down to 5 kHz, and will go low within a few ms of the signal disappearing.
(no subject) (by Henrik Olsson)
Many thanks Jonathan!
I certanly didn't expect you to come up with a schematic too, much appreciated!
/Henrik.
closed loop control (by ANWAR basheer)
hi every body, i have a one project implementation of closed loop speed motor controller. its possible to do the ld micro.
give me any example.
If anyone has any ideas I'm all ears, thanks!