for izumi and ayami
Dependencies: RS405cb enc mbed
Revision 2:531e6b0346e6, committed 2013-12-12
- Comitter:
- ohtake_i
- Date:
- Thu Dec 12 15:01:32 2013 +0000
- Parent:
- 1:2fddb5d4ad27
- Commit message:
- for ayami;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 2fddb5d4ad27 -r 531e6b0346e6 main.cpp --- a/main.cpp Thu Dec 12 07:26:55 2013 +0000 +++ b/main.cpp Thu Dec 12 15:01:32 2013 +0000 @@ -43,19 +43,19 @@ //for control_angle void Control_Motor(); void Sample_Move(); - void Control_DCMotor(double desired_value, double offset, double speed_control); + //void Control_DCMotor(double desired_value, double offset, double speed_control); + void Control_DCMotor(int desired_value, int offset, double speed_control); int main() { while(1) { - //Control_DCMotor(180.0,5.0,0.05); - Sample_Move(); + printf("Start\r\n"); + Control_DCMotor(180.0,5.0,0.05); + //Sample_Move(); //VALVE_OPEN; //VALVE_CLOSE; //servo.TORQUE_ON(1); - //servo.Rotate_Servo_Float(1,0.0); - + //servo.Rotate_Servo_Float(1,0.0); } - } //Servo performance test @@ -82,17 +82,25 @@ } //Control z-axis angle of rotation -void Control_DCMotor(double desired_value, double offset, double speed_control) { - double tmp = abs(arm_enc.getPulses()); //get rev value +//void Control_DCMotor(double desired_value, double offset, double speed_control) { +void Control_DCMotor(int desired_value, int offset, double speed_control) { + //double tmp = abs(arm_enc.getPulses()); //get rev value + printf("Control_DCMotor_Start\r\n"); while(1) { - if(desired_value - offset <= tmp && tmp <= desired_value + offset) { + //if(desired_value - offset <= tmp && tmp <= desired_value + offset) { + if(desired_value - offset <= abs(arm_enc.getPulses()) && abs(arm_enc.getPulses()) <= desired_value + offset) { arm = 0.5; break; + printf("1 Rotation_of_Angle : %d\r\n", abs(arm_enc.getPulses())); } - else if(tmp < desired_value - offset) { + //else if(tmp < desired_value - offset) { + else if(abs(arm_enc.getPulses()) + < desired_value - offset) { arm = 0.5 + speed_control; + printf("2 Rotation_of_Angle : %d\r\n", abs(arm_enc.getPulses())); } else { arm = 0.5 - speed_control; + printf("3 Rotation_of_Angle : %d\r\n", abs(arm_enc.getPulses())); } } }