AN1905 ST Microelectronics, Inc., AN1905 Datasheet - Page 45

no-image

AN1905

Manufacturer Part Number
AN1905
Description
St7mc Three-phase BLDC Motor Control Software Library
Manufacturer
ST Microelectronics, Inc.
Datasheet
ST7MC THREE-PHASE BLDC MOTOR CONTROL SOFTWARE LIBRARY
4.3 APPLICATION LAYER
The application layer is split into modules; each module comes with a set of routines dedicated
to a peripheral, event (interrupt routines), or are grouped by functionality. The following infor-
mation summarizes the most important routines in the different modules.
regul.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . page 45
adc.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . page 45
it_ST7MC.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . page 46
ports.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . page 47
LinSCI.c. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . page 48
4.3.1 regul.c
This module contains the code of the PI regulation loop, which is used for closed loop opera-
tion.
The ‘u16 Period_To_Frequency(void)’ routine converts the Step_Z buffer information into
frequency (the Step_Z buffer contains the time elapsed between 7 zero-crossing events ->
corresponds to the time of six (6) steps period of the electrical frequency).
The ‘u16 regul_PI(u16 Target_Freq)’ routine computes the PI output according to Ki, Kp,
sampling time, and target electrical frequency. The returned value is a 10-bit long integer (0 to
1024).
4.3.2 adc.c
This module starts and initializes the analog to digital converter, and launches upon request a
conversion on a channel. It is able to provide ready-to-use values to the upper software layer.
It was basically written to monitor signals that vary slowly, such as trimmers, since the re-
turned results are averaged values of 8 successive conversions.
The ‘u16 ADC_Get_10bits(u8 Channel)’ and ‘u8 ADC_Get_8bits(u8 Channel)’ functions
return the ADC result on the selected channel.
The ‘u8 Get_RV1(void)’, ‘u8 Get_RV2(void)’ and ‘u8 Get_RV3(void)’ routines return the
value read on the potentiometers connected to the MCU (RV1, RV2, RV3).
The ‘BOOL Get_Temperature(void)’ returns a boolean. This function returns ‘TRUE’ if the
voltage on the thermal resistor connected to channel AIN0 has reached the threshold level or
if the voltage has not yet reached back the threshold level minus the hysteresis value after an
overheat detection.
In order to set the temperature and hysteresis threshold, the ‘NTC_THRESHOLD’ and
‘NTC_HYSTERIS’ values can be adjusted in the adc.c file.
45/77

Related parts for AN1905