TVout Color - NTSC [upped new code - Oct. 04]

Hi !
I have tried to generate NTSC color signal with an Arduino and some registers.

Hardware
https://picasaweb.google.com/117534855759200010314/ArduinoTVoutColorNTSC#5870797060544309458
Display 7 colors
https://picasaweb.google.com/117534855759200010314/ArduinoTVoutColorNTSC#5870799542950661026
The signal at 7 colors
https://picasaweb.google.com/117534855759200010314/ArduinoTVoutColorNTSC#5884519987867834162
Simulation for registers select
https://picasaweb.google.com/117534855759200010314/ArduinoTVoutColorNTSC#5870801524748013842
Colorburst signal
https://picasaweb.google.com/117534855759200010314/ArduinoTVoutColorNTSC#5884519959081339202

The code to generate Colorburst signal is written by assembly language like this.

#define OutBurst\
        "out 0x08,r18\n\t"\
        "out 0x08,r19\n\t"\
        "out 0x08,r20\n\t"\
        "out 0x08,r21\n\t"\

void CINT::SP_Txt( UH AddrGRP, UB Mode, UB Color )
{
    __asm__ __volatile(
        "mov r24,%2\n\t"        // r24:select color
        "mov r25,%1\n\t"        //                                          |
        "ldi r18,0\n\t"         // -40IRE                                   |           //V-Sync
        "out 0x08,r18\n\t"      // output H-Sync level (-40RE/0V)       +---+   //H-Synch 4.7us:67cycle
        "cpi r25,2\n\t"         // V-sync timing?   1cycle              |       1       1
        "brne NEXT\n\t"         // if not V-sync    1cycle/2cycle       |       2,3     1
        "jmp EXIT2\n\t"         // now V-sync
"NEXT:"
        "ldi r23,7\n\t"         // 0IRE                                 |       4
        "ldi r18,7\n\t"         // COLBST0                              |       5
        "ldi r19,3\n\t"         // COLBST1                              |       6
        "ldi r20,7\n\t"         // COLBST2                              |       7
        "ldi r21,11\n\t"        // COLBST3                              |       8
        "nop\n\t"               //                                      |       9
        "ldi r22,19\n\t"        // loop count                           |       10
"HS_LOOP:"                      // for H-Sync level keep
        "dec r22\n\t"           // 1cycle                              ||
        "brne HS_LOOP\n\t"      // 2/1      (1+2)*18+(1+1) = 56        ||       66
        
        "out 0x08,r23\n\t"      // 0IRE                                     |   1
        "out 0x08,r23\n\t"      // 0IRE                                     |   2
        "out 0x08,r23\n\t"      // 0IRE                                     |   3
        "out 0x08,r23\n\t"      // 0IRE                                     |   4
        "out 0x08,r23\n\t"      // 0IRE                                     |   5
        "out 0x08,r23\n\t"      // 0IRE                                     |   6

        "push r1\n\t"           //                                          |   7
        "push r16\n\t"          //                                          |   8
        "push r17\n\t"          //                                          |   9
        
        OutBurst                // No.1 Color Burst                        --
        OutBurst                // No.2                                    --
        OutBurst                // No.3                                    --
        OutBurst                // No.4                                    --
        OutBurst                // No.5                                    --
        OutBurst                // No.6                                    --
        OutBurst                // No.7                                    --
        OutBurst                // No.8                                    --
        OutBurst                // No.9                                    --

I want to display more characters per line.
So, I will continue to improve.

Thanks !

That deserves a bucket-load of karma.
Sadly, I can only give one for now.
Nice work!

This is great work to see! A couple of questions, though:

  1. Will you be posting your work on this like you have for your arduino-vgaout display (https://code.google.com/p/arduino-vgaout/)?

  2. By "NTSC" - do you mean Japan or USA? I know they are fairly similar, with minor differences (but I'm not an expert)...

The images and code you supplied give only the barest hint at what is possible (someone with a lot of experience in NTSC could probably take what you've posted so far here and make it work - but it wouldn't be easy for most). Regardless - bravo!

Hi! AWOL and cr0sh
Thank you for your replies.

  1. Will you be posting your work on this like you have for your arduino-vgaout display (https://code.google.com/p/arduino-vgaout/)?

Yes, I will create new project "NTSC color wit Arduino" on Google code site.
If someone move this code, he needs more information.
But, I'm not ready for those documents.
So, I just uploaded here. (A_NTSC_Trial_20130524.zip)
https://code.google.com/p/arduino-vgaout/downloads/list
Please check this.

  1. By "NTSC" - do you mean Japan or USA? I know they are fairly similar, with minor differences (but I'm not an expert)...

I live in Japan. and the code for the TV in Japan.
There is not much difference in NTSC-M and NTSC-J.
I think so and we can change the 0-IRE data of the code.

Only Japan's variant "NTSC-J" is slightly different: in Japan, black level and blanking level of the signal are identical (at 0 IRE), as they are in PAL, while in American NTSC, black level is slightly higher (7.5 IRE) than blanking level. Since the difference is quite small,

But PAL's Color Sub Carrier is different.

Color Sub Carrier of NTSC is 3.579545NHz.
We make the colorburst signal to display with color composite.
[ColorBurst]

To make the composite color sigal, we need the crystal that the frequency is colorburst frequency x 4.
NTSC -> 3.57954MHz x 4 = 14.318MHz
we can get it easily.
http://bit.ly/ZNcU3S

This time, I used Arduino Uno.
I noticed the crystal for ATmega328P is the small one.
And I use Arduino IDE boot loader for 16MHz.
So, I had to be able to replace the crystal.
https://picasaweb.google.com/117534855759200010314/ArduinoTVoutColorNTSC
I will continue to improve the program.
And I will add more information every weekend.

Thanks! All

Nabe

I tried something similar a few years ago - I also used a 14.318MHz crystal crystal. But I was using a Duemilanove, which was much easier as it already had a crystal oscillator for the 328P. All I needed to do was desolder the crystal and replace it with a socket, then I could change over the crystals easily.

I will see if I can find that Duemilanove, I think it is buried in my RepRap somewhere, and the 14.318MHz crystal, and see if I can get your code to work :slight_smile:

Success :smiley: Your code works well!

Karma'd

I was looking to make a dirt cheap color bar generator as those online costs over $150. Your project will do nicely for checking old color TV to see if they are in operation or not.

Hi! stimmer and wilykat
Thanks for your replies.

I also think that Duemilanove is suitable for this project.
Exchange of crystal makes easy Duemilanove than UNO.

I have tried to display simple graphic pattern.

There are sum bugs. And I am not satisfied with it.
So I will continue to improve.


The color is decided by the signal amplitude and the phase of color burst signal.
One color dot is generated by 4 commadns.
#define OutPixel
"out 0x08,r18\n\t"
"out 0x08,r19\n\t"
"out 0x08,r20\n\t"
"out 0x08,r21\n\t"\

In order to change a color, four commands are required as follows.
And in the meantime the modulation of the signal is stop.
#define SetColGrn
"ldi r18,9\n\t"
"ldi r19,13\n\t"
"ldi r20,27\n\t"
"ldi r21,23\n\t"\

right,Your project will do nicely for checking old color TV to see if they are in operation or not.

Yes. We can use old color TV.
And we can use LCD TV or monitor with composite input.
In Japan, analog television broadcasting was terminated 2 years ago.
So many CRT TV have discarded.

I tried to display simple graphics.
Arduino does not have enough RAM.
So, This is the limit for me at this stage.
I used LCD TV.
This is the latest achievements.

I changed the method of generating the sybchronization signal.
For synchronization signal simplified, this television seems to have determined that the signal is interlaced scan signal.
https://picasaweb.google.com/117534855759200010314/ArduinoTVoutColorNTSC#5893030025201887202
https://picasaweb.google.com/117534855759200010314/ArduinoTVoutColorNTSC#5893030134825134738

I will modify the code in this week.

I tried using an Arduino Duemilanove?that has been used before.
The color of the resist is black.
https://picasaweb.google.com/117534855759200010314/ArduinoTVoutColorNTSC#5897513433131707874

I had used the original bootloader for 16MHz crystal.
So, after writing the code, I had to off the power and change the crystal to 14.31818MHz.
And to rewrite the code, I had to change the crystal to 16MHz.
It's a little bother.

I have examined how to rewrite the boot loader.

The C source and make files in that folder.
arduino-1.0.4\hardware\arduino\bootloaders\atmega

change "Makefile"

#atmega328: AVR_FREQ = 16000000L 
atmega328: AVR_FREQ = 14318180L

add the define "ATmegaBOOT_168.c"

#define EEWE 1

I used WinAVR to compilie the code.

And I used avrdude-GUI to write the bootloader to Arduino Duemilanove.
http://www.geocities.jp/arduino_diecimila/bootloader/

I will continue to improve the program little by little.

Hi All!

I had a lot trial and error in order to increase the number of characters displayed per line.
I came to be display in a stable 12 lines - 20 columns.
But it is not displayed correctly by the display.
Because it was too simplified synchronization signals
and for non-interlace signal.
I think so.
And I can to improve it?may be.

CRT TV

LCD TV

PC Monitor Compsite in

I will up the new code about one month later.
I will continue to diligently improvemnet.
Please wait a little more.

Looks great ! :astonished:

That deserves a bucket-load of karma.
Sadly, I can only give one for now.

Hmm, that seems not to be true for moderators, so here, have some more!
Truly, great work, keep it coming, thanks!

Yes?
To that bucket from this bucket...
Beaten with the horizontal sync signal...
8bit microcomputer is working hard! :slight_smile:

I upped new demo video and new code.
Video on YouTube

I tried to start "TVout Color NTSC" project on google code.
But..
"...where is download tab?"

So, I upped the new code into Dropbox.
https://dl.dropboxusercontent.com/u/85872655/TVoutColor_20131004.zip

Does anyone
have any question or request?
Please post.

Best regards,
Nabe

Hi

i dont have atema328 arduino board :frowning:
do you have hex of you'r project to test it on other board?

thanks lot

Hi I'm Nabe.

We can get the hex file by Using Arduino IDE.

at the tool bar
[File -> Preferences]
[Show verbose during:] check "compilation" and "upload"

[File -> Open] select .ino file.
and "Verify"

We can see the message in the window
and .elf file and .hex file are generated in that directry.
xxxxx:user name
zzz : file name
D:\Users\xxxxx\AppData\Local\Temp\build7828201751720452090.tmp\zzz.cpp.elf
D:\Users\xxxxx\AppData\Local\Temp\build7828201751720452090.tmp\zzz.cpp.hex

I am developing in te project using Arduino IDE.
Therefore, the boot loader is written to CPU.

The bootloader is active for a few seconds when the board resets; then it starts whichever sketch was most recently uploaded to the microcontroller.

I do not know how it starts without the boot loader.
But not using Arduino board
if the board which uses ATMega328P and 14.31818MHz crystal
you change the initialization routine.
Then it should operates normally.

Regards,
Nabe_RMC

Hi Nabe, excellent work !!

I have been working on adding colour to the TVout library, I add 24bit colour by multiplexing PWM driven voltages out to the R, G & B pins of the VGA connector, works like a dream, although I only have 128x96 display on my 328. I will be upgrading to the 1284 so I can get more resolution out

:slight_smile:

Hello,

That's awesome .. nice work Nabe ..

I have tried the normal TVout library and it works fine .. but now I want to display pixels (text and images) in green color .. only green ..
so do I need all the hardware and code or just a portion of it ..

I also want to ask about the resistors' values and connection to the arduino and to the RCA cable ..

Sorry if these are silly questions .. but I'm not a specialist in these things :slight_smile:

Regards ..
Ragy Samy ..

could you help me? i need to create a custom color OSD (on screen display) to put it on a combat robot, in less words i need something like this: HD2 vs Nomad Tucson, cockpit view. Mech Warfare, RoboGames 2013 - YouTube i have already asked him about the osd, but him keeps it as a secret... thanks in advance for the help...