Over the past few weeks, a circuit diagram for the Micro-moto version 2 has been created from the previous considerations. After some productive reviews and discussions about the schematic and the incorporation of various improvements and changes, a board layout was drawn in KiCad.
The production of the board was sponsored by Aisler and after only about a week of waiting the boards and all components arrived in our lab.
Quickly two boards were assembled and except for one single solder bridge successfully soldered in the reflow oven. Only the (optional) vertical Micro-USB connector had been forgotten when ordering the components, but this was no problem, since programming via SWD is more convenient for testing due to its debugger interface.
Step by step, power supply, STM32 microcontroller, status LEDs and gate drivers including MOSFET power stage were tested successfully. Everything worked on the first try, for once.
The next step is to bring the current and voltage measurement into operation. For this purpose we document in this blog post the requirements and development of the implementation with the analog-to-digital converter of the STM32G4 microcontroller.
- ADC sampling synchronous to PWM of motor (approx. 100kHz)
- Sampling on every PWM cycle
- For all phases either current or voltage are measured: current on both “switched” phases, voltage on the “high-impedance” phase
- Measure current in both phases simultaneously
- Additional ADC measurements at low priority and with low frequency
- Motor supply voltage
- 3.3V supply voltage (Vbat)
- NTC temperature sensor
- Internal temperature
ADC channel usage on the micro-motor
|Possible ADC channels
|Motor supply voltage
|3.3V supply voltage
|NTC temperature sensor
The three critical measurements will be sequenced as “Injected Conversions” and triggered by a event generated from the timer which generates the Motor-PWM.
In an “Injected conversions sequence” (sequence length is limited to 4) each conversion has its own output data register. Thus all conversion results can be easily read one after the other in the time until the next PWM cycle and no interrupts are needed.
For every of the six valid commutation steps that define the state of the three MOSFET half bridges, a mapping to the ADC channels is predefined and applied during the commutation.
Low-Priority measurements are sequenced in the ADCs “normal-mode” sequence and are triggered at a lower frequency (by another timer or manually from code).