Counter in 89C51

Thread Starter

OSOO

Joined Feb 19, 2014
34




I want to ask why the pulses that come from the output of the comparator do not increase the counter ( Timer 1 ) value, meanwhile, using a single pulse generator increase it ,although they are all high and low pulses !! I really don't know why !! can anyone please help me
 

Thread Starter

OSOO

Joined Feb 19, 2014
34
actually I didn't get it

the circuit is working ,you can see this from the led when connected to the output of the op-amp comparator






ِAlso when I use the oscilloscope is see the pulses ( high and low ), and everything looks good until I feed it to the T1 pin ,the counter doesn't count anything !!
 

shteii01

Joined Feb 19, 2010
4,644
Did you set the P3.5 for input in the software?

When I first saw your thread, I got my 8051 book out and there is sort of step by step procedure for setting the timer for counting.
 

Thread Starter

OSOO

Joined Feb 19, 2014
34
Yes for sure

counter is working well when I put a single pulse generator :)

but when I replace it by the circuit shown the counter doesn't work :(
 

joeyd999

Joined Jun 6, 2011
6,456
A comparator will work better in this application. Ensure you include a pullup resistor on the output if it has an open collector output.

Oh, and get rid of the Q1, R1 and R4. You don't need them.
 

Thread Starter

OSOO

Joined Feb 19, 2014
34
Could you please give me the comparator number, I've tried 6 commercially available comparators in Proteus library ,but unfortunately nothing works

I used Q1 ,R1 and R4 intentionally for a certain purpose :)
 

joeyd999

Joined Jun 6, 2011
6,456
Could you please give me the comparator number, I've tried 6 commercially available comparators in Proteus library ,but unfortunately nothing works

I used Q1 ,R1 and R4 intentionally for a certain purpose :)
Some of the other guys here will hopefully give you a number. I haven't used a comparator in years. LM311 comes to mind, but the input voltage range may or may not be good enough for your application.

BTW, I just noticed your Q1 and R4 is badly configured. There is no place for the base or emitter current to go. You should remove R4 (replace it with a short). Then, apply your 10K resistor between the emitter and ground. I think your circuit, as is, may work then.
 

Thread Starter

OSOO

Joined Feb 19, 2014
34
I removed R4 ,but nothing new, counter still not working !!

I used a 555 timer ,triggered by the comparator output ,and now I can see the timer pin counting the pulses :) ,is that a good solution ?
 
Top