Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
09.02.2010 at 17:39:17
News: Server upgrade went fine, you are now at the new system


Pages: 1 2 
[APL] Vidéo avec Arduino, afficher sur moniteur (Read 19512 times)
ikaruga
YaBB Newbies
*
Offline

M0OOPHONE

Posts: 18

Re: [APL] Vidéo avec Arduino, afficher sur moniteu
Reply #15 - 25.08.2007 at 20:09:44
 
alors penses tu pouvoir reposter le code avec les indents de NTSC en comments Cheesy ??

Est ce que sa serais possible avec un setup du genre a . je n ai vraiment pas bcp de trucs d electro chez moi. Je pense que je n ai meme pas de truc pour digital to analog :/ .


Back to top
 
 
View Profile   IP Logged
xSmurf
Full Member
***
Offline

Practice safe hex!

Posts: 185
Montréal, Qc
Re: [APL] Vidéo avec Arduino, afficher sur moniteu
Reply #16 - 25.08.2007 at 20:29:05
 
Ma config ressemble bcp a ça (J'avais pas les diodes)...


Regarde sur flickr pour plus d'informations (il y a des notes).
J'ai monté le circuit sur un shield de developement, mais ton setup est encore mieux Cheesy

Ok le code, temporaire, avec les commentaires suivra!
Back to top
 
 
View Profile | MSN | GTalk | ICQ | AIM   IP Logged
xSmurf
Full Member
***
Offline

Practice safe hex!

Posts: 185
Montréal, Qc
Re: [APL] Vidéo avec Arduino, afficher sur moniteu
Reply #17 - 25.08.2007 at 20:44:14
 
C'est surement mieux formaté sur pastie, mais si tu es paresseux...
(EDIT ou si pastie fini par jetter cette entré)

P.S. Je code dans TextMate plutôt que l'IDE en utilisant le Makefile, raison pour laquelle il y a le include et les prototypes.

Code:
#include "WProgram.h"

#define	DEBUG				1
//#define	USE_SPI				1

// Définition des pins
#define PIN_SYNC			8
#define PIN_VIDEO			9
#define PIN_LED				12
#define PIN_AUDIO			11

#define _SYNC				0x00
#define _BLACK				0x01
#define _GRAY				0x02
#define _WHITE				0x03

// Non modifié, voir mon post! (pas sur de comprendre)
#define _LONG_SYNC			19
#define _SHORT_SYNC			2
#define _LONG_SYNC_DELAI	2
#define _SHORT_SYNC_DELAI	30

#define _NB_PIXELS			29
#define _NB_LIGNES			19

#define	_NB_TV_LIGNES		262	// Modifié pour NTSC

#define _COMPENS_BOUCLE		7
#define _COMPENS_IF_SERIAL	17

#define _BAUD_RATE			19200

// Prototypes
void SPI_MasterInit(void);
void clearScreen(boolean mode);
#ifdef DEBUG
	void blinkStatus(void);
#endif
void resetCursor(void);

// Variables definition
byte memVideo[_NB_PIXELS][_NB_LIGNES];
byte index, index2;

int ligne;
char c;
int cx=(_NB_PIXELS / 2), cy=(_NB_LIGNES / 2);
byte couleur = _BLACK;

#ifdef USE_SPI
void SPI_MasterInit(void)
{
	/* Set MOSI and SCK output, all others input */
	DDRD = (1<<DDB0)|(1<<DDB1);
	/* Enable SPI, Master, set clock rate fck/16 */
	SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);
}
#endif

// Fonction d'effacement de l'écran (avec possibilité de faire un "cadriage" pour les tests)
void clearScreen(boolean mode)
{
	for (index2 = 0; index2 < _NB_LIGNES; index2++)
		for (index = 0; index < _NB_PIXELS; index++)
			if (!mode) {
				memVideo[index][index2] = _BLACK;
			} else {
				memVideo[index][index2] = (index + index2) % 3 + 1;
			}

	memVideo[0][0] = _WHITE;

	resetCursor();
}

// Remet le curseur au milieux
void resetCursor(void)
{
	cx=(_NB_PIXELS / 2);
	cy=(_NB_LIGNES / 2);
}

#ifdef DEBUG
void blinkStatus(void)
{
	int ii;

	pinMode(PIN_LED, OUTPUT);

	for(ii=0;ii<3;ii++)
	{
		digitalWrite(PIN_LED, HIGH);
		delay(75);
		digitalWrite(PIN_LED, LOW);
		delay(75);
		digitalWrite(PIN_LED, HIGH);
		if (ii < 2) delay(75);
	}
}
#endif

void setup()
{
	pinMode(PIN_SYNC, OUTPUT);
	pinMode(PIN_VIDEO, OUTPUT);
	pinMode(PIN_AUDIO, OUTPUT);

	digitalWrite(PIN_SYNC, HIGH);
	digitalWrite(PIN_VIDEO, HIGH);

#ifdef USE_SPI
	SPI_MasterInit();
#endif
	Serial.begin(_BAUD_RATE);
	Serial.println("GO");

	clearScreen(true);
#ifdef DEBUG
	blinkStatus();
#endif
}

