Library to control the bike (just basic for now)

Dependents:   TORTUGA_BLE

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BikeControl.h Source File

BikeControl.h

00001 #ifndef BIKECONTROL_H
00002 #define BIKECONTROL_H
00003 #include "mbed.h"
00004 #include "BikeData.h"
00005 #include "BatteryState.h"
00006 
00007 class BikeControl{
00008     
00009 protected:
00010     //State machine states definition
00011     typedef enum DriveState {
00012         DRIVE_START=0,
00013         DRIVE_BRAKE,
00014         DRIVE_BOOST,
00015         DRIVE_RUN,
00016     } DriveState_t;
00017     
00018     
00019     //WHEEL
00020     //const float WHEEL_CIRCUMFERENCE = 1.66; //Wheel Circumference
00021     //MOTOR
00022     //const float GEAR_RATIO = 13.3;     //Motor gear ration
00023    
00024     
00025     //TRAILER
00026     DigitalOut trailerCtrl;
00027     
00028     //MOTOR
00029     PwmOut motorRightCtrl;
00030     InterruptIn motorRightHall;
00031     uint16_t motorRightCounter;
00032     uint16_t motorRightRpm;
00033     PwmOut motorLeftCtrl;
00034     InterruptIn motorLeftHall;
00035     uint16_t motorLeftCounter;
00036     uint16_t motorLeftRpm;
00037     
00038     //BRAKE
00039     DigitalIn brakeFront;
00040     DigitalIn brakeRear;
00041     
00042     //GENERATOR
00043     InterruptIn generatorHallA;
00044     PwmOut generatorBrake;
00045     uint16_t generatorHallACounter;
00046     uint16_t generatorHallARpm;
00047     InterruptIn generatorHallB;
00048     uint16_t generatorHallBCounter;
00049     uint16_t generatorHallBRpm;
00050     
00051     //BUTTONS ON STEERING
00052     //DigitalIn userButton;
00053     DigitalIn buttonGreen;
00054     DigitalIn buttonRed;
00055     DigitalIn buttonDirectionRight;
00056     DigitalIn buttonDirectionLeft;
00057     
00058     //SWITCH
00059     DigitalIn switchOn;
00060     DigitalIn switchWalk;
00061     
00062     //LIGHT
00063     DigitalOut lightFront;
00064     DigitalOut lightBack;
00065     DigitalOut lightLeft;
00066     DigitalOut lightRight;
00067     
00068     
00069     void generatorHallAPulsed();
00070     void generatorHallBPulsed();
00071     void motorRightPulsed();
00072     void motorLeftPulsed();
00073     void periodicCallback();
00074     
00075     Ticker t;
00076     BikeData *bd;
00077     BatteryState *bikeBat, *trailerBat, *auxBat;
00078     
00079 public:
00080     BikeControl(BikeData* bikeData, BatteryState* trailerBat, BatteryState* bikeBat, BatteryState* auxBat);
00081     void runTestLight();
00082     void startControlLoop();
00083     void checkStatus();
00084 };
00085     
00086 #endif