Video "sensing" Switch

I just ordered my Arduino Mega 2560 (I haven't recieved it yet) I am looking to create a circuit to sense when a composite, s-video, or component is active.

I am using this chip to switch video lines http://www.fairchildsemi.com/ds/FM/FMS6501.pdf

I have read up a bit on video signals and it seems (and I may be wrong) that they output about 1 volt max normally, but I am unsure of how to check the line without degrading the signal.

the chip I am using (FMS6501) has a gain which you can set to 6dB, 7dB, 8dB and 9dB. It also has bias and clamp, but to be honest I am not 100% of what those are for.

so currently I am simply splitting the input on both the FMS6501 and the arduino, but I am afraid of degradation should I use some sort of IC or component to split the signal? or since there is a variable gain, can I simply split it and check if it is high, if so, I will use I2C to set the correct register to switch the video... does the split to test the line need a diode or resistor?

My goal is to keep the video at best quality possible, and check if video is coming through. Anyone with video input experience could chime in, that would be awesome. Thanks.

edit: also, here is my simple diagram idea:

I know it says picaxe, but that is just a place holder for some programmable ic, I am attempting it with arduino first.

LM1881

pardon my ignorance, but how would this device be used (as I am still learning) in my situation. I am trying to read the datasheet and understand, but failing miserably. Just a simple idea of how it would work would push me a long way. I see the sample diagrams, but they are using completely different components, I can try using them, do you think that would work better?

thank you for the response.

edit: after staring at the examples for a bit, I have come to realize what the diagrams are doing, but I am still not sure what the point of the LM1881 is, I mean, say I have it on every line, but all I will be doing is putting the sync output to my arduino and checking if it is hot, and if it is, then control my switch, is there another reason I am missing for the LM1881?

it seems to me they are simply doing the switch logic with gates instead of my idea of using an arduino, so is separating the signal required to figure out if a line is hot or not? or just recommended?

Sorry for all the questions, I am just trying to understand what I am doing. :-D

krum110487: how would this device be used

I've never used it so I may have got the wrong end of the stick, but it seems to be a chip that outputs a frame sync pulse each time it sees a frame. So if you see the pulse, you know the video source is active. Isn't that what you're trying to achieve?

It outputs both horizontal frequency 15.734 kHz and vertical frequency 59.939 Hz, both are kind of pwm signal. Just flip a coin to select which one you like to work with.

PeterH: I've never used it so I may have got the wrong end of the stick, but it seems to be a chip that outputs a frame sync pulse each time it sees a frame. So if you see the pulse, you know the video source is active. Isn't that what you're trying to achieve?

well I guess my main question is what is the point of LM1881 chip in my project?

PWM signal vid in ---> LM1881 ---> One of the two PWM sync signals ---> Arduino

then the arduino can check the input for values?

Compared to: PWM signal vid in ---> Arduino

am I missing something?

Thanks so much!

Did you call it PWM signal ?

ah, see this is where my lack of knowledge of electronics comes into play. :grin:

ok, does this mean you cannot test that signal? which means I would need a pwm signal to be able to tell if it is active?

question part 2, how would one test a pwm signal? in my mind, you would take a short sample and see if there are any high points.

Also, I assumed the video signal was pwm, because I tried searching google, and I couldn't find a name, and that was the closest I could figure :~

Arduino Demo: PWM Input

http://www.instructables.com/id/RC-Quadrotor-Helicopter/step12/Arduino-Demo-PWM-Input/

I think this is the last question I have on this subject (at least for now):

can I only read pwm from the 15 pwm pins on the arduino?

I know this seems like an obvious answer, but I am not reading them for data, I just want to check if a signal exits and there may be more than 15.

(if I sound like I am new to this, it is because I am XD)

Thanks.

krum110487: can I only read pwm from the 15 pwm pins on the arduino?

Different types of Arduino have different numbers of pins, but on all of them the PWM pins are digital I/O pins which are capable of generating a PWM output in hardware. They don't provide any special capabilities for [u]reading[/u] a PWM signal.

I'm really confused by this thread now. Where did the PWM discussion come from? Is this a separate requirement to the video signal detection?

AWOL: Where did the PWM discussion come from?

I did, since host was not in house yesterday, we have party time. :P

I use "kind of pwm signal", which is not 100% accuracy and should be hsync and vsync signal and LM1881 only give vsync signal.

AWOL: Is this a separate requirement to the video signal detection?

We, if I understand Peter correctly, just help OP understand your solution.

The nice thing about using the LM1881 instead of just measuring >0.3 <1.0V is it’s checking if you have a valid video signal and not just some random line voltage. If the signal is valid it will mark frames/fields for you. You can even measure fields over a fixed time and determine if the signal is NTSC or PAL.
Used these things several years ago in a PIC project that read and decoded Sony LTC audio track and compared it to the frame count coming from the LM1881 so we could detect timecode discontinuity (an occasional problem when picking up a recording using some Sony digibeta camcorders.

Riva:
The nice thing about using the LM1881 instead of just measuring >0.3 <1.0V is it’s checking if you have a valid video signal and not just some random line voltage. If the signal is valid it will mark frames/fields for you. You can even measure fields over a fixed time and determine if the signal is NTSC or PAL.
Used these things several years ago in a PIC project that read and decoded Sony LTC audio track and compared it to the frame count coming from the LM1881 so we could detect timecode discontinuity (an occasional problem when picking up a recording using some Sony digibeta camcorders.

This explains a lot, and it makes sense. So to prevent false positives it is a good idea to use LM1881.

PeterH:
Different types of Arduino have different numbers of pins, but on all of them the PWM pins are digital I/O pins which are capable of generating a PWM output in hardware. They don’t provide any special capabilities for reading a PWM signal.

so I guess my confusion stems from not knowing if you needed a special type of pin to read and check the pwm signal (analog or digital) coming from the hsync or vsync. So just to be clear, any digital pin can be used to read the hsync or vsync signal?

AWOL:
I’m really confused by this thread now.
Where did the PWM discussion come from?
Is this a separate requirement to the video signal detection?

Well that was part of my question, as to why I needed to get the hsync and vsync to detect a video signal, instead of just checking the voltage, which I believe Riva has answered for me. Mostly it is just my confusion of signals and which pins can read or be used with certain pins, or if they are restricted or not.

krum110487: So just to be clear, any digital pin can be used to read the hsync or vsync signal?

If you have a TTL level signal that changes slowly enough for the Arduino to detect it by polling then the Arduino can read it on any digital pin (and also on any analog input pin).

If the signal is fast enough that you can't read it reliably by polling and are forced to use interrupts then you need to know that some types of interrupt are only supported on specific pins.

ok, so on the topic then Reading the LM1881 hsync signal output, would I use a simple pulsein, it seems right to me at least it would make sense. I just test the pin for a signal, if I get a pulse even 1, it is active, otherwise it will timeout and return 0?

http://arduino.cc/en/Reference/pulseIn

could it be that easy?

also, I got my arduino in the mail today, once I order a couple LM1881's and the required diodes and components, I will start tinkering with it!

You could use pulseIn(), but it would mean blocking your sketch for the length of the frame in order to measure the pulse length - and I don't think you actually care about the pulse length.

If it was me I'd find out how long the pulse was and what frequency it was expected at, and decide from that whether it was practical to poll for it or use an interrupt to detect it.

If your sketch has nothing else to do at all you may be able to get away with polling a digital input to wait for the pulse. Using interrupt is slightly more complex, generally only works on specific pins, and has the advantage of being (if you choose) edge-triggered, making pulses harder to miss.

polypagan: If your sketch has nothing else to do at all you may be able to get away with polling a digital input to wait for the pulse. Using interrupt is slightly more complex, generally only works on specific pins, and has the advantage of being (if you choose) edge-triggered, making pulses harder to miss.

my diagram is pretty much all I want to do with the line, all I have to do is detect a signal, the rest of the code will be used to send signals over the I2C bus and switch the video according to what is on or off.

PeterH: You could use pulseIn(), but it would mean blocking your sketch for the length of the frame in order to measure the pulse length - and I don't think you actually care about the pulse length.

If it was me I'd find out how long the pulse was and what frequency it was expected at, and decide from that whether it was practical to poll for it or use an interrupt to detect it.

by blocking your sketch, you mean the code on the arduino will have to wait on the function to finish correct, which is true, I don't care about the pulse length, but if I find interrupts too hard to understand as an electronics beginner, hsync is very short each pulse, and would be ideal for a test solution.

After reading around, it seems an interrupt is ideal for what I want, it pauses the code where it is at to run the interrupt code, which would work great, except from what I have read it seems there are only a few interrupt pins, is this true?

I will need at least 8 interrupt pins in my project, more is preferable, but I am starting small.

would it be more feasible to transform the pwm much like this one is doing: http://www.ti.com/lit/ds/symlink/lm1881.pdf (Figure 10, page 9)

I am not sure HOW they accomplish it (as I don't understand it all, while I do understand logic gates pretty well) they seem to be controlling the transistors in the CD4066BC. I am not sure how they negate the pulse wave, possibly with the capacitor? if someone could explain how this diagram is working, I think I can mold it to my needs fairly easily.

Edit: I have attempted to run through the diagram and the ic's diagrams, and I am having a terrible time of keeping track of flip-flops with nand gates.