void loop()
{
	// SYNC VERT A

	/**
	 * Cette section je suis pas certain de comprendre
	**/

	// ligne 1 LONG SYNC
	PORTB = _SYNC; delayMicroseconds(_LONG_SYNC);
	PORTB = _BLACK; delayMicroseconds(_LONG_SYNC_DELAI);

	PORTB = _SYNC; delayMicroseconds(_LONG_SYNC);
	PORTB = _BLACK; delayMicroseconds(_LONG_SYNC_DELAI);

	// ligne 2 LONG SYNC
	PORTB = _SYNC; delayMicroseconds(_LONG_SYNC);
	PORTB = _BLACK; delayMicroseconds(_LONG_SYNC_DELAI);

	PORTB = _SYNC; delayMicroseconds(_LONG_SYNC);
	PORTB = _BLACK; delayMicroseconds(_LONG_SYNC_DELAI);

	// ligne 3 MIXTE SYNC
	PORTB = _SYNC; delayMicroseconds(_LONG_SYNC);
	PORTB = _BLACK; delayMicroseconds(_LONG_SYNC_DELAI);

	PORTB = _SYNC; delayMicroseconds(_SHORT_SYNC);
	PORTB = _BLACK; delayMicroseconds(_SHORT_SYNC_DELAI);

	// ligne 4 SHORT SYNC
	PORTB = _SYNC; delayMicroseconds(_SHORT_SYNC);
	PORTB = _BLACK; delayMicroseconds(_SHORT_SYNC_DELAI);

	PORTB = _SYNC; delayMicroseconds(_SHORT_SYNC);
	PORTB = _BLACK; delayMicroseconds(_SHORT_SYNC_DELAI);

	// ligne 5 SHORT SYNC
	PORTB = _SYNC; delayMicroseconds(_SHORT_SYNC);
	PORTB = _BLACK; delayMicroseconds(_SHORT_SYNC_DELAI);

	PORTB = _SYNC; delayMicroseconds(_SHORT_SYNC);
	PORTB = _BLACK; delayMicroseconds(_SHORT_SYNC_DELAI-_COMPENS_BOUCLE);

	// IMAGE

	for (ligne = 0; ligne < _NB_TV_LIGNES; ligne++)
	{
		//** synchro

		// HSync
		PORTB = _SYNC;
		delayMicroseconds(4.7);	// Modifier NTSC

		// Black
		PORTB = _BLACK;
		delayMicroseconds(4.7);	// Modifier NTSC

		//** image ligne 51.5 uS

		for (index = 0; index < _NB_PIXELS; index++)
		{
			PORTB = memVideo[index][ligne>>4];
			PORTB = PORTB;	// Pas sur de comprendre ???
			PORTB = PORTB;	// Pas sur de comprendre ???
		}

		delayMicroseconds(1.4);	// Modifier NTSC

		/**
		 * Cette section je suis pas certain de comprendre
		**/
		PORTB = _BLACK;
		PORTB = _BLACK;
		PORTB = _BLACK;
		PORTB = _BLACK;
		PORTB = _BLACK;

		PORTB = _BLACK;
		PORTB = _BLACK;
		PORTB = _BLACK;
		PORTB = _BLACK;
	}

	// SYNC VERT B

	/**
	 * Cette section je suis pas certain de comprendre
	**/

	// ligne 310 LONG SYNC
	PORTB = _SYNC; delayMicroseconds(_SHORT_SYNC);
	PORTB = _BLACK; delayMicroseconds(_SHORT_SYNC_DELAI);

	PORTB = _SYNC; delayMicroseconds(_SHORT_SYNC);
	PORTB = _BLACK; delayMicroseconds(_SHORT_SYNC_DELAI);

	// ligne 311 SHORT SYNC
	PORTB = _SYNC; delayMicroseconds(_SHORT_SYNC);
	PORTB = _BLACK; delayMicroseconds(_SHORT_SYNC_DELAI);

	PORTB = _SYNC; delayMicroseconds(_SHORT_SYNC);
	PORTB = _BLACK; delayMicroseconds(_SHORT_SYNC_DELAI);

	// ligne 312 SHORT SYNC
	PORTB = _SYNC; delayMicroseconds(_SHORT_SYNC);
	PORTB = _BLACK; delayMicroseconds(_SHORT_SYNC_DELAI);

	PORTB = _SYNC; delayMicroseconds(_SHORT_SYNC);
	PORTB = _BLACK; delayMicroseconds(_SHORT_SYNC_DELAI-_COMPENS_BOUCLE-_COMPENS_IF_SERIAL);

// Fin au prochain poste
 

Back to top
 
 
View Profile | MSN | GTalk | ICQ | AIM   IP Logged
xSmurf
Full Member
***
Offline

Practice safe hex!

Posts: 185
Montréal, Qc
Re: [APL] Vidéo avec Arduino, afficher sur moniteu
Reply #18 - 25.08.2007 at 20:44:48
 
Code:
	if (Serial.available())
	{
		c = Serial.read();
		switch (c)
		{
			case '4' : if (cx>0) cx--; break;
			case '6' : if (cx<29) cx++; break;
			case '8' : if (cy>0) cy--; break;
			case '2' : if (cy<18) cy++; break;
			case '5' : memVideo[cx][cy] = couleur; break;
			case 'n' : couleur = _BLACK; break;
			case 'g' : couleur = _GRAY; break;
			case 'b' : couleur = _WHITE; break;
			case 'c' : clearScreen(false); break;		// Clear screen
			case 'f' : clearScreen(true); break;		// Fill screen
		}
	}
}
 

