helpe

Post your requests and ideas on the future development of mikroC PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
walid_med
Posts: 1
Joined: 05 Jun 2011 10:06

helpe

#1 Post by walid_med » 05 Jun 2011 10:14

hi every one i make a programme in MIKROC 8.1 who can make the motore stop (PORTD.F4) when the angle theta1=mesure1,
this is the programme and please help me to say me where is the probleme:


#include <math.h>
unsigned float pot;
unsigned float pot2;
unsigned float pot3;
unsigned float pot4;
unsigned float pot5;
unsigned float pot6;
double theta1;
double theta2;
double mesure1;

#define M1_actif {PORTD.F1=1;PORTD.F0=0;PORTC.F3=1;}
#define M1_avant {PORTD.F4=1;PORTD.F5=0;}
#define M1_ariere {PORTD.F4=0;PORTD.F5=1;}

void angle()
{
double Px=2;
double Py=5;
double Pz=0;

{
theta1=atan2(Py,Px); }

}
void main()
{
ADCON1=0x80;
TRISA=0xFF;
TRISB=0x00;
TRISC=0x00;
TRISD=0x00;
while(1)
{
pwm_init(5000);
pwm_start();
pwm_change_duty(128);

pot=Adc_Read(0);
mesure1=pot*(160/255)-80;
angle();
if(mesure1==theta1)
{
PORTD=0;
}
else if(mesure1<theta1)
{M1_actif;
M1_avant;}

else
{M1_actif;
M1_ariere;}

}
}

Post Reply

Return to “mikroC PRO for dsPIC30/33 and PIC24 Wish List”