Go Down

Topic: Interfacing with an NTSC TV (Read 4 times) previous topic - next topic


DrWho, both the medium res version I posted to the forum and the Pong mod I posted to the dailyduino can VERY easily be modified to take inputs etc.   Just put whatever you want in the loop routine (the loop routine is just an example).  Because the vertical refresh is interrupt driven you dont have to worry about timing in any code you add.  The only limitation is that loop doesnt get very many CPU cycles and the bitmap uses a bunch of RAM.  

FYI I havent gotten around to coding the "High Res" version, but I have it worked out how to double the pixels again.  It shouldnt take any more RAM than the existing code.  If anyone wants to try it I will outline the changes that need to be made.


I'm the chap behind the Batsocks TellyMate Shield.

@bill2009 - you might find that the circuit shown at the top of this thread isn't quite giving you the voltage range you expect because the TV has an (equivalent of) a 75ohm resistor within it. This forms a voltage divider with the other 75ohm resistor (shown in the circuit at the top of the thread) giving a 0.5v p2p signal, rather than the required 1v p2p.

I've found much better results without the 75ohm resistor in the circuit. Whites are white, rather than grey.

Having said that, on the more recent design of the TellyMate Shield, I've added a jumper (J7) to optionally connect this 75ohm resistor back in, because I found a small portable telly that wouldn't work otherwise.

(See this thread over at AVRFreaks)

@doctorwho8 - There shouldn't be any real problems in reading input to display, but you'll have to bear in mind that you won't be able to use interrupt driven methods because the interrupt routines will interfere with the timing of the sync and display signals - e.g. you don't want a 'USART_RXC' (serial received) interrupt called part-way through outputting your pattern!

@drspectro - I'm interested in the 'High Res' version!


Rough outline of hi-res

The original Pong video used the low 2 bits of a 38 wide by 14 high array.

medium res demo used the low 4 bits (2 at a time) of a 37 by 16 arrray.  Uses two copies of the 2 resistor D2A converter but only ONE D2A converter is really active at any time.  By bit masking the for loop index, we step through the array twice.  The first time we enable the low two bits    (0-1) of PORTC using the DDRC command.  The second time we enable the bits (2-3 ) using DDRC.   The DDRC command is a single and runs after each scan line so you dont get jitter halfway down the screen.

High Res (proposal)
Eliminate the grey tone.  Black and white only.  Instead of two copies of a 2 bit D2A, we use 4 (or8) one bit D2A converters (330 ohm resistor).  If you use all 8 this ties up all 8 bits of PORTB.  We use one bit from another port to drive a 1K resistor to get "black level" when all 9 bits go low that is blacker than black.

Finally we make the frame buffer roughly 60 bytes wide by 8 bytes high and loop through it 8 times (4 for square pixels) enable a different bit each time with DDRC. The loop logic is REALLY funky, but you can see it work in the medium res demo.

The big problems are
1) If you use all 8 bits of PORTB you loose hardware serial (could reduce vertical res and use a 6 bit port - needs thought here)
2) the DDRC mask logic has to take a constant amount of time.  Currently its an if/else but 4 or 8 options is hard to make constant time.
3) The logic for looping through the array multiple times is a bit confusing (well REALLY confusing).
5) it might be better to use only the low 4 bits and keep the high 4 for a working copy of the bitmap (thats how medium res works).  4 line pixels vs 8 line pixels depending on how you count it.
6) Sync line ties up another digital out line.
7) All the Pong type video programs depend let horizontal sync drift during the vertical sync period, it works but causes that top of the screen jitter.  Looks like you keep sync tighter in Batsocks????


[font=Times New Roman][size=14]
One of the things I forgot to mention below is that I am running on a
Arduino Duemilanove http://arduino.cc/en/Main/ArduinoBoardDuemilanove

So I suspect that something will need to be changed to accomodate this board as opposed to the ones you are using for this great idea. As for what that is, I am not sure. I am getting great smears of black and white color patterns on this set.

Time only stands still for an appointment.


Drwho8 - I am running on a Duemilanove also.

I agree with Condemmed, try removing (or increasing) the 75Ohm resistor.  There are a couple of versions of the 3 resistor D2A converter around, you might try a different one.

I guess the fact that you are getting some grey and colors indicates you are in the ballpark for voltage levels.  Unlike XSmurf who isnt really getting anything.  Yours sounds more like timing problems.

If you load the stripped down Pong example from the DailyDuino link I gave earlier I can tell you where you can tweak the timing.  I couldnt tell which code you had downloaded earlier.  Basicly there are a couple of dummy instructions at the end of line , the  "PORTB=PORTB" statement.  Add or remove these ONE AT A TIME.

The vertical refresh is set by the "FrequencyTimer2Init", but I think it is as close to the correct value as the hardware will support.  You can change the vertical refresh by changing the timer2 value.  NOTE - the timer2 code rounds your selected time to a value the timer can actually do.  You can ask for a more accureate 58.x hz time, but the timer probably will round it for you...

Condemmed -
I think it would be possible to make the vertical more accurate by halting the timer for a couple of NOP instructions then restarting it each frame. (possible, not easy..)  

Go Up