Hi everybody
i have a problem to program my 16f877A to control a stepper motor via uln2003A in order to guide my solar tracker.
the analogic inputs of the pic are RA0 and RA1 who are connected to ldr,and the output are the impulsions send from PORTD to the uln2003A after the stepper motor. some information :
Vref+=5v, Vref-=2v,clock=8Mhz
this is my schema in proteus :
and this is my code in mikroc :
unsigned long sens1;
unsigned long sens2;
void main() {
ADCON1=0b10001000;
TRISA=0xff;
PORTA=0x00;
TRISD=0x00;
PORTD=0x00;
while(1){
sens1=ADC_Read(0);
sens2=ADC_Read(1);
while(sens1>sens2){
PORTD=0b00000001;
delay_ms(50);
PORTD=0b00000100;
delay_ms(50);
PORTD=0b00000010;
delay_ms(50);
PORTD= 0b00001000;
delay_ms(50);
if(PORTD==0b00001000)PORTD=0b00000001 ;
}
while(sens1<sens2){
PORTD=0b00000001;
delay_ms(50);
PORTD=0b00001000;
delay_ms(50);
PORTD=0b00000010;
delay_ms(50);
PORTD=0b00000100;
delay_ms(50);
if(PORTD==0b00000100)PORTD=0b00000001;
}
if(sens1==sens2) PORTD=0x00;
}
}
the simulation was som strange :s
pleaseeeeeeeeeeeee help me it's urgent