code of robot bike
Dependencies: SDFileSystem mbed
Fork of Robot_Bicycle by
Diff: RobotServo.h
- Revision:
- 0:830ddddc129f
- Child:
- 1:709be64ca63c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RobotServo.h Thu Jun 09 09:46:38 2016 +0000 @@ -0,0 +1,60 @@ +#include "mbed.h" + +#define PWM_PERIOD 1.0f/244.0f +#define POWER_REDU_PW 0.0001f + +#define PWR_REDU_PW 0.0001 //100us ~ 200us +#define PWR_REDU_DUTY_1024 PWR_REDU_PW*244*1024 +#define PWR_REDU_DUTY_256 PWR_REDU_PW*244*256 +#define MIN_SERVO_PW 0.0007 //pulse width in second +#define MAX_SERVO_PW 0.0023 //pulse width in second +#define MIN_SERVO_DUTY_1024 MIN_SERVO_PW*244*1024 +#define MAX_SERVO_DUTY_1024 MAX_SERVO_PW*244*1024 +#define MIN_SERVO_DUTY_256 MIN_SERVO_PW*244*256 +#define MAX_SERVO_DUTY_256 MAX_SERVO_PW*244*256 + +#define Ts 0.004098 +#define pi 3.14159 + +#define H_PEDAL_DIVIDER 2 +#define M_PEDAL_DIVIDER 3 +#define L_PEDAL_DIVIDER 5 +#define Z_PEDAL_DIVIDER 5 + +#define TOT_ARM_POS 41 +#define TOT_FOOT_POS 55 //48 + TOT_STOP_POS +#define TOT_STOP_POS 7 +#define FIRST_POS 7 + +#define HANDLE_STOP 30 +#define HANDLE_STRAIGHT 0 - 6 +#define HANDLE_START 20 //16 - 6 + +#define COUN2_LOW_V TOT_STOP_POS +#define COUN2_MID_V 19 +#define COUN2_HIGH_V 38 + +#define COUN2_HANDLE_CNTRL 19 +#define COUN2_HANDLE_START 10 + +extern const int servoangle_left[TOT_ARM_POS][3]; +extern const int servoangle_right[TOT_ARM_POS][3]; + +extern const float footangle_left[TOT_FOOT_POS][4]; +extern const float footangle_right[TOT_FOOT_POS][4]; + +extern void setupServo(void); + +extern void pwm_left(float angle_up, float angle_mid, float angle_down); //Left arm +extern void pwm_right(float angle_up, float angle_mid, float angle_down); //Left arm +extern void lookuptable_steering(int8_t sensor_output); + +extern void pwm_left_foot(float angle_1, float angle_2, float angle_3, float angle_4); +extern void pwm_right_foot(float angle_1, float angle_2, float angle_3, float angle_4); +extern void lookuptable_pedaling(int index); + +extern void reset_left_butt(void); +extern void reset_pos(void); +extern void stop_pos(void); + +extern int angle_to_duty(int resolution, float degree);