A Library to drive the RenBuggy_Servo.

Dependencies:   PinDetect

Dependents:  

Fork of RenBuggyServo by Renishaw

Files at this revision

API Documentation at this revision

Comitter:
Markatron
Date:
Mon Mar 31 07:44:16 2014 +0000
Parent:
3:01bc89d7ae8e
Child:
5:c06b90175a54
Commit message:
Called configure functions for motor and servo inside the constructor so that a default setting can be used.

Changed in this revision

Car.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Car.cpp	Thu Mar 13 07:31:10 2014 +0000
+++ b/Car.cpp	Mon Mar 31 07:44:16 2014 +0000
@@ -31,11 +31,25 @@
 #include "Car.h"
 #include "mbed.h"
 
+const int SERVO_PWM = 1500;             // 1500 = centre.
+const int SERVO_PWM_PERIOD = 2000;  
+const int SERVO_PWM_RANGE = 500;        // + or - 500 microseconds.
+const float SERVO_DEGREES_RANGE = 45.0; // + or - from centre is full right/left.
+    
+const int MOTOR_PWM = 20000;
+const int MOTOR_PERIOD = 20000;
+
 Car::Car(PinName servoPin, PinName motorPin) 
  : m_servo(servoPin), m_motor(motorPin) {
+    
     m_speed = 15000;
     m_countsPerRevolution = 0;
     m_wheelCircumference = 0;
+    
+    configureServo_us(SERVO_PWM, SERVO_PWM_PERIOD, 
+    SERVO_PWM_RANGE, SERVO_DEGREES_RANGE);
+    
+    configureMotor_us(MOTOR_PWM, MOTOR_PERIOD);
 }
 
 Car::Car(PinName servoPin, PinName motorPin, int countsPerRevolution, float wheelCircumference, PinName sensorPin)
@@ -45,6 +59,11 @@
     m_speed = 15000;
     setDirection(0);
     
+    configureServo_us(SERVO_PWM, SERVO_PWM_PERIOD, 
+    SERVO_PWM_RANGE, SERVO_DEGREES_RANGE);
+    
+    configureMotor_us(MOTOR_PWM, MOTOR_PERIOD);
+    
     m_encoderCount = 0;
     m_sensor.setSampleFrequency(1000);
     m_sensor.setSamplesTillHeld(5);