Sign in

Not a member? | Forgot your Password?

Search Comp.Arch.Embedded

Search tips

Free PDF Downloads

Advanced Linux Programming

What Every Programmer Should Know About Memory

Introduction to Embedded Systems

C++ Tutorial

Embedded Systems - Theory and Design Methodology

Microcontroller Programming and Interfacing

Introduction to Microcontrollers


More Free PDF Downloads

Recent Blogs on EmbeddedRelated

The CRC Wild Goose Chase: PPP Does What?!?!?!
posted by Jason Sachs


Ada - 7 Segments and Catching Errors
posted by Mike Silva


Project Directory Organization
posted by Stephen Friederichs


OOKLONE: a cheap RF 433.92MHz OOK frame cloner
posted by Fabien Le Mentec


Practical protection against dust and water (i.e. IP protection)
posted by Dr Cagri Tanriover


Introduction to Microcontrollers

1 - Beginnings

2 - Further Beginnings

3 - Hello World

4 - More On GPIO

5 - Interrupts

6 - More On Interrupts

7 - Timers

8 - Adding Some Real-World Hardware

9 - More Timers and Displays

10 - Buttons and Bouncing

11 - Button Matrix & Auto Repeating

12 - Driving WS2812 RGB LEDs

13 - 7-segment displays & Multiplexing

See Also

ElectronicsDSPFPGA

Discussion Groups | Comp.Arch.Embedded | How to find the pulse width of unknown frequency using 8051 microcontroller

There are 7 messages in this thread.

You are currently looking at messages 1 to 7.


So far in October, you have voted 0 times ou of a total of 0 votes by the community.
Please help us clean the archives from unuseful discussion threads by using the voting system! Details here.

How to find the pulse width of unknown frequency using 8051 microcontroller - 2005-09-08 10:17:00

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


Re: How to find the pulse width of unknown frequency using 8051 microcontroller - Jan Wagner - 2005-09-08 10:50:00

r...@sunlux-india.com wrote:
> 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.

Which 8051/80c51? Different 8051 based devices offer different 
peripherals. You could use I/O pin level transition interrupts or 
timers.

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

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

Re: How to find the pulse width of unknown frequency using 8051 microcontroller - 2005-09-08 11:20:00

Thanks Jan,
                            I am using ATMEL based AT89c52
microcontroller.


Re: How to find the pulse width of unknown frequency using 8051 microcontroller - Jan Wagner - 2005-09-08 11:51:00

r...@sunlux-india.com wrote:
> Thanks Jan,
>                             I am using ATMEL based AT89c52
> microcontroller.

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

Re: How to find the pulse width of unknown frequency using 8051 microcontroller - Jim Granville - 2005-09-08 15:51:00

r...@sunlux-india.com wrote:

> Thanks Jan,
>    I am using ATMEL based AT89c52 microcontroller.

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




Re: How to find the pulse width of unknown frequency using 8051 microcontroller - Meindert Sprang - 2005-09-08 16:16:00

"Jim Granville" <n...@designtools.co.nz> wrote in message
news:4320962b$1...@clear.net.nz...
> r...@sunlux-india.com wrote:
>
> > Thanks Jan,
> >    I am using ATMEL based AT89c52 microcontroller.
>
> 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.

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



Re: How to find the pulse width of unknown frequency using 8051 microcontroller - Jim Granville - 2005-09-08 17:25:00

Meindert Sprang wrote:

> "Jim Granville" <n...@designtools.co.nz> wrote in message
> news:4320962b$1...@clear.net.nz...
> 
>>r...@sunlux-india.com wrote:
>>
>>
>>>Thanks Jan,
>>>   I am using ATMEL based AT89c52 microcontroller.
>>
>>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.
> 
> 
> Oh?
> 
> If I apply my signal to the counter input, the micro measures frequency. 

  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