Hardware Setup + Communication Interfaces drive me crazy
Before you look at the time and freak out, I ran into like a dozen errors and each could have been caused by at least ten different independent variables 😭.
What did you do?
Anyway, I set up a Raspberry Pi 4 (the thing I’m also currently using for my website, www.StatixLabs.org) and a Pi Pico. I soldered the pins on a DRV8833 motor driver module and connected it to the Pico. I then created 2 UART lines from the Pi to the Pi Pico, allowing them to communicate serially. I then attached a mini N20 motor (with encoders) to the Pico’s motor driver, but this will change when I get the funding to buy motors that can actually sustain the weight of the robot. I then created a command structure in which the Pi transmits a single byte of data to control the motor. The structure of the packet (well, at least I think it’s a packet?) is 4 bits for speed + 4 bits for command. On the regular Pi, I created a script that accepted user input in the form command,speed in which speed was a normalized float, being optional for the command stop which assumes a speed of 0. Commands like forward and backward transmit 0x?A and 0x?B, respectively, and the ? is just a placeholder for the speed nibble.
Sooooo, why three and a half hours?
Great question! It took me a solid hour to figure out how to use the motors with the Pi Pico. This is because I initially had one of the Undercity themed Pico Devboards, and I thought they were really cool so I didn’t wanna mistakenly ruin the design because of my lousy soldering. So, I just decided to use header pins and sandwiched the devboard in between the header pins and the breadboard. It partially worked, but it was unreliable for the entire right half of the board. I ended up having to use one of my Pico 2’s that I had already soldered, and I also had to change the CMake to account for this. I was extra confused because UART communication worked perfectly fine with my previous sandwich approach, but simple PWM motor control didn’t. Oh well, at least everything worked out in the end after the switch 🫠.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.