PDA

View Full Version : frequency detector



grounded
- 5th December 2008, 14:38
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


'************************************************* ***************
'* 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

mackrackit
- 5th December 2008, 15:19
This might work for the amplifier. Can be used with a single power supply.
http://www.national.com/mpf/LM/LM324.html

grounded
- 5th December 2008, 17:22
thanks Mac are you thinking that, that is my problem?

Acetronics2
- 5th December 2008, 17:30
Hi, Grounded

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

Alain

mackrackit
- 5th December 2008, 17:35
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.

grounded
- 5th December 2008, 19:30
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.:D

timmers
- 5th December 2008, 22:05
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 (http://www.national.com/images/pf/LM1881/00915001.pdf) 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.

grounded
- 6th December 2008, 02:40
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 :confused:

fronkensteen
- 6th December 2008, 03:01
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 :confused:

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.