Requirements of display filtering in power electronics data
-
I am trying to debug a complex firmware CCS V.5 program with compiler V.6.0.2. My control code has access with a PC program. All registers of my application is customized. My goal is to display particular channel voltage, but logically mathematical code should be understand. Here we go
void DispFiltering1(void)
{
float k;
float in_data;/////////////////////////////////////////////////////////////////// in\_data = Register\[CH1\_VOLTAGE\] \* 1000 - Vfilt\_16; dVfilt\_16 = in\_data + (dVfilt\_16 \* 0.5f); idvfilt\_16 += dVfilt\_16; k = (int)(idvfilt\_16 \* timeconst\_inverse\_16); idvfilt\_16 -= k \* timeconst\_16; if(k < -slewrate\_16) Vfilt\_16 -= slewrate\_16; else if(k > slewrate\_16) Vfilt\_16 += slewrate\_16; else Vfilt\_16 += k; Register\[DISP\_CH1\_VOLTAGE\] = Vfilt\_16 \* 0.001; /////////////////////////////////////////////////////////////////// in\_data = Register\[CH1\_CURRENT\] \* 1000 - Vfilt\_17; dVfilt\_17= in\_data + (dVfilt\_17 \* 0.5f); idvfilt\_17 += dVfilt\_17; k = (int)(idvfilt\_17 \* timeconst\_inverse\_17); idvfilt\_17 -= k \* timeconst\_17; if(k < -slewrate\_17) Vfilt\_17 -= slewrate\_17; else if(k > slewrate\_17) Vfilt\_17 += slewrate\_17; else Vfilt\_17 += k; Register\[DISP\_CH1\_CURRENT\] = Vfilt\_17 \* 0.001;
}
I will be happy if you can explain why filtering, slewrate and time constant is necessary here? Discuss kindly.
-
I am trying to debug a complex firmware CCS V.5 program with compiler V.6.0.2. My control code has access with a PC program. All registers of my application is customized. My goal is to display particular channel voltage, but logically mathematical code should be understand. Here we go
void DispFiltering1(void)
{
float k;
float in_data;/////////////////////////////////////////////////////////////////// in\_data = Register\[CH1\_VOLTAGE\] \* 1000 - Vfilt\_16; dVfilt\_16 = in\_data + (dVfilt\_16 \* 0.5f); idvfilt\_16 += dVfilt\_16; k = (int)(idvfilt\_16 \* timeconst\_inverse\_16); idvfilt\_16 -= k \* timeconst\_16; if(k < -slewrate\_16) Vfilt\_16 -= slewrate\_16; else if(k > slewrate\_16) Vfilt\_16 += slewrate\_16; else Vfilt\_16 += k; Register\[DISP\_CH1\_VOLTAGE\] = Vfilt\_16 \* 0.001; /////////////////////////////////////////////////////////////////// in\_data = Register\[CH1\_CURRENT\] \* 1000 - Vfilt\_17; dVfilt\_17= in\_data + (dVfilt\_17 \* 0.5f); idvfilt\_17 += dVfilt\_17; k = (int)(idvfilt\_17 \* timeconst\_inverse\_17); idvfilt\_17 -= k \* timeconst\_17; if(k < -slewrate\_17) Vfilt\_17 -= slewrate\_17; else if(k > slewrate\_17) Vfilt\_17 += slewrate\_17; else Vfilt\_17 += k; Register\[DISP\_CH1\_CURRENT\] = Vfilt\_17 \* 0.001;
}
I will be happy if you can explain why filtering, slewrate and time constant is necessary here? Discuss kindly.
-
I am trying to debug a complex firmware CCS V.5 program with compiler V.6.0.2. My control code has access with a PC program. All registers of my application is customized. My goal is to display particular channel voltage, but logically mathematical code should be understand. Here we go
void DispFiltering1(void)
{
float k;
float in_data;/////////////////////////////////////////////////////////////////// in\_data = Register\[CH1\_VOLTAGE\] \* 1000 - Vfilt\_16; dVfilt\_16 = in\_data + (dVfilt\_16 \* 0.5f); idvfilt\_16 += dVfilt\_16; k = (int)(idvfilt\_16 \* timeconst\_inverse\_16); idvfilt\_16 -= k \* timeconst\_16; if(k < -slewrate\_16) Vfilt\_16 -= slewrate\_16; else if(k > slewrate\_16) Vfilt\_16 += slewrate\_16; else Vfilt\_16 += k; Register\[DISP\_CH1\_VOLTAGE\] = Vfilt\_16 \* 0.001; /////////////////////////////////////////////////////////////////// in\_data = Register\[CH1\_CURRENT\] \* 1000 - Vfilt\_17; dVfilt\_17= in\_data + (dVfilt\_17 \* 0.5f); idvfilt\_17 += dVfilt\_17; k = (int)(idvfilt\_17 \* timeconst\_inverse\_17); idvfilt\_17 -= k \* timeconst\_17; if(k < -slewrate\_17) Vfilt\_17 -= slewrate\_17; else if(k > slewrate\_17) Vfilt\_17 += slewrate\_17; else Vfilt\_17 += k; Register\[DISP\_CH1\_CURRENT\] = Vfilt\_17 \* 0.001;
}
I will be happy if you can explain why filtering, slewrate and time constant is necessary here? Discuss kindly.
This code fragment contains some global variables, we cannot see how they are declared, initialized and probably used somewhere else. We don't see also the constants, maybe there are some comments in their definitions. Anyway, looks like some (smoothing?) filter. The best way to understand such code is to add logging with all variables printed, and to understand what happens reading this log. Another way is to make manual calculations with some predefined set of input data, with all code branches applied.
-
This code fragment contains some global variables, we cannot see how they are declared, initialized and probably used somewhere else. We don't see also the constants, maybe there are some comments in their definitions. Anyway, looks like some (smoothing?) filter. The best way to understand such code is to add logging with all variables printed, and to understand what happens reading this log. Another way is to make manual calculations with some predefined set of input data, with all code branches applied.
Quote:
This code fragment contains some global variables, we cannot see how they are declared, initialized and probably used somewhere else
Thanks a lot to write here. Yes this code has global variable like Global.c. But this file explains to call internal and external memory and RAM. A summary can find here, DSP Global Variable Specification Syntax[^] Looking at the first defination,
in_data = Register[CH1_VOLTAGE] * 1000 - Vfilt_16;
Register[CH1_VOLTAGE]=float Register[COUNT_OF_REGISTER]; Vfilt_16 is also a register value. About k the C2000 digital lib manual says, Proportional gain is usually applied directly to servo error, however, a feature of this controller is that sensitivity of the proportional path to the reference input can be weighted differently from that of the feedback input. This is achieved through the Kr variable, and provides an additional degree of freedom when tuning the controller. The proportional control law is shown in Equation v5 (k) = Krr(k) - y(k) In most situations the weighting gain Kr will be unity. Its a PID controller equation. Such functions are typically based on integrating the transient error over a fixed time interval. The DCL.h library header file includes a set of default floating-point values that can be used for initialization purposes. These configure the proportional path to have unity gain, zero integral gain, output saturation limits of ±1.
#define PI_DEFAULTS { 1.0f, \
0.0f, \
0.0f, \
1.0f, \
-1.0f, \
1.0f \
}An example of the C declaration of an initialized PI structure is: PI pi1 = PI_DEFAULTS; The formation of the graph can be find here,7.7. Graph Tools — Code Composer Studio 9.3.0 Documentation[^]