Go Down

Topic: TVout: NTSC and PAL Composite Video Output. (Read 13938 times) previous topic - next topic

mdmetzle


@mdmetzle, Thanks!

I am looking for a way to get the tvout lib to let one pin go HIGH when there is a white pixel, and another pin go HIGH when there is a black pixel..

it should probably be done close to here, but i don't understand this..:

__asm__ __volatile__ (
   "ADD   r26,r28\n\t"
   "ADC   r27,r29\n\t"
   //save PORTB
   "IN      r16,%[port]\n\t"
   "ANDI   r16,0xFD\n\t"
   
(the above is from version 3 of the tvout lib, video_gen.ccp).



The first two lines are a 16bit add and are calculating the pointer to the current render line in the frame buffer.  The second 2 lines grab the port containing the output pin and set it to the video pin to low and the sync pin(if applicable in later versions) high.  Then through out the rest of the line rendering routine the video pin is modified and the rest of the port is left alone.  If you dont care about the port status then the these lines are not needed.

leo72

Hello.
A couple of days ago I tried to realize a little idea of mine...
I used 2 standalone Atmega328 on a breadboard: the first one runs a sketch that uses the PS2Keyboard lib to read the input from a PS2 keyboard, the second one has a sketch inside che reads the input from the first Atmega and then sends the output on the TV.

But I'm having a strange problem: keys that I see on the TV are different from the ones I press on the keyboard.... I.E. I get [ESC] from "h" or "3[ESC]" from "7" etc...

Strange because if I connect the first Atmega to an Arduino and send the keys I read from the keyboard to a serial terminal open under the Arduino IDE I can see the correct keys (i.e. if I digit "h"-"e"-"l-"l"-"o" I see "hello"), so I can say for sure that the connection of the keyboard is OK. It seems that "pollserial" doesn't read the correct datas.

I connected the 2 Atmega using pins 2 and 3 (RX & TX): of course, 2->3 and 3->2.
This is the sketch on the first Atmega:
Code: [Select]
/*  PS2Keyboard library example*/
   
#include <PS2Keyboard.h>

const int DataPin = 2;
const int IRQpin =  3;

PS2Keyboard keyboard;

void setup() {
  delay(2000);
  keyboard.begin(DataPin, IRQpin);
  Serial.begin(9600);
}

void loop() {
  if (keyboard.available()) {
   
    // read the next key
    char c = keyboard.read();
   
    // check for some of the special keys
    if (c == PS2_ENTER) {
      Serial.println();
    } else if (c == PS2_TAB) {
      Serial.print("[Tab]");
    } else if (c == PS2_ESC) {
      Serial.print("[ESC]");
    } else if (c == PS2_PAGEDOWN) {
      Serial.print("[PgDn]");
    } else if (c == PS2_PAGEUP) {
      Serial.print("[PgUp]");
    } else if (c == PS2_LEFTARROW) {
      Serial.print("[Left]");
    } else if (c == PS2_RIGHTARROW) {
      Serial.print("[Right]");
    } else if (c == PS2_UPARROW) {
      Serial.print("[Up]");
    } else if (c == PS2_DOWNARROW) {
      Serial.print("[Down]");
    } else if (c == PS2_DELETE) {
      Serial.print("[Del]");
    } else {
     
      // otherwise, just print all normal characters
      Serial.print(c);
    }
  }
}


This is the sketch that is running on the second Atmega:
Code: [Select]
#include <TVout.h>
#include <pollserial.h>
#include <fontALL.h>

TVout TV;
pollserial pserial;

void setup()  {
  TV.begin(_PAL,120,96);
  TV.select_font(font6x8);
  TV.println("Terminale seriale");
  TV.println("-- Versione 0.1 --");
  TV.set_hbi_hook(pserial.begin(9600));
}

void loop() {
  if (pserial.available()) {
    TV.print((char)pserial.read());
  }
}

pocketscience

Is life really that serious...??!

leo72

What do you mean?
That I don't have to use common grounds or that I have to use them?  :smiley-roll-sweat:

mdmetzle

Does the tvout sketch work when you send data from the pc?

leo72

I have to try it with my notebook. Until now I didn't try this test because my PC is far from the TV set.
I'll do a test later (I'm at work now).

pocketscience

Should we expect to be able to create a portrait screen - eg 96x128? Seems the current TVout lib doesn't like it. The first row of the display is positioned up beyond the viewable part of the TV screen. I did a simple TV.print and only the bottom half of the text was visible.


Cheers,
Is life really that serious...??!

film4scott

TvOut seems a marvelous solution to my specialized Arduino need.  I have succeeded in making an Arduino into what I call a Grobot rover, from a child's riding toy...  but well-timed composite output is slightly beyond my programming and workshop skills and tech.

Are there resources on the Arduino forums to hire freelance Arduino video experts?

I need a variation of TvOut that allows me to sync a non-genlock camera to another genlockable device expecting only Black (as opposed to Black Burst, tho any advanced sync signal will work too).

My design approach to the problem is to slightly increment/dec. the time length of a single field by a useful number of uSeconds, thus the Arduino-genlocked device does not loose sync and regain it, but shifts slightly in time until I can confirm full sync between camera and device by means of a dual trace scope.

This device is for an indie feature film - an Arduino-friendly enterprise with tolerances for slightly-less-than-perfect specs, and a budget to match.

fiero79

I am having the following problem...'TVOUT' does not name a type in the DEMONTSC.pde File

Why?

Charlie

pocketscience

TVout, not TVOUT - C is case-sensitive.


G.
Is life really that serious...??!

fiero79

I am sorry, I just looked again, it is:

TVout TV;

not TVOUT like I typed earlier.  I simply opened the demo and tried to verify it before uploading it.  It is not working as I downloaded it.  I made no changes to the code.

DemoNTSC from the TVoutBeta1.zip

Help.

Charlie

pocketscience

Did you install the library correctly into your Arduino environment?


Is life really that serious...??!

fiero79

I hadn't installed a custom library in a while, so I went to Arduino help pages and followed the directions exactly.

Thanks for your help in advance.

Charlie

fiero79

I think I misled with my last post...  I hadn't done a custom library install in a while so I used the procedure from arduino.cc to do the install, and the problem is still there.  I used the correct procedure, but TVout TV;

is still kicking the previously mentioned error.

Charlie

pocketscience

Do other libraries work? I never had any issues using the library after simply copying it to the Library folder and restarting the IDE. Methinks your problem might be unrelated to the TVout library...

Are you on Windows, Linux or Mac?


G.
Is life really that serious...??!

Go Up