Electric Longboard
February 2020
This is my highschool project. Initially this featured a single motor, 20 battery cells, controller and a custom remote. The first motor controller I made myself, as well as a 3-channel switching regulator for the control electronics. The battery was welded using a microwave oven transformer. Later I added a second motor, doubled the amount of battery cells and 2 VESCs instead of my own controller.
Building the battery pack
Li-ion 18650 cells were chosen over Li-Po because they're cheaper per Ah and pack more energy per volume. Ten cells in series gives roughly 37V nominal (42V full, 25V empty), and each pair of cells is put in parallel to reach 40A continuous. The cells are welded together into a 10S2P pack. A cheap commercial BMS board handles charging, balancing, over/undervoltage protection and overcurrent protection. Since its default current limit was too conservative for this pack, the shunt resistors on the board were bridged with extra copper to raise the limit, relying on a separate fuse for protection instead.
Spot welding the pack
To weld the nickel strips onto the cells, I built a spot welder from a microwave oven transformer, rewound to output a few volts at very high current. I built a small relay board with a trigger button that times how long the welding current flows, giving repeatable, short welding pulses without frying the cells.
Designing a voltage regulator
The battery sits at up to 42V, far too high for the logic and control electronics, so a step-down converter is needed. A linear regulator would be simple but wastes the difference as heat, which isn't acceptable on a limited battery budget. Instead I designed a buck-converter board around Allegro's A8498 switching regulator, built up three times to generate the 3.3V, 5V and 12V rails the rest of the electronics need from the battery voltage.
Designing a custom ESC
Rather than buying a motor controller, I wanted to build one myself as a challenge. I did some experimenting with controlling the motor trough FOC using a Trinamics IC, but without extra hardware and software this proved rather hard to configure correctly. The First version of the PCB had support for for this chip, breaking out each FETs gate signal along with the bridge centers. Later I switched over to an Atmega328p and IR2113 half bridge driver ICs to drive the FETs. All firmware runs on interrupts (pin-change interrupts from the hall sensors, a timer for PWM) rather than the slow Arduino library calls.
Debugging current spikes
Testing the ESC was done with a lower 12V source first. After spinning the motor by hand to start the commutation cycle, the motor got stuck. Looking at the supply it looked like it was hitting its current limit. The solution was to use an additional comparator that stops conduction in the current cycle once the current exceeds a set limit, as well as extra capacitors on the supply to suppress voltage spikes during switching. After this the motor ran properly. After connecting a 30V source and giving the motor a spin the supply entered current limit mode. Thinking the supply couldn't handle the current requirements, I used the battery with a small resistor in series for safety. Testing again a PCB trace burned. Probing the current with a scope revealed the problem: the moment an upper and lower branch of the three-phase bridge started conducting, the current shot up so high the PCB traces could not handle the power. Initially the motor inductance limits the current, but once the field is saturated, the current rises very fast. Even with this, the current was still shooting up too quick. The used microcontroller just is not fast enough to react. voltage.
Switching to a VESC
To actually ride the board, I moved to a VESC, the open-source ESC platform started by Benjamin Vedder. It supports much higher voltages, lets the motor parameters be auto-detected from a desktop tool, and talks UART, CAN-bus, PPM or analog throttle input. I first tried driving it over CAN through an MCP2515 SPI-to-CAN chip, but the small SPI buffer caused poor performance; switching to UART (which the ATmega has built in) fixed that, at the cost of losing the ability to address multiple VESCs on a shared bus.
Building a custom remote
Commercial remotes only show battery level, if anything, so I built a custom one based on the open-source FireFly Remote hardware design, with my own firmware on top. It houses an Arduino Nano, a tiny OLED display, a hall-effect throttle sensor (contactless, so no potentiometer wear), and an NRF24L01 radio. A LiPo cell, charged through a TP4056 module and boosted to 5V, powers it all. The remote streams throttle values to the board over the radio link and receives back speed, distance and battery voltage to show on the display; a trigger button has to be held for any data to be sent, acting as a basic deadman's switch. The communication is secured with AES to prevent someone from taking over the board. Replay attack are prevented by implementing a rolling code system.
Solving the RF noise
Due to the large currents and switching of the power supply the NRF module had issues maintaining a stable connection. To solve this extra capacitors were added to the supply rails, but this only improved the problems slightly. To fully solve the issues a SPI isolator and 2 AA batteries in series were used to power the NRF module. This is only a temporary solution, since constantly having to replace those batteries will become tiring.
Final assembly
The base PCB, buck converters and VESC are all mounted with Velcro rather than screws, so nothing needs to be drilled into the deck, and a plastic enclosure protects the electronics. The battery pack is Velcro-mounted too, with a shortable XT60 "kill" connector as a failsafe to cut power in an emergency or before working on the board.
Building a charger
To charge the pack I built my own charger rather than buying one: a small mains transformer steps 230V down to 12V, which a boost converter then steps back up to 41V for the battery, with the current limited to 1A. A small display shows live voltage and current so it's easy to tell when the pack is topped up.
Later additions: battery upgrades
After riding for while the board suddenly stopped working. Tearing it apart showed a battery connection got loose. The method used to weld the nickel strips to the battery did not penetrate the batteries deep enough, causing weak welds to loosen due to vibrations. This was fixed by using a K-weld to weld the batteries instead. This uses a large LiPo battery so supply the welding current along with a accurate joule counter to have consistent welds. While doing this I also doubled the cell count. The battery was later packed in a large heat shrink wrap to improve safety.
Later additions: improving the motor mount and adding motors
During riding the motors brackets had the tendency to come loose. The mount used a single setscrew that when tightened clamped on the trucks. This single failurepoint was solved by created my own bracket. It uses 2 screws clamping evenly on the trucks. Then 3 large bolts and nuts are used to secure the sliding bracket onto the clamp. This sliding mechanism allows tightening the belts. An extra motor and ESC was also fitted to increase power.
Later additions: metal housing and paint
Adding more batteries and power also meant a better housing was needed. The plastic housing cracked when going over bumps. The new housing was created using aluminum sheets bent into a box shape, with a lip to drill holes for screws. The inside was lined with rubber sheets connected with silicon, providing waterproofing as well as vibration dampening. The new housings were mounted using threaded inserts in the deck. This prevents the need for drilling holes trough the deck, improving strength and appearance.