kusano kiyoshige / Mbed 2 deprecated 17robo_tokyo_kaede

Dependencies:   QEI accelerator bit_test cyclic_io cyclic_var cylinder event_var limit mbed mecanum motor_drive pid pid_encoder rs422_put sbdbt servo

Fork of 17robo_fuzi by kusano kiyoshige

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers accelerator_.h Source File

accelerator_.h

00001 class Accel
00002 {
00003 public  :
00004     void setup(float Acceleration, float time) {
00005         a = Acceleration*time;
00006         v = 0;
00007     }
00008     
00009     float duty(float target) {
00010         if (fabs(target-v) <= a){
00011             v = target;
00012         } else if (v < target) {
00013             v = v + a;
00014         } else if (v > target) {
00015             v = v - a;
00016         }
00017         return v;
00018     }
00019 
00020 private :
00021     float a;
00022     float v;
00023 };