1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

How to find the pulse width of unknown frequency using 8051 microcontroller

Discussion in 'Embedded' started by ravikumar.n, Sep 8, 2005.

  1. ravikumar.n

    ravikumar.n Guest

    Respected Experts,
    I am Ravikumar.N, working on 8051 microcontroller. I
    have an issue regarding the pulses of unknown frequency.

    I am equipped with the following things:
    1) I have an 8051 based development baord.
    2)I have an unknown frequency source.

    My Purpose:
    I want to measure the pulse width of the unknown frequency that
    will be fed to 8051.

    My queries:

    1) I dont know to which pin of 8051, these unknown frequency
    pulses has to be fed inorder to measure the pulse width.

    2) Please let me know what logic has to be used to calculate the
    pulse width after these pulses(unknown frequenc pulses) are fed to an
    appropriate pin of 8051 microcontroller.


    Thanks In Advance,
    Ravikumar.N
     
    ravikumar.n, Sep 8, 2005
    #1
    1. Advertisements

  2. ravikumar.n

    Jan Wagner Guest

    Which 8051/80c51? Different 8051 based devices offer different
    peripherals. You could use I/O pin level transition interrupts or
    timers.
    You might find something in the http://www.8052.com/ code library. A
    frequency counter would use one of the Timer pins. For pulse width
    measurement, you could configure the internal timer as a timer to
    count at certain speed, and put it into gated mode. Signal to
    INTx/P3.2 and c.f. the GATE bit(s) in TMOD or TCON. With the gating,
    you can then read the counter value, from which you can determine
    the pulse width (ON-time, and OFF-time you get with some small
    calculations from the ON-time and the frequency). For details how to
    config the timer(s) I think you should check the datasheet and
    programming reference for your particular 8051.

    - Jan
     
    Jan Wagner, Sep 8, 2005
    #2
    1. Advertisements

  3. ravikumar.n

    ravikumar.n Guest

    Thanks Jan,
    I am using ATMEL based AT89c52
    microcontroller.
     
    ravikumar.n, Sep 8, 2005
    #3
  4. ravikumar.n

    Jan Wagner Guest

    Ok then this one
    http://www.keil.com/download/docs/189.asp
    should work for you. In the .zip, main.lst contains assembler that
    you can use for your reference if you don't have a the Keil C compiler.

    - Jan
     
    Jan Wagner, Sep 8, 2005
    #4
  5. Get the manual, and search for the word Capture.

    Microcontrollers do not measure frequency, they measure time,
    and can count internal or external clock edges, and capture.

    The approach you use will depend very much on the "unknown Frequency",
    relative to the CPU clock, and how many digits of precision you
    want on the result.
    -jg
     
    Jim Granville, Sep 8, 2005
    #5
  6. Oh?

    If I apply my signal to the counter input, the micro measures frequency. If
    I apply the signal to a capture input, the micro measures time. IMHO.

    Meindert
     
    Meindert Sprang, Sep 8, 2005
    #6
  7. Nearly; it actually simply counts edges. (as I said above)
    If you want Frequency, you need to capture that count result, at
    accurate time intervals, and do some maths. Hz = Cycles/Time

    ie to get Frequency, you need two counters, one for the timebase, and
    one for the Fu, and ideally, the Fu counter clears-on-capture, from
    the period signal of the timebase. With this HW, when you read, you read
    Frequency.

    Such HW can be created in CPLDs, and FPGAs, but is very rare in uC.
    Most uC lack the "Timer1 triggers capture of Timer2" etc HW paths, but
    in the 89C52, you could externally wire a HW output pin ( like TXD ) to
    the Capture T2EX IP pin.

    Pulse WIDTH is also non trivial; in pure HW - Capture gives pulse
    PERIOD ( which may be what that OP actually meant? )

    In the C52, you CAN apply an external gate, to the T0,T1 counters,
    so it only INC's when gate is HIGH, but there is no HW capture,
    thus you have to react in SW, to grab the result while the IP is low,
    and that imposes a time limit.

    If the OP uses a 89C51RD2, with the PCA, then it is possible to
    capture both edges, and derive Period and PW.
    This also has upper and lower Frequency/period limits.

    -jg
     
    Jim Granville, Sep 8, 2005
    #7
  8. ravikumar.n

    thothefali

    Joined:
    Nov 11, 2010
    Messages:
    2
    Likes Received:
    0
    pwm

    It would be great if u can provides me some assembly code samples for doing this thing.
     
    thothefali, Nov 24, 2010
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.