Rastreador solar 2 eixos


#1

BOA NOITE ESTOU COM PROBLEMA NESTE CODIGO E PRECISO DE AJUDA. ESTOU USANDO UM PIC18F452 E NÃO ESTOU CONSEGUINDO ATIVAS AS SAIDAS DO MODULO CCP PARA QUE POSSA CONTROLAR 2 MOTORES, E GOSTARIA DE ALGUMA AJUDA. O CODIGO SEGUE ABAIXO. GRATO

float x,y,aa,bb;
float dutycycle=12.5;
float dutycycle1=12.5;
float sensor1, sensor2, sensor3, sensor4;
void main()
{
TRISC = 0x00;
TRISA = 0xFF;
PWM1_Init(500);
PWM2_Init(500);
while (1)
{
sensor1= ADC_Read(0);
sensor1=(sensor14.88)/1000;
sensor2= ADC_Read(1);
sensor2=(sensor2
4.88)/1000;
sensor3= ADC_Read(0);
sensor3=(sensor14.88)/1000;
sensor4= ADC_Read(1);
sensor4=(sensor2
4.88)/1000;
delay_ms(2);
if(sensor1>sensor2)
{ x= sensor1-sensor2;
if (x>0.1)
{ dutycycle= dutycycle+0.2; }
else
{ dutycycle= dutycycle1; }
}
else if(sensor1<sensor2)
{ y= sensor2-sensor1;
if (y>0.1)
{ dutycycle= dutycycle-0.2; }
else
{ dutycycle= dutycycle
1; }
}
else if(sensor2=sensor1)
{dutycycle= dutycycle1; }
if (dutycycle <12.5)
{dutycycle=12.5; }
else if (dutycycle >52)
{dutycycle=52; }
else
{dutycycle=dutycycle
1;}
if(sensor3>sensor4)
{ aa= sensor3-sensor4;
if (bb>0.1)
{ dutycycle1= dutycycle1+0.2; }
else
{ dutycycle1= dutycycle11; }
}
else if(sensor3<sensor4)
{ bb= sensor3-sensor4;
if (bb>0.1)
{ dutycycle1= dutycycle1-0.2; }
else
{ dutycycle1= dutycycle1
1; }
}
else if(sensor3=sensor4)
{dutycycle1= dutycycle11; }
if (dutycycle1 <12.5)
{dutycycle1=12.5; }
else if (dutycycle1 >52)
{dutycycle1=52; }
else
{dutycycle1=dutycycle1
1;}
PWM1_Set_Duty(dutycycle);
PWM2_Set_Duty(dutycycle1);
PWM1_Start();
PWM2_Start();
Delay_ms(100);
}}