kappa_am
Full Member level 6
Hi all,
Recently, I have been working on inverter controlled by dspic33EP512MU810. I was updating angle of output voltage using following code
ROT_DIR is direction of rotation, FTHETA is voltage angle in float format and THETA voltage angle in integer format. 0xFFFF=360 degree. After a wile depending of output votage ferequency, THETA does not get updated first some bits of less significant byte and after some extra time is elapsed whole THETA gets equal to 0xFFFF and does not get any update.
I changed the code to
and it seems it works good. I am wondering what is wrong with first updating method. how overflow affects the procedure and cause the weird behavior?
Thank you for your response
Recently, I have been working on inverter controlled by dspic33EP512MU810. I was updating angle of output voltage using following code
Code:
void Timer1Int() iv IVT_ADDR_T1INTERRUPT { //Voltage vector rotation
T1IF_bit = 0;
if (ROT_DIR==1) FTHETA = (float) FTHETA + (float) DELTHETA;
else FTHETA = (float) FTHETA - (float) DELTHETA;
THETA = FTHETA;
LATD=THETA;}
I changed the code to
Code:
void Timer1Int() iv IVT_ADDR_T1INTERRUPT { //Voltage vector rotation
T1IF_bit = 0;
if (ROT_DIR==1) FTHETA = (float) FTHETA + (float) DELTHETA;
else FTHETA = (float) FTHETA - (float) DELTHETA;
if (FTHETA>65535) FTHETA=FTHETA-65535;
if (FTHETA<0) FTHETA=65535-FTHETA;
THETA = FTHETA;
LATD=THETA;}
Thank you for your response
Last edited: