Composite video signal detector


Senior Member
This project uses a PICAXE to detect the presence of a composite video signal (CVBS) which is normally connected using a single RCA or phono jack ( usually coloured yellow ).

This is a proof-of-concept part of a larger project designed to control an auto-selecting video switcher so it changes the signal for a TV to a composite video input whenever it is connected but can also be used in its own right as a "video present" indicator.

Most auto-selecting video switchers monitor a signal on a SCART connector pin which goes high when the connected device is powered up but very few detect if an actual video signal is present. This circuit is the first step in generating such a signal which can control the SCART pin when composite video is present; here just a LED is lit to indicate that state.

A composite video signal, whether PAL, NTSC or SECAM, is usually around 1 volt peak-to-peak, with the blanking level at 0V, sync pulses going negative, black level being just above 0V and white level higher. The technique used here is to simply look for levels somewhat greater than 0V and take that as an indicator of video presence. To handle the low voltage an internal hardware comparator is used with the voltage to compare against selected internally.

The composite video passes through a 47K resistor to the comparator input. That is high enough to ensure there is minimal impact on the video signal itself and also helps minimise problems should the input pin inadvertently be set as an output. It may even be possible to increase this resistor value. The low current negative voltage sync signals will be clamped by the input pin internal diode but have little affect on the actual video signals due to the 47K. The resistor also protects the PICAXE from damage and being phantom powered if video is connected with the PICAXE powered off.

To ensure the input does not float when a signal is not connected a 100K pull-down is placed across the video signal input. This again is a high value to have minimal impact on the video signal itself and can be omitted if the unit the video passes to has a suitable input resistance to 0V.

Operation is simple; the comparator output will go high when the video signal is connected and somewhat greater than 0V. The comparator output is connected through to an output pin which can be used to drive a LED. So far we are using the PICAXE as nothing more than a hardware comparator with the program only configuring the internal hardware.

To cater for misinterpretation of the video signal, black levels being interpreted as lack of video signal, the PICAXE program monitors the state of the comparator output and sets the software "detected" output pin immediately video is detected but clears it only when there has been a lack of video for a while. When the video signal is disconnected the "comparator" LED will extinguish immediately and the "detected" LED shortly after.

While the initial circuit used a PICAXE-20X2 ( to cater for additional digital signal input and output to be added in the final project ) it can likely be modified for use with any PICAXE which has an on-chip comparator and suitable analogue input which feeds that comparator. Where there is no support for the COMPSETUP command ( as for the M2 range ) the comparator hardware will need to be configured using appropriate POKESFR commands as demonstrated with the code example for the PICAXE-08M2.



Senior Member
Or if you wanted a hardware solution some thing like this should work:
 |---->|-------to device
 |        |
 o        =
out       |
    0v o--'

>| is meant to be a diode
...although you probably wont be able to drive an LED with it.

Don't want to take the bounce from your bunge though hippy :) Great work
Last edited:


Senior Member
That would create a signal but how it would impact on the actual video signal I don't know, and it wouldn't drive the switcher which needs a signal greater than 4V. True, one can enhance it with an op-amp, probably even a transistor, so it's a worthy alternative.

Of course you can't beat a PICAXE for adding capabilities above and beyond the basic functionality. One thing I've noticed with auto-switchers is they tend to switch to the last device powered-on where I want a priority system with auto fall-back, and composite video override so it's quick and easy to plug-in 'junk' from bootsales to check it works. And I can change things if I find I don't like the functionality I've created !


New Member
Hi Hippy!

Great article! It is somewhat working on my setup but not 100% how I need to. I would like to ask you for a little help with modifying your program file for 08M2.

I would like to
1) change ReadADC to pin C.1 (but don't know how to... it will be trickier than to simply rewrite "ReadAdc 4, b0" to "ReadAdc 1, b0", right?)
2) Instead of having output led that turns on/off, I would like to tell Picaxe to low pinC.4 after 5 minutes of no signal detection
3) Can I make it more sensitive? In order to light up Video Detected Led, the volume coming from the amplifier needs to be almost at max. I would like to make it as close to lowest volume/noise as possible.

Sorry to ask you these but this is way too much advanced stuff for me and all those SFR's and bit magic looks to me like Chinese letters :) I don't even know what I am looking at. The only part I am able to comprehend in the code is the Do -> Loop section by the end.

Thank you!


Senior Member
Welcome to the PICAXE forum

1) change ReadADC to pin C.1 (but don't know how to... it will be trickier than to simply rewrite "ReadAdc 4, b0" to "ReadAdc 1, b0", right?)
Yes, the program relies on using an internal comparator and the pins for those are fixed by the hardware. The READADC simply ensures the pin is configured for analogue rather than configuring anything else.

The PICmicro datasheet shows it should be possible to use C.1 for the comparator input but I am not sure exactly what would have to change for that. It may simply be that CM0CON1/CM0CON2 can be used instead of CM1CON1/CM1CON2.

2) Instead of having output led that turns on/off, I would like to tell Picaxe to low pinC.4 after 5 minutes of no signal detection
That should just be a case of giving the 'timeout=100' a larger value to extend the 'turn off' time. If 'timout=65535' is too short one would have to add additional variables to allow a longer timeout to be achieved.

3) Can I make it more sensitive?
Possibly. The sensitivity is set by the "b0=%00010 : PokeSfr DACCON1, b0" commands. You can try "b0=%00001". You might be able to use "b0=%00000" but that may not work, cause false detection, or may require the DAC ladder configuring differently.

You could use the DAC ladder driven from the FVR rather than V+, or even from an external Vref.

the volume coming from the amplifier needs to be almost at max.
Are you trying to use this with an audio amp rather than a video signal ? If so it may be that the signal is just too low for the comparator the way it is setup for video signal.

Or it could be the nature of the signal, the code simply not suitable for the AC nature of audio where video is more DC-like.


New Member
Hi Hippy,
thank you for your fast reply!

I was playing with the sensitivity and ultimately fried something inside Picaxe - perhaps comparator itself. both leds now stay on no matter how loud or quiet signal gets. When I download other program to test pins (pwm or simple high/low C.2....) leds flash. But your program does not work as it should anymore - I would say hardware problem. So new Picaxe is coming and so far I am at square one. I just don't know how to tell Picaxe "when song stops playing (from bluetooth module), go to sleep after XX minutes.


Senior Member
Hi Hippy,

If you don't mind adding 1 IC, why not use the LM1881 Video sync seperator IC?

It accepts compostite video in, and generates composite sync out, vertical sync out, odd/even outputs etc.

These would be very valid signals to feed into a picaxe for the confirmation of "real" video presence.

just a thought ;-)


Senior Member
Using the right tool to do the job would always be the best way forward. This was more a project to see if it could be done 'on the cheap' using a PICAXE and the components I had to hand.

The original project came about because I had a composite video switcher to handle a variety of AV devices which I had to manually change and wanted the PICAXE to press the appropriate buttons for me when something was turned on or off. That would require multiple LM1881 to do it properly.