code of robot bike

Dependencies:   SDFileSystem mbed

Fork of Robot_Bicycle by Chris LU

Committer:
YCTung
Date:
Thu Jun 09 09:46:38 2016 +0000
Revision:
0:830ddddc129f
Child:
1:709be64ca63c
add header files

Who changed what in which revision?

UserRevisionLine numberNew 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 0:830ddddc129f 6 #define PWR_REDU_PW 0.0001 //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 0:830ddddc129f 9 #define MIN_SERVO_PW 0.0007 //pulse width in second
YCTung 0:830ddddc129f 10 #define MAX_SERVO_PW 0.0023 //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 0:830ddddc129f 16 #define Ts 0.004098
YCTung 0:830ddddc129f 17 #define pi 3.14159
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 0:830ddddc129f 29 #define HANDLE_STOP 30
YCTung 0:830ddddc129f 30 #define HANDLE_STRAIGHT 0 - 6
YCTung 0:830ddddc129f 31 #define HANDLE_START 20 //16 - 6
YCTung 0:830ddddc129f 32
YCTung 0:830ddddc129f 33 #define COUN2_LOW_V TOT_STOP_POS
YCTung 0:830ddddc129f 34 #define COUN2_MID_V 19
YCTung 0:830ddddc129f 35 #define COUN2_HIGH_V 38
YCTung 0:830ddddc129f 36
YCTung 0:830ddddc129f 37 #define COUN2_HANDLE_CNTRL 19
YCTung 0:830ddddc129f 38 #define COUN2_HANDLE_START 10
YCTung 0:830ddddc129f 39
YCTung 0:830ddddc129f 40 extern const int servoangle_left[TOT_ARM_POS][3];
YCTung 0:830ddddc129f 41 extern const int servoangle_right[TOT_ARM_POS][3];
YCTung 0:830ddddc129f 42
YCTung 0:830ddddc129f 43 extern const float footangle_left[TOT_FOOT_POS][4];
YCTung 0:830ddddc129f 44 extern const float footangle_right[TOT_FOOT_POS][4];
YCTung 0:830ddddc129f 45
YCTung 0:830ddddc129f 46 extern void setupServo(void);
YCTung 0:830ddddc129f 47
YCTung 0:830ddddc129f 48 extern void pwm_left(float angle_up, float angle_mid, float angle_down); //Left arm
YCTung 0:830ddddc129f 49 extern void pwm_right(float angle_up, float angle_mid, float angle_down); //Left arm
YCTung 0:830ddddc129f 50 extern void lookuptable_steering(int8_t sensor_output);
YCTung 0:830ddddc129f 51
YCTung 0:830ddddc129f 52 extern void pwm_left_foot(float angle_1, float angle_2, float angle_3, float angle_4);
YCTung 0:830ddddc129f 53 extern void pwm_right_foot(float angle_1, float angle_2, float angle_3, float angle_4);
YCTung 0:830ddddc129f 54 extern void lookuptable_pedaling(int index);
YCTung 0:830ddddc129f 55
YCTung 0:830ddddc129f 56 extern void reset_left_butt(void);
YCTung 0:830ddddc129f 57 extern void reset_pos(void);
YCTung 0:830ddddc129f 58 extern void stop_pos(void);
YCTung 0:830ddddc129f 59
YCTung 0:830ddddc129f 60 extern int angle_to_duty(int resolution, float degree);