Simple piece of code for simulation sensor inputs of a hoverboard to do basic control of wheels.

Dependencies:   WiiNunchuck mbed-dev

This program is inspired by this site:

http://drewspewsmuse.blogspot.co.at/2016/06/how-i-hacked-self-balancing-scooter.html

Here you can get more information of the protocol revervse engineering.

This program uses a Wii nunchuk connected over I2C to controll the speed. Speed is controlled by a closed loop P controller. Feedback is done by counting HALL events from the brushless motor. Some more pictures are available here:

https://github.com/tyler123durden/hoverboard-hardware

Basically you need a serial TX and 3 HALL IRQs per motor side.

Wiring of the board. Gyro boards are not used, input is generated from nucleo board. Motor board has still the HALL connections. Nucleo board just also reads HALL inputs to get speed information for closed loop controll.

/media/uploads/Thomas_H/wiring.jpg

Committer:
Thomas_H
Date:
Sun Oct 23 19:38:35 2016 +0000
Revision:
2:6e0dfe2caf48
Parent:
1:5acd27cb1857
removed unused files

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Thomas_H 0:fe156910301e 1 #ifndef HALLDECODER_H
Thomas_H 0:fe156910301e 2 #define HALLDECODER_H
Thomas_H 0:fe156910301e 3
Thomas_H 0:fe156910301e 4 #include "mbed.h"
Thomas_H 0:fe156910301e 5
Thomas_H 0:fe156910301e 6
Thomas_H 0:fe156910301e 7 class HallDecoder {
Thomas_H 0:fe156910301e 8
Thomas_H 0:fe156910301e 9 public:
Thomas_H 0:fe156910301e 10 HallDecoder(PinName hall1, PinName hall2, PinName hall3);
Thomas_H 0:fe156910301e 11 int32_t getticks();
Thomas_H 0:fe156910301e 12 void resetticks();
Thomas_H 0:fe156910301e 13
Thomas_H 0:fe156910301e 14 void hall1_handler();
Thomas_H 0:fe156910301e 15 void hall2_handler();
Thomas_H 0:fe156910301e 16 void hall3_handler();
Thomas_H 0:fe156910301e 17
Thomas_H 0:fe156910301e 18 private:
Thomas_H 0:fe156910301e 19 InterruptIn _int1;
Thomas_H 0:fe156910301e 20 InterruptIn _int2;
Thomas_H 0:fe156910301e 21 InterruptIn _int3;
Thomas_H 0:fe156910301e 22 volatile int32_t _ticks;
Thomas_H 0:fe156910301e 23 volatile uint8_t _lastint;
Thomas_H 0:fe156910301e 24 };
Thomas_H 0:fe156910301e 25
Thomas_H 0:fe156910301e 26
Thomas_H 0:fe156910301e 27 #endif
Thomas_H 0:fe156910301e 28