Tuesday, October 20, 2020

Trash Kart Chassis Design

In the last two posts I talked about finding a motor and motor controller combination for my kart, but I haven't written about the chassis or other mechanical systems of Trash Kart yet. Building a custom chassis for Trash Kart was necessary because I couldn't afford to buy a commercial chassis and I didn't have a ride-on toy like a Power Wheels to modify for this build. I also thought starting from scratch could alleviate some of the pain of trying to modify an existing system for my use.

Getting seated

My first step was to collect the basic building materials for the chassis. I had a 2X4 lying around so that seemed like a good place to start. To compliment the 2X4 I found an old shipping palate that could donate some flat hardwood pieces. I also went to my local university's surplus store to look for other cheap materials. That was where I found an old plastic classroom chair to use for my seat and some scraps of steel from some old shelves that I thought might wind up useful. For wheels and axles I used some very cheap 10 inch handcart wheels from Harbor Freight and 5/8 inch threaded rod and bolts.

Laying the framework

The rules of the Power Racing Series stated that a vehicle shouldn't be more than 36X48 inches, so I made a rough layout of my parts on the ground and tried sitting down to see if I'd actually fit in the kart. I tried to make the seat as far forward as I could manage so that I would have a more even weight distribution. If my weight was too biased to the rear, I would have issues with the front wheels slipping while steering and cornering.

The initial layout for the kart. The seat is about as far forward as I can put it without my knees lodging inside my rib cage.
The batteries and motor are also shown here to make sure there's room for them.

You might have noticed that there's only three wheels being shown here. That was a design choice I'd made at this point, pretty much entirely for budget reasons. I'd already made a preliminary bill of materials and I didn't think I had the budget for a nice steel axle or another tire when I inevitably switched to more expensive tires. I made the decision to design around a three-wheeled kart to save cost and complexity, reducing my part count and simplifying my frame since I wouldn't have to get any rear frame bearings perfectly aligned.

Putting on the hard hat

The core principal of Trash Kart is that it's made from very cheap materials using only a few tools. I used a saw and a drill to do most of the manufacturing, but to supplement that I bought a 3d printer so I could have complex and precise pieces to help augment the simple wood frame. Anything seen on the kart that is green is something that I designed and printed myself.

The chassis! The green parts here are 3d printed brackets to hold things square while I fastened the wood.

The rear axle is a 5/8 inch threaded rod. The rear wheel has bearings in it and spins around this axle. I made some spacers out of electrical conduit to hold the wheel in the center. I made another plastic part to mount a chain cog onto the rear wheel.

A mess of electronics while testing the motor.


I eventually designed full-plastic front and rear wheel hubs to accommodate some of my needs for the kart. In particular, the steel hubs that came with the cheap Harbor Freight wheels had a lot of wobble and shaking when they were spun. They also didn't have any convenient attaching points for brakes or chain cogs.

Steering systems

I haven't cut the steering column yet

Steering systems are complex! I had to do a lot of research and digital design to end up at a functional, adequate steering system. It turns out that on racing karts, there are a few pieces of steering geometry that can be adjusted to affect how the kart drives. I'm not going to dive into this here, because it's fairly complex but also well documented elsewhere. The main thing I'll talk about here is the positioning of the kingpins, which are the pins that the wheels turn around when steering. In my case, they were 1/2 inch bolts with printed pieces around them.

Here's the wooden and plastic supports I made. They're kinda janky, but work surprisingly well!

The rest of the steering system was a cheap steering wheel I found online, a piece of electrical conduit for a steering column, some threaded rods and rod-ends, and some various other plastic and wood pieces to support the whole thing.

"Lean-in" geo and issues

My first attempt at steering geometry was based around a few ideas. First I gave the kingpins 10° of inclination, which tips the pins in toward the center of the kart. Inclination causes the wheels to move downward against the ground, raising the kart slightly when turning. This is usually used to give the kart some self-centering steering impulse, since gravity will try to pull the frame down. I chose a value for inclination that I thought would provide a healthy amount of self-centering, but not a completely overwhelming amount.

