This is the part 2 of Module 6: Current Sensing (Part 1/2)
We finally reached to the most important part of the whole module. You may say that we "saved the best for last". This part make all the difference between reading the currents accurately or reading a total garbage. As a disclaimer, there is no bullet-proof method to setup the proper times for ADC reading. You will have to perform a series of tests that might be separated into 2 main categories:
- trial and error - start from an approximation of the known delays value and change the values steps by steps until you obtain the expected results;
- a combination of actual measurements and experiments to make sure the ADC sampling happens at the correct time intervals.
To demonstrate what i'm trying to say about these two methods let me share some oscilloscope captures with you that will prove my point. Now, i think is obvious for you why we have spent the time to implement the simple V/f open loop scalar control in Module 5: V/F Scalar Control . Having the possibility to drive the motor at various speeds allows us to investigate in detail how the current measurement works under real life conditions.
Lets start with Fig. 32, that shows the PDB interrupt triggered by the FTM PWM counter re-initialization. The interrupt is highlighted by a simple GPIO output pin toggle. Going further we have Fig. 33, that shows the phase A and B current variation. If we synchronize the PDB interrupt with the actual input to the ADC channel for one of the current and measure the waveform that corespondents to the worst case scenario as defined in Fig. 6, then we see that we might have up to 86us delay between the moment when the FTM is initialized and the moment when the lower transistor goes in conduction for the top speed we want to achieve. This is delay we want to consider for the PDB configuration.
Fig. 32: Synchronization between PWM command for the lower switch (cyan) and
PDB Interrupt (yellow) as result of FTM initialization trigger
|Fig. 34: PDB interrupt (yellow) vs. phase current (cyan) at the highest speed we want to achieve. Note the 86us delay between FTM initialization trigger and the actual motor when the lower transistor goes in conduction|
Furthermore, if we check the DC-link shunt voltage drop that corresponds to the current that is drown from the power supply we can see its variation and the delay relative to the beginning of the PWM period. That is another information we want to consider for the PDB configuration.
|Fig. 35: PDB interrupt (yellow) vs the DC-link current (cyan) at the highest speed we want to achieve. Note the 70us delay between FTM initialization trigger and peak of the DC-link current|
Based on the hardware measurement for the phase currents at high speeds and various experiments I've reached to the ADC triggering timings diagram shown in Fig. 36.
This diagram is valid for 10kHz PWM switching frequency only and shows how the ADC conversions are controlled via the PDB pre-triggers that are in turn delayed compared with the beginning of the PWM period. Please note that how the phase current ADC conversion are synchronized to happen in the same time for both ADC modules.
Based on the information shown in Fig. 36, we can configure the PDB0 and PDB1 instances directly from Simulink blocks
|Fig. 37: PDB0 and PDB1 global configurations: trigger source, external trigger type and PDB counter value|
This way the PDB0 and PDB1 will trigger the ADC0 and ADC1 conversions at specific time intervals and all that remains for the CPU is to read those values and use them for FOC. To ADC0 and ADC1 conversion results are read on PDB1 interrupt handler that is triggered each time the PBD counter is re-initialized.
For the moment the ADC conversion are read based on the PDB interrupt. This will be later on changed to read the values as soon as the last ADC hardware conversion is ready. This will ensure a minimal delay between the moment when the phase current are acquired and the moment when the next commutation sequence is updated.
For most of the common application that deals with relative small speed range this kind of mechanism is robust enough, but once you go into high speed regions like tens of thousandth of RPM the delay between the moment the current are measured and the computation of the rotor position is becoming critical. In practice to deal with such scenario you will need to perform electric angle compensation to avoid the lost of de-synchronization of PMSM.
MEASUREMENT OF CURRENTS and VOLTAGE
Once the ADC conversion are ready we need to transform those into actual currents and voltages by applying various scaling factors and offset compensation. We are not going crazy with explanations about how the ADC conversion works and how the read hardware implements the shunt voltage drop scaling. If you wish to get more information about this subject you may consult the Motor Control Class: Lecture 3 - Input Commands
The PMSM phase current measurement model is shown in Fig. 41. All you need to know is that the ADCs were configured to use 12bit precision and the shunts resistors can measure an instantaneous AC currents with the peak-to-peak amplitude of 31.25Amps
The DC-link bus voltage measurement Simulink model is shown in Fig. 42. Depending on the MotorGD DevKit jumper settings the DC voltage that can be measured via the voltage resistors divider network is up to 45Volts DC.
And finally for the DC-link current the Simulink model used to covert the ADC acquisitions into actual Amps is shown in Fig. 43.
|Fig. 44: ADC conversion raw data: (yellow) - phase A current, (cyan) - phase B current, (red) - DC link current, (blue) - DC bus voltage|
Fig. 45: 1000RPM PMSM phase currents: (yellow) - phase A current measured, (cyan) - phase B current measured,
(green) - phase C current computed
Fig. 46: 3000RPM PMSM phase currents: (yellow) - phase A current measured, (cyan) - phase B current measured,
(green) - phase C current computed
For DC bus values acquisitions we are going to modify the power supply voltage levels. The ADC acquisition from the target shall follow those variations.
Due to the scalar control method that keeps constant V/f ratio the DC-link current is going to follow the variations in the DC bus voltage.
As a final validation we can check the PMSM startup sequence and how the values of the currents are changing over the time.
After going thru this module you should now have a good understanding about the hardware and software techniques required to perform various system measurements. You should now be aware of various tips & tricks to measure the most important quantities needed for Field Oriented Control. Depending on the hardware your are working on there might be slightly different hardware modules involved but the generic approach is the same: you need to synchronize the ADC readings with the PWM commands.
Another aspect that is highlighted in these 2 parts article is the correspondence between the actual analogue signals and the values used application. As you have seen the sensing information is totally different than what you normally expect as current waveform and it is up to the software to assemble all the pieces together and form the AC quantities we are all used with.
In the end I would like to highlight that each system engineer that is involved in the area of power drivers should always verify the measurements since those represent a very important factor in the overall control strategy. As you can see the measurements are polluted with EMI noise that may create us lot of problems later on. Understanding the rood cause of the noise and delay is a key factor towards a robust motor control solution.
Before using the new models make sure you apply all the hot-patches from here: HotFix: MBD Toolbox 2018.R1 for S32K