Go Down

Topic: NTSC signal with Arduino and Miku H@chuNe (Read 5731 times) previous topic - next topic


Arduino was heard to become popular on the Net. I bought Arduino Duemilanove and I made it for MTM04.

Arduino Duemilanove ATMEGA328P
160*120 pixels
16-level gradation
5*7dot Ascii Character

Here is a video demo of my work. Please enjoy!

Picasa web - some images

Make Tokyo Meeting 04


It looks good well done.  :)

I would be interested in knowing what the arduino is actually doing. From what I can gather it is detecting the waving bat with a photo cell but what else is it doing. There is a box attached to the arduino through USB, what is this box?



Dec 04, 2009, 02:51 pm Last Edit: Dec 04, 2009, 02:59 pm by MeowJPN Reason: 1
Thanks for your posting.

>There is a box attached to the arduino through USB, what is this box?

It's a battery box with switch and USB connector.

I use NiMH batery ×4

Photo sensor input, Sound out and Display picture and text,
they are all executed with the AVR ATMEGA328P.



impressive, I was going to say something about memory and the resolution / depth, but then I saw you added ram on the side

Ive been tinkering with VGA stuff, and when i get to the point if adding in an arduino I hope you dont mind me referencing your work


Dec 05, 2009, 12:26 pm Last Edit: Dec 05, 2009, 12:41 pm by MeowJPN Reason: 1
Thanks for your porsting.

Arduino Duemilanove
ATmega328P has only 2kbyte RAM but has 32kbyte Flash ROM.
So, image data are arranged in Flash ROM

[Display Graphics]
There are 2 image dates.
One is the leek up and another is down.

16-step depth -> 16=2^4 so needs 4bits.
160[dot] *120[dot] * 4[bit(depth)] * 2[image] /8bit
= 19200byte < 32kbyte

bit7 bit6 bit5 bit4  bit3 bit2 bit1 bit0
d3   d2   d1   d0   d3   d2   d1   d0
|                   |     |                   |
+--------------+    +--------------+
imag2 data           image1 data

--- image1 out ---
   lpm r0,Z+   ;0   [3clock]
   nop            ;     [1clock]
   out 0x08,r0 ;     [1clock] 5clock/dot
   lpm r0,Z+   ;1                      
   out 0x08,r0

--- image2 out ---
   lpm r0,Z+   ;0  [3clock]
   swap    r0   ;    [1clock]
   out 0x08,r0 ;    [1clock]
   lpm r0,Z+   ;1
   swap    r0
   out 0x08,r0
   5clock/dot -> 1/16MHz * 5=312.5ns
   312.5ns * 160 = 50us
[Display Text]
From the limitation of the processing time,it can display 8 characters.
I used V-RAM for horizontal scanning 1line.
so 8*8 = 64 byte RAM use.
Text data -> character generate data -> V-RAM for 1 sweeping
do this on every other line sweeping.
The effect of the afterimage of CRT and the mistake of man's eyes are used.

Not in time for MTM04,
the display about 20 lines is possible.
I think so using this way.

After MTM04,I hit on the idea of the technique for achieving 16characters * 20rows.
I think I can do it whithout using USART or SPI.
I try it soon or later.

I'm sorry poor in English.


That's really great.  I tried getting a VGA signal direct out of the atmega but I had terrible jitter problems.  Yours looks great.

Will you post the schematic and code?


I had made several video display using the one-chip microcomputers.

It was first to use AVR microcomputer and Arduino.
And this time ,I was troubled by jitter.
Back-to-basics, I considered the cause of the jitter.

Then, the jitter was able to be free by putting in compensation processing of delay.

There is no time not much to "Make Tokyo Meeting", and it was difficult to have mastered Arduino IDE.
And I found this web site.
[Arduino Diecimila - Burning the Bootloader without AVR-Writer]

[Arduino - FAQ]----------------------------------------------
Can I use an Arduino board without the Arduino software?

Sure. It's just an AVR development board, you can use straight AVR C or C++ (with avr-gcc and avrdude or AVR Studio) to program it.

So, I decided the work with free development environment,
- AVR Studio,WinAVR and that "by FT232RL BitBang Mode AVR-Writer software".

I am considering library creation, it can be used from sketch.
And I'm going to open the library.

