pic16f88 frequency counter triples result

Status
Not open for further replies.

truffaldino

Junior Member level 3
Joined
Feb 14, 2016
Messages
28
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
295
I wrote a frequency counter program in PICBASC PRO for 16F88. This is a pretty standard stuff: timer1 is an asynchronous counter and timer0 is a clock.

When I run this counter in Proteus, everything is OK if I feed B6 timer1 pin with the digital clock signal (it works up to 100 MHZ).
But when the signal is not digital clock, even if it is suare 50%duty cycle with raise/fall time 1 picosecond, it triples the frequency. It shows correst frequency only if rise/fall time is 0.

What could cause this problem? Is it software, configuration or simulator error?
 

it works up to 100 MHZ
Makes clear that the simulation hasn't much to do with a real PIC. Maximum asynchronous input frequency is 16 MHz.
But when the signal is not digital clock, even if it is square 50%duty cycle with raise/fall time 1 picosecond, it triples the frequency. It shows correst frequency only if rise/fall time is 0.
You actually mean picoseconds? And observe a difference between 1 ps and 0 ps rise time? I wonder if Proteus can simulate superluminal phenomena.
 

OK, we cannot trust simulator.

I have another question.

I put two microcontroller circuit on the solderless breadboard to test the counter on low frequencies (just 5-10 Hz). First microcontroller is the pulse generator, while the second one is a frequency counter.

It shows zero frequency, while in Proteus everything works fine. Could it be caused by solderless breadboard parasitic effects?
 

Could it be caused by solderless breadboard parasitic effects?

Possible but unlikely. I would rather expect a coding or wiring error. You would check if either the generator or the counter are failing.
 
It was indeed a small coding error unnoticed by simulator. I guess all these problems with simulation is caused by bugs in SPICE model of PIC.
 

I have another problem with the counter: I have put a jfet buffer and npn self-biased transistor as a preamplifier before counter. Everything works fine up to about 12MHZ when I use ordinary 2N3904 transistor as preamplfier, but when I try to use high-frequency transistors, such as BF199 or PN3563 counter shows zero result.

As for BF199, I run a simulation in LTSPICE and everything is going excellent there. What could be cause of such behavior: stray capactance of solderless breadboard?
 

At 12MHZ stray capacitance could well be the issue.
However use a scope to see the actual signal traces and in particular voltage and frequency to make sure they are acceptable.
If there is capacitance then the transitions may be slowed.
Susan
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…