Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Requirements of display filtering in power electronics data

Requirements of display filtering in power electronics data

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingbusinessquestion
4 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Md Mubdiul Hasan
    wrote on last edited by
    #1

    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.

    L 1 2 Replies Last reply
    0
    • M Md Mubdiul Hasan

      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.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Your question is about mathematics, the device that you are monitoring, and the data it produces. You should check the documentation that comes with the device.

      1 Reply Last reply
      0
      • M Md Mubdiul Hasan

        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.

        1 Offline
        1 Offline
        11917640 Member
        wrote on last edited by
        #3

        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.

        M 1 Reply Last reply
        0
        • 1 11917640 Member

          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.

          M Offline
          M Offline
          Md Mubdiul Hasan
          wrote on last edited by
          #4

          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[^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups