Problems/Confusion with composite video out

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

I'm hoping someone can clear up some confusion for me. I've been hammering away at my AVR (ATMEGA328 @ 16Mhz) for a few days now in a vain attempt to achieve video output with it (just greyscale). I've researched the topic thoroughly, reading almost any article I can find on the subject, including the ubiquituous articles of Rickard Gunee and the fairly comprehensive notes at Batsocks (home of Tellymate).

I believe my lack of progress is related to my lack of understanding of a few fundamentals.

Firstly, I had believed that I could get some sort of image on the screen (e.g full white or full black) just by sending accurate h-sync pulses followed by an output at white or black level. Is this correct, or do I need to account for anything else? For example, considering the ~12uS blanking period; how much of this do I need to account for? Should you always set the front/back porch at the beginning/end of each line regardless? Are these pulses always at black level? I understand the difference between "blanking" and syncing, but am confused as to how they both relate to your average scanline.

I've written a very simple program in assembly that has a timer interrupt that fires at the beginning of each scanline (~64uS), the timer ISR simply sends a sync pulse (4uS), followed by an 8uS backporch (don't really know what I'm doing here, just making up the total 12uS "pre-picture" part of each line). Then, during the main program loop, I just output at white level until interrupted again and so on.

I'd have expected to see a plain white screen by doing this, but instead I have two grey bars (picture attached) that jitter slightly. The bars actually seem to be my sync/backporch pulses (the second is almost exactly twice the width of the first), which I'd have expected to be off-screen. Also, as it may not come out perfectly in the image, the rest of the screen (allegedly at white level) is a pale grey.

In terms of hardware, I just have a 1K and 470 ohm resistor connected up to the TV and to sync/video pins on the AVR respectively (the setup is identical to the Arduino TV-out schematic). In case I'm making a mistake here, I'm just setting both to low for sync, the 1K path to high for black level and both high for white level. No matter what I do, I can only get shades of grey on the screen.

It's obvious I'm doing something seriously wrong, but the more I read on the subject, the further it seems I'm getting from actually seeing it work. Obviously something is working right, as my TV actually sees the pulses as a video signal, albeit a messed-up one (my early attempts were merely a case of the endless "No Signal" message).

If possible, would someone please be kind enough to outline the exact procedure I need to follow to get a minimal display working. By minimal I mean something along the lines of:

- No need for v-sync initially
- Just the ability to draw white/black horizontal bars
- Is acceptably jitter-free

I'm not asking for a complete code example or anything, just the steps that need to be taken, especially accounting for the blatant gaps in my knowledge.

Hopefully this post makes some sense.
Thanks in advance.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did that once. Have a look at this page, it's very useful:
http://www.rickard.gunee.com/pro...

I bet you could even port the assembler code to AVR.

/Jakob Selbing

Last Edited: Mon. Mar 25, 2013 - 09:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Search out the work of AtomicZombie. You need your vsync, back and front porch and hsyncs. If you want simple, just code a big loop that uses delays to time everything.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Should you always set the front/back porch at the beginning/end of each line regardless? Are these pulses always at black level?
Yes and yes (though I would not call them pulses).
Quote:
just by sending accurate h-sync pulses followed by an output at white or black level
Well, you also need v-sync.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Part of the problem could be related to the voltage levels.

I am assuming you are talking about RS-170 video, but this is true for other video standards as well. The RS-170 standard specifies that sync is negative going... below 0 volts.

Without that negative going signal, the TV set never syncs, or syncs rather haphazardly.

Consumer grade televisions often do not play well with this, while a studio grade monitor, and most 'security grade' monitors, might be very happy with it, because they have circuitry designed to clamp the signal to around -.5 volts.

Gawd! Am I really showing my age with this?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You might also want to take a look at http://code.google.com/p/arduino-tvout/ and http://playground.arduino.cc/Main/TVout

Note that, even if you get your code to do the right things, not all composite video monitors will (as @mikericetga has said) "play well". Although the vast majority of modern monitors will have no problem with the resulting signal, it is not truly compliant with NTSC (or PAL, if that's what you're going for). I'd suggest that, before you bang your head against the wall too much, you confirm that the monitor with which you are testing is capable of displaying this signal. Try out an existing project like the one above, or any of the others mentioned in previous posts.

JJ

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mikericetga wrote:

The RS-170 standard specifies that sync is negative going... below 0 volts.

Not true.

Sync does go negative BUT it is measured relative to the Black Level.

Most monitors have AC coupled inputs anyway so the concept of absolute negative or positive is meaningless.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Search out the work of AtomicZombie.

Specifically this:

http://www.lucidscience.com/pro-...

Though it's true that is generating VGA not composite.