Go Down

Topic: TVout Color - NTSC [upped new code - Oct. 04] (Read 38315 times) previous topic - next topic


Jun 01, 2013, 05:13 pm Last Edit: Oct 04, 2013, 01:55 pm by Nabe_RMC Reason: 1
Hi !
I have tried to generate NTSC color signal with an Arduino and some registers.


Display 7 colors
The signal at 7 colors
Simulation for registers select
Colorburst signal

The code to generate Colorburst signal is written by assembly language like this.
Code: [Select]

#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
       "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!
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.


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)
Please check this.

2. 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.
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.

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.
I will continue to improve the program.
And I will add more information every weekend.

Thanks! All



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 :)
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html


Success :D Your code works well!

Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html



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.


Jun 16, 2013, 03:49 am Last Edit: Jun 16, 2013, 03:53 am by Nabe_RMC Reason: 1
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.

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.

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.

change "Makefile"
Code: [Select]

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

add the define  "ATmegaBOOT_168.c"
Code: [Select]

#define EEWE 1

I used WinAVR to compilie the code.

And I used  avrdude-GUI to write the bootloader to Arduino Duemilanove.

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.



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.


a][+ ascii express, 110/300 novation cat, xmodem


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!


Oct 04, 2013, 01:34 pm Last Edit: Oct 04, 2013, 01:52 pm by Nabe_RMC Reason: 1
To that bucket from this bucket...
Beaten with the horizontal sync signal...
8bit microcomputer is working hard! :)

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

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

So, I upped the new code into Dropbox.

Does anyone
have any question or request?
Please post.

Best regards,

Go Up