Swerve Drive
Hardware- 14 Devlogs
- 65 Total hours
Coaxial FRC style swerve drive using n20 motors for steer and brushless gimbal motors with FOC for drive
Coaxial FRC style swerve drive using n20 motors for steer and brushless gimbal motors with FOC for drive
Done! 🎉
I finished making all the things for the github like the wiring diagram and demo video. Fixed all issues with field relative control, my original math was incorrect. Also one of the modules wasn’t rotating correctly but it turns out it was just the magnet came loose.
Will be submitting to Outpost soon!
Demo video link: https://www.youtube.com/watch?v=bPC4PA_9ZH0
First Movements
Tested full motion for the first time woohoo! 🎉🎊
Things surprisingly worked alright, the kinematics for the rotation while strafing is still a bit off but translation by itself works great. Also the wheels have very little traction so I’ll have to increase that somehow.
Additionally, field centric control on the joystick works really well, so up on the joystick means up in real life relative to the start heading and regardless of the rotation of the robot.
Things Left to Do on Hardware
Things Left to Do on Software
Integration Pain
I got all the subsystems working separately but the extremely fun part of integrating them all together was the first time I truly understood why engineers hate integration. There were a plethora of pin conflicts underlying the hardware since many of the pins on the nucleo serve multiple purposes.
One example of this was the adafruit motor shield’s i2c bus interfering with the front left drive motor’s FOC math since PB8 and PB9 are connected to the sda and scl pins on the Arduino headers of the nucleo. As you can see from the extremely janky wiring in the photo, just connecting the shield so it gets power on the other side of headers and manually connecting the shield to a separate i2c bus using jumper wires, I was able to finally make all the subsystems work together.
This was just one example of the many problems that arose, hence why there are almost 12 hours being logged in this post, but this project is finally on the last stretch. I did also make a lot of other progress like confirming the swerve kinematics work along with the flysky controller for inputs :)
Things Left to Do on Hardware
Things Left to Do on Software
Side Quest
The adafruit motor shield v2 that I am using to control the n20 motors suddenly stopped working today. After a long struggle, I managed to trace it back to the A4 and A5 pins being attached to the nucelo alongside the dedicated SDA and SCL pins. Since SDA and SCL are tied to A4 and A5 on normal arduinos but seemingly not on nucelos, simply removing those pins fixed all issues. A very unsatisfying end to a 3 hour struggle :(
I did mange to test out the front left module, and spent some time tuning the azimuth pid.
Things Left to Do on Hardware
Things Left to Do on Software
Finished Wiring
As you can tell by this extremely beautiful cable management and totally not messy arrangement of wires, I should have probably made a pcb for this (Maybe I will later).
Things Left to Do on Hardware
Things Left to Do on Software
Swerve Drivebase update
Cut out bellypan out of scrap board because creating large panels isn’t really suited for 3d printing and I can drill new holes into this material easily for mounting electronics. Mounted the majority of the electronics as well.
On the software side I got radio communication working and created a new .h and .cpp file for implementing radio control into the main program.
Things Left to Do on Hardware
Things Left to Do on Software
Finished Drive Base
Got all the modules built and attached. Some modules are a little bit stiff so if that hinders the motors I’ll need to change some clearances, but I think its minimal enough to where it won’t matter.
Things Left to Do on Hardware
Things Left to Do on Software
Swerve azimuth control
Got PID working for one module, though it probably still needs to be tuned. Also I need to figure out the logic for wrapping around since the encoder measures values from 0-1023 which I have mapped to 0 to 360, but after 360 it goes back to 0 which complicates the logic a bit. I also need to implement the logic for the swerve just switching the wheel rotation direction rather than rotate the entire module 180 degrees whenever it can. Realistically, the module should only ever rotate a max of 90 degrees from one input to the next
Tested all hardware for the swerve drive. The latest version of SimpleFOC (2.4.0) doesn’t work for some reason but the previous version (2.3.5) works perfectly fine. The as5600 encoders work great and track the rotation of the module nicely. I also made a few design changes to make assembly easier which includes changing the design of the encoder column support and the design of the standoffs.
Swerve module v1 assembled! The gears mesh nicely and the entire system has a lot less friction than I thought it would :)
Things needed to do in terms of design:
Finished soldering wires to the motors and header pins to the encoders. Got stm32 nucleo 64 f411re working with platformio ready for programming along with the motor shield to control everything!
finished building one module in real life!
Added drive column for drive gear train which is coaxial to the encoder column which has the magnet for the as5600 to track the module’s rotation. Done with the drive module for now, moving on to the motor mounts!
CAD for a single module done including gear relations. No motors yet