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.
Diff: DtPWM.h
- Revision:
- 0:f4cf8380dbee
- Child:
- 2:1ef7ff2f120e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/DtPWM.h Sat Mar 25 17:26:48 2017 +0000
@@ -0,0 +1,45 @@
+#include "mbed.h"
+
+#ifndef DTPWM_H
+#define DTPWM_H
+
+/** Library for fast and high resolution opposite PWM output with
+ * controllable dead times
+ */
+
+class DtPWM{
+public:
+ /**
+ * Create a dtPWM object connected to channel 2 and 4, optionally to LED 2&4
+ *
+ * @param led - false does not connect LEDs (default)
+ */
+ DtPWM(bool led = false);
+ ~DtPWM();
+
+ /**
+ * Set the period, duty cycle, and dead time.
+ *
+ * @param p_us - period in micro seconds
+ * @param d - duty cycle from 0-1 as float
+ * @param dt_us - dead time between switching in micro seconds
+ */
+ void setDtPWM(double p_us, float d, double dt_us);
+
+ /**
+ * Value for maximum duty cycle that fulfils minimum dead times
+ */
+ float d_max;
+
+ /**
+ * Fast way to change the duty cycle.
+ *
+ * @param d - duty cycle from 0-1 as float no checking is done in this function
+ */
+ void setD(float d);
+
+private:
+ unsigned int p_tcks; // clock ticks in period
+ unsigned int dt_tcks; // dead time ticks
+};
+#endif
\ No newline at end of file