GithubHelp home page GithubHelp logo

thelastbilly / bipropellant-hoverboard-firmware Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bipropellant/bipropellant-hoverboard-firmware

0.0 1.0 0.0 47.11 MB

OpenSource Hoverboard firmware based on Niklas Fauth's one https://github.com/NiklasFauth/hoverboard-firmware-hack

License: GNU General Public License v3.0

C++ 0.71% C 97.12% Assembly 2.16% Makefile 0.02%

bipropellant-hoverboard-firmware's Introduction

Bipropellant

bipropellant[ bahy-pruh-pel-uh nt ] - Most liquid-propellant rockets use bipropellant systems — i.e., those in which an oxidizer and a fuel are tanked separately and mixed in the combustion chamber.

This repo, when mixed with the protocol repo, rocket-propels your hoverboard derived projects, now with added sinusoidal motor control.

Build Status

This firmware is a heavily modified version of Niklas Fauth's hoverboard firmware which allows you to:

  • Use the hoverboard AS A HOVERBOARD
  • Control externaly the hoverboard with a reliable serial protocol.

This project was started by btsimonh

It branched from Niklas Fauth's hoverboard firmware at this commit: Aug 24, 2018

Added:

Software serial:

This allows you to use ANY GPIO pins (with modififcation) as serial. Probably best to stay at 9600 baud, as the receive interrupt is serviced at 8x the bitrate.

Sensor reading:

It reads the original serial data (9 bit) from the original sensor boards from USART2&3.

Sensor control:

Sensor data can control the PWM demands (power to the wheels). Double tap on pads to enable.

Serial diagnostic control:

Protocol.c implements a simple ASCII serial protocol which allows for manual control of the board.

Serial Machine control:

Protocol.c implements the bones of an acked/checksummed serial protocol. Embryonic as yet, but intended to be a generic control protocol for the hoverboard.

Sample C++ code to send pwm and steer:

setHoverboardPWM(300,-300); // sends 300 (=30% duty cycle forward) to one wheel and -300 (=30% duty cycle backwards) to the other


typedef struct MsgToHoverboard_t{
  unsigned char SOM;  // Start of Message
  unsigned char CI;   // continuity counter
  unsigned char len;  // len is len of bytes to follow, NOT including CS
  unsigned char cmd;  // read or write
  unsigned char code; // code of value to write
  int32_t pwm1;           // absolute value ranging from -1000 to 1000 .. Duty Cycle *10 for first wheel
  int32_t pwm2;           // absolute value ranging from -1000 to 1000 .. Duty Cycle *10 for second wheel
  unsigned char CS;   // checksumm
};

typedef union UART_Packet_t{
  MsgToHoverboard_t msgToHover;
  byte UART_Packet[sizeof(MsgToHoverboard_t)];
};

char hoverboardCI = 0;  // Global variable which tracks CI

void setHoverboardPWM( int32_t pwm1, int32_t pwm2 )
{
  UART_Packet_t ups;

  ups.msgToHover.SOM = 4 ;    // Start of Message, 4 for No ACKs;
  ups.msgToHover.CI = ++hoverboardCI; // Message Continuity Indicator. Subsequent Messages with the same CI are discarded, need to be incremented.
  ups.msgToHover.len = 1 + 1 + 4 + 4 ; // cmd(1), code(1), pwm1(4) and pwm2(4)
  ups.msgToHover.cmd  = 'r';  // Pretend to send answer to read request. This way HB will not reply. Change to 'W' to get confirmation from board
  ups.msgToHover.code = 0x0E; // "simpler PWM"
  ups.msgToHover.pwm1 = pwm1;
  ups.msgToHover.pwm2 = pwm2;
  ups.msgToHover.CS = 0;

  for (int i = 0; i < (2 + ups.msgToHover.len); i++){  // Calculate checksum. 2 more for CI and len.
    ups.msgToHover.CS -= ups.UART_Packet[i+1];
  }

  Serial.write(ups.UART_Packet,sizeof(UART_Packet_t));
}

This code is only able to write values to the board, replies can not be parsed. For more information check the hoverboard protocol wiki and examples. An Arduino compatible C++ module which can communicate in both directions can be found at bipropellant-hoverboard-api.

PID Control:

PID control loops for control of Speed (in mm/sec) and Position (in mm). Currently separate control modes, and parameter need better tuning.

Hall Interupts:

Used to read Position and Speed data.

Flash settings:

Implements a flash page available for efficitent storage of parameters (currently unused, but tested).

Should work with original control settings (in config.h), but not tested...

ADC inputs

Multiple inputs like Joystick, speed throttle and Gametrak can be easily configured. Check out the wiki

Hardware

Motherboard

The original Hardware supports two 4-pin cables that originally were connected to the two sensor boards. They break out GND, 12/15V and USART2&3 of the Hoverboard mainboard. Both USART2 & 3 can be used for UART and I2C, PA2&3 can be used as 12bit ADCs.

The reverse-engineered schematics of the mainboard can be found here: http://vocke.tv/lib/exe/fetch.php?media=20150722_hoverboard_sch.pdf

Building and flashing

The repository uses a submodule for the serial protocol. Clone with submodules: ´git clone --recurse-submodules´ Or afterwards: ´git submodule update --init --recursive´

Take a look at our wiki

Any other problems ?

First take a look at our wiki and open issues, if you still have any problem/question, feel free to open a new issue!

bipropellant-hoverboard-firmware's People

Contributors

btsimonh avatar crinq avatar emerickh avatar jana-marie avatar lalalandrus avatar larsmm avatar leodj avatar p-h-a-i-l avatar rene-dev avatar tobleminer avatar trilader avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.