Last Updated: 2021-04-12
Now supports level cruising.
Faster angle correction.
Smarter Filtering.
Tested over 35km to date. Both on and off road.
Video coming soon.
I'm not a skateboarder, but I have decent balance and can lay down code. So instead of learning to ride someone else's board, I built my own.
I wanted to be able to adjust my ride on the fly without having to pair up my phone, so I added a simple settings interface and utilized the existing switches.
My gryo filter uses a simple principle for smooth and reliable angle measurement. As the accelerometer jumps around quite a bit while in motion, I factored it's parameter depending how far off it was from the current gyro reading. The further the accelerometer was from the gyro, the less I mixed into the current angle routine. I then averaged the total output over the last ten readings with a bias closer to zero.
The drive routine is simple. Multiply power by current angle, then compound additional power when desired angle is reached. This helps to keep the board within the desired operational angle.
The overdrive works by adding additional power over time while the desired angle is maintained. This allows the board to continue to reach higher speeds while maintaining a comfortable ride angle.
My board is utilizing a 48 volt, 800 watt hub motor and a VESC for the drive train. Powered by a 12s2p Samsung 18650 25R battery pack, I get a little over 10kms of range, a comfortable cruising speed of 20km/h, and a top speed of just over 35km/h.
The controller is an Arduino Nano V3 paired with an MPU6050.
Total firmware size is 15082 bytes (49%) of program storage & 1154 bytes (55%) of dynamic memory. Eeprom storage is 28 bytes.
The board is 30 inches long and 9.5 inches wide. The aluminum railes are 1 inch wide, 2 inches tall, 1/8 inch wall thickness and 28 inches long with a 45 degree cut on each end.
Wrap yourself in a thick mattress before stepping on this board...
But seriously, wear a helmet and a well fitting pair of flat souled shoes.
Gloves, elbow and knee pads are also a smart idea.
On power up, you must first wait for the counter to reach 0 and display the battery voltage. This step is the software calibrating the gyro offset.
The board must be in a still position for this to take place. If the board senses any movement, the counter will reset to 10 and restart the calibration. This process takes place everytime you power on the board.
To arm the board, you must first place the board at a greater than 10 degree angle with the back on the ground.
You then must step on the back button or foot sensor, followed by the front button or foot sensor. The display will now show 1111 and then quickly to 0. To engage the motor, you must tilt the board to the level position.
The board will now be armed and in operation.
You must be standing on atleast one of the two buttons or foot sensors to maintain operation of the board. Due to the weight of the board, the breaks will immediately engage when both buttons are released to prevent the board from being a powered projectile.
To enter the settings menu, hold down the front button or foot sensor for atleast 5 seconds then release. The rear button or foot sensor must not be pressed for this procedure.
To cycle through the menu, press and release the front button or foot sensor.
To alter a setting, press and release the back button or foot sensor.
To reset a value to its lowest setting, hold the back button or foot sensor for atleast 3 seconds and release.
To exit the menu and save your settings, hold down the front button or foot sensor again for atleast 5 seconds. Your settings are now saved and you will be shown the voltage displays.
This setting allows you to set the max cruise speed. The board will sound the beeper if you exceed this by 10 including angle retention.
I personally find a setting of 50 (1050) is a good setting to prevent from over speeding the board and nose diving.
This allows the user to set a custom center point. Angle the board to the desired angle and press and release the rear foot button/pad.
This setting will be set automatically when using Setting 3 and 4.
Place front of board on ground and press the rear foot button/pad.
This will also update setting #2, the center point.
Place back of board on ground and press the rear foot button/pad.
This will also update setting #2, the center point.
This is the cruising speed increment. This should be set high enough to accelerate comfortably, but not high enough to cause the board to kick back when accelerating.
My setting is currently 20 (5020).
This is the power multiplied by each degree over the Center Point.
This should be set high enough to keep the board level. If the board feels like it is bouncing back and forth on center, it's set to high.
My setting is 3.5 (6035).
This setting allows you to set the max speed indicator. The further the board passes this mark, the harder it will kick back to let you know you have reached your set speed.
If you have installed a beeper, it will sound if you ignore or miss this boundery by 10%.
I personally find a setting of 50 (1050) is a good setting to prevent from over speeding the board and nose diving.
This allows the user to set a custom center point. Angle the board to the desired angle and press and release the rear foot button/pad.
I like to set about 4 - 5 degrees to the rear foot so that I am level while cruising and the nose is a little higher when climbing bumps and curbs.
This sets desired cruising angle.
My setting is 7 (3007).
This is the power to apply for angle.
My setting is 3.5 (4035).
This is the power multiplied by each degree over the Center Zone. This is added to the Angle Power.
This should be set high enough to make it difficult to angle beyond the Center Zone, but not to high as to force the board to jerk back and forth.
My setting is 1.5 (5015).
This is the angle to start applying over drive too.
My setting is 5 (6005).
This is the value to start multiplying by each degree after Overdrive Angle.
This value should be set low enough that the board doesn't feel like it is kicking up when activated.
My Setting is 0.5 (7005).
This is the maximum overdrive to add. This should not be set to high as to max out the forward throttle. If you max out the thottle, you will lose angle retention.
My setting is 30 (8030).
This is the initial power sent to the motor when past 0 in either direction.
Usually not needed for most motors, but lets say your motor required 2% power to start to turn under load, you would set a value of 2.0 (9020).
My setting is 0 (9000).
This setting determines whether the board move only forward or in both directions.
1001 = 1 way. The board will only move in the forward direction.
1002 = 2 way. The board will move in both directions.
I like to place the board in 1 way for long journeys, and in 2 way for playing around.
This allows the user to set a custom center point. Angle the board to the desired angle and press and release the rear foot button/pad.
I like to set about 2 degrees to the rear foot so that I am level while cruising and the nose is a little higher when climbing bumps.
This sets desired cruising angle.
My setting is 7 (3007).
This is the power to apply for angle.
My setting is 3.5 (4035).
This is the power multiplied by each degree over the Center Zone. This is added to the Angle Power.
This should be set high enough to make it difficult to angle beyond the Center Zone, but not to high as to force the board to jerk back and forth.
My setting is 1.5 (5015).
This is the angle to start applying over drive too.
My setting is 5 (6005).
This is the value to start multiplying by each degree after Overdrive Angle.
This value should be set low enough that the board doesn't feel like it is kicking up when activated.
My Setting is 0.5 (7005).
This is the maximum overdrive to add. This should not be set to high as to max out the forward throttle. If you max out the thottle, you will lose angle retention.
My setting is 30 (8030).
This is the initial power sent to the motor when past 0 in either direction.
Usually not needed for most motors, but lets say your motor required 2% power to start to turn under load, you would set a value of 2.0 (9020).
My setting is 0 (9000).
This setting determines whether the board move only forward or in both directions. I like to place the board in 1 way for long journeys, and in 2 way for playing around.
1001 = 1 way. The board will only move in the forward direction.
1002 = 2 way. The board will move in both directions.
This setting determines how much of the 100% throttle to utilize in either direction.
Do not exceed 100 (2100)
This setting determines, in degrees, how far to tilt the board prior to utilizing the overdrive variable. This is your equal power to tilt zone.
I find a setting of 7 (3007) works best for me. The minimum setting is 5 as their has to be value less then the set value to allow the software to subtract incurred overdrive.
This is the equal multiplier for standard power to angle ratio.
Ex: a setting of 30 (4030) will provide 3.0% duty to angle to drive the board. At 10 degrees of angle, the board will be attempting to drive the motor at 30% power.
This is the overdrive power variable. This will tell the board to add this value devided by 10 times how many degrees beyond the center zone to the overdrive variable.
Returning the board to an angle less than the center zone will subtract this value devided by 10 times how many degrees inside of the center zone from the overdrive variable.
The higher this setting, The more the board will feal like it is fighting you. This is by design as it naturally pushes the board to the center zone value. Holding the angle past the center zone will steadily increase the boards speed.
Be warned: The incurred overdrive value must be scrubbed before the board can be stopped in the level position. This is simply done by leaning back, but the more overdrive incurred the harder it will be to perform a sudden stop.
Personally I find 5 (5005) to be a good value for this setting.
This is the initial power sent to the motor when past 0 in either direction.
Usually not needed for most motors, but lets say your motor required 2% power to start to turn under load, you would set a value of 20 (6020).
This is kick power in percent. This will cause the board to jump this value to the board once it reaches the Max Power Setting minus this value. This is designed to keep the board from traveling beyond the Max Power Setting.
This is the factory reset settings. Hold the back button for atleast 3 secconds under this option to reset all values to their minimum values. The board will then save and exit the settings menu.
This setting is soon to be replaced by the set level option.
Pending...
My setup utilizes 2 waterproof momentary switches mounted flush to act as the front and rear safety/settings switches. These switches are wired in pull-up configuration. I also utilize a Piezo Buzzer and a TM1637 display module.
Utilizing a 4k7 resistor I bridge digital pin 6 to 5 volt positive, then wire the switch from pin 6 to ground when pressed.
Utilizing a 4k7 resistor I bridge digital pin 7 to 5 volt positive, then wire the switch from pin 7 to ground when pressed.
The buzzer I wire positive to digital pin 10 and negative to ground.
I wire VIN to 5 volt positive, GND to ground, CLK to digital pin 4, and DIO to digital pin 3.
VCC to 5 volt positive, GND to ground, SCL to A5 (SCL), SDA to A4 (SDA).
More Pending...
Note: disconnect UART cable from VESC before programming Arduino, even if VESC is powered off.
Use these versions of the required libraries. Some have been modified to work better with the Arduino Nano.
Version 1.15 now released.
This new version is now smoother and has a couple of new settings available.
Note: Upgrading to this version will erase your current settings.
Rail Ends |
|
Best printed with TPU, this part doubles to protect the aluminum rail ends and for breaking. |
|
Download |
Pending...
This is coming soon, sorry.
This is Firmware Version 1.11 cut down for smaller projects.
The board will beep when the Gyro is calibrated and beep again when Armed. During operation, the board will beep when 85% of max speed is reached in either direction.
Requires a piezo buzzer. (The one found in most PCs or are provided with new computer cases.)
Adjust your settings at the top of the code. Add your drive routine near the bottom inside the motorRoutine routine.