Frequency


Closed Thread
Results 1 to 10 of 10

Thread: Frequency

  1. #1
    MICOCALI's Avatar
    MICOCALI Guest

    Default Frequency

    If possible read one frequency at 100hz with pbp and in wich mode

  2. #2
    MICOCALI's Avatar
    MICOCALI Guest


    Did you find this post helpful? Yes | No

    Default

    the frequency is 1000 hz +/-

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Yes you an do 1kHz very easily.

    As with all frequency measurements you have two choices...

    1. Meausre the Length of a Pulse

    Here you measure the lenth (in time) of the input signal... so for example you can use PulseIn, measure the Positive Going part of your cycle, then measure the Negative going part and add the two together. Another way would be to start a timer at the beginning of your first cycle, then stop the timer at the start of the next cycle. The timer will then tell you the length of the cycle.

    2. Measure the number of Pulses in a Set Time

    Using either an internal or external timer, you simply count the number of pulses received in one set time period. Here you can also use the Capture Compare feature of the CCP Module if your PIC has one (the PIC's Datasheet has all the setup details).

    I posted an Olympic Timer last week in the Code Examples section... it should take all of about ten minutes to trash that code and convert it to a simple direct-reading Frequency Counter as a starting point.

    Melanie

  4. #4
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    For a frequency of 1000Hz */- Count would be the easiest way:

    F VAR WORD

    Loop:
    COUNT PORTB.1,1000,F
    LCDOUT "Freq. = ", DEC5 F," Hz"
    goto loop

    See PBP Manual Section 5.10

  5. #5
    MICOCALI's Avatar
    MICOCALI Guest


    Did you find this post helpful? Yes | No

    Default

    WHEN THE FREQUENCY IS 1000HZ THEN SET PORT TO HIGH
    VERIFY IF THE COMMAND IS GOOD

    F VAR WORD

    LOOP:
    COUNT PORTB.1,1000,F
    IF F=1000 THEN,OK
    GOTO LOOP
    OK:HIGH PORTB.0
    PAUSE 1000
    LOW PORTB.0
    GOTO LOOP


    IS OK ?
    THE SIGNAL WICH AMPLITUDE 200 mvolt IS GOOD OR POOR SIGNAL?

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    200mV is inadquate for direct connection to a PIC - UNLESS you have built-in Comparators. Set your VRef to trip say at 100mV, use the option to feedback the Comparator Output to the pin you will be taking the measurements with Count. Refer to your PIC's Datasheet on how to do this.

    You have an error in your code... remove the comma from the line...

    IF F=1000 THEN,OK

    If you are using a PIC as a 1kHz detector... it's probably cheaper to use an NE567.

  7. #7
    MICOCALI's Avatar
    MICOCALI Guest


    Did you find this post helpful? Yes | No

    Default

    I KNOW NE567 BUT I DONT HAVE SPACE FOR THIS COMPONENT
    IF I AMPLITUDE THE SIGNAL WITH TRANSISTOR NPN ?

  8. #8
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Yes, you can use your NPN transistor. What PIC are you using?

  9. #9
    MICOCALI's Avatar
    MICOCALI Guest


    Did you find this post helpful? Yes | No

    Default

    PIC 16F628
    ONE QUESTION FOR THIS COMMAND I INSERT ANY DEFINE?

  10. #10
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    The COUNT Command has no defines itself, but relies on the correct DEFINE OSC statement that most of the other PICBasic time critical commands rely on.

Similar Threads

  1. HPWM command and oscillator frequency
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th March 2009, 22:41
  2. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th January 2009, 23:49
  3. HPWM10 Frequency Updating
    By duncan303 in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 19th January 2008, 12:30
  4. inaccurate frequency using TMR1 PI18F452
    By nkarpovich in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 14th October 2006, 16:22
  5. frequency measurement
    By big-x in forum General
    Replies: 2
    Last Post: - 25th November 2005, 00:53

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