Solar Tracker + LabView

Hi everyone!
i'm developing solar tracker, I have 4 LDR's in ADC channels A0,A1,A2 and A3, also I have a battery witch is charged by the solar panel on A4.After reading the analog LDR value I set the 2 servos position to follow the light.

Here is my arduino code:

#include <Servo.h>// Inclui biblioteca de servos
const int led   = 13;
const int LDR_0 = A0; 
const int LDR_1 = A1; 
const int LDR_2 = A2; 
const int LDR_3 = A3; 
const int BATTE = A4;

unsigned int valCima     = 0;//Cima
unsigned int valDireita  = 0;//Direita 
unsigned int valBaixo    = 0;//Baixo
unsigned int valEsquerda = 0;//Esquerda
unsigned int val_B       = 0;//Bateria

long tempo_anterior      = 0;
long intervalo        = 1000; //milisegundos
unsigned long tempo_atual;

Servo servoRotacao;// Cria variaveis para controlar servos
Servo servoPasso;// Cria variaveis para controlar servos
char  delayMovimento = 100;// Tempo de delay dos servos
int   valRotacao  = 90;// Posicao inicial dos servos
int   valPasso    = 135;// Posicao inicial dos servos

void setup() 
{
  Serial.begin(9600); 
  servoRotacao.attach(10);// Atribui ao pino 10 o servo rotacao
  servoPasso.attach(9);// Atribui ao pino 9 o servo passo
  pinMode(LDR_0,INPUT);
  pinMode(LDR_1,INPUT);
  pinMode(LDR_2,INPUT);
  pinMode(LDR_3,INPUT);
  pinMode(BATTE,INPUT);
  pinMode(led,OUTPUT);
  digitalWrite(led,LOW);
}

void loop() 
{
  valCima     = analogRead(LDR_0);//faz leitura do canal ad 
  valDireita  = analogRead(LDR_1);//faz leitura do canal ad 
  valBaixo    = analogRead(LDR_2);//faz leitura do canal ad 
  valEsquerda = analogRead(LDR_3);//faz leitura do canal ad 
  val_B       = analogRead(BATTE);//faz leitura do canal ad 

  tempo_atual = millis();// o tempo atual é igual ao tempo de funcionamento do uC   

  if(tempo_atual - tempo_anterior > intervalo)// se o tempo atual menos o tempo anterior for maior que o intervalo com que eu quero fazer minha acao
  { 
    tempo_anterior = tempo_atual;//tempo anterior recebe o tempo atual 

      Serial.print(valCima);
    Serial.print(",");
    Serial.print(valDireita);
    Serial.print(",");
    Serial.print(valBaixo);
    Serial.print(",");
    Serial.print(valEsquerda);
    Serial.print(",");
    Serial.print(val_B);
    Serial.print(",");
    Serial.print(valRotacao);
    Serial.print(",");
    Serial.print(valPasso);
    Serial.println("");
  }

  if(valEsquerda - valDireita > 2 || valEsquerda - valDireita < -2)// Comparando os LDR's da esquerda e direita com threshold de "2" para evitar tremer os servos (jitter)
  {
    if(valEsquerda > valDireita && valRotacao > 0)// Luz vindo da direita, prepara para virar servo para direita (valor de travamento menor que 0)
    {
      valRotacao--;// Decrementa variavel
    }  
    if(valDireita > valEsquerda && valRotacao < 180)// Luz vindo da esquerda, prepara para virar servo para esquerda (valor de travamento maior que 180)
    {
      valRotacao++;// Incrementa variavel
    }
  }

  if(valCima - valBaixo > 2 || valCima - valBaixo < -2)// Comparando LDR's de Cima e Baixo com threshold de "2" para evitar tremer os servos (jitter)
  { 
    if(valCima > valBaixo && valPasso > 90)// Luz vindo de Cima, prepara servo para virar para cima (valor de travamento menor que 90)
    {
      valPasso--;// Decrementa variavel
    }
    if(valBaixo > valCima && valPasso < 180)// Luz vindo de Baixo, prepara servo para ir para baixo (valor de travamento maior que 180)
    {
      valPasso++;// Incrementa variavel
    }  
  }
  /*dica: o servo de passo so precisa oum alcance de 90 graus em caso de luz vindo horizontalmente para o chao(sunset/nascer do sol)
   ou verticalmente (sol do meio dia)
   */
  servoRotacao.write(valRotacao);// Coloca a posicao do servo de acordo com valor calculado
  servoPasso.write(valPasso);// Coloca a posicao do servo de acordo com valor calculado
  delay(delayMovimento);// Espera o servo se mover até a posicao
}

So I also print the value of all conversions over the serial port, now I have big deal,my Labview program get each value between comas and graph the variable.I have this time acquisition each second, but my Labview program crash my win7 32bits computer after running for while, the usbserv.sys crashes and I get blue screen.

Anyone have idea what could be happening?

i'm attaching my Labview program and Proteus simulation

SEGUIDOR_SOLAR_TOOLS.vi (40.8 KB)

seguidor.DSN (107 KB)

There are equations that give you very accurate values for the azimuthal and elevation angles for the location of the sun based on your location and time, if you have these you can just point the solar panel in that direction. An analysis would need to be made to see if the time from an RTC would be accurate enough. A GPS could be used if the RTC drifts too much, doubtful but a possibility, and the GPS would also alleviate the need for you to enter your latitude and longitude.

Just my two cents and I overcharged,

wade

well thank you!!

Nice ideas that I should implemente in the near future.
For the Labview Crash I think i just figured out how to fix it:
I chaged the arduino COM proprieties over device manager, I got no flux control and lowered the buffer reception to 4 and also buffer transmission to 6.It seems to have fixed the problem cos now i'm sending data to labview each 300ms, it has been running for the hole day and i got no problems at all.

thank you