Back to top
 
 
View Profile | MSN | GTalk | ICQ | AIM   IP Logged
xSmurf
Full Member
***
Offline

Practice safe hex!

Posts: 185
Montréal, Qc
Re: [APL] Vidéo avec Arduino, afficher sur moniteu
Reply #19 - 25.08.2007 at 20:49:29
 
ikaruga wrote on 25.08.2007 at 20:09:44:
Je pense que je n ai meme pas de truc pour digital to analog :/ .


Tu n'as pas d'Arduino? Grin
Back to top
 
 
View Profile | MSN | GTalk | ICQ | AIM   IP Logged
ikaruga
YaBB Newbies
*
Offline

M0OOPHONE

Posts: 18

Re: [APL] Vidéo avec Arduino, afficher sur moniteu
Reply #20 - 25.08.2007 at 21:24:36
 
AH !!! good good ; D ouais j ai arduino ! j ai commencer a essayer mais je suis vraiment idiot en electronique alors sa ne marche pas en ce moment hehe ..

Voici une pic webcam de mon setup en ce moment.



Back to top
 
 
View Profile   IP Logged
xSmurf
Full Member
***
Offline

Practice safe hex!

Posts: 185
Montréal, Qc
Re: [APL] Vidéo avec Arduino, afficher sur moniteu
Reply #21 - 26.08.2007 at 22:18:07
 
Bon, j'ai décidé de re-écrire le code a zero, c'est moin mélangeant.
Mais bon, ca marche toujours pas et là.. je comprend vraiment pas pourquoi...
Si quelqu'un a une idée... http://pastie.textmate.org/private/34gzhibb7e8gcflkbw

P.S. J'ai aussi changer pour une résistance de 900ohm et 350ohm. Ca me semble plus juste (voir ici)
Back to top
 
« Last Edit: 27.08.2007 at 02:01:15 by xSmurf »  
View Profile | MSN | GTalk | ICQ | AIM   IP Logged
xSmurf
Full Member
***
Offline

Practice safe hex!

Posts: 185
Montréal, Qc
Re: [APL] Vidéo avec Arduino, afficher sur moniteu
Reply #22 - 27.08.2007 at 01:56:17
 
Bon voilà. Ça marche Cheesy



On peut voir qu'il y a un problème de timing durant les premières lignes. Celle la je capte pas!
Le code pour le pattern de la photo n'est pas dans le code qui suit... mais la version complète ce trouve en pastie. Le code est fait pour être relativement facile a "porter" pour PAL (ou d'autre format).
EDIT Le code ne marchait pas, je vais reposter plus tard!

Back to top
 
« Last Edit: 27.08.2007 at 05:10:39 by xSmurf »  
View Profile | MSN | GTalk | ICQ | AIM   IP Logged
xSmurf
Full Member
***
Offline

Practice safe hex!

Posts: 185
Montréal, Qc
Re: [APL] Vidéo avec Arduino, afficher sur moniteu
Reply #23 - 28.08.2007 at 01:41:16
 
Bon, j'ai créer un nouveau thread pour le ntsc, en anglais comme ca touche surtout les gens en Amerique et au Japon. S'il y a des francophone qui aimerais une traduction faite moi savoir et je posterais la traduction ici Smiley
Back to top
 
 
View Profile | MSN | GTalk | ICQ | AIM   IP Logged
xSmurf
Full Member
***
Offline

Practice safe hex!

Posts: 185
Montréal, Qc
Re: [APL] Vidéo avec Arduino, afficher sur moniteu
Reply #24 - 30.08.2007 at 03:31:24
 
Dit Ben, peux-tu expliquer un peu comment tu utilises le registre de timer? J'ai regardé un peu la datasheet mais je suis pas certain de capter... Évidemment juste le 256-128 et les while... le reste c'est plus simple encore que sans l'interrupt  Wink  Aussi, ça serait pas mieux de remettre Code:
timer0_overflow_count++ 

 dans la fonction d'overflow?
Back to top
 
 
View Profile | MSN | GTalk | ICQ | AIM   IP Logged
Benoît ROUSSEAU
Full Member
***
Offline

Ca va j'vais le
faire !

Posts: 136
Poitiers (France)
Gender: male
Re: [APL] Vidéo avec Arduino, afficher sur moniteu
Reply #25 - 01.12.2007 at 19:23:36
 
Bonsoir toutes mes excuses xSmurf,

Je n'étais plus prévenu des ajouts à ce post... Je vais regarder la version anglaise.
Back to top
 
 
View Profile | WWW   IP Logged
Pages: 1 2