July 27 2022
The very first step that I took was to begin implementing the motor controllers with the Raspberry Pi and testing the thrusters. I started by breaking down the motor controller's datasheet and deciding which mode to place it in. After comparing the different options, I thought it would be best to use Mode 3 Option 2: Simplified Serial with Slave Select. This mode would make transmitting instructions to the two motor controllers simple and efficient. However, upon further research, I realised that I would have to use a level shifter in order to facilitate the serial communication between the Raspberry Pi and the motor controller or else the higher voltage may destroy the Raspberry Pi. Due to the inflexibility of the level shifter which is capable of performing only a single task, I opted to use an Arduino instead. The Arduino can easily communicate with the motor controllers through the TTL serial protocol and interface with the Raspberry Pi at the same time, with its SoftwareSerial library and dedicated serial hardware ports. As such I decided to combine the best of both boards and create a system wherein the Raspberry Pi would act as the central board for computation and data processing, running ROS and calculating thrust values, which would send instructions to the Arduino to request sensory data or output to the motor controllers. After setting up the circuit and uploading the programs I got the system working as shown in the video. Small steps, small victories!
The full code for the test can be seen here.