Library to control the bike (just basic for now)
Diff: BikeControl.h
- Revision:
- 0:792a8f167ac0
- Child:
- 1:39f462024f10
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BikeControl.h Mon Jul 18 09:25:53 2016 +0000 @@ -0,0 +1,76 @@ +#ifndef BATTERYSTATE_H +#define BATTERYSTATE_H +#include "mbed.h" + +class BikeControl{ + +public: + Bikecontrol(); + +protected: + + //State machine states definition + typedef enum DriveState { + DRIVE_START=0, + DRIVE_BRAKE, + DRIVE_BOOST, + DRIVE_RUN, + } DriveState_t; + + + //WHEEL + //const float WHEEL_CIRCUMFERENCE = 1.66; //Wheel Circumference + //MOTOR + //const float GEAR_RATIO = 13.3; //Motor gear ration + + //BATTERY + AnalogIn batteryVoltageTrailer(PB_0); + AnalogIn batteryVoltageBike(PC_5); + AnalogIn batteryVoltageAuxiliay(PC_4); + + //TRAILER + DigitalOut trailerCtrl(PB_1); + + //MOTOR + PwmOut motorRightCtrl(PB_15); + InterruptIn motorRightHall(PC_0); + float motorRightCounter = 0; + float motorRightRpm = 0; + PwmOut motorLeftCtrl(PB_13); + InterruptIn motorLeftHall(PC_1); + float motorLeftCounter = 0; + float motorLeftRpm = 0; + + //BRAKE + DigitalIn brakeFront(PC_10); + DigitalIn brakeRear(PC_12); + + //GENERATOR + InterruptIn generatorHallA(PD_2); + PwmOut generatorBrake(PC_9); + float generatorHallACounter = 0; + float generatorHallARpm = 0; + InterruptIn generatorHallB(PC_3); + float generatorHallBCounter = 0; + float generatorHallBRpm = 0; + + //BUTTONS ON STEERING + DigitalIn userButton(USER_BUTTON); + DigitalIn buttonGreen(PB_11); + DigitalIn buttonRed(PB_12); + DigitalIn buttonDirectionRight(PA_15); + DigitalIn buttonDirectionLeft(PB_7); + + //SWITCH + DigitalIn switchOn(PC_11); + DigitalIn switchWalk(PB_2); + + //LIGHT + DigitalOut lightFront(PB_14); + DigitalOut lightBack(PA_11); + DigitalOut lightLeft(PC_6); + DigitalOut lightRight(PC_8); + +}; + +#endif \ No newline at end of file