cancel
Showing results for 
Search instead for 
Did you mean: 

Integer conversion resulted in trucation - ID_DEMAG

luke23
Associate III
Posted on March 31, 2014 at 21:32

I am receiving this compiler error in SystemNDrivePrarms.h on lines 8182, 8216, and 8250 when compiling MCTasks.c.  (MC version: 3.4.1, IDE: IAR EW for ARM 7.10)

  ID_DEMAG,        /*!< Demagnetization current in s16A: 

                        Current(Amp) = [Current(s16A) * Vdd micro]/ 

                               [65536 * Rshunt * Aop] */

The demagnetisation value I input to MCWB is 5.1Ampere.  Did I do something wrong? 

To work-around, will the algorithm tolerate a maximum representable value that has not truncated?

#hj #integer-truncation
5 REPLIES 5
luke23
Associate III
Posted on March 31, 2014 at 21:47

Here is the #define from lines 51-54 of

PMSM motor parameters.h

:

#define NOMINAL_CURRENT         15745 

#define MOTOR_MAX_SPEED_RPM     23000 /*!< Maximum rated speed  */

#define MOTOR_VOLTAGE_CONSTANT  0.6 /*!< Volts RMS ph-ph /kRPM */

#define ID_DEMAG                -47236 /*!< Demagnetization current */

Gigi
ST Employee
Posted on April 01, 2014 at 09:46

Ciao Luke

This warning isn't to understimate this because it means that with these setting some overflow has occurred by the preprocessor.

In this case I suspect that the Demagnetizing Current in motor - electrical parameter is greather than the measurable one due the current feedback network.

If you attach the WB file I can take a look.

Ciao

Gigi

luke23
Associate III
Posted on April 01, 2014 at 21:21

Attached.

The demag current for my motor is provided for me as >5A.

If I reduce the demag current from 5A to 3.5, then this figure does not clip (truncate) in the pre-processor - it's easy to see this from the formula which is used to represent the demag current.

Must the demag current be within the dynamic range of the current detection processing circuits, or is this figure used for setting motor operating parameters?

Thanks

________________

Attachments :

Demag_Current_Trunc.stmc : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzJ9&d=%2Fa%2F0X0000000bJb%2Fv33vKP8kPvceCDSO7Wt7xCi6rcbdUyQaQBPVkrp6ZuI&asPdf=false
Gigi
ST Employee
Posted on April 02, 2014 at 09:24

Ciao Luke,

you catch the point. It has to stay in the dynamic range of the current detection processin circuits oterwise you get an overflow in the computation.

Ciao

Gigi

Laurent Ca...
Lead II

Adding of "STM32 Motor Control" topic.

Best regards.