Hello,
for my college project i have to program a ccd sensor (ILX551A the data sheet http://home.fnal.gov/~maeshima/alignment/zip/ILX551A.pdf), this consists in comparing the tensions of the output (Vout), taking the highest which corresponds with the peak of luminous intensity. The sensor is composed with pixels in line (first, 33 useless, next 2048 explotables and the last 6 useless), the light hit a pixel zone and a luminous peak is in a precise pixel which the position is what we search. So the program has to compare tensions and when he found the highest he has to tell the position of the pixel with the highest tension, there is my program, i just explain you my variables:
Rog and clock are two logic signals.
i is the position of the pixel (the number)
lum and lum1 are the tension in Vout
pic-lum is the position of the most lighted pixel
poslum is the position of a pixel (in the program)
poslum1 is the position of the next pixel
Please help me to understand if my comparing part is ok, so what i want is just the position of the pixel, thank you so much for your attention and sorry for my english (i'm french).
THANKS
#include <Wire.h> //inclusion de la libraire Wire (protocole I2C / TWI)
#include <LiquidCrystal_I2C.h> //inclusion librairie écran LCD
?LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); //definir adresse LCD ) 0x27 pour un affichage de
#define Vout A0 // Vout sur broche A0
boolean rog = 3; //rog sur broche 3
boolean clock =2; //clock sur broche 2
float n, D, B; //n,D,B en float
int i, Ntemp; //déclarer i et Ntemp
int posmin = 1; //position minimum du pixel à 1
int lum; //lum est la tension sur Vout (sortie)
int pic_lum =2047; //position du pixel le plus lumineux
int poslum
int poslum1
int lum1
void setup(){
lcd.begin(20,4); // init lcd 20 caractères 4 lignes
lcd.backlight(); // retro éclairage on
Serial.begin(9600); //Conexon série 9600 bauds
}
void loop(){
mesure();
lcd.setCursor(1,0); //postion curseur
?lcd.print(i); //écrire i
calcul_taux();
}
// *****************************mesure*****************************
void mesure(){
depart_mesure();
i = 1; //on se place au pixel 1
while(i<34){ // 33 premiers clock inutiles (voir doc ilx551a)
digitalWrite(clock,LOW); //Niveau logique bas sur clock
delay(0.002); //délai de 0,002 ms
digitalWrite(clock,HIGH); //niveau logique haut
delay(0.002);
i=i+1; //incrémentation (on change de pixel)
}
i = 34; //on se place au pixel 34 (33 inutiles)
while(i<2049){ // mesure des 2048 pixels utiles
digitalWrite(clock,LOW); //niveau logique bas sur clock
delay(0.002);
digitalWrite(clock,HIGH);
delay(0.001);
lum = analogRead(Vout); //acquérir tension de Vout
delay(0.001);
poslum= i
i=i+1
lum1 = analogRead(Vout);
poslum1 = i
if (lum > lum1){
pic-lum = i;
else pic-lum= poslum
positionmin = i;
}
i=i+1;
}
}
//******************************************************************
//*************depart mesure**********************
void depart_mesure(){
pic_lum =2047;
positionmin = 0;
digitalWrite(rog,HIGH);
digitalWrite(clock,HIGH);
delay(0.01);
digitalWrite(rog,LOW);
delay(0.001);
digitalWrite(rog,HIGH);
delay(0.001);