frequency detector


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2005
    Location
    down south
    Posts
    90

    Default frequency detector

    A few months ago I built a VCR controller using a NE567 and a 12f629 when the ne567
    locks on the line frequency in the video(This horizontal frequency is around 15.750khz )
    it give a input to the 12f629 and it starts and stop the VCR recording. which works get.
    BUT
    I was wondering could I use the count command to detect the 15.750khz and not use
    the NE567. so I wrote a little code and hooked it up to my LCD demo board and nothing.
    it does not detect the frequency. I'm think the code is OK but maybe the aptitude of the
    video signal is to low and maybe need amplified. I don't have a scope so I not sure.
    If you think that maybe the case how can I make a simple amplifier to boost it
    any help thanks

    Code:
    '****************************************************************
    '*  Name    : freq count.BAS                                      *
    '*  Author  : grounded                                    *
    '*  Notice  : Copyright (c) 2008 homemade stuff   *
    '*          : All Rights Reserved                               *
    '*  Date    : 12/2/2008                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
     pic16f676
        'FUSES SET IN INC FILE
     'INTRC_OSC_NOCLKOUT, WDT_ON, MCLR_OFF,
    'CPD_OFF, BOD_OFF, PWRT_ON,PROTECT_OFF   
      DEFINE OSC 4
      Define OSCCAL_1K 1						
    Pause 3000                   	 ' Allow pic to Stabilize	
    
    CMCON = 7                        'COMPARATOR OFF
    VRCON = 0                        'VOLTAGE REF. DISABLE	
    TRISA = %0000110                 'MAKE PORTA.2  INTPUTS(.3 MUST BE INPUT) 
    TRISC = %00000000				 'MAKE ALL PORTC OUTPUTS
    ANSEL = %00000000                'PORTA. DIGITAL
    SYMBOL LED= PORTA.5              'POWER UP LED
    SYMBOL FI=  PORTA.2               'FREQ IN
    SYMBOL LP=  PORTA.0 
    OPTION_REG.7 = 0                 'ENABLE WEEK PULLUPS (CLEAR RAPU) 
    WPUA = %0000000                  'NO WEAK PULLUPS ON PORTA 
    LED=0
    DEFINE CHAR_PACING 1000
    DEFINE LCD_DREG PORTC         ' Set LCD Data PORTC
    DEFINE LCD_DBIT 0             ' Set starting Data BIT (0 OR 4) IF 4-BIT bus
    DEFINE LCD_RSREG PORTC        ' Set LCD Register Select PORTC
    DEFINE LCD_RSBIT 5            ' Set LCD Register Select BIT PORTC
    DEFINE LCD_EREG PORTC         ' Set LCD Enable PORTC
    DEFINE LCD_EBIT 4             ' Set LCD Enable BIT PORTC.3
    DEFINE LCD_BITS 4             ' Set LCD bus size (4 OR 8 bits)            
    DEFINE LCD_LINES 2            ' Set number of lines ON LCD
    DEFINE LCD_COMMANDUS 2000     ' Set command delay time in us
    DEFINE LCD_DATAUS 50          ' Set Data delay time in us
    LED=0 :FI=0 : LP=0             'TURN EVERTHING OFF
     LED=1 :PAUSE 2000 : LED=0    'POWER O.K.
     
     F VAR WORD :F=0
    
    Loop:
    COUNT FI,1000,F
    LED=0
    LCDOut $FE,1
    LCDOUT "FREQ  ", DEC5 F," Hz"
    IF F=>15000 AND F=<17000 THEN LED=1
     goto loop
    " be nice it's people like me that make people like you look smart"
    yes I read the datasheet, of the 300 pages I understood 10

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    This might work for the amplifier. Can be used with a single power supply.
    http://www.national.com/mpf/LM/LM324.html
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Aug 2005
    Location
    down south
    Posts
    90


    Did you find this post helpful? Yes | No

    Default

    thanks Mac are you thinking that, that is my problem?
    " be nice it's people like me that make people like you look smart"
    yes I read the datasheet, of the 300 pages I understood 10

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink

    Hi, Grounded

    AS you have comparators aboard ... you could use their interrupt and one of the timers ... should work also with the '629

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by grounded View Post
    thanks Mac are you thinking that, that is my problem?
    Yes, The signal would need to be around 4 volts for the pic to detect it.
    Alan has a good solution too.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Aug 2005
    Location
    down south
    Posts
    90


    Did you find this post helpful? Yes | No

    Talking

    think to you both.
    I'm a little green this stuff and have never used the comparators part of these
    little big boy toys. (and gals) so I will start learning what I can. if there is anything that yo care to share on the matter I'm all ears.
    I'm just a hobbyist and enjoy learning from this forum and I'm trying hard not to be a pain in the butt.
    " be nice it's people like me that make people like you look smart"
    yes I read the datasheet, of the 300 pages I understood 10

  7. #7
    timmers's Avatar
    timmers Guest


    Did you find this post helpful? Yes | No

    Default

    Hi,

    The PIC lives in a digital world where evrything is between 0v and 5v. Video lies in the analogue world, a strange and wonderful world it is too... But everything in analogue video does not live within the 0v to 5v parameter.

    Video feeds are often AC coupled through a capacitor and require an amplifier and a DC clamp circuit before they can be sampled. Easiest way to interface to video is to use a dedicated sync seperator which can perform all the analogue processing and output into the digital domain. Take a look at National LM1881 for example.

    PAL video sync is 300mV with the video sitting a further 700mV above that. Total amplitude is 1v peak to peak. The sync is a composite sync containing short pulses for line sync, longer pulses for frame sync and equalising pulses between the two. There is a good description of video sync structure in the LM1881 data sheet.

    Tim.

  8. #8
    Join Date
    Aug 2005
    Location
    down south
    Posts
    90


    Did you find this post helpful? Yes | No

    Default

    thanks
    so it data sheet, Google and print PDF time.
    like I said using the NE567 work fine just thinking it would be easy todoall with 12f629 but look a lot more than I thought
    any search tips?
    thanks as always
    " be nice it's people like me that make people like you look smart"
    yes I read the datasheet, of the 300 pages I understood 10

  9. #9
    fronkensteen's Avatar
    fronkensteen Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by grounded View Post
    thanks
    so it data sheet, Google and print PDF time.
    like I said using the NE567 work fine just thinking it would be easy todoall with 12f629 but look a lot more than I thought
    any search tips?
    thanks as always
    You want just the 15.75Khz signal and you're trying to count just that 15.75Khz signal to detect the presence of a video signal.
    One of the problems is the fact that there's a lot more going on than just that 15.75Khz signal, so you're probably counting a heck of a lot more than just that.

    Maybe add a fairly tight bandpass filter in front of your input/amplifier and see what happens.
    Mostly though I think I would put an o-scope on the input pin and see what you actually looking at.

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. HPWM10 Frequency Updating
    By duncan303 in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 19th January 2008, 12:30
  3. How do I convert an internal variable into frequency
    By schlaray in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 13th February 2007, 07:26
  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 : 1

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