ライブラリ化を行った後
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_Practice1 by
accelerator.h@3:9ef929639c4a, 2017-06-30 (annotated)
- Committer:
- echo_piyo
- Date:
- Fri Jun 30 00:55:12 2017 +0000
- Revision:
- 3:9ef929639c4a
accelerator.h?main.cpp??????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
echo_piyo | 3:9ef929639c4a | 1 | class Accel |
echo_piyo | 3:9ef929639c4a | 2 | { |
echo_piyo | 3:9ef929639c4a | 3 | public : |
echo_piyo | 3:9ef929639c4a | 4 | void setup(float Acceleration, float time) { |
echo_piyo | 3:9ef929639c4a | 5 | a = Acceleration*time; |
echo_piyo | 3:9ef929639c4a | 6 | v = 0; |
echo_piyo | 3:9ef929639c4a | 7 | } |
echo_piyo | 3:9ef929639c4a | 8 | |
echo_piyo | 3:9ef929639c4a | 9 | float duty(float target) { |
echo_piyo | 3:9ef929639c4a | 10 | if (fabs(target-v) <= a){ |
echo_piyo | 3:9ef929639c4a | 11 | v = target; |
echo_piyo | 3:9ef929639c4a | 12 | } else if (v < target) { |
echo_piyo | 3:9ef929639c4a | 13 | v = v + a; |
echo_piyo | 3:9ef929639c4a | 14 | } else if (v > target) { |
echo_piyo | 3:9ef929639c4a | 15 | v = v - a; |
echo_piyo | 3:9ef929639c4a | 16 | } |
echo_piyo | 3:9ef929639c4a | 17 | return v; |
echo_piyo | 3:9ef929639c4a | 18 | } |
echo_piyo | 3:9ef929639c4a | 19 | |
echo_piyo | 3:9ef929639c4a | 20 | private : |
echo_piyo | 3:9ef929639c4a | 21 | float a; |
echo_piyo | 3:9ef929639c4a | 22 | float v; |
echo_piyo | 3:9ef929639c4a | 23 | }; |