cancel
Showing results for 
Search instead for 
Did you mean: 

STMCWB 4.0: enabling differential terms

christianwaldmann9
Associate II
Posted on August 19, 2014 at 18:29

In the dialog ''Drive Mng - Drive Settings'' there are some inactive (grayed out) check boxes to enable differential terms. 

How can a activate these check boxes?

#stmcwb-foc-4.0
3 REPLIES 3
Gigi
Senior
Posted on August 25, 2014 at 11:16

Ciao Christian

The thing is not as simple as it might seem. Ideed is not just matter of activate the check boxes in the WB because the differential terrm is not automaticaly enabled in the FW is such way.

I try to explain better.

Enable the differential term of any PI in the FW means to use the code of PID insted of PI and to do this you have to change the name of the function that actually creates the PI.

This is done by the MCBoot function inside the MCTasks.c. Let consider the speed PI that is created by this function:

oPIDSpeed[M1] = (CPI)PI_NewObject(&PISpeedParamsM1);

And, as you can read in the name of the function, it creates just a PI (not a PID). To create the PID is necessary to use another function that is

PID_NewObject (pPIParams_t pPIParam, pPIDParams_t pPIDParam);

You have to change the type of oPIDSpeed from

CPI oPIDSpeed[NBR_OF_MOTORS];

to

CPID_PI oPIDSpeed[NBR_OF_MOTORS];

Regarding the parameter structures required by PID_NewObject you can use the PISpeedParamsM1 as usual but you need to create also another structure that defines the differential part. This is defined in the PID_PIRegulatorClass.h as:

typedef const struct

{

int16_t hDefKdGain; /*!< Default Kd gain, used to initialize Kd

gain software variable */

uint16_t hKdDivisor; /*!< Kd gain divisor, used in conjuction with

Kd gain allows obtaining fractional values.

If FULL_MISRA_C_COMPLIANCY is not defined

the divisor is implemented through

algebrical right shifts to speed up PI

execution. Only in this case this parameter

specifies the number of right shifts to be

executed */

uint16_t hKdDivisorPOW2; /*!< Kd gain divisor expressed as power of 2.

E.g. if gain divisor is 512 the value

must be 9 because 2^9 = 512 */

}PIDParams_t, *pPIDParams_t;

That is not managed in the SystemNDriveParams.h. So you need to create it somewere, for instance in the begin of MCTasks.c after the #include ''SystemNDriveParams.h''

PIDParams_t PISpeedParamsM1 =

{

PID_SPEED_KD_DEFAULT,

SP_KDDIV,

(uint16_t)SP_KDDIV_LOG2

}

And someting like this...

So there is a little bit of work that is required to do to use also the differential term.

Ciao

Gigi

Laurent Ca...
Lead II

The question has been moved from the "Motor Control Hardware" section to the "STM32 Motor Control" section (the question is about the STM32 MC SDK). 

Best regards

christianwaldmann9
Associate II
Ich bin bis Ende Juli abwesend. Die Email wird nicht weitergeleitet. In dringenden Fällen bitte bei meinen Kollegen melden.
I'm out of the office till the end of July. The emails are not forwarded. In urgent cases please contact my officemates.