## 2 Design, Modeling, and Control
### Electronics Design  
Regarding the communication system between all subsystems (robot and joint microcontrollers), it must be robust, fast, and consistent. Previously [21], it was necessary to implement two serial COM (communication port) on the Arduino to communicate between the main microcontroller and the ones on the joints. However, the complexity of the message flow between the joints and the microcontroller increased drastically. Therefore, the system's expandability was very limited. For example, it would be difficult to increase the number of sensors/actuators for each joint, which would impact the vehicle modularity. Another added difficulty was that the joints had no knowledge of their position in the leg.  
Considering the described issues, several changes were performed. The first one was the introduction of a third microcontroller associated with the hip joint, since it was necessary to divide all the peripherals being used.  
Another one was to replace the Arduino main microcontroller with a Teensy 4.1 board. This board has increased processing power, a greater number of available serial ports, as well as I/O pins.  
Another adopted strategy was to use the flash memory of the NINA W102 ESP32 module that the Arduino Nano 33 IOT has built-in to save each joint position on the robot. For example, joint 1 of the leg 0 was numbered _joint10_, making it possible to identify the low-, middle-, or top-level joints. This flash memory usage serves also to implement another change, which is saving the parameters associated with each joint, namely, absolute encoder offsets and controller tuning parameters, among others.  
\begin{table}
\begin{tabular}{c c} \hline \hline  & **Dimensions** \\ \hline Length & 0.850 m \\ Width & 0.465 m \\ Minimum Height & 0.320 m \\ Maximum Height & 0.505 m \\ Weight & 18 kg \\ \hline \hline \end{tabular}
\end{table}
Table 1: Robot dimensions.  
Figure 8: Robot dimensions.  
Another important improvement was the addition of an absolute encoder on the angle before the joint, i.e., directly to the motor shaft (defined as _Absolute Encoder In_, from here onwards). Using this information, it is possible to calculate the springs extension, and avoid an extension greater than the allowed one, which would cause damage to the springs. To obtain this measurement, AS5048B encoders were used, which communicate through the I2C (Inter-Integrated Circuit) protocol.  
As another safety measure, Reed effect end switches were included in each non-rigid joint, preventing them from hitting the vehicle itself. The sensors used for this function were the LittelFuse 59025, and the respective 57025 magnets.  
Another consideration regarding the electronic design was that the previously used motor driver was capable of sending high currents to the motors, which caused some accidental motor damaging, when some problems on the joint's references occurred. Considering this, the motor drives of the non-rigid joints were also changed, now using the Adafruit 3190 (DRV8871).  
This set of changes made it possible to transfer all the required calculations to the main processor, such as calculating direct and inverse kinematics, angular and speed references for each joint, as well as their smoother trajectories of each of the joints. Additionally, it is also in this microcontroller that the robot's kinematics is calculated for its trajectory tracking mode.  
With this configuration, the joint microcontrollers are only responsible for receiving the position and speed references, calculating them through the respective controllers, and defining the PWM references of the respective motors.  
Figure 9 illustrates the mentioned hardware, as well as their positioning in the leg and, specifically, in the joint.  
Figure 9: Single leg hardware diagram.  
Considering that the low-cost is a concern, and that all the hardware used for its construction has already been presented, Table 2 contains a detailed version of all the materials, as well as the individual and total price range.