i write this code by mikroC
it gives me no error when simulation , but when i burn it by "winpic"
and test it in the circuit the motor does not move :S :S
(
i dont know why ?!!!
Papabravo, or anyone plz check this code and tell me whats wrong
am gonna to be crazy :S :S
----------------------------------------------------------------------------
------------------------------Code-----------------------------------------
//*------------------Globals--------------------------*
unsigned short j,oj;
signed short error1,error;
unsigned short refrence_input;
unsigned short measured_output;
//*------------Initialization Function----------*
void Initmain()
{
//------(o) --> output & (1)--> input ---------
ADCON1=6;//All ADC pins to digital I/O
PORTC=0xFF;//set PORTC to FF
TRISC=0;//Port C is output
PWM_Init(5000);//intialize PWM module
PORTB=0;
PORTD=0;
TRISB=255;
TRISD=255;
PORTE=0;
TRISE=0;//set PortA is output
}
//*-------------main Program------------------*
void main()
{
Initmain();
//i want here to send start signal to ADC 1 & 2
//while( )
//{
PORTE.F1=1;
PORTE.F1=0;//start signal to ADC1 is activated
PORTE.F1=1;
delay_us(100);
refrence_input=dataport1;
PORTE.F2=1;
PORTE.F2=0;//start signal to ADC1 is activated
PORTE.F2=1;
delay_us(100);
measured_output=dataport2;
error1=refrence_input-measured_output;
//error=BCD2DEC16(error1);
//*---------------PWM Code-------------------*
j=80;
oj=0;//oj will keep the old j value
PWM_Start();//start PWM
if(error1>0)
j++;
if(error1<0)
j--;
if(oj!=j)
{//if change in duty cycle requestred
PWM_change_Duty(j);//set new duty ratio
oj=j;
Delay_us(200);//slowdown a bit
}//end if
//}
}