Posts

LunchBox ESkateboard Part 0: Introduction

Image
There is a 500 meter long walk from where I live to where I am working which I am forced to undertake every single day. As lazy as I am, I decided to build a DIY electric skateboard to relieve myself from this "excruciating" pain. So after two months of scavenging and tinkering, it is finally finished, with a lunchbox. 

A video of me testing it in local park.


The skateboard is controlled by my android application via Bluetooth as I dislike carrying an extra radio controller. Speed adjustment and brake can be triggered by pressing the volume button for convenience.  Here is a snapshot of the app UI Interface. 


The overall cost of the skateboard is 440SGD or 330 USD. The majority of components were purchased from Taobao and shipped from China to Singapore. Below is the component list.  Mechanical Component Choice and remarks Final price deck Normal skateboard deck 49RMB Trucks(滑板架) DIY kit 360+15= 375RMB Motor mount Pulley(轮滑组) wheels Motor(马达) N5065-270kv 185+7=192RMB Electr…

LunchBox ESkateboard Part 4 : Android App Software

Image
Note: Due to the complexity of Android Application, this blog post will not explain the code in detail. If you are not familiar with Android programming, maybe it is better to learn fundamentals from android websites.

I made an application to control the ESkateboard via bluetooth.  It automatically scans my skateboard and tries to establish connection and it allows speed control from volume up/down button or touch screen(currently disabled as I found that using volume button was good enough for me). The full code can be accessed from my Github.
The UI of my application looks like this:

The application was modified from Android Bluetooth Low Energy example project from here. The structure of the application consists mainly two parts: the main activity and a service that bound to it. The activity takes care of all the input handling and UI display while the service takes care of Bluetooth communication. 
Section 1: Bluetooth Communication

Upon clicking the connect button on the top righ…

LunchBox ESkateboard Part 3 : Arduino Software

Unlike radio receiver, Arduino needs to be programmed manually to output correct PWM signal to ESC. The skateboard ESC I used expected to receive pulse every 20ms (50Hz) and the minimum time of the pulse is 1ms while the maximum is 2ms. (This is the standard PWM signal for controlling servo). Because I configured the ESC mode to be forward with brakes, a signal with duty cycle above 50% (1.5ms~2ms) will rotate the motor forward while a signal with duty cycle below 50% (1ms~1.5ms) will trigger the brake. If ESC receives a signal with duty cycle 50%, it will not output any command to motor and therefore allowing it to rotate freely. 
Luckily, Arduino has a ready-to-use servo library for outputting the desired PWM signal. So in my code I initialized servo with minimum and maximum as required by the PWM signal.  #include <Servo.h> Servo mServo; const int minPulseRate = 1000; const int maxPulseRate = 2000; mServo.attach(pwmPin, minPulseRate, maxPulseRate);
After the above initializa…

LunchBox ESkateboard Part 2: Electronics

Image
The electronics of the E-skateboard is quite straightforward. The overall structure was summarized nicely by vlad pomogaev in his video

while random88ish uploaded an awesome video to explain everything extensively

And here is a picture of my system in the lunchbox. The only difference is that instead of radio receiver, I used Arduino101 for Bluetooth control.



In summary, the key to choosing the right motor is that choose a motor with the proper kv value so that it could deliver your desired top speed and starting torque.  The formula for top speed is
wheel rpm = kv * voltage of battery * gear ratio * efficiency speed(km/h) = wheel rpm * wheel circumference(cm) * 60 min/h / 1000000 
http://calc.esk8.it/ is a online calculator that can be used to calculate speed easily.
For starting torque, The torque per armature current is inversly proportional to kv of the motor

meaning that for constant current, a lower kv motor would generate larger torque. Normally, from experience, suitable kv valu…

Lunchbox ESkateboard Part 1: Mechanics

Image
The skateboard itself was purchased from TAOBAO for 10 SGD. It is the cheapest I could find as I am quite new to skateboard and do not have specific needs for good quality.  
The mechanic hardware of the electric skateboard are all purchased from TAOBAO from a vendor that sells complete DIY kits to modify your normal skateboard to electric version. The kit includes wheels, pulley, belt, trucks and necessary screws and nuts. 


Assembling the kits was quite straight forward although the vendor didn't provide any manual or instruction. Moreover, there are numerous videos on Youtube that describes the procedures in details such as this:


Overall, I am quite satisfied with the quality of the DIY kit except the following two parts.
1. Due to the pulling force of the belt, the wheel that connects to motor could not be mounted straightly, resulting in friction against the truck. I had to purchase lubricant oil to reduce the friction so that wheel could rotate properly.


2. Provided screws w…

Custom Flight Controller Part 2.8: Getting the Orientation --- Processing Orientation Visualization

Image
The last step is to visualize the orientation to check whether the orientation calculated correspond to the real orientation. Previously, Matlab was used which proved to be slow. Therefore, processing is used this time. It has been a popular choice for orientation visualization and there are a lot of ready-to-use packages to aid the development. I have chosen to follow the steps indicated in tutorial from DIY Hacking by Arvind Sanjeez.
The serial function inside the processing code provided by the tutorial has to be modified however to interface with serial communication sent from STM32. So I have configured STM32 to send quaternion in the following format.  For example, if the quaternion is [1 0 0 0], it would be printed as "Q: 1 0 0 0".  Character "Q:" can be used to check whether the data received in processing is correct. To extract the quaternion from the string received. The following code is implemented. functions like split() and trim() are inbuilt process…

Custom Flight Controller Part 2.7: Getting the Orientation --- Mag Calibration and Overall Algorithm Structure.

Image
Magnetometer measures the direction and magnitude of magnetic field present. It is a great tool to correct yaw measurement. However, it needs calibration before it can be used to update orientation. For example, if a uncalibrated magnetometer measures 100 milliGause in x direction currently, rotating the magnetometer around z axis for 180 degrees should theoretically yield -100 milliGauss. But since the magnetometer is uncalibrated, it might give you a value like -50 millGauss. In this case, a -25 milliGauss bias should be added to the magnetometer x axis measurement so that the two measurements become +75 and -75 and are just opposite to each other.  This procedure of determining the magnetometer bias is done via magnetometer calibration. 
The method proposed in this post by Kris Winer is adopted to calibrate magnetometer in this project. Essentially, user needs to rotate the magnetometer non-stop during the calibration until the magnetomer has collected enough sample data. Then the…