This robot is supposed to resemble the miniature toy version of Johnny 5 robot from the movie "Short Circuit 2". Learning STM32 I have decided to migrate this robot from Arduino to STM32F411 and FreeRTOS. It is amazing how much you can do with the power of Cortex M4 in STM32F411, FreeRTOS is in particular interesting because it allows you to use the kernel's scheduler to manage execution of tasks. Each task implements specific code that is executed in an infinite loop, so we don't have to manage what is executed in sequence, the scheduler does that for us based on tasks priorities. This allows for implementation of code that for the user gives immersion as if the robot was performing few things at the same time.
This project has a long history and I have made it before I acquired a 3D printer. Originally it was based on Arduino which is very limited when it comes to interrupt or methods of communication with peripherals. Now this project uses three timers. One is for counting the time in which a signal from an ultrasonic sensor returns. This sensor also uses interrupt so that the robot is not waiting for the signal in a hot loop but can actually execute something else. Second timer is used for control of servo motors of arms and neck. The neck is important because it moves ultrasonic sensor around. Angle of servo motors is controlled by the duty cycle of PWM signal generated by the timer. Third timer is also used to generate the PWM but for the motors so that speed can be controlled.