This post was last edited by yang_alex on 2018-7-4 13:53 Having said so much before, let me quickly summarize the tasks I have completed:
Task 1: When the motor is running, use P-NUCLEO-IHM002 to measure the three-resistance current sampling waveform, and output this waveform through DA, and take a screenshot Use Motor Workbench to set the current Ia to output from DAC1, and then use an oscilloscope to measure the DAC output.
Task 2: Get the key variables during FOC control: Ia, Ib, Ic, Ialpha, Ibeta, Id, Iq, Vd, Vq, and take screenshotsTask 3: Monitor any data variables and take screenshots These two tasks feel that Task 2 can represent Task 3 (the special case must meet the requirements of the general situation). Of course, Task 3 can also monitor other data, and the means are the same. The key variables for FOC control, Ia, Ib, Ic, Ialpha, Ibeta, Id, Iq, Vd, Vq, are located in the project file mc_tasks.c automatically generated by MotorControl Workbench. The relevant code is as follows:
- inline uint16_t FOC_CurrController(uint8_t bMotor) { Curr_Components Iab, Ialphabeta, Iqd; Volt_Components Valphabeta, Vqd; int16_t hElAngledpp; uint16_t hCodeError; hElAngledpp = SPD_GetElAngle(STC_GetSpeedSensor(pSTC[bMotor])); PWMC_GetPhaseCurrents(pwmcHandle[bMotor], &Iab); Ialphabeta = MCM_Clarke(Iab); Iqd = MCM_Park(Ialphabeta, hElAngledpp); Vqd.qV_Component1 = PI_Controller(pPIDIq[bMotor], (int32_t)(FOCVars[bMotor].Iqdref.qI_Component1) - Iqd.qI_Component1); Vqd.qV_Component2 = PI_Controller(pPIDId[bMotor], (int32_t)(FOCVars[bMotor].Iqdref.qI_Component2) - Iqd.qI_Component2); FOCVars[bMotor].Vqd = Vqd; Vqd = Circle_Limitation(pCLM[bMotor], Vqd); Valphabeta = MCM_Rev_Park(Vqd, hElAngledpp); hCodeError = PWMC_SetPhaseVoltage(pwmcHandle[bMotor], Valphabeta); FOCVars[bMotor].Iab = Iab; FOCVars[bMotor].Ialphabeta = Ialphabeta; FOCVars[bMotor].Iqd = Iqd; FOCVars[bMotor].Valphabeta = Valphabeta; FOCVars[bMotor].hElAngle = hElAngledpp; return(hCodeError); }
复制代码We know that the sum of the three-phase current is 0: Ia+Ib+Ic = 0, so Ic can be calculated by sampling only Ia and Ib. Then through continuous coordinate transformation, Ia, Ib, Ic ----> Ialpha, Ibeta -----> Id, Iq Then PI adjustment is performed on Id and Iq to obtain Vd and Vq, and finally an inverse park transformation is performed to convert the two-phase voltage into a three-phase voltage. Therefore, the most convenient way is to import the variables into STM-STUDIO and use the functions of STM-STUDIO to view the relevant variables.
It can also be expressed in the form of a table:
Another way is what I said in my previous post 2.4, Software Analysis--Code Compilation and Debugging, which introduced the Motor Workbench function. In the motor debugging function interface, many data and key variables can be monitored and even changed. (Dashboard form, register table form, space form). But it is a bit strange that the values of Ia, Ib, Ic, Ialpha, Ibeta, Id, Iq, Vd, and Vq can be seen in the register tab, but there is no output. I have studied it for a long time and still have no clue. I will study it later when I have time. But many other variables can be monitored and changed (some can be changed, some cannot be changed). This can be regarded as completing Task 3.
Self-designed evaluation task: Test the low-speed performance and stall protection of the 5.0 library Use the motor debugging function of Motor Workbench to complete it. Use this function to adjust the motor speed. In the current test, the motor protects when it detects that the speed is lower than 200. This is probably not a problem with the algorithm, but a problem with the relevant parameter settings. If there is enough time to debug the parameters, the effect will be better.
This content is originally created by EEWORLD forum user yang_alex. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source