PolySTAR-mtl / PolySTAR-Taproot

GNU General Public License v3.0
6 stars 0 forks source link

Arduino UART Debug Display #13

Open FreshOlives opened 1 year ago

FreshOlives commented 1 year ago

Specification

We need a way for the robots to display information for debugging purposes.

For example, when setting the angle limits for the turret, it would be helpful to have a way to see the turrets current position as read by the robot. In another use-case, we might want to see exactly what inputs the robot is receiving from the controller.

We will solve this problem by using an Arduino microcontroller hooked up to an I2C LCD Screen. The Arduino will receive data over its UART pins (0 and 1) from the RoboMaster Board A, and then display that data on the screen via I2C.

Here is the hardware we are using: Component Link
Arduino Nano https://docs.arduino.cc/hardware/nano
20x4 LCD Display Module https://www.amazon.ca/gp/product/B07TXBV8MS

We will go about implementing this in two phases:

Level 1: Forwarding received Strings

The first implementation will assume that only strings will be sent to the Arduino, and it will display them as is on the LCD display.

Each string will end with a null terminator ('\0'), and string may contain newline ('\n') characters. The newlines should be reflected in the display.

Level 2: Multiple message types and simultaneous display

The second implementation will instead consider the serial data received as packets, and each packet will have an identifier indicating what variable is being sent over. The Arduino will process these messages and update each variable in memory as necessary. While this happens, the Arduino will continuously display all the variables at once on the screen.

Implementation

For both levels of implementation, you can test your code by sending data to your Arduino via the Serial Monitor interface. This will send data over UART in exactly the same way as the Board A will.

Level 1

For this level, you will need to figure out two things:

And here is an example project doing something similar to what we are trying to do.

Remember that almost all Arduino libraries come with example sketches, use them as a starting point for your code.

As usual, don't hesitate to give us a shout on Discord if you have any questions.

Level 2

Coming soon

FreshOlives commented 1 year ago

@h-SLberu @Cloudedxyekay I ran some tests while putting together the LCD for Yemisi, therefore I can confirm that the LiquidCrystal I2C does indeed work with our hardware.