Second I gave the king pins 15° of caster, which causes one wheel to raise while the other lowers when turning.In a racing kart caster will lift the inside rear wheel when turning, which is important to both encourage better traction on the front tires and to prevent the rear from having to slip because racing karts have solid rear axles. Since I only had one rear wheel I didn't have to worry about it slipping! I decided it would be neat if the kart actually leaned into corners so that I wouldn't have to lean my body into corners as much to keep it from tipping. This means my caster angle is actually more accurately labeled as negative 15°. -15° of caster is a lot, but I wanted a pronounced effect because I thought this was a brilliant innovation that would give me a noticeable advantage in corners.


I was wrong (oops).

It turns out that having a lot of caster angle on a three-wheeled vehicle means that you can make the kart steer by leaning, and it was pretty sensitive to this. And since the weight of the system is pushed to the outside of the corner, it meant that my kart actually had significantly more resistance to turning than I expected, proportional to how fast I was turning. This all added up to a very unstable and uncomfortable steering system where the kart felt like it was fighting me every time I turned, and it couldn't really drive straight. So -15° of caster was too much, especially for a trike...

A suddenly-much-more-complete trike!

I decided to toss the caster angle idea and just keep the inclination, so that the kart would have some self-righting force. Solving this made the kart waaaay more driveable and I started taking it out for more spirited drives, which was a great time but exposed another issue. Holding the steering wheel, and turning it, was putting my wrists and fingers in very uncomfortable positions. I ended up moving the steering column from a 20° angle to 25°, and I shortened the column by several inches. This helped a lot, but there was still room for improvement. However I wasn't sure I could make everything fit if I tried to lower the column further and I had other tasks to complete, so I left it.

Don't mind the mess of wires under the seat. They're hiding.

Tuesday, September 29, 2020

Trash Kart Motor Controller Selection

In the last post I went into some detail about how I converted an automotive alternator into a motor for my go-kart project. The alternator was turned into a separately-excited 3-phase brushless motor and I needed to find a motor controller to pair with it. This ended up being quite a process so here's some things I’ve learned.

Requirements

I needed a 3-phase brushless motor controller to handle the current-switching for my kart. This type of controller is pretty commonly used for hobby projects like R/C cars, planes, and helicopters as well as larger human-scale things like mobility scooters and electric longboards. They are also used for much larger systems like cars and industrial equipment. Given how commonly this sort of a controller is used, it provided me with a lot of options for my application. Some of the requirements I had for my controller were:

  • Since the racing series I was entering put a $500 budget on the karts I had to be careful to keep my costs in line. I was looking for something that cost less than $150

  • Rated to handle 24 or 48 V to match the battery system I was planning to use

  • Rated at least 2 Kw continuous power rating and at least 5 Kw burst power rating to match the performance expected for a kart of this scale

  • 3-phase controller with active braking to match my motor and to relieve stress from my mechanical brake system. Ideally this would be a regenerative braking to push energy back into the batteries to extend life a bit.

The first controller

The first controller I tried was one that I found on HobbyKing (YEP 120A HV). It showed that it was capable of handling my target voltage and current and seemed pretty well reviewed. It met all of my requirements as I had decided them at this point. After soldering it up with battery and motor connections, this controller was able to spin up my motor pretty reliably when testing on a bench.

 

The first setup, with a sneak peak of the kart frame


Unfortunately this controller did not work as well once I had my kart moving. Once the motor had a large inertial load (my body) the controller started to have really serious issues with successfully moving the motor. I did some more research to try and find a solution and I learned that this motor controller was designed and tuned for propeller applications like planes and helicopters which have low inertia and low starting torque requirements. I found out that for traction applications like cars and scooters there were different motor controller and so a new requirement was born:
  • The motor controller should be designed for traction applications so that it can handle low-speed commutation well and provide consistent starting performance

 

Back to the internet for more research!

Enter the VESC project

I was tipped off to the VESC project by my friend Isaak who had encountered them in combat robotics applications. The VESC project is an open-source motor controller and configuration tool which is intended to provide a flexible platform for DIY projects needing a 3-phase motor controller. It was pretty commonly used by people building e-bikes and electric longboards, so it seemed like it would work for my kart and it met all my requirements so far. 

 

