There was a lot of learning opportunities that uh occurred during this entire process and i’ll kind of walk you through all that and then we’ll get into some basic testing of the car itself. 好, so first up was the actual front suspension itself, which i hadn’t completed. In the last video, i went through a ton of different design, approaches for the front suspension and actually finally, just settled on attaching the shock directly to the servo arm. I ended up with just a tiny bit: less travel about 17 millimeters of travel at the servo instead of 20 millimeters in the rear and close to really close to actually 40 millimeters at the wheel. So it’s really not that far off. Only a couple millimeters less than the rear. Also in the last video i mentioned that i’d be using uh 10k potentiometers here at each wheel to measure the deflection of the suspension system itself, but that proved to be horribly problematic. If you watched my f1 gearbox videos, you saw, i fought with poor quality potentiometers on that project and i faced the exact same issue with this project. I had two of the potentiometers go bad within five minutes of installing them, and the readings were super. Inconsistent would jump around so like the f1 gearbox i enlisted the use of the as5600 magnetic encoder, so this lever arm here is attached to a small, diametrically uh magnetized magnet, which is inside this little uh cylinder here and that’s kept about a millimeter off of the As5600 itself, i’m getting very consistent readings, and i also positioned all the magnets so that i didn’t have to deal with the wrap around logic, which is another challenge i faced with the f1 gearbox so thumbs up on that.
Oh and the library for the as5600 from electronic cats for the arduino addressed the memory register issues i was facing when i was doing the f1 gearbox development. So i can actually read the as5600 while it’s moving at a high rate of speed. So that’s awesome as well and because the as5600 only has one i2c address available. I had to use a tca 95 48a i2c multiplexer, which has proven to be really easy to use. You can just plug each of the individual encoders for each wheel into this chip and then tell it which encoder you want to talk to, and the tca 9548 acts like a direct pass through and you don’t have to change any of your code, 这是真棒. So now that i had everything wired up, i performed some basic testing to make sure all the encoders were reading and that the servos were working properly. I definitely need an emergency stop switch as the servos are more than strong enough to break parts, so i definitely will be implementing that in the future. Now to make the suspension move in a coordinated manner, i need to develop a kinematic model for the truck. Initially, i thought about working back through all the suspension angles to come up with a full inverse kinematic model where i specified a wheel position and the algorithm figured out how to position the wheel there. But i quickly gave up on this because my trigonometry game is very weak and it’s difficult to account for the suspension travel, particularly from the front which has such an extreme caster angle.
Because the front and rear suspension, regardless of the controller scheme, will need to be tuned differently. I went ahead and opted to use my own units of measurement for now, which i can easily change later. 所以, to do this, i lowered the entire truck as low as you go without the servos fouling. I then raised whichever end was lower of the truck until the chassis was perfectly level front to rear. I then had to trim a little bit side to side because because the left side was a little bit higher for some reason, so i went ahead and did that and then i repeated the same process for the maximum height possible. I now had recorded kind of my min and max microsecond values for each servo. Now these min and max values are really relative to the actual chassis position, so the reality is that the min value, which is the minimum height of the chassis, can actually be higher. In microseconds than the max value that’s, because the servos are all spinning in different directions, depending on which corner they’re installed on so then i create a method in code that actually takes in a value from 0 自 100 and using the map function, that’s built into Arduino i linearly interpolate each servo between their min and max values, meaning that if i pass in a value of 100, the chassis will be at its max ride height. If i pass in a value of 0, it will be at its minimum ride, height and 50.
Should be exactly in the middle, i wanted to work out some relatively tame transformations. 第一, like controlling roll and pitch about a point. So i created this method which uh actually took far longer than i expected, but i can pass in a value between 0 和 100 to control the right now, just the role of the chassis, 0 being full right, lean and 100 being full left lean and because I’M, using the same positioning range for the front and rear servos, the movements end up actually being interpolated or actually kept in sync. So at this point i was actually itching just to start testing this out a bit in the real world to see how the truck servos would hold up. So i created a simple anti sway translation for the truck, because this truck doesn’t have sway bars and has very soft off road springs. It tends to have excessive body roll, particularly when turning quickly on high grip surfaces. So what my function does is it actually takes the steering input angle and proportionally leans the truck into the turn, meaning it’s, just kind of like a motorcycle leans into the turn to counteract any of the body roll and actually bias the center of gravity uh towards The inside of the turn visually it’s rather hard to see the net effect. Maybe i can mount some cameras on the truck here to show it later, but i can tell you the driving experience is surprisingly different.
首先, the turn in is much faster and the truck will oversteer if you’re, not careful. 也, the turning radius is greatly decreased. 我是, not sure exactly why this is happening if it’s, due to changes in the suspension geometry or somehow having the center of gravity closer into the middle helps, keep the slip angle tighter, but it’s kind of cool, because i can do donuts now very easily. With this truck now, i wanted to quantify this change by measuring the lateral g force with the accelerometer. But the truck was now leaning at a large angle, meaning that the accelerometer would no longer be parallel to the world frame and it would be missing a component of that lateral acceleration. 此外, if you’re familiar with accelerometers, they actually measure all accelerations, including gravity itself. 所以, as the car is tilted, i would actually need to begin to remove a portion of the acceleration that would now be due to gravity, as the trucks began, to lean away from the vertical. This is a well documented algorithm, as if you have the exact tilt angle, but again, a six axis. Imu like the 6050, throws us a curveball. The gyro only measures the rate of change in radians per second around each axis, not the actual angle that the truck would be leaning at. So you can attempt to integrate that gyro rate over time and to come up with an angle, but this method quickly introduces drift air, 所以我, actually leaning towards purchasing a 9 axis mpu like the bosch bno0555, which integrates a magnometer and an arm cortex m0 processor.
On board and just directly outputs all the information i could ever want with fairly high accuracy and a lot of other cool built in functionality. So if you guys have any experience with this imu, let me know i’m naturally cheap. So i want to kind of fight with the mpu 6050 for a while so that’s, where i am with the truck right now. I have started studying uh various suspension controllers and i’ll, hopefully focus on those more in the next video, but another major bit of the controller software i need to create is the force algorithm for the servos, so in an active suspension, there’s always going to be an Actuator, and in my case that actuator is the servo itself. This actuator creates a force that counteracts or dampens a suspension movement, but you can’t really tell a servo to just go ahead and apply x amount of force to the wheels because at it’s a position based component. So what i actually need to do is create a method that positions the servo relative to the deflection of the suspension arm itself. So if i want to apply more force to this particular wheel, what i need to do is actually have measure the position of the wheel, the deflection of the wheel and then set the servo so that, as the wheel moves, the servo keeps the spring. 基本上, at the same rate of compression and keeps the force constant now that force is going to be continuously re forecasted by the suspension controller algorithm itself.
But i do need to go ahead and create an algorithm that essentially moves the suspension uh relative to the servo. 同时, and allows me to uh taper that force, this will also be more complicated in the future, because i have the damper in line with the spring. So i don’t have a nice linear. You know hooks law type response from the spring, but that’s a future problem that i have some ideas of how to counter. Well that wraps it up for this video.