Counter in 89C51

Discussion in 'Embedded Systems and Microcontrollers' started by OSOO, Apr 8, 2014.

  1. OSOO

    Thread Starter Member

    Feb 19, 2014
    34
    0
    [​IMG]

    [​IMG]

    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
     
  2. bertus

    Administrator

    Apr 5, 2008
    15,638
    2,344
    Hello,

    Basicaly the inout is almost floating and pulled high.

    Have a look at the change I made:

    [​IMG]

    Bertus
     
  3. OSOO

    Thread Starter Member

    Feb 19, 2014
    34
    0
    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

    [​IMG]


    [​IMG]

    ِ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 !!
     
  4. OSOO

    Thread Starter Member

    Feb 19, 2014
    34
    0
  5. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,377
    494
    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.
     
  6. OSOO

    Thread Starter Member

    Feb 19, 2014
    34
    0
    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 :(
     
  7. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,673
    2,712
    A 741 generally cannot swing withing a volt or two of the power supply rail. This is probably your problem.
     
  8. OSOO

    Thread Starter Member

    Feb 19, 2014
    34
    0
    so, what should I use instead
     
  9. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,673
    2,712
    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.
     
  10. OSOO

    Thread Starter Member

    Feb 19, 2014
    34
    0
    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 :)
     
  11. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,673
    2,712
    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.
     
  12. OSOO

    Thread Starter Member

    Feb 19, 2014
    34
    0
    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 ?
     
Loading...