Since this is an open-source hardware platform there are genuine controllers that can be bought from Germany for $$$, and there are cheap Chinese clones that have dubious quality and much lower price tags. Since I was on a budget I went for a cheap clone, specifically the “FlipSky Mini FSESC 4.20” which is based off of hardware version 4.12 of the VESC project. This was basically the cheapest VESC clone I could find, but it’s pretty much hardware and software compatible with the reference controllers. 

 

Learning how to configure the VESC controller to optimize performance and get good input control is something that I’m still working on, but getting the controller working at a basic level is pretty easy. The configuration software has a lot of helpful information about every setting and button. As a bonus the VESC controller can be set to have both cutoff current and voltage limits, which can help protect batteries and also make sure I stay within the electrical power limits defined by the racing series. 

 

After wiring this controller into my system I was able to get the kart performing at a decent level for the first time. It was often able to get going from a stand-still without stalling, and I was able to get the kart all way up to its top speed (~20 mph) as long as I was easy on throttle. I ended up having an issue where the controller would fault and cut out if I pushed the throttle too fast and it would have to reset before moving the motor again. It seemed like I was tripping a current sensor or dropping too much voltage on a component, but I really couldn’t find the root of the issue. I figured that since the alternator was a lot larger than the sort of motors other people were usually using with these controllers I was probably just pushing it past its intended capabilities. I was pretty hooked on the configurability of the VESC at this point, so it was time to go for a more expensive version.

Make it bigger!

The VESC project has another common hardware version other than the 4.12; the VESC 6. This version brings a variety of improvements, but the big thing seems to be having current sensing on all three phases, instead of just two. The VESC 4.12 uses #math to estimate the current in the third phase, but the VESC 6 can directly measure it, which allows for improved control and higher current sensing limits. I figured that a new and improved version of the controller would help me out, so I purchased a cheap(ish) clone online.

 

This motor controller was quite a bit more expensive than the mini one I had been using, but if it solved my performance issues then I would be able to make it work for my budget. Just like before, I wired the new controller into my system and got it calibrated and programmed using the VESC software. On the first test runs this controller showed a great improvement in performance compared to the mini VESC; it was able to generally run at high performance without cutting out much. This was the first time I really got a feel for the acceleration that my kart was capable of, and it was FAST. 

 

I was still having some issues with startup on the kart, with the controller sometimes losing track of the motor position and squealing, or failing to start entirely, creating a “cogging” motion that is somewhat common for brushless motors.

 

 

Hall sensor addition

The go-to solution for startup issues on brushless motors is to add sensors. When running without sensors a controller uses the back-EMF to estimate the position of the motor. Back-EMF is generated by the motor when the magnets move past the coils, but by definition this only works when the motor is moving. To get a motor moving without sensors, the controller will dump a lot of current into the motor and try to force the magnets to start moving so that it can sense where they are, but this can lead to “cogging” where the motor doesn’t move enough for the controller to get a reading.

 

Sensors will tell the controller what position the motor is in at all times, allowing it to consistently start and provide maximum power at all speeds of the motor. The VESC supports the two most common types of sensors for hobby motors: digital encoders and Hall-effect sensors. I would be retrofitting my alternator with these sensors so I decided that adding Hall-effect sensors would be the easier integration. You can check my last post for more details about this installation!

 

After adding the sensors to the motor I was able to detect and calibrate them with the controller, and like magic my kart had excellent off-the-line acceleration and consistent low speed torque. I was able to stop on my driveway and then drive up it, without any problems! Now that performance was acceptable, I wanted to find a way to integrate a reversing functionality into my kart.

Writing custom firmware

Adding reverse to my kart was an important competitive feature; if I got turned around on the track or ran into a barrier, being able to get back in the race without dismounting from my kart is a BIG deal. And the VESC did have some built in control schemes which included reverse functionality.

 

Unfortunately there wasn’t an existing control scheme that gave me my desired control scheme. I wanted one throttle which would cause the motor to brake when released and accelerate when pulled, with a switch which would reverse the direction of the acceleration. There were similar features spread out amongst the control schemes but no single existing scheme that had all these features. Luckily this was an open-source project so I learned how to modify, build and save the firmware to the controller, and modify and build the configuration software to handle the new control scheme. All told it was probably 5 or 6 lines of code mostly copied from stuff already existing on the controller. It all seemed to work fine so I added pull requests on GitHub and I am now a contributor to the VESC project!

