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.
Revision 1:464cd2cb852e, committed 2013-11-10
- Comitter:
- Reiko
- Date:
- Sun Nov 10 15:36:47 2013 +0000
- Parent:
- 0:a6123d12f08b
- Commit message:
- Added debounce to DIRO
Changed in this revision
| a3930.cpp | Show annotated file Show diff for this revision Revisions of this file |
| a3930.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r a6123d12f08b -r 464cd2cb852e a3930.cpp
--- a/a3930.cpp Mon Nov 04 17:04:34 2013 +0000
+++ b/a3930.cpp Sun Nov 10 15:36:47 2013 +0000
@@ -29,10 +29,21 @@
extIO->setPin(coastPinNumber);
extIO->clearPin(dirPinNumber);
- interruptDiro.rise(this, &A3930::diroRise);
- interruptDiro.fall(this, &A3930::diroFall);
+ /*interruptDiro.rise(this, &A3930::diroRise);
+ interruptDiro.fall(this, &A3930::diroFall);*/
interruptTacho.rise(this, &A3930::tachoChanged);
interruptTacho.fall(this, &A3930::tachoChanged);
+
+ interruptDiro.attach_asserted(this, &A3930::diroRise);
+ interruptDiro.attach_deasserted(this, &A3930::diroFall);
+ /*interruptTacho.attach_asserted(this, &A3930::tachoChanged);
+ interruptTacho.attach_deasserted(this, &A3930::tachoChanged);*/
+
+ interruptDiro.setSamplesTillAssert(3);
+ //interruptTacho.setSamplesTillAssert(2);
+
+ interruptDiro.setSampleFrequency(500);
+ //interruptTacho.setSampleFrequency(1000);
}
void A3930::setPWM(float newPWM) {
@@ -40,16 +51,23 @@
if (newPWM < -0.5) {
pwm = -1 * newPWM;
extIO->setPin(dirPinNumber);
- extIO->setPin(coastPinNumber);
+ //extIO->setPin(coastPinNumber);
+ extIO->setPin(brakePinNumber);
} else if (newPWM > 0.5) {
pwm = newPWM;
extIO->clearPin(dirPinNumber);
- extIO->setPin(coastPinNumber);
+ //extIO->setPin(coastPinNumber);
+ extIO->setPin(brakePinNumber);
} else {
- extIO->clearPin(coastPinNumber);
+ extIO->clearPin(brakePinNumber);
}
}
+void A3930::setRawPWM(float newPWM) {
+ currentPWM = newPWM;
+ pwm = newPWM;
+}
+
int A3930::getSpeed() {
return currentSpeed;
}
diff -r a6123d12f08b -r 464cd2cb852e a3930.h
--- a/a3930.h Mon Nov 04 17:04:34 2013 +0000
+++ b/a3930.h Sun Nov 10 15:36:47 2013 +0000
@@ -3,6 +3,7 @@
#include "mbed.h"
#include "PCA9555.h"
+#include "PinDetect.h"
/** Class for controlling motors trough PCA9555 */
class A3930 {
@@ -43,6 +44,8 @@
*/
void setPWM(float newPWM);
+ void setRawPWM(float newPWM);
+
int getStallLevel();
void stallChange(void (*function)(void));
@@ -81,7 +84,10 @@
unsigned int coastPinNumber;
InterruptIn interruptTacho;
- InterruptIn interruptDiro;
+ //InterruptIn interruptDiro;
+
+ //PinDetect interruptTacho;
+ PinDetect interruptDiro;
volatile int diro;
volatile int pulses;
