Connect with us

pic micro programming

Discussion in 'Electronic Repair' started by eddie, Mar 16, 2007.

Scroll to continue with content
  1. eddie

    eddie Guest

    I am trying to program a pic micro 16f877 to desplay the rpm of a
    motor on a lcd. I as using a sensor which gives me 4 puls per
    revolution of the motor shaft. I am trying to use the capture and
    compare property if the pic . can anyone help me . Anyothe method to
    do the same procedure is appreciated.
    thank yo
  2. There are many app notes on the Microchip website.
  3. Any idea what the pulses you get, will look like? Any idea about minimum and
    maximum speed expected? Have the PIC16F877 datasheet already? Read it? (It's
    only about 200 pages and you will not need all of them.) I may be wrong but
    from your post I got the idea that someone told you to start this project
    but that you have hardly an idea how and where to start. You even seem to
    have no feeling about what you really want to measure. Who told you to use a
    PIC16F877? Nice chip but quite a gun to kill a fly. Advise you'd better
    think over the basic idea of rpm and ways to measure it. Then look for how
    to use a micro to do so.

    petrus bitbyter
  4. eddie

    eddie Guest

    As you should know i can only put 5v into the pic and the puls am
    getting goes from 0 to 5 volts. its square waveform.Its part of a
    ptoject yes...and i choses this 40pin device because i have other
    things which i have to impliment on the project.Its a small 12v Dc
    motor which am trying to find the Rpm . minimum rpm i want to desplay
    on my Lcd is 400 and maximum is 1500. I have got the data sheet and
    some other aplication notes from the microchip website and have been
    reading it thats why i mentioned about the capture and compare
    function of the pic. All the other part of the porject i can
    handle ..i need just a little help on makin the pic calculating the
    RPM. I dont have much knowlwdge on assembler language so am using C.I
    am using Mplab with Hitech compiler.
    anyhelp is appreciated
  5. So this clears a lot for me. As "rpm" has the property "events/time" you
    have two approaches to measure it. The first is: count events for a fixed
    time, the second is: measure time between two events. With your sensor that
    provides four pulses/revolution you will have a range of 1600-6000 pulses/

    With the first approach approach mentioned you have to count pulses for a
    minute, divide the result by four and display it. You can also count for a
    quarter of a minute and display the result without dividing. You can count
    for shorter times as well at the cost of accuracy. In this approach you will
    need a counter and a timer. Both are available in the chip you want to use.
    Set up the counter to count external pulses and the timer for the time you
    want to count. Reset the counter and start the timer. When the timer times
    out you can stop the counter and read out its content.

    For the second approach we need to look at the time between two pulses. So
    1600-6000 pulses/minute is 27-100 pulses/s which results in 37.5-10ms/pulse.
    A PIC running at 20MHz can measure time in units of 0.2us (which is the
    internal clock divided by four). So you set up a counter to count those
    units. Which will have values between 187500 and 50000. That first value
    does not fit in a 16-bit counter. So we use the prescaler to divide the
    internal clock by 4 once more, to count units of 0.8us. (You achive the same
    by running the PIC at 5MHz but at the cost of processing power). Having that
    counter value you can calculate the rpm, which will not be too difficult
    using the Hitech compiler.

    Whatever you choose, you will need the PICs datasheet badly. Setting up
    timers, counters and the prescaler requires several bits set (or cleared) in
    the special function registers. Once you're going to do more things with the
    PIC, you will need some kind of interrupt scheme. But you have the right
    tools at your hands. You may need some time to learn the best way using

    As an aside: Use "I" instead of "i" when you mean yourself. It's the way its
    defined in English.

    petrus bitbyter
  6. eddie

    eddie Guest

    thankxx......i will definatly look in to that
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.
Electronics Point Logo
Continue to site
Quote of the day