Commit 7a71897e authored by Alessio Igor Bogani's avatar Alessio Igor Bogani
Browse files

Re-enable old Debug statements

parent fc712a8a
......@@ -125,7 +125,7 @@ struct pru2user_data_transfer p2udt;
volatile float SetPoint;
volatile unsigned int IOStatus;
volatile unsigned int Debug0,Debug1,Debug2,Debug3;
volatile float Debug0,Debug1,Debug2,Debug3;
volatile float Kp,Ki,Kd,RampStep,Imin,Imax,Kff;
volatile int Reset; // 0xffff = retest interlocks
volatile unsigned int PRU0FirmRev;
......@@ -286,15 +286,12 @@ int main(void)
ReadIO();
}
Debug0++; // Cycle
if (SetPoint != p2udt.SetPoint || IOStatus != p2udt.IOStatus) {
Debug1++; // Change
p2udt.SetPoint = SetPoint;
p2udt.IOStatus = IOStatus;
Debug2++; // Notification
if (pru_rpmsg_send(&transport, dst, src, &p2udt,
sizeof(struct pru2user_data_transfer)) != PRU_RPMSG_SUCCESS) {
Debug3++; // Notification failed
// Notification failed
}
if (pru_rpmsg_receive(&transport, &src, &dst, NULL, &len) == PRU_RPMSG_SUCCESS) {
__halt();
......@@ -387,9 +384,9 @@ void Compensator(float SP, float Iout) // PWM frequency 100kHz, control loop 50
//regulator = sum(mpy(Kp, error), Integrator);
regulator = sum(sum(mpy(Kp, error), Integrator), Derivator);
//Debug0 = regulator;
//Debug1 = Integrator;
//Debug2 = Derivator;
Debug0 = regulator;
Debug1 = Integrator;
Debug2 = Derivator;
// pwm1offset e'l'offset per andare al 50% duty cycle (16056320 dec)
regulator=sum(regulator, (pwm1offset << 16));
......@@ -414,7 +411,7 @@ void Compensator(float SP, float Iout) // PWM frequency 100kHz, control loop 50
prev_error = error; // update error for derivative part
//Debug3=pwm1corr;
Debug3=pwm1corr;
//Debug2=pwm2corr;
......
......@@ -110,7 +110,7 @@ volatile float ScaleA5; // if needed cubic calibration: OutputCurrent = A0 + A1
volatile unsigned int ADC0, ADC1, ADC2, ADC2_previous, ADC3, ADC4, ADC5, ADC6;
// ADC0=Aux V, ADC1=Heater temp, ADC2=Out V, ADC3=dc link, ADC4=3.3V, ADC5=heatsink temp, ADC6=5V
volatile unsigned int PRU1FirmRev;
volatile unsigned int Debug0,Debug1,Debug2,Debug3;
volatile float Debug0,Debug1,Debug2,Debug3;
struct pru2pru_data_transfer {
float OCnorm;
} p2pdt;
......@@ -230,7 +230,7 @@ int main(void)
sum -= Buffer[i]; //substract old sample
Buffer[i] = GetADC(); //get new sample
sum += Buffer[i]; //add new sample
//Debug0 = Buffer[i];
Debug0 = Buffer[i];
i++;
if (i>31) i=0;
// check the sign make average on 16 samples, divide by 16 (shift 4 times)
......@@ -244,13 +244,13 @@ int main(void)
//avg=GetADC();
// scale the output currrent
//Debug1 = avg;
Debug1 = avg;
//OCnorm = mpy((float) avg,9.536752259018191355E-7); // divide by fffff/9.536752259018191355E-7 16samples 20bit (>>1)
//OCnorm = mpy((float) avg,7.6294527393E-6); // divide by 1ffff/7.6294527393E-6 18bit (>>3)
//OCnorm = mpy((float) avg,1.9073504518E-6); // divide by 7ffff/1.9073504518E-6 20bit (>>1)
OCnorm = mpy((float) avg,-12.3023170647082461E-6); // divided by (1ffff*1.612) // dovrebbe essere diviso per il max valore ammissibile
//Debug2=OCnorm;
Debug2=OCnorm;
// even coefficients negated
// 40us execution time
......@@ -280,9 +280,7 @@ int main(void)
//ADC6 &= 0xff0; // read only one channel for digital FF
//ff=mpy((ADC6+0.0),0.005);
Debug0++; // Cycle
if (OCnorm != OCnorm_previous || ADC2 != ADC2_previous) {
Debug1++; // Change
OCnorm_previous = OCnorm;
ADC2_previous = ADC2;
......@@ -302,10 +300,9 @@ int main(void)
if (HEAD_index >= SAMPLES) {
HEAD_index = 0;
Debug2++; // Notification
if (pru_rpmsg_send(&transport, dst, src, &p2udt,
sizeof(struct pru2user_data_transfer) * SAMPLES) != PRU_RPMSG_SUCCESS) {
Debug3++; // Notifications failed
// Notifications failed
}
if (pru_rpmsg_receive(&transport, &src, &dst, NULL, &len) == PRU_RPMSG_SUCCESS) {
......@@ -343,7 +340,7 @@ signed int GetADC()
// positive 00000-1FFFF (0 - 131071dec) 0V _ 10V all'ingresso
if(retval >= 0x20000) // negative 20000-3FFFF (131072 - 262143dec) -10V _ 0V
retval |= 0xFFFE0000; // 1111|1111|1111|1110|0|0|0|0
//Debug1=retval;
Debug1=retval;
return retval;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment