Tuesday, April 20, 2021

MaxiSkateKick - A Ridekick powered skateboard (controlled remotely on your phone with failsafe)

This article describes a project with no implied warrany of any kind. Try it and use it at your own risk. Always wear a helmet for your safety and knee/elbow pads.

keywords: electric skateboard, Ridekick, fun, DIY, arduino nano, bluesmirf, bluetooth, roboremo app.


This projects has 2 parts:  the skateboard adapter and the bluetooth control system upgrade.

What is it ?

-Your favorite skateboard or longboard pushed by an electric bike pusher trailer. 

Does it have brakes?

- No, use your feet instead as on a regular skateboard.

Positions?

- Sitting & standing.

How do you make it work?  DIY skateboard adapter

- DIY: bend a 1/4 in. thick piece of steel in a vise with a hammer to get it "L" shaped, dill holes in it for attachment screws and hitch bolt. No wizardry involved.


 

Sitting on it :


 How far does it go?

- Depends on your battery, i have a Lead-acid 12AH that goes 12km or 8 miles ish and a LiFePO4 50AH that goes 100km or 60 miles ish with a bike, perhaps less here with those smaller wheels...

How fast does it go?

-i d recommend using it on the "P0" setting to prevent going too fast and accelerating too much - remember there are no brakes!

What about the electronic part?

- 2 options: use the throttle that comes with the Ridekick or make your own bluetooth control system as follows:

What parts do i need for the DIY bluetooth control system?

-the e-trailer - you ll have it already perhaps... https://ridekick.com/

-arduino Nano (see ebay).

-Bluesmirf bluetooth silver bluetooth adapter (https://www.sparkfun.com/products/12577) or you can try one super cheap bluetooth adapter from china...good luck with that as they are super hard to program and use, if they ever work.

-a dc-to-dc high efficiency converter to get ~5V DC from the 24 V battery of the ridekick (do not use the ridekick usb port as it only delivers 25mA before switching to error mode). - a dc to dc step down converter like a 2A LM2596 buck power converter 4-40V - at 150kHz (genuine).

-a few resistors and capacitors, a LED.  see schematics.

-terminals and a prototype soldering board.

- XT60 male plug to solder

- Cu wires

 


The simple soldered connections




Schematics of the circuit board:


 
The usb cable gets connected to the throttle usb port plug of ridekick controller. Older trailer versions might have a different plug. (is it compatible with the right connection?).

The DC-step down buck connects to the battery charge port of the ridekick. preadjust it to 4.7V (to prevent frying your arduino!) then connect it to the above board after the rectifying diode (not needed on diagram) and ground. check the polarity!
 
 
the final working setup strapped in a high tech yahourt box which attaches with velcro tape on the ridekick.
 

 
How do i control this board?
 
- See video at bottom of this link:
https://www.roboremo.com/arduino-bluetooth-dc-motor-speed.html
 
- install Roboremo on your android phone, setup a scroll bar to send command "vitesse" then the number between 0 and 255 and it should work once connected  to the device both through the Bluetooth on the phone (with connection code input (1234 by default)) and Roboremo (bluetooth(RFCOMM) in setup)
optionally, add a button that sends the text "s" to stop... read the code to figure out alternatives.
 
    Setup in Roboremo: 
Menu/edit UI. touch screen, select : "slider". Still in edit mode, touch the slidebar, select "set id" :type "vitesse", set limits from 0 to 255, select "send when moved", "send space",)

- Failsafe implementation principle: 
Roboremo app can send a "heartbeat" or a command of your choice (here a "c") every 650ms. if no heartbeat or"c" is detected by the CPU before 2s have elapsed, it will shut down the throttle. This prevents runaways upon crashes of the phone or dead battery etc... 
 
    Setup in Roboremo:
Menu/edit UI. touch screen, select : "heartbeat sender". Still in edit mode, touch the new heart, select "set repeat period" to 650 ms, "set id" to "c".
 
PS: your bluetooth adapter can be renamed to any name you fancy with the arduino IDE with a specific program code that will talk to the bluesmirf (see manual website).

Video of the prototype spinning the wheel:



