![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
control for robotic arm that can play chess using a granular gripper
Dependencies: Encoder mbed HIDScope Servo MODSERIAL
Fork of chessRobot by
Diff: actuators.cpp
- Revision:
- 55:ee5257fb73df
- Parent:
- 54:c14c3bc48b8a
- Child:
- 60:20945383ad1b
--- a/actuators.cpp Fri Oct 09 12:08:35 2015 +0000 +++ b/actuators.cpp Fri Oct 09 12:59:00 2015 +0000 @@ -39,6 +39,7 @@ float prevTime = 0; float now = 0; float timechange; + bool pidOut = 0; // Create object instances // Initialze motors @@ -68,10 +69,13 @@ // Set motor PWM period motor1.period(1/pwm_frequency); motor2.period(1/pwm_frequency); - + + motor1PID.SetSampleTime(motorCall); + motor2PID.SetSampleTime(motorCall); + // Turn PID on - motor1PID.SetMode(1); - motor2PID.SetMode(1); + motor1PID.SetMode(AUTOMATIC); + motor2PID.SetMode(AUTOMATIC); // start the timer t.start(); @@ -111,7 +115,7 @@ void writeMotors(){ motor1PID.Compute(); // calculate PID outputs, output changes automatically - motor2PID.Compute(); + pidOut = motor2PID.Compute(); // write new values to motor's if (motor1PWM >= 0 ){ // CCW rotation direction1 = false;