The Ada Motorcontrol software platform for a brushless DC motor controller was developed by Jonas Attertun from Sweden. It consists of a basic but clean and readable implementation of a sensored field oriented control algorithm along with a logging feature that will simplify development and allows users to see what is happening. The project shows that Ada successfully can be used for a bare-metal project that requires fast execution.
As the Ada programming language has been designed specifically for safety critical applications, it could be a good alternative to C for implementing safe motor controllers in applications such as electric vehicles. However, it is not uncommon that a mistake in C eads to destroyed hardware such as burned motor or power electronics, says Attertun. The stricter compiler of Ada could prevent such accidents.
The open source project includes core software for controlling brushless DC motors with support both sensored and sensorless operation. It uses Ada on top of the Ravenscar runtime for the STM32F446, ARM Cortex-M4, 180 MHz microcontroller with FPU but should not be too difficult to port to another microcontroller or exend, he says. The hardware board uses 60V power MOSFETS with Inline phase current sensing, a PWM/PPM control input, position sensor input as either hall or quadrature encoder, motor and board temp sensor (NTC) and expansion header for UART/ADC/DAC/SPI/I2C/CAN.
The 'Make with Ada' competition was sponsored by French tool developer Adacore and Attertun won €5000. A smartwatch running Ada and an Internet of Things (IoT) stack came second and third.