This post was last edited by my student number on 2023-1-23 19:02
This article mainly records the Infineon imotion motor control solution
To run imotion on the motor kit, three softwares need to be downloaded:
MCEWizard tool: It can be used to configure the development board information and motor parameters, and generate txt, ldf, map and other files
MCEDesigner tool: Use it to write scripts and burn files, change parameters and track status in real time
IMOTION2GO software package: The official routine is of reference value. If an error occurs, you can flash back to the official firmware.
In addition to INFINEON's own IDE, it also supports MADK (keil) development, which is not the focus of this evaluation and is omitted.
The above files can be downloaded after registering on the INFINEON official website. The addresses of the first two are:
https://www.infineon.com/cms/cn/product/power/motor-control-ics/imotion-integrated/?tab=~%27all#!designsupport
Download address of the package:
https://www.infineon.com/cms/cn/product/evaluation-boards/eval-imotion2go/?tab=~%27all#!designsupport
After downloading, just follow the next installation, no big problems
Next, let's understand the configuration of MCEWizard in combination with the example:
Double-click to open the MCEWizard shortcut, and select "iMOTION2go190904-Neweco2.mc2" from the unzipped 2GO software package in "File".
If the hardware has not been changed, just click the default setting on the left and click Next. If there are any changes, select the menu on the right to modify them.
Displays basic information. The lower right corner shows that 74% of MCU resources are used.
Next is 14 questions about motor parameters and starting methods
First, the motor name, this is optional, it must be at least one word without spaces or tabs
Second, the rated effective current of the motor, which needs to take into account the current, frequency and temperature protection of the power converter
Third, the number of motor pole pairs. This test is 8 pole pairs.
Fourth, motor stator impedance
Fifth, the q-axis impedance of each phase of the motor
Sixth, the motor's D-axis impedance per phase
Seventh, the motor back EMF constant, which is usually marked on the nameplate; or by measuring the line-to-line voltage and converting it to the line-to-center voltage; if measuring a BLDC motor, note that the calculation method of the effective value is different
Eighth, the maximum speed of the motor; if the value exceeds the manufacturer's design, it may affect the safety of the motor.
Ninth, minimum operating speed; it is the initial speed of the motor when the slope is running; if it is set too low, the motor will not run reliably;
If flux estimation is used, the minimum speed can be set to 5% to 10% of the rated speed.
Tenth, the acceleration and deceleration slopes of the motor, can the acceleration and deceleration only maintain the same value?
11. Open loop slope, the speed slope during the startup phase. When set to 0, the open loop startup will be closed.
12. Parking time, the positioning time before open-loop start. Setting it to 0 will skip this stage. Note that this function may be invalid under high load and high friction conditions.
Thirteenth, low speed threshold, setting the low speed limit and low speed threshold will generate a linearly increasing current limit value between the two; this will facilitate smooth starting at low speed
14. Low speed current limit value; same as above
Then the ADC PIN and GPIO settings of the IC
The ADC for detecting the speed control signal and the GPIO7 for controlling the LED are used here.
Resistance sampling settings, UART communication, PWM frequency, etc., and GK signal protection. Because the template is used, no settings are required here.
Click "Script Coding", the script content is as follows:
#SET SCRIPT_USER_VERSION (1.00) /*Script version value should be 255.255*/
#SET SCRIPT_TASK0_EXECUTION_PERIOD (50) /*Script execution time for Task0 in mS, maximum value 65535*/
#SET SCRIPT_TASK1_EXECUTION_PERIOD (1) /*Script execution time for Task1 in 10mS, maximum value 65535*/
#SET SCRIPT_START_COMMAND (0x3) /* Start command, Task0 : Bit0, Task1 : Bit1; if bit is set, script executes after init */
#SET SCRIPT_TASK0_EXECUTION_STEP (1) /* Script Task0 step, This defines number of lines to be executed every 1mS*/
#SET SCRIPT_TASK1_EXECUTION_STEP (10) /* Script Task1 step, This defines number of lines to be executed every 10mS*/
*/
/*********************************************************************************************************************/
int sVar0,led;
/*********************************************************************************************************************/
/*Task0 init function*/
Script_Task0_init()
{
int sSVar0,sSVar1,sSVar2,volt,limit;
sSVar0 = RunTimeCounter;
sSVar2=0;
limit=16000;
}
/******************************************************************************************************************/
/*Task0 script function*/
Script_Task0()
{
if((RunTimeCounter-sSVar0)>5000) //Every 5S
{
sSVar0 =RunTimeCounter;
sSVar1=1;
}
if (ADC_Result0>100) /*(AIN0)*/
{
volt=ADC_Result0<<2; //max=4096X4=16383, min=100x4=400
if (volt>limit)
{
volt=limit;
}
if (sSVar1==1) /* RunTimeCounter */
{
if (Command == 1)
{
Command=0;
}
else
{
if (sSVar2==1) //switch direction
{
TargetSpeed = volt;
sSVar2=0;
}
else
{
TargetSpeed = (-1)*volt;
sSVar2=1;
}
Command=1;
}
sSVar1=0;
}
}
else
{
Command=0;
}
}
/******************************************************************************************************************/
/*Task1 init function*/
Script_Task1_init()
{
int sBVar0,sBVar1;
sBVar0=0;
GPIO7_OUT=1;
}
/******************************************************************************************************************/
/*Task1 script function*/
Script_Task1()
{
if (MotorSpeed==0)
{
GPIO7_OUT=1;
}
led= GPIO7_OUT;
sVar0=sBVar0;
if(sBVar0<16000)
{
if (MotorSpeed>0)
{
sBVar0=sBVar0+(MotorSpeed>>2);
}
else
{
sBVar0=sBVar0-(MotorSpeed>>2);
}
}
else
{
sBVar0=0;
GPIO7_OUT=~GPIO7_OUT;
led=GPIO7_OUT;
}
}
The script defines 4 functions, namely the initialization of task0 and task1, task0 executed once every 1ms and task1 executed once every 10ms.
According to the comments, each time task0 is entered, the speed value read by ADC is queried, and the speed direction is changed every 5 seconds; task1 combines the LED status light with the motor speed.
After that, the settings are confirmed, and the regulator, PWM control mode, ADC sampling mode, error checking, etc. are set.
Then select compile, and if it is correct, the script can be generated. Select export to generate a txt file for use by MCEDesigner
From now on, the MCEWizard setup is complete