NTSC signal with Arduino and Miku H@chuNe

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

Arduino Duemilanove ATMEGA328P
160120 pixels
16-level gradation
5
7dot Ascii Character

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

Picasa web - some images
http://picasaweb.google.co.jp/MeowJPN/ELJ09#

Make Tokyo Meeting 04
http://www.oreilly.co.jp/mtm/04/

It looks good well done. :slight_smile:

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?

Thanks

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.


http://akizukidenshi.com/catalog/g/gP-02681/

I use NiMH batery ×4
http://picasaweb.google.co.jp/MeowJPN/ELJ09#5411370403749805426
http://picasaweb.google.co.jp/MeowJPN/ELJ09#5411370414048915682

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

Thanks!

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

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 /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
nop
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.
8bits/character
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.
http://picasaweb.google.co.jp/MeowJPN/ELJ09#

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.
http://picasaweb.google.co.jp/MeowJPN/ELJ09#5408385710517206802
http://picasaweb.google.co.jp/MeowJPN/ELJ09#5408385794054034978
http://picasaweb.google.co.jp/MeowJPN/ELJ09#5408385879635953218

Then, the jitter was able to be free by putting in compensation processing of delay.
http://picasaweb.google.co.jp/MeowJPN/ELJ09#5408385972967783890

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]
http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html

[Arduino - FAQ]----------------------------------------------
http://arduino.cc/en/Main/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.
UH_TCNT1 = TCNT1;

[font=Courier]
[size=6]
/*  ----------------------------------------------------
    -   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
*---------------------------------------------------------------------------*/
ISR (TIMER1_CAPT_vect)
{
    UH_TCNT1 = TCNT1;
    (*TBL_int_icf1[UBmodeCRTtbl])();
}
[/size]
[/font]

call compensation processing of delay routine.
CRT_FitDelay( UB_DLY_icf1 );

[font=Courier]
[size=6]

/*----------------------------------------------------------------------------
* Function : 
*---------------------------------------------------------------------------*/
void CRT_icf1_GRP160_120( void )
{
    UB_DLY_icf1 = ( UB )( UH_TCNT1 & 0xFF );
    CRT_FitDelay( UB_DLY_icf1 );
    
    UB_h_line++;

    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) ){

[/size]
[/font]

Compensation processing of delay routine is this.
"CRT_FitDelay" is this.

[font=Courier]
[size=6]
;------------------------------------------------------------------------------
;  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                              ;

      ret

[/size]
[/font]

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.

Thanks

Hi,
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!

Robert

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

You can now.

Very nice project.

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

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.
http://homepage3.nifty.com/two_legs/neo/project/Arduino/proj_Arduino.htm

and I upped a movie to YouTube

Are there any questions? Please post reply.

Thanks! and let's enjoy!

That's brilliant :slight_smile: 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!

:slight_smile:

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.
http://homepage3.nifty.com/two_legs/syuuhou/syuuhou2004/syuuhou11/dora3.MPG
this use R-2R DAC
http://homepage3.nifty.com/tlgjpn/neo/project/OAKS16_MINI/9_video_sig.htm

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

Nabe

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.

So - you are using PROGMEM for storage of the image?

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

If there were a way to modify the font, or have multiple fonts, that could open up some nice possibilities for games and such.

When you display it on the screen full,there is processing timing of the application only at vertically returning.

So you have to do all processing in a very narrow time-slice of the vertical blank. Could be an issue, depending on what is being done of course...

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?

Well, for one, a very small gaming system display is a possibility (in other words, there would be the single ATMega328 drawing the display based on serial commands, with another controlling it) - you could also, with external circuitry, mix in live video and do text overlays (there are similar boards on the market that do this already, but they use a different uP, or a separate video IC of some sort).

Thanks the comment. I like model planes.

I like paper airplanes, myself, and that video reminded me of some designs I have seen and played with; the plane in the video looks like some lightweight loops of foam connected to long spars of carbon fiber, in a canard configuration; with other parts (servos and motors) for control from a lightweight park flyer, perhaps?

Its a very eye catching design, and looks fun to fly!

:slight_smile:

So - you are using PROGMEM for storage of the image?

Yes.
The image can be somewhat moved by changing the reading address position of ROM.
like this
http://homepage3.nifty.com/two_legs/syuuhou/syuuhou2006/syuuhou05/dora.AVI
However, being able to do is only such the thing,

If there were a way to modify the font, or have multiple fonts, that could open up some nice possibilities for games and such.

The file name of Character Generator code ( Font convert ) is "CG_20100316.h"
The data is arranged in order of ASCII code.
(the characters < 0x20 ) --> control code , so we place any charcters in the area.
Each charcters are made up by 68 dots.( = 68bits = 6bytes )
Conversion to V-RAM data from text data is performed at the time of the display of spacing line.
And three line is needed for conversion of 15 characters.
So, this method, The line - 3lines which nothing can display exists every 8 lines.

Quote:
When you display it on the screen full,there is processing timing of the application only at vertically returning.

So you have to do all processing in a very narrow time-slice of the vertical blank. Could be an issue, depending on what is being done of course...

I'm sorry. I was not able to express it well in English.
So in such occasions (many tasks to do whithin a certain time ), We only have using a tricky technique.
CRT - interlaced scan is used. So, a picture is reflected even if it performs display processing every other time.
we can use the effect of the afterimage of CRT.
And processing time can be acquired.


The work ( NTSC with Arduino ) is an only exercise.
How to use AVR, how to use interrupt, timer, how to avoid jitter, etc.
and studuy NTSC signal.
Although full-scale image processing is treated, ATMEGA328P, capability is too low.

I think that it is the time when now CPLD and FPGA are used also in a hobby.

I want to cahllenge to handle FPGA and CPLD.....

Best Regards