Frequency Counter


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Location
    Merango, IL
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Bruce:
    Thank you I did forget to set up those two registers. I will fix that.

    Joe:
    I'm using a function generator on the input with a scope on it as well and there is no bouncing on the pin. In the end it will be from a hall effect switch which also should not have any bouncing.

    Ioannis:
    I believe PBP will do negative numbers, Location should never be a negative number anyways as 0 would be the lowest number of counts you can have it will be zero we it is set up.

    I think I'm going to try and use the internal timer which I haven't been able to work on it much as work has me burried. I did have some time to write out some code. I will post is below, if you guys would like to comment on it I would appreciate it. It might be a little chopy at the moment though.

    ************************************************** *****
    @ DEVICE PIC12F683, INTRC_OSC_NOCLKOUT
    @ DEVICE PIC12F683, WDT_ON
    @ DEVICE PIC12F683, PWRT_ON
    @ DEVICE PIC12F683, MCLR_OFF
    @ DEVICE PIC12F683, BOD_ON
    @ DEVICE PIC12F683, CPD_OFF
    @ DEVICE PIC12F683, PROTECT_OFF

    '* Hardware Setups *

    INTCON = %10001000
    PIE1 = %00000000
    PIR1 = %00000000
    OSCCON = %01110000

    '* I/O Pin Descriptions Below *
    '* PIN 1 - VDD - 5V *
    '* PIN 2 - T1CK1 - Input - Pulses from Hall Effect *
    '* PIN 3 -
    '* PIN 4 - GP3 - Input for the direction of the Hall Effect *
    '* PIN 5 - CCP1 - PWM Output to the Analog converter *
    '* PIN 6 -
    '* PIN 7 -
    '* PIN 8 - VSS - Ground *

    TRISIO = %00101000
    WPU = %00000000
    IOC = %00001000

    '* Timer Setup *
    T1CON = %00100111



    Location var WORD

    Mult_Count VAR BYTE

    Was_Low VAR BIT

    Pulse var gpio.3
    Direction VAR gpio.5

    Mult_Count = 0
    Location = 0
    Was_Low = 0

    PAUSE 500

    main:


    GOTO main
    end

    ************************************************** ***

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Asmith View Post
    Ioannis:
    I believe PBP will do negative numbers, Location should never be a negative number anyways as 0 would be the lowest number of counts you can have it will be zero we it is set up.
    Sure, PBP and assembly both will do negative numbers, but they won't show up the way you want them to...i.e.:

    5 - 6 = -1, but PBP will show 255 (for a byte variable), 65535 (for a word variable).

    You're going to want to add something like this to your program in post #4:

    main:
    IF Pulse = 1 AND Was_Low = 0 THEN
    IF Direction = 1 THEN
    Mult_Count = Mult_Count + 1
    ELSE
    if mult_count > 0 then mult_count = mult_count - 1
    ENDIF
    Was_Low = 1
    ENDIF
    ...............

    IF Mult_Count = -10 THEN(statement won't work the way you want it to in PBP)
    Location = Location - 1
    Mult_Count = 0
    ENDIF

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Asmith View Post
    Bruce:

    Joe:
    I'm using a function generator on the input with a scope on it as well and there is no bouncing on the pin. In the end it will be from a hall effect switch which also should not have any bouncing.




    ************************************************** ***
    It was worth checking.
    JS
    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.

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. Audio Frequency Counter
    By mister_e in forum Code Examples
    Replies: 8
    Last Post: - 29th July 2009, 08:25
  3. frequency counter help and pointers
    By comwarrior in forum General
    Replies: 2
    Last Post: - 30th June 2009, 11:51
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Frequency Counter using PIC and PicBasic
    By PICtron in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 28th January 2005, 06:20

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