Arduino Nano source code to compile in IDE and upload on chip: 

 (select OLD Bootloader in the "tools/processor" menu, if your arduino is pre-2018 or replica from China)

/*****************************************************************************
//created by Maxime Cuypers on 29-march-2021 for ridekick control by bluetooth with roboremo on android phone
//bluetooth module Bluesmirf silver (10m range)
//
 * AUTHOR   : Maxime Cuypers
 * COMPANY  : private
 * REVISION : 0.1
 * DATE     : 24/04/2021
********************************************************************************/

#include <SoftwareSerial.h>  

/*******************************************************************************
 * IO DEFINITION                                                                *
 *******************************************************************************/
//setup bluetooth bluesmirf port
int bluetoothTx = 2; // TX-O pin of BT module to Arduino pin2
int bluetoothRx = 3; // RX-I pin of B module to Arduino pin3

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

//const = variable "read-only".
// PWM is connected to pin 7.
const int pinPwm = 5;
int val=0;
int val2=51; // ridekick must start with throttle at 1-1.5V as zero speed.
int count=0;
unsigned long now; //unsigned to prevent problems with large numbers

/*******************************************************************************
 * PRIVATE GLOBAL VARIABLES                                                     *
 *******************************************************************************/

char cmd[1000];
int cmdIndex;

void exeCmd() { //runs only when a command is received
  if( cmd[0]=='v' &&
      cmd[1]=='i' &&
      cmd[2]=='t' &&
      cmd[3]=='e' &&
      cmd[4]=='s' &&
      cmd[5]=='s' &&
      cmd[6]=='e' &&
      cmd[7]==' ') {
        String cmdStr;
        String valueStr;   
        cmdStr = String(cmd);
        valueStr = cmdStr.substring(8);
        val = valueStr.toInt(); //special thanks to LP to get this to work
//for ridekick - voltage value |1-4|Volt range only. otherwise error E2. 1-1.5V = stop, 4V = full speed
//startup only  1-1.5V allowed, or E3
//E7 if usb throttle line (5V) draws more than 25mA.
// since val is stored into integer, decimal not stored, add .0 to allow decimal
        val2= 51.00 + ( val * 0.66 ); // val2= 51.00 + ( val * 0.66 ) input 0-255 from roboremo, output 51-204 (1-4 Volt) here. Attention 1-3.18v if ridekick off. - full compatibility with train DC control board then. 0.6 +0.06 for adjustmnet with the LED take bit of power
   analogWrite(pinPwm, val2);
   }
   if(cmd[0]=='s') {  // stop
      analogWrite(pinPwm, 51); // ridekick speed zero at 1 volt
      delay(1000); //wait 1s after emergency stop before any other restart
   }
   if(cmd[0]=='c') {  // FAILSAFE heartbeat signal "c" every 650ms from roboremo. see loop below
     now= millis();
   }
}

/*******************************************************************************
 * FUNCTIONS                                                                    *
 *******************************************************************************/

void setup() {   // at power on
  delay(500); // wait for bluetooth module to start
// Initialize the PWM and DIR pins as digital outputs.(upon reset)
  pinMode(pinPwm, OUTPUT);
//  pinMode(pinDir, OUTPUT);  
// change Bluetooth module baud rate to 9600:
  bluetooth.begin(115200); // Bluetooth default baud is 115200
  bluetooth.print("$");
  bluetooth.print("$");
  bluetooth.print("$"); // enter cmd mode
  delay(250);  
  bluetooth.println("U,9600,N"); // change baud to 9600
  bluetooth.begin(9600);
  cmdIndex = 0;
  now=millis(); //initialize the time reference for FAILSAFE
}

void loop() {
  if(bluetooth.available()) {
    char c = (char)bluetooth.read();
    cmd[cmdIndex] = c;  
    if(cmdIndex<99) cmdIndex++;
    if(c=='\n') {   // each command ends with '\n'
      exeCmd();
      cmdIndex = 0;
    }  
  }
  //constant detection of presence of signal from roboremo heart beat
  if(millis()-now > 2000) {
  analogWrite(pinPwm, 0); // ridekick speed FAILSAFE to prevent a runaway!
  }    
}