tachometer


Closed Thread
Results 1 to 6 of 6

Thread: tachometer

  1. #1
    Join Date
    Jul 2008
    Posts
    2

    Default tachometer

    Hello

    This is my first posting. Hope not to be much of a pain with this question. But I am using a 16F84 to make a tachometer. I am reading the pulse from a photo interrupt. I can get the MCU to read the pulsin signal I'm just not sure if I am processing the data correctly. Please bear in mind that I am a complete novice at this. Extra info I guess would be that I am taking a pulse off a small dc motor with a 1.5" disk as an encoder. I am using 2 holes on a 1.25" bolt center, each hole 1/8" diameter. If anyone can point me in the right direction, it would be greatly appreciated.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Show some code! What have been your results so far? What's the problem? What's working? What's not working? Is anything working?
    http://www.picbasic.co.uk/forum/showthread.php?t=1742

  3. #3
    Join Date
    Jul 2008
    Posts
    2


    Did you find this post helpful? Yes | No

    Default tachometer

    Well here is my code, not much to it. Again I am complete novice and I think I'm trying to over simplify the code.

    'Program --- Encoder ---
    'Initialize variables

    symbol trisb = 134
    symbol portb = 6
    symbol pulse = w1
    symbol rpm = w0

    'Initialize trisb for input

    poke trisb, 1 'Set RB0 to input by bitweight

    'Start reading photo opt

    start:
    pulsin 0, 1, pulse 'Read high pulse off RB0, record to var. pulse
    rpm = 50/pulse 'Calculated rpm from pulse
    serout 1, n2400, (254, 1)
    serout 1, n2400, ("RPM = ", #rpm)

    goto start

    I was just reading a thread about the math capabilities of the 16F84 and I think I'm calculating something that is not compatible with the MCU. When I multiply the 50 and pulse I do get a result to the LCD. Of course the result is inverted from what I want but the basic code works. Not sure how to handle the decimal I guess is my problem.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    I think you've got the general idea, but the execution isn't the best.
    Check the COUNT command and let it count for a second, divide by how many slots are in the wheel, then multiply the result by 60. That should give you RPM. You won't get the best resolution, but the idea should trigger some better ideas for you.

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Count is what I was thinking too but I do not see it as an option in PBC
    http://www.melabs.com/resources/pbcmanual/
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Doh! You're right...
    Well, then, it's likely going to be a matter of setting up one of the timers on the PIC manually, waiting for a pulse, starting the timer, waiting for another pulse, then doing the math. For instance, running a 4Mhz PIC, set up a 16 timer running with no prescale. Set the timer to zero. Wait for a pulse, start the timer. Wait for another pulse, stop the timer. Read the timer and save the values.
    Assume you get a count of 1,000 from the timer registers and you've got 1 slot in the wheel. That means it took 1,000us to get one revolution (timer ticks at one count per us @ 4Mhz/no prescale). In one second, you get 1,000 revolutions. In 60 seconds, you get 60,000 revolutions.
    1,000,000 / 1000 = 1000 * 60 = 6000
    If you get 2,000us per pulse,
    1,000,000 / 2000 = 500 * 60 = 3000
    Problem is, PBC doesn't support anything over a word variable. So hopefully, the O/P can come up with some creative math to solve that problem.
    We'll see what happens...

Similar Threads

  1. Tachometer with DT Interrupts?
    By DanPBP in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th November 2009, 19:51
  2. Tachometer with Interrupts
    By serkanc in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 28th August 2009, 08:10
  3. PIC16F84A Tachometer LED routine
    By ThaSanta in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 24th July 2009, 02:58
  4. Wireless Tachometer - Design Help
    By DanPBP in forum Off Topic
    Replies: 2
    Last Post: - 3rd May 2009, 09:06
  5. Better way to drive an auto tachometer
    By skimask in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 22nd July 2008, 20:24

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts