This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/LAUNCHXL-F28379D: Adding PID contoller to the eQEP speed measurement example

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hello everyone.

I added to the "eqep_pos_speed" C2000ware example a pid controller wich I took from the DCL C2000ware library, I added all neccssary files and headears and the programm is building and debugging without any problem.

this example take PWM1A and PWM1B to simulate the eQEP periphal. so the speed measured at the end by this example is 300 rpm.

I want to change this speed to 500 rpm trough using PID, so I added the following lines in the interrupt function :

yk = (float) qep_posspeed.SpeedRpm_fr; //reading the speed (300 rpm)
uk = DCL_runPID_C3(&pid1, rk, yk, 1.0f); // calculate the PID command

(I changed the referrence rk to rk=500.0f )

but in the debbug session the command uk is always equal to uk=1.0 and it doesn't change at all.

I don't know what I'm missing here in the program.

here is main file.c : 

Eqep_pos_speed.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//### ########################################################################
//
// FILE: Eqep_pos_speed.c fgjnoierjgel
//
// TITLE: EQEP Speed and Position measurement
//
//! \addtogroup cpu01_example_list
//! <h1>EQEP Speed and Position Measurement (Eqep_pos_speed)</h1>
//!
//! This example provides position measurement,speed measurement using the
//! capture unit, and speed measurement using unit time out. This example
//! uses the IQMath library. It is used merely to simplify high-precision
//! calculations.
//! The example requires the following hardware connections from EPWM1 and
//! GPIO pins (simulating QEP sensor) to QEP peripheral.
//! - GPIO20/eQEP1A <- GPIO0/ePWM1A (simulates eQEP Phase A signal)
//! - GPIO21/eQEP1B <- GPIO1/ePWM1B (simulates eQEP Phase B signal)
//! - GPIO23/eQEP1I <- GPIO4 (simulates eQEP Index Signal)
//!
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Hakacm,

    I am working to find the appropriate expert to help you. This may take some time to reach the right person depending on availability. Please expect an update after the weekend. I appreciate your patience.
  • It seems very likely the controller is saturating. If you consider just the proportional path for a moment: the output is (500 - 300) * 9 = 1,800, yet the controller is clamped at 1.0 because

    pid1.Umax = 1.0f;
    pid1.Umin = -1.0f;

    Think about the numerical ranges at the inputs and outputs of the controller. I suggest you normalise the reference and feedback so you are dealing with "per unit" values at the error; in other words, scale rk and yk so they always lie in the range -0.5f to +0.5f.

    That is: rk/(2*x) and yk/(2*x), where 'x' is the fastest rpm you want.

    Regards,

    Richard
  • Hi Hakacm,

    It has been a while since our reply. Let us know if your concern is resolved so we can close this thread. Thanks.