Frequency Counter using PIC and PicBasic


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    you can do something like that too. BUT you must consider the time you get out of counting and do the math with your variable + return to the counting stuff and such. And more if you're using PAUSE 1000, it will never interrupt before the PAUSE statement has finish. That come bigger and bigger then?!?!

    To do that, in software, you'll need at least 1 timer and 1 counter. Let's say we gonna use TIMER1 as 1 sec time-base and TIMER0 as counter. See datasheet for that.

    OR More simple, use a external 1sec time-base and do the count untill you're time-base tell you to stop.

    IMO, the easyest way is to begin with a sampling time of 1ms, checking if there's any result, if not, redo with a higher sampling time, testing the overflow and result if it's not what you expect, redo with a higher sampling time, testing the overflow and result .... utill you have 1Sec sampling time or expected result.

    so it could be as propose 1ms, 10ms, 100ms, 1Sec

    don't forget timer will gives count a max of 65536. This is why if your sampling time is 1 sec = max frequency 65.536 KHz.

    frequency = pulses / secondes

    where 65.536 KHZ is 65536 pulses / secondes.
    Last edited by mister_e; - 27th January 2005 at 20:48.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. using AND as an IF statement
    By dw_pic in forum mel PIC BASIC
    Replies: 27
    Last Post: - 8th June 2006, 18:05
  2. Need help deciding = BASCOM 0r PICBASIC
    By Chris DeHut in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 26th January 2006, 16:38
  3. Replies: 22
    Last Post: - 12th July 2005, 17:39
  4. Pic To Pic Serial Communication?
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 5th February 2005, 00:59
  5. PicBasic Fundamentals
    By Billyc in forum General
    Replies: 9
    Last Post: - 4th May 2004, 10:04

Members who have read this thread : 0

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