E=MC / Mbed 2 deprecated figure_eight

Dependencies:   mbed-rtos mbed MODSERIAL mbed-dsp telemetry

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers encoder.h Source File

encoder.h

00001 #ifndef ENCODER_H
00002 #define ENCODER_H
00003 
00004 #include "mbed.h"
00005 
00006 
00007 class Encoder{
00008     Timer t;
00009     
00010     //Intervals used during encoder data collection to measure velocity
00011     int interval1;
00012     int interval2;
00013     int interval3;
00014     int avg_interval;
00015     int lastchange1;
00016     int lastchange2;
00017     int lastchange3;
00018     int lastchange4;
00019     
00020     //Variables used to for velocity control
00021     float avg_speed;
00022     float stall_check;
00023     float tuning_val;
00024     
00025     // Servo parameters
00026     float lastTurnTime;
00027     bool servoLeft;
00028     
00029     //Parameters specifying sample sizes and delays for small and large average speed samples
00030     float num_samples_small;
00031     float delay_small;
00032     float num_samples_large;
00033     float delay_large;
00034     
00035     // Large and small arrays used to get average velocity values
00036     float large_avg_speed_list [100];
00037     float small_avg_speed_list [10];
00038 public:
00039     Encoder(Timer t);
00040     float velocity_control(float duty_cyc, float tuning_const);
00041     void fallInterrupt();
00042     void riseInterrupt();
00043 private:
00044     // Internal functions
00045     float get_speed();
00046     float get_avg_speed(float num_samples, float delay);
00047 };
00048 
00049 
00050 #endif