4.1.3 Software Architecture
The software performs the following tasks:
- Microcontroller and motor control peripheral initialization
- FOC State machine in the ADC ISR
- Motor start and stop command through the GPIO button
- Motor speed command from the potentiometer
Motor Control Peripheral Initialization
On Power-on Reset (POR), the software initializes the microcontroller and motor control peripherals according to the user requirements.
Motor Control State Machine
The software implements the motor control tasks in the ADC ISR. The ADC ISR incorporates the following states:
- Idle: In this state, the motor does not spin. The software waits for a valid button press from the user to start the motor.
- Start-up: In this state, the software executes the PMSM start-up procedure as described in Start-Up Procedure.
- Close-loop speed control: In this state, the software executes an SMO-based sensorless FOC.
Motor Speed Command From Pentiometer
The software calculates the speed reference from the measured potentiometer input.
Motor Start and Stop Command by GPIO
The software polls the GPIO button every 10 ms to check if the button has been pressed. If the button press is detected, the software changes the motor control state from Idle to Start-up. This initiates the motor spin at the specified reference speed.
The following figure illustrates the software flow-chart of the example project: