Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Tourobo2022_TBCMotorDriver
Diff: motorDrive_LAP.cpp
- Revision:
- 0:6a48e14ebdfa
diff -r 000000000000 -r 6a48e14ebdfa motorDrive_LAP.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/motorDrive_LAP.cpp Wed Mar 25 09:25:28 2020 +0000
@@ -0,0 +1,28 @@
+#include "motorDrive_LAP.h"
+
+motorDriveLAP::motorDriveLAP(PinName PwmH,PinName Phase) : pwmh(PwmH),phase(Phase) {
+ lowerLimitDuty = -1.0f;
+ upperLimitDuty = 1.0f;
+ pwmh.write(1);
+}
+
+void motorDriveLAP::setupFrequency(float frequency) {
+ phase.period(1.0f / frequency);
+}
+
+void motorDriveLAP::setupLimitDuty(float lowerLimit,float upperLimit) {
+ lowerLimitDuty = lowerLimit;
+ upperLimitDuty = upperLimit;
+}
+
+void motorDriveLAP::output(float duty) {
+ if(duty > 0.0f) {
+ if(duty > upperLimitDuty) duty = upperLimitDuty;
+ phase.write(fabs(0.50f + (duty *0.50f)));
+ } else if(duty < 0.0f){
+ if(duty < lowerLimitDuty) duty = lowerLimitDuty;
+ phase.write(fabs(0.50f + (duty * 0.50f)));
+ } else {
+ phase.write(fabs(0.50f));
+ }
+}
\ No newline at end of file