Releasing the magic smoke

About two weeks before my first race with the kart I drove it to work to give it a real stress test, and to show it off to my coworkers. This was in early June, and it wasn’t a particularly warm day but the sun was pretty intense. I ended up pausing for about 10 minutes on my way to work to give the components a chance to cool down mid-way. 

 

At work I charged my batteries back up, then took the kart out to the parking lot to let my coworkers take it for a spin. They were very excited and it was performing well, and then there was a puff of magic smoke and my motor controller was dead. It turns out that the VESC 6 variant I had purchased had an anti-spark circuit on it, which I had been bypassing, and after some extended use that system burned out. 

 

With a very short window to my race and no spare motor controller I had another one (with a real anti-spark switch) rush shipped to me. Once I got tracking information the delivery window was forecasting an arrival on the day that I had to leave for Kansas, so I started to scramble for another solution since that probably wouldn’t turn out.

Maybe smaller is good enough?

In desperation I turned back to the smaller, cheaper VESC 4.12 clone I had purchased earlier and then abandoned. Now that I had learned more about the configuration tool *and* I had added sensors to my motor, I was hoping that I would be able to get acceptable performance out of the smaller controller. I plugged everything in, and it worked! Mostly…


I set a lower current limit to help protect the smaller, cheaper motor controller. I also learned that the pins on the controller to switch from forward to reverse were in slightly different spots, so I had to make an adapter for my switch to shuffle the wires around. But the little controller performed admirably, almost meeting the expectations set by its next-gen brother. It still had some issues with cutting out occasionally, but it was good enough to get me moving and hopefully not burst into flames.

 

The replacement VESC 6 ended up arriving early the night before I was leaving, so I soldered and programmed it and threw it in my car along with the already-packed-up kart to be installed once I got to Kansas.

Bonus: powering the separately-excited rotor

My original plan with the alter-motor was to vary the current in the rotor in order to change its magnetic characteristics while driving. The idea was to create a sort of "shifter" like you'd find on a car, so that I could increase the magnetism of the rotor for low-speed torque and decrease it for an increase in top speed. 

The current controller. It's a pretty sizable chunk, but it's more reliable than everything else

This ended up being a fruitless idea for me. Perhaps as a whole research project of its own I could learn how to do it, but I found that when I tried to reduce the rotor current the motor controllers would have issues. I ended up buying a nice constant current controller for the rotor so I could set the desired current and then rely on it not to change as the batteries drained.

Monday, August 31, 2020

Trash Kart Begins: Converting an Alternator

In August of 2018, I moved into a house which had some space for me to work on a larger project. Up until then all of my projects had been “desktop scale,” but with some space in a garage I started thinking about larger projects that I’ve always wanted to do. Something I’ve always wanted to work on is a human-scale electric vehicle, something like a scooter or powered mountain board. I ended up settling on building a go-kart because they’re silly, impractical, childish, and I really wanted to make one.

Research

The starting place for my motorized vehicle was the motor. I needed to find a motor that could deliver enough power and torque to move a person and would be reliable enough to run at least half an hour at a time without burning up. I learned from a little research that racing karts are often around 5 Kw (at the low end) so I used that for target motor power.

Around the time that I was working through some options, my friend Isaak offered me an alternator from his car. The alternator in a car acts as a generator to keep the batteries topped up while the car is on, and most rotary generators are effectively motors working in reverse. As a bonus, alternators are intended to run continuously in hot and dirty environments, so it would probably be a reliable choice.

After pulling up the specifications for this alternator, I found it was rated for 110 A at 12 V. That’s about 1.3 Kw at the rated specifications (which I assume is its continuous rating, considering the safety requirements of car parts). From some past experience, motors can often be run at much higher voltages than they’re rated for without too many fires. So if I could run the motor at 48 V instead of 12 V, that means the alternator would have a power rating of almost exactly 5 Kw!

At this point I wasn’t actually sure if an alternator could actually be used as a motor. From quite a bit of internet research and some inspection of the alternator (which will be covered in the next section), I came to a pretty decent understanding of how alternators work and how one could be turned into a motor. 

