code of robot bike
Dependencies: SDFileSystem mbed
Fork of Nucleo_ZTC_20160607_never_touched by
RobotServo.h@12:60593247555d, 2017-02-22 (annotated)
- Committer:
- cpul5338
- Date:
- Wed Feb 22 09:49:44 2017 +0000
- Revision:
- 12:60593247555d
- Parent:
- 9:159bad8bae03
robot bike
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
YCTung | 0:830ddddc129f | 1 | #include "mbed.h" |
YCTung | 0:830ddddc129f | 2 | |
YCTung | 0:830ddddc129f | 3 | #define PWM_PERIOD 1.0f/244.0f |
YCTung | 0:830ddddc129f | 4 | #define POWER_REDU_PW 0.0001f |
YCTung | 0:830ddddc129f | 5 | |
YCTung | 3:197b748a397a | 6 | #define PWR_REDU_PW 0.0001f //100us ~ 200us |
YCTung | 0:830ddddc129f | 7 | #define PWR_REDU_DUTY_1024 PWR_REDU_PW*244*1024 |
YCTung | 0:830ddddc129f | 8 | #define PWR_REDU_DUTY_256 PWR_REDU_PW*244*256 |
YCTung | 3:197b748a397a | 9 | #define MIN_SERVO_PW 0.0007f //pulse width in second |
YCTung | 3:197b748a397a | 10 | #define MAX_SERVO_PW 0.0023f //pulse width in second |
YCTung | 0:830ddddc129f | 11 | #define MIN_SERVO_DUTY_1024 MIN_SERVO_PW*244*1024 |
YCTung | 0:830ddddc129f | 12 | #define MAX_SERVO_DUTY_1024 MAX_SERVO_PW*244*1024 |
YCTung | 0:830ddddc129f | 13 | #define MIN_SERVO_DUTY_256 MIN_SERVO_PW*244*256 |
YCTung | 0:830ddddc129f | 14 | #define MAX_SERVO_DUTY_256 MAX_SERVO_PW*244*256 |
YCTung | 0:830ddddc129f | 15 | |
YCTung | 3:197b748a397a | 16 | #define Ts 0.004098f |
YCTung | 3:197b748a397a | 17 | #define pi 3.14159f |
YCTung | 0:830ddddc129f | 18 | |
YCTung | 0:830ddddc129f | 19 | #define H_PEDAL_DIVIDER 2 |
YCTung | 0:830ddddc129f | 20 | #define M_PEDAL_DIVIDER 3 |
YCTung | 0:830ddddc129f | 21 | #define L_PEDAL_DIVIDER 5 |
YCTung | 0:830ddddc129f | 22 | #define Z_PEDAL_DIVIDER 5 |
YCTung | 0:830ddddc129f | 23 | |
YCTung | 0:830ddddc129f | 24 | #define TOT_ARM_POS 41 |
YCTung | 0:830ddddc129f | 25 | #define TOT_FOOT_POS 55 //48 + TOT_STOP_POS |
YCTung | 0:830ddddc129f | 26 | #define TOT_STOP_POS 7 |
YCTung | 0:830ddddc129f | 27 | #define FIRST_POS 7 |
YCTung | 0:830ddddc129f | 28 | |
YCTung | 4:b0967990e390 | 29 | #define HANDLE_STOP 10 |
YCTung | 4:b0967990e390 | 30 | #define HANDLE_STRAIGHT 0 - 2 |
YCTung | 4:b0967990e390 | 31 | #define HANDLE_START 5 //16 - 6 |
YCTung | 9:159bad8bae03 | 32 | #define HANDLE_START_BAL 0//20 |
YCTung | 0:830ddddc129f | 33 | |
YCTung | 0:830ddddc129f | 34 | #define COUN2_LOW_V TOT_STOP_POS |
YCTung | 0:830ddddc129f | 35 | #define COUN2_MID_V 19 |
YCTung | 0:830ddddc129f | 36 | #define COUN2_HIGH_V 38 |
YCTung | 0:830ddddc129f | 37 | |
YCTung | 0:830ddddc129f | 38 | #define COUN2_HANDLE_CNTRL 19 |
YCTung | 0:830ddddc129f | 39 | #define COUN2_HANDLE_START 10 |
YCTung | 0:830ddddc129f | 40 | |
YCTung | 1:709be64ca63c | 41 | extern PwmOut pwm_lw; |
YCTung | 1:709be64ca63c | 42 | extern PwmOut pwm_le; |
YCTung | 1:709be64ca63c | 43 | extern PwmOut pwm_ls; |
YCTung | 1:709be64ca63c | 44 | extern PwmOut pwm_la; |
YCTung | 1:709be64ca63c | 45 | extern PwmOut pwm_lk; |
YCTung | 1:709be64ca63c | 46 | extern PwmOut pwm_ll; |
YCTung | 1:709be64ca63c | 47 | extern PwmOut pwm_lb; |
YCTung | 1:709be64ca63c | 48 | extern PwmOut pwm_rb; |
YCTung | 1:709be64ca63c | 49 | extern PwmOut pwm_rl; |
YCTung | 1:709be64ca63c | 50 | extern PwmOut pwm_rk; |
YCTung | 1:709be64ca63c | 51 | extern PwmOut pwm_ra; |
YCTung | 1:709be64ca63c | 52 | extern PwmOut pwm_rs; |
YCTung | 1:709be64ca63c | 53 | extern PwmOut pwm_re; |
YCTung | 1:709be64ca63c | 54 | extern PwmOut pwm_rw; |
YCTung | 1:709be64ca63c | 55 | |
YCTung | 0:830ddddc129f | 56 | extern const int servoangle_left[TOT_ARM_POS][3]; |
YCTung | 0:830ddddc129f | 57 | extern const int servoangle_right[TOT_ARM_POS][3]; |
YCTung | 0:830ddddc129f | 58 | |
YCTung | 0:830ddddc129f | 59 | extern const float footangle_left[TOT_FOOT_POS][4]; |
YCTung | 0:830ddddc129f | 60 | extern const float footangle_right[TOT_FOOT_POS][4]; |
YCTung | 0:830ddddc129f | 61 | |
YCTung | 0:830ddddc129f | 62 | extern void setupServo(void); |
YCTung | 0:830ddddc129f | 63 | |
YCTung | 0:830ddddc129f | 64 | extern void pwm_left(float angle_up, float angle_mid, float angle_down); //Left arm |
YCTung | 0:830ddddc129f | 65 | extern void pwm_right(float angle_up, float angle_mid, float angle_down); //Left arm |
YCTung | 0:830ddddc129f | 66 | extern void lookuptable_steering(int8_t sensor_output); |
YCTung | 0:830ddddc129f | 67 | |
YCTung | 0:830ddddc129f | 68 | extern void pwm_left_foot(float angle_1, float angle_2, float angle_3, float angle_4); |
YCTung | 0:830ddddc129f | 69 | extern void pwm_right_foot(float angle_1, float angle_2, float angle_3, float angle_4); |
YCTung | 0:830ddddc129f | 70 | extern void lookuptable_pedaling(int index); |
YCTung | 0:830ddddc129f | 71 | |
YCTung | 0:830ddddc129f | 72 | extern void reset_left_butt(void); |
YCTung | 0:830ddddc129f | 73 | extern void reset_pos(void); |
YCTung | 0:830ddddc129f | 74 | extern void stop_pos(void); |
YCTung | 0:830ddddc129f | 75 | |
YCTung | 0:830ddddc129f | 76 | extern int angle_to_duty(int resolution, float degree); |