Smart Bike Suspension

by Jallson S in Circuits > Arduino

10587 Views, 75 Favorites, 0 Comments

Smart Bike Suspension

FotoProjectKomplitHOR.JPG

AI Driven Bike Suspension. An automatic suspension adjustment on a bicycle that able to understand the character of the terrain and the activities of the rider. Check video in the last step!

In this project we use data from the motion sensor on the Arduino Nano 33 BLE Sense which is mounted on a bike’s suspension and used under different road conditions. The data was cut into 5 seconds and labeled according to the surface variation and activities. Then processed in Edge Impulse Studio through Neural Network blocks: Spectral Analysis (x, y, z acc) and Classification (Keras) which will produce an ML model that can detect 5 road surface characters and rider activity output (idle, medium, rough, smooth, sprint). The model is deployed into the program on the Nano 33 BLE Sense which has an angle servo motor installed that can adjust the bike’s suspension knob. In the end, this project succeeded in implementing a "smart" system on the bike's suspension which can automatically adjust the level of travel on the suspension (lock, medium, open) according to the character of the road and the activities. Comfort, efficient use of energy have been achieved, and the effect of excessive bobbing can be eliminated with the help of embedded ML from Edge Impulse. This project also has the potential to maximize its use in sport cycling activities such as MTB (cross country, trail, downhill) so the riders focus more on handling and pedalling.

Supplies

AA_DiagramBikeSuspension.png

Hardware Component:

- Arduino Nano 33 BLE Sense

- Lipo Charger/Booster 5V/1A

- Lithium Ion Battery - 1Ah, 3.7V

- Smartphone (Android or iPhone)

- Mini servo 9g SG90

- Custom 3D print parts - stl files attached (for cases, bracket, gears, and mounting base)

- Bolt, nuts, styrofoam, plastic ties, o ring rubber, silicon glue


Software/apps & online services:

- Edge Impulse Studio

- Arduino Science Journal app (iOS or Android)

- Arduino IDE

Collect Data

AA_Download_Arduino-SJ.png
A1_Connect-to-computer.png
A0_SS1_MenuINCOMPATIBLENanoBleSense.png
A0_SS2_firmwareSciencJournalToUpload.png
A2_arduino-case-battery-on-bike.png
B_Arduino-science-journal-on-bike.png
C_Data-recording-bike-setup.png
D_Collecting-data-riding-bike.png
ArduinoSJ_sampleResult.jpg
Collecting data - Arduino Nano 33 BLE Sense acc X, Y, Z (motion sensor)
SS_sampleCSV.png

This data collecting is a very important stage and requires preparation, we have to make a mounting case for the Nano 33 BLE Sense and the battery on the bike suspension tube. For easy data recording, we use a smartphone with the Arduino Science Journal (Arduino SJ) app. We also use a smartphone bike mounting so the graphs result can be seen immediately when data recording occurs. The first thing to do on Nano BLE Sense is to upload Arduino Science Journal firmware via Arduino IDE. Find and install the libraries by using the Library Manager (Tools > Manage Libraries…) the type arduino science journal, select latest version and download. After that, go to File > Examples > INCOMPATIBLE > Arduino_ScienceJournal > Nano33BLESenseFirmware. Then click the Upload button. Now Nano BLE sense is ready to be attached on bike suspension.

After everything is installed in place, power on and connect the Nano BLE Sense to the Science Journal app via bluetooth. Click on Add button then choose sensor input, add accelerometer X, Y, and Z. So now it is ready to take data samples, start ride, then start record - stop, and name each recorded condition (rough/gravel, medium/pavement, smooth/asphalt). In addition, I added an idle state, and also a sprint (power pedal and lean bike to left and right).

After getting data from the app, you can download the csv file. Then we can proceed to step 2 in Edge Impulse Studio side.

Data Acquisition and Labelling

00Accelerometerdata.png
00Latency.png
00UploadData.png
01_data_acquisition.png
SS_split_data.png

Open studio.edgeimpulse.com (sign-in/up). Create new project, then choose accelerometer data.

In dashboard > Project Info, choose one label per data and Arduino Nano 33 BLE Sense for latency.

Then in Data acquisition, click on Upload Data tab, choose your CSV files, auto split, then click Begin upload.

Now, it’s time for labelling. Click on data sample collected, click on … (three dots) then choose split sample. Set segment length 5000 ms (5 sec), or add segment manually then click Split. Repeat.. until all samples labelled in 5 sec interval. Make sure that the ratio between Training and Test data is ideal, around 80/20.

Train and Build Model

02_create_impulse.png
03_spectral_features.png
04_generate_features_explorer.png
05_NNsettings.png
06_Training_output.png
07_Test_data_modeltesting.png

Once you have dataset ready, go to Create Impulse and set around 4500ms in Window size (for 5 sec data sample), and 80ms on Window increase. Then add Spectral Analysis processing block, and Classification (Keras) as learning block, then Save Impulse.

Go to Parameter section, and press Save parameters.

Click on Generate features button, you should get a result just like the one below.

Then, navigate to NN Classifier section, and leave training setting for Neural Network as it is. Train the model by press the Start training.. and you can see the progress. If everything is OK, you should see something like this (91% accuracy is quite good).

After that we can test the model, go to Model testing section and click classify all. If the accuracy result is more than 80%, then we can move on to the next step — deployment.

(If accuracy result is not as good as expected, re-start with quality datas, label, or just retrain the model with Training cycle and Learning rate setting changes)


Deploy Model and Test

08_deploy_as_ArduinoLibrary.png
09_Built_ArduinoSketch add to ZIPlibrary.png
Arduino Serial Monitor - Test - Smart Bike Suspension Project

Now, we can start to deploy the model to Arduino Nano 33 BLE Sense. Click on deploy your impulse, choose Arduino Library, then click Build. The .ZIP library will be downloaded then open your Arduino IDE to add this library. After that you can find examples in menu File > Examples > Smart_Bike_Suspension_inferencing

Upload it to your Nano 33 BLE Sense, open Serial monitor then try to simulate motion on your Nano 33 BLE Sense.

If your motion simulation detected by BLE Sense correctly, the we can move on final step, attach to servo and apply it on the bike suspension to test it on the real conditions.

Code, Attach and Test

Smart Bike Suspension test

We need to modify the example from library above which is embedded with the trained model in order to convert the output to the desired servo rotation. So if the detected condition is idle or smooth, the servo will turn the suspension knob to lock position. If the road conditions are pavement or when sprinting, the servo turns the knob to half open (medium). And if a very rough condition is detected, the servo will fully open the knob in order to maximize the suspension travel. The following is a modified arduino code that can be uploaded to the Nano 33 BLE Sense.

For installing servo components on bike suspension, we need to design servo mounting brackets with gears which are connected to the upper suspension knob (needs to adjust/modify my design for different suspension types and brands).

We have tested it in the real conditions and make it happen the idea of “smart” bike suspension. This project also has the potential to maximize its use in sport cycling activities such as MTB (cross country, trail, downhill) with complex conditions such as climbing, jumping, dropping, cornering, and data can be retrieved by involving professional athletes so the output setting of the suspension is better. scalable, and more “smart”.