Hello Everone!
there is a problem relate to PMSM Sensorless Temperature Measure ,I can not understand following Program:
Who can hellp me!
Thanks!
Hellorzkity@163.com,
Regarding the sensor, please refer to AN3624 S12X Temperature Sensor
https://www.nxp.com/docs/en/application-note/AN3624.pdf
All MagniV S12Z MCU have the same sensor.
BR, Daniel
The internal temperature sensor is described in the Reference Manual. You can find some basic information e.g. on the page No.324, where the voltage of the temperature sensor is calculated as VHT(temp) = VHT(150DgC) – (150 – temp)*dVHT.
The slope dVHT is defined in Table B-1, row #13, typically 5.25 mV/DgC. The VHT(150DgC) is defined by the same table, row #14, as 2.4 V without any trimming.
VHT(temp) = 2.4 – (150 – temp)*5.25E-3
As an example, if the temp is 20 DgC, the voltage would be
VHT(temp) = 2.4 – (150 – 20)*5.25E-3 = 1.7175 V
Now, since the ADC is scaled to VDDA, typically 5 V, the full scale voltage (5 V) would mean
Temp = (VHT(temp) – 2.4 + 150*5.25E-3)/5.25E-3 = (5 – 2.4 + 0.7875)/5.25E-3 = 645.2381 DgC
However, this voltage should never occur since the chip would already burned out.
You may notice that the characteristics obtained the way above will be shifted as indicated below by orange Original line (ADC input relative, fitting the Frac16 format). To compensate this, a shift and slope needs to be added.
The Original line can be expressed as:
VHT(temp) = 2.4 – (150 – temp)*5.25E-3
Scaled as:
VHT(temp) = (2.4 – (150 – temp)*5.25E-3)/5 = 0.48 – 0.1575 + 1.05E-3 * temp = ADC
ADC = temp * 1.05E-3 + 0.3225
To compensate, we would like to keep the maximum and have a zero output for zero temperature. Basically, we need to get from the input to the temperature through the Original line and then back to the input through the Compensated line.
Inverting the ADC function gives us:
Temp = (ADC – 0.3225) / 1.05E-3
The desired form of Compensated function is:
ADC_comp = Temp / 645.2381 (the output is scaled to 1.0)
Combining these two functions in one, we get:
ADC_comp = (ADC – 0.3225) / 1.05E-3 / 645.2381
To create a form of
y = k * x + q
We simply need to extract the k and q values:
k = 1/(1.05E-3 * 645.2381) = 1.476014
q = - 0.3225/(1.05E-3 * 645.2381) = - 0.476014
These values are unfortunately outside of the Frac16 scale (outside of the -1.0 to 1.0 range). Therefore, let’s divide it by two (to be able to use bitwise shift).
k = 0.738007
q = - 0.238007
This operation is giving us the result divided by two. After the operation is done, we can multiply it again by two and get the compensated results.
The math concluded is:
ADC_comp = (0.738007 * (ADC) – 0.238007)*2
ptr->measured.f16Temp.raw = (tFrac16)(ADC1ResultList[0][1]);
ptr->measured.f16Temp.filt = MLIB_Mul_F16(ptr->measured.f16Temp.raw,FRAC16(0.73801));
ptr->measured.f16Temp.filt = MLIB_Sub_F16(ptr->measured.f16Temp.filt, FRAC16(0.23801));
ptr->measured.f16Temp.filt = MLIB_ShL_F16(ptr->measured.f16Temp.filt, 1);
The calculation provided in the meas_s12zvm.c in the GetTemperature() function should be as above (in case it is not yet corrected in the examples provided online).
HI!
Matej Pacha ,Thanks ! I understand the implications of this programs for your answer.But how do i calculate the temperature value via this variable.
please help me !
Thangks!!