Tear Down

Here’s the alternator all torn apart:

 Not pictured here is the diode pack that sits inside this sandwich, because I tore it apart and recycled it before I started taking photos.

So what we have, from left to right is the following:

  1. The main casing of the alternator, and the claw-pole rotor.

  2. The stator windings (three phases unterminated, giving six wires).

  3. A middle piece of casing. Originally the diode pack sat on top of this. The diode pack (which I removed before taking photos) is a set of diodes whose purpose is to rectify the current from the three stator phases into one DC current to supply the car. I’ve labelled the places where the stator connections come out as phases: A, B and C.

  4. The brushes to excite the rotor. Originally there was a little power controller stuffed in here to manage the rotor current, raising and lowering it as needed to generate the right voltage out of the stator.

  5. The end cap of the casing.


Here’s some more details on the claw-pole rotor:

  1. The input shaft for the alternator. This is where the pulley would attach to bring in motion from the car’s engine. This is where I attached the chain sprocket to drive the kart.

  2. Fan blades to help cool the alternator.

  3. The design’s namesake claws. These two large pieces with claws help to direct the magnetic field from being axially aligned (as a donut sitting over the axle) to being radially aligned (as a series of humps between each claw).

  4. The field winding.

  5. Two copper contact rings. The graphite brushes ride here to provide current to the rotor.

  6. A bearing to support the rotor. There’s a similar one that lives in the casing to support the other end.


I’m very impressed with the way this alternator was constructed. The rotor is coated in an enamel to prevent corrosion and electrical shorts, the casing has heavy-duty mounting points, and the rotor and stator use very thick wires to handle high currents. The whole unit looks built to take physical blows, dirty water splashes, and high heat without failing for a long time... Which I suppose is what I should expect from an automotive component that’s bolted to an engine. 

Modifications 

There were a few modifications that had to be made to get the alternator running as a motor instead of a generator: 

  • Removed the diode pack and replaced the connections to the stator with wires to a motor controller

  • Hijacked the brushes by removing the original current/voltage controller and replacing it with one I know how to use (I didn’t want to reverse engineer this system)

  • Attached a chain cog to the output shaft to drive a chain. I used a rotary tool to grind a keyway into the shaft, and modified a small chain cog to fit on the shift.
 

First runs

Now I just hooked it up to a 3-phase brushless motor controller aaand it’s alive!

 
It was actually a little more work than that since I had to supply ~12 volts to the rotor to induce a field, and then I had to do a little trial and error to get the polarities of the three phases matched up right, since they weren’t labelled by the manufacturer. But once I figured that out it spun up surprisingly nicely, with smooth action, low noise, and excellent balance.

By varying the current to the rotor, I was able to observe that the torque and maximum speed were adjustable. Increasing the current to the rotor effectively increases the torque and lowers the maximum speed of the motor. I thought I would be able to utilize this to implement “field weakening” for the motor, which would theoretically allow me to increase the torque or top speed of the motor as needed. However, I had a hard time getting enough current into the rotor without making it too hot. Since I was running the stator at 48 V, I needed to run the rotor at high current to match, and it was running really hot. Roughly nearly-burn-me hot, which would likely turn into burned-enamel hot if it went on for long enough.

Adding sensors

The alternator basically worked like a 3-phase brushless motor now. The common name for a motor of this type is actually a separately-excited motor, because there are no permanent magnets and the rotor has to be excited separately from the stator. One of the common problems with brushless motors, especially in traction applications, is that they can get stuck in a stall when they first start. The most reliable way to fix this is to add position sensors to the motor so that the motor controller can know the position of the rotor as it starts up. I ended up having this stalling issue as I was working on my kart, so I added 3 Hall-effect sensors to sense the magnetic position of the rotor. 

A little messy, but it runs smooth

I used a rotary tool to grind three cavities into the stator and then glued in the Hall-effect sensors. I had to shave down the plastic casing of the sensors a little after gluing them in so they wouldn't rub on the rotor, but they ended up working perfectly! This solved my stalling problem entirely, and improved the off-the-line acceleration of the motor quite a bit.