Voltage "scaling" for digital Arduino port?

Hi people,

i am sorry, this is a really noob question, but still i couldnt find a simple answer to this...

i am trying to read the V-Sync signal of a VGA adapter with my arduino uno, in the first step to sync an LED to the framerate of a camera (using an HDMI to VGA converter). so i checked the V-Sync out of the adapter - I think the sync signal is usually supposed to have 5v, but according to my oscilloscope, this particular cheapo adapter is rather outputting a 2.5-3v peak. So i guess to get the digital port to register the sync correctly, i need to amplify the 3v to 5v, right?

my wild guess is, that i'd use a transistor to do that, correct? or is there a simpler way? the other question is, how do i find the correct transistor for that purpose?

thanks for the patience, t.

Maybe a voltage comparator would be easier.

Ok, so i read up that suggestion:

Note that the voltage level for both the positive and negative output voltages will be about 1 V less than the power supply. Thus, if the op-amp power supply is 9 V, the output voltage will be +8 V if the input voltage is greater than the reference voltage, 0 V if the input voltage is equal to the reference voltage, and –8 V if the input voltage is less than the reference voltage.

http://www.dummies.com/how-to/content/electronics-components-how-to-use-an-op-amp-as-a-v.html

so, since the sync signal on the vga out is oscillating between 0 and 2.5 volt, could i use 0v (nothing connected) as the reference voltage of the voltage comparator? and, wouldnt i need 6v to power the IC, to get to the 5v needed by the digital arduino port, correct? it would be comfortable to just use 5v from the arduino itself, what voltage is exactly needed to switch a digital port from low / high?

and would the LM393 be the right part for this?

Strictly you dont need to amplify your sync signal. You just need to ensure the voltage level shift will also shift the digital input on your Arduino.

This is done using a transistor as a simple level converter. The collector of transistor goes to digital input, emitter to ground. A series resistor of 10K on the base would do, this is where you connect your sync signal. Then program the Arduino pin as input with pull-up, making the pull-up resistor a collector resistor for your transistor.

It has only one minor snag : Whenever you apply a high level sync pulse, the transistor will pull the Arduino pin low, effectively inverting your sync signal. Then you simply look for an active low in your Arduino sync program.

Any small NPN transistor will do, like the common 2N2222.

Why is inverting your signal a snag?

A sync signal is -ve going anyway so the code should look for a high to indicate a sync pulse.

am i correct in the assumption that the difference between the "voltage comparator" and the transistor approach would actually be, that the voltage comparator would "enhance" a sloppy square signal (and the signal definitely looks very sloppy and not at all square on my admittedly very bad oscilloscope) and make it cleaner, while the transistor is just a "helper" to get the digital pin triggered?

in this particular example i am fine with the latter approach. just trying to understand.

another thing about transistors. given my example, how do i choose the correct transistor for the job. not to be ungreatful to the 2N2222 reference, just for future projects?

am i correct in the assumption that the difference between the "voltage comparator" and the transistor approach would actually be, that the voltage comparator would "enhance" a sloppy square signal (and the signal definitely looks very sloppy and not at all square on my admittedly very bad oscilloscope) and make it cleaner, while the transistor is just a "helper" to get the digital pin triggered?

No both would increase the sharpness of the signal.

how do i choose the correct transistor for the job.

You look at the requirements of "the job" and choose a transistor that matches that. Things like maximum current, gain and collector emitter voltage.

but according to my oscilloscope, this particular cheapo adapter is rather outputting a 2.5-3v peak.

Was that open circuit? Most VGA signals are designed to be correct when terminated by 75 ohms, so open circuit they are often a lot higher. Measure the voltage with the correct termination.

Is what you really need an LM1881?