But, I'm busy this month.
Another my hobby is to enjoy Radio Control.
I could get many siemens key switches a short time ago.
So, I promised to make a friend of mine a Tx emulator in the 1960s.
After next month that I will resume programming of Arudino.

----- Point of the program -----
I often use the function pointer. To replace processing wholly.
Read TCNT1 at interrupt top.
Code: [Select]

/*  ----------------------------------------------------
   -   function pointer                                -
   -----------------------------------------------------   */
void( *const TBL_int_icf1[MODE_CRT_N] )(void) = {    
   CRT_icf1_DBG,           /* mode0    DEBUG           MODE_CRT_DBG    0   */
   CRT_icf1_GRP160_120,    /* mode1    160*120 No.1    MODE_CRT_GRP1   1   */
   CRT_icf1_GRP160_120,    /* mode2    160*120 No.1    MODE_CRT_GRP2   2   */
   CRT_icf1_DBG,           /* mode3    Menu            MODE_CRT_CSL    3   */
   CRT_icf1_TXT,           /* mode4                    MODE_CRT_TXT    4   */

* Function : interrupt ICF1
   UH_TCNT1 = TCNT1;

call compensation processing of delay routine.
CRT_FitDelay( UB_DLY_icf1 );
Code: [Select]


* Function :
void CRT_icf1_GRP160_120( void )
   UB_DLY_icf1 = ( UB )( UH_TCNT1 & 0xFF );
   CRT_FitDelay( UB_DLY_icf1 );

   if( UB_h_line == V_SYNC_START ){
       OCR1A  = CRT_OCR1A_VS;
       TCCR1A = CRT_TCCR1A;
   else if( UB_h_line == V_SYNC_END ){
       OCR1A = CRT_OCR1A_HS;

   if( (UB_h_line >= V_BLANK) && (UB_h_line <= H_LINE_END_GRP) ){


Compensation processing of delay routine is this.
"CRT_FitDelay"  is this.
Code: [Select]

;  CRT_Fitdelay.s Compensation Delay program
;  Copyright (C) 2009 Masami Watanabe
;  This program is free software; you can redistribute it and/or modify it
;  under the terms of the GNU General Public License as published by the Free
;  Software Foundation; either version 3 of the License, or (at your option)
;  any later version.
;  This program is distributed in the hope that it will be useful, but
;  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
;  for more details.
;  You should have received a copy of the GNU General Public License along
;  with this program. If not, see <http://www.gnu.org/licenses/>.

CRT_FitDelay:                  //[ch38306][ch25968][ch12398][ch38283][ch22987]

                                   ;                  50            49            48            47
     cpi            delay,50      ;[1]            [1/1]      [1/1]      [1/1]      [1/1]
     BREQ      50f                  ;[1/2]            [2/3]      [1/2]      [1/2]      [1/2]
     cpi            delay,49      ;[1]                        [1/3]      [1/3]      [1/3]
     BREQ      49f                  ;[1/2]                        [2/5]      [1/4]      [1/4]
     cpi            delay,48      ;                                          [1/5]      [1/5]
     BREQ      48f                  ;                                          [2/7]      [1/6]
     cpi            delay,47      ;                                                      [1/7]
     BREQ      47f                  ;                                                      [2/9]
     cpi            delay,46
     BREQ      46f
     cpi            delay,45
     BREQ      45f
     cpi            delay,44
     BREQ      44f
     cpi            delay,43
     BREQ      43f
     cpi            delay,42
     BREQ      42f
     cpi            delay,41
     BREQ      41f
     cpi            delay,40
     BREQ      40f
     cpi            delay,39
     BREQ      39f
     cpi            delay,38
     BREQ      38f
     cpi            delay,37
     BREQ      37f
     cpi            delay,36
     BREQ      36f
     cpi            delay,35
     BREQ      35f
     cpi            delay,34
     BREQ      34f
     cpi            delay,33
     BREQ      33f
     cpi            delay,32
     BREQ      32f
     cpi            delay,31
     BREQ      31f
     cpi            delay,30
     BREQ      30f
     cpi            delay,29
     BREQ      29f
     cpi            delay,28
     BREQ      28f
     cpi            delay,27
     BREQ      27f
     cpi            delay,26
     BREQ      26f
     cpi            delay,25
     BREQ      25f
     cpi            delay,24
     BREQ      24f
     cpi            delay,23
     BREQ      23f
     cpi            delay,22
     BREQ      22f
     cpi            delay,21
     BREQ      21f
     cpi            delay,20
     BREQ      20f

50: nop                              ;+31      3      34      84      *62.5ns =5.25us
49: nop                              ;+30      5      35      84
48: nop                              ;+29      7      36      84
47: nop                              ;+28      9      37      84
46: nop                              ;
45: nop                              ;
44: nop                              ;
43: nop                              ;
42: nop                              ;
41: nop                              ;
40: nop                              ;
39: nop                              ;
38: nop                              ;
37: nop                              ;
36: nop                              ;
35: nop                              ;
34: nop                              ;
33: nop                              ;
32: nop                              ;
31: nop                              ;
30: nop                              ;
29: nop                              ;
28: nop                              ;
27: nop                              ;
26: nop                              ;
25: nop                              ;
24: nop                              ;
23: nop                              ;
22: nop                              ;
21: nop                              ;
20: nop                              ;



I am considering library creation, it can be used from sketch.
And I'm going to open the library.
That source list in which the present condition is not ordered.
Even so if you need the such code, please mail to me.



Mar 10, 2010, 04:52 pm Last Edit: Mar 10, 2010, 04:52 pm by rtwomey Reason: 1
rtwomey from youtube.  I didn't realize we couldn't post URLs.  Weird.
Anyway, this project is great.  I got the 16-level grayscale output working at a very low horiz / vert resolution (using arduino IDE), and was curious to see your full code for 160x120 (using AVR Studio).  

Of course, if you have gotten it working inside of Arduino IDE I would love to see that as well.

Thanks and keep up the good work!



I didn't realize we couldn't post URLs.  Weird

You can now.

Very nice project.
Per Arduino ad Astra


oh, that was a comment about youtube... couldn't post URLs on youtube.  but thanks!


Mar 24, 2010, 12:50 pm Last Edit: Mar 25, 2010, 10:13 am by MeowJPN Reason: 1

I'm sorry to have kept you waiting.
I reprogramed with C++ and inline assembler.
It can be built using Arduino IDE.
I hit on new idea so I added text display. It's no trick.
I upped program code and circuit schematic on this site.

and I upped a movie to YouTube
Are there any questions? Please post reply.

Thanks! and let's enjoy!


That's brilliant :) Do you think there is overhead and room on the 328 for programming and using the display? If not you could always use one 328 as a display module and another to provide text for it.


Do you think there is overhead and room on the 328 for programming and using the display? If not you could always use one 328 as a display module and another to provide text for it.

Look closely at the video; the demo program apparently uses nearly ALL the memory on the 328, but not quite all. There seems to be a few hundred bytes left, so...

I would imagine if you stripped the demo code out and dropped the bootloader, you would probably gain enough room back to build on a display library command set, and then use some form of serial control to control it (like a serial LCD) - but it would end up being a tight fit! It would make for a nice "video shield", though!

I am actually interested in details of that airplane that was shown in the video!

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.


Yeah, a video shield controlled via serial somehow would be a great addition to the arsenal.


Thanks your postings.

The build of Arduino IDE is slow.So, I am using AVR studio/WinAVR until the error disappears.

This is result.
AVR Memory Usage
Device: atmega328p

Program:   22180 bytes (67.7% Full)
(.text + .data + .bootloader)

Data:        526 bytes (25.7% Full)
(.data + .bss + .noinit)
The picture data put on Flash ROM(Program)
- use - 120*120=14400bytes
So, if use only text display and not use graphic, then there is room in ROM.

Text display - use only  1 row for V-RAM
use -> 6byte/char * 15char/row = 90bytes/row
So, there is room in RAM.

When you display it on the screen full,there is processing timing of the application only at vertically returning.
It takes a rest from display job once and do application at such time.
If it is CRT, this is possible.

Like a serilal LCD,  I think it is possible.
However, for what do you use it?

So, I will take the camera shot.

This is M16C tiny 20MHz,2k-RAM
48*36 pixel capture data serial in and display with only one chip.
this use R-2R DAC

>I am actually interested in details of that airplane that was shown in the video!

Thanks the comment. I like model planes.

Sorry only japanese.
[5 loops that flew over the sky were made]

[I want to fly Daison like]

Thanks a lot


Go Up