Control an H-Bridge using a PwmOut (enable) and two DigitalOuts (direction select) For maxon controll

Dependents:   NHK2015 NHK2015_new

Fork of Motor by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
WAT34
Date:
Thu Sep 10 07:27:18 2015 +0000
Parent:
3:d35b291eb6f2
Commit message:
can to modulate frequencies.

Changed in this revision

Motor.cpp Show annotated file Show diff for this revision Revisions of this file
Motor.h Show annotated file Show diff for this revision Revisions of this file
diff -r d35b291eb6f2 -r e98b342edd25 Motor.cpp
--- a/Motor.cpp	Thu Sep 03 02:36:46 2015 +0000
+++ b/Motor.cpp	Thu Sep 10 07:27:18 2015 +0000
@@ -41,6 +41,8 @@
     _rev = (speed < 0.0);
     _pwm = abs(speed);
 }
+void Motor::setfrequency(float frequency) {
+    _pwm.period(1/frequency);
+}
 
 
-
diff -r d35b291eb6f2 -r e98b342edd25 Motor.h
--- a/Motor.h	Thu Sep 03 02:36:46 2015 +0000
+++ b/Motor.h	Thu Sep 10 07:27:18 2015 +0000
@@ -45,6 +45,7 @@
      * @param speed The speed of the motor as a normalised value between -1.0 and 1.0
      */
     void speed(float speed);
+    void setfrequency(float setfrequency);
 
 protected:
     PwmOut _pwm;