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.
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
Diff: Libs/DC_DC/DC_DC.h
- Revision:
- 30:91af74a299e1
- Child:
- 36:0afc0fc8f86b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/DC_DC/DC_DC.h Thu Nov 13 10:53:10 2014 +0000
@@ -0,0 +1,71 @@
+#ifndef _FILE_DC_DC_H
+#define _FILE_DC_DC_H
+
+#include "mbed.h"
+#include "FanPump.h"
+
+enum Channel_T {
+ FAN1=0,
+ FAN2,
+ PUMP1,
+ PUMP2,
+};
+enum Status_Bits_T {
+ ConvOn=1,
+ SetOn=2,
+ PowerUp=4,
+ PowerDown=8,
+ OverCurrent=16,
+ SensorFault=32,
+ FailStart=64,
+ FailStop=128,
+};
+const int DC_DC_FILTER_TAPS = 10;
+
+class DC_DC{
+public:
+ DC_DC(PinName _dcdcPin, PinName _dcdcCurrent, PinName _fan1, PinName _fan2, PinName _pump1, PinName _pump2, float period, float slew);
+ float getCurrent() { return current; }
+ void zeroCurrent();
+ void set(bool on);
+ void setPwm(enum Channel_T chan, float duty);
+ float readPwm(enum Channel_T chan);
+ /*
+ char status =
+ bit0 - 1 = DC-DC converter is actually on
+ bit1 - 1 = DC-DC converter is set to on
+ bit2 - 1 = DC-DC Startup, its use is currently blocked until ready
+ bit3 - 1 = DC-DC Power-down, its use is currently blocked until ready
+ bit4 - 1 = DC-DC over current (drawing more current than allowed according to sensor)
+ bit5 - 1 = DC-DC current sensor out of range (broken)
+ bit6 - 1 = DC-DC failed to start
+ bit7 - 1 = DC-DC failed to stop
+ */
+ char getStatus() { return status; }
+ bool hasCritError() { return critError; } // An error exists according to status above
+ void sample(); // Attach this function in a 10ms RTOS timer
+
+private:
+ Timer startTimer;
+ Timer stopTimer;
+ volatile bool starting;
+ volatile bool stopping;
+
+ DigitalOut dcdcControl;
+ AnalogIn dcdcCurrent;
+ volatile float currentOffset;
+ volatile float filterBuff[DC_DC_FILTER_TAPS];
+ volatile int buffTracker;
+ void updateCurrent();
+
+ volatile float current;
+ volatile char status;
+ volatile bool critError;
+
+ FanPump fan1;
+ FanPump fan2;
+ FanPump pump1;
+ FanPump pump2;
+};
+
+#endif
\ No newline at end of file
