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
Libs/DC_DC/DC_DC.h@38:8efacce315ae, 2015-02-07 (annotated)
- Committer:
- pspatel321
- Date:
- Sat Feb 07 08:54:51 2015 +0000
- Revision:
- 38:8efacce315ae
- Parent:
- 36:0afc0fc8f86b
Updated with profiles, operating info, etc. Just like the other programs. Awaiting test in car.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| pspatel321 | 30:91af74a299e1 | 1 | #ifndef _FILE_DC_DC_H |
| pspatel321 | 30:91af74a299e1 | 2 | #define _FILE_DC_DC_H |
| pspatel321 | 30:91af74a299e1 | 3 | |
| pspatel321 | 30:91af74a299e1 | 4 | #include "mbed.h" |
| pspatel321 | 30:91af74a299e1 | 5 | #include "FanPump.h" |
| pspatel321 | 30:91af74a299e1 | 6 | |
| pspatel321 | 30:91af74a299e1 | 7 | enum Channel_T { |
| pspatel321 | 38:8efacce315ae | 8 | FAN1 = 0, |
| pspatel321 | 38:8efacce315ae | 9 | FAN2 = 1, |
| pspatel321 | 38:8efacce315ae | 10 | PUMP1 = 2, |
| pspatel321 | 38:8efacce315ae | 11 | PUMP2 = 3, |
| pspatel321 | 30:91af74a299e1 | 12 | }; |
| pspatel321 | 38:8efacce315ae | 13 | |
| pspatel321 | 30:91af74a299e1 | 14 | enum Status_Bits_T { |
| pspatel321 | 38:8efacce315ae | 15 | CONV_ON = 1<<0, |
| pspatel321 | 38:8efacce315ae | 16 | SET_ON = 1<<1, |
| pspatel321 | 38:8efacce315ae | 17 | POWER_UP = 1<<2, |
| pspatel321 | 38:8efacce315ae | 18 | POWER_DOWN = 1<<3, |
| pspatel321 | 38:8efacce315ae | 19 | OVER_CURRENT = 1<<4, |
| pspatel321 | 38:8efacce315ae | 20 | SENSOR_FAULT = 1<<5, |
| pspatel321 | 30:91af74a299e1 | 21 | }; |
| pspatel321 | 30:91af74a299e1 | 22 | |
| pspatel321 | 30:91af74a299e1 | 23 | class DC_DC{ |
| pspatel321 | 30:91af74a299e1 | 24 | public: |
| pspatel321 | 38:8efacce315ae | 25 | DC_DC(PinName _dcdcPin, PinName _dcdcCurrent, PinName _fan1, PinName _fan2, PinName _pump1, PinName _pump2, float period, float slew, unsigned int size=50); |
| pspatel321 | 38:8efacce315ae | 26 | void setup(float* onThreshold, float* overCurrent, float* startDelay, float* stopDelay); |
| pspatel321 | 38:8efacce315ae | 27 | bool size(unsigned int size); |
| pspatel321 | 30:91af74a299e1 | 28 | float getCurrent() { return current; } |
| pspatel321 | 30:91af74a299e1 | 29 | void set(bool on); |
| pspatel321 | 30:91af74a299e1 | 30 | void setPwm(enum Channel_T chan, float duty); |
| pspatel321 | 30:91af74a299e1 | 31 | float readPwm(enum Channel_T chan); |
| pspatel321 | 30:91af74a299e1 | 32 | /* |
| pspatel321 | 30:91af74a299e1 | 33 | char status = |
| pspatel321 | 30:91af74a299e1 | 34 | bit0 - 1 = DC-DC converter is actually on |
| pspatel321 | 30:91af74a299e1 | 35 | bit1 - 1 = DC-DC converter is set to on |
| pspatel321 | 30:91af74a299e1 | 36 | bit2 - 1 = DC-DC Startup, its use is currently blocked until ready |
| pspatel321 | 30:91af74a299e1 | 37 | bit3 - 1 = DC-DC Power-down, its use is currently blocked until ready |
| pspatel321 | 30:91af74a299e1 | 38 | bit4 - 1 = DC-DC over current (drawing more current than allowed according to sensor) |
| pspatel321 | 30:91af74a299e1 | 39 | bit5 - 1 = DC-DC current sensor out of range (broken) |
| pspatel321 | 30:91af74a299e1 | 40 | */ |
| pspatel321 | 30:91af74a299e1 | 41 | char getStatus() { return status; } |
| pspatel321 | 30:91af74a299e1 | 42 | bool hasCritError() { return critError; } // An error exists according to status above |
| pspatel321 | 30:91af74a299e1 | 43 | void sample(); // Attach this function in a 10ms RTOS timer |
| pspatel321 | 30:91af74a299e1 | 44 | |
| pspatel321 | 30:91af74a299e1 | 45 | private: |
| pspatel321 | 38:8efacce315ae | 46 | |
| pspatel321 | 30:91af74a299e1 | 47 | Timer startTimer; |
| pspatel321 | 30:91af74a299e1 | 48 | Timer stopTimer; |
| pspatel321 | 36:0afc0fc8f86b | 49 | volatile bool isControlPinOn; |
| pspatel321 | 30:91af74a299e1 | 50 | DigitalOut dcdcControl; |
| pspatel321 | 30:91af74a299e1 | 51 | AnalogIn dcdcCurrent; |
| pspatel321 | 38:8efacce315ae | 52 | |
| pspatel321 | 38:8efacce315ae | 53 | float currentOffset; |
| pspatel321 | 38:8efacce315ae | 54 | float* filterBuff; |
| pspatel321 | 38:8efacce315ae | 55 | int buffTracker; |
| pspatel321 | 38:8efacce315ae | 56 | unsigned int _size; |
| pspatel321 | 38:8efacce315ae | 57 | |
| pspatel321 | 30:91af74a299e1 | 58 | void updateCurrent(); |
| pspatel321 | 30:91af74a299e1 | 59 | volatile float current; |
| pspatel321 | 30:91af74a299e1 | 60 | volatile char status; |
| pspatel321 | 30:91af74a299e1 | 61 | volatile bool critError; |
| pspatel321 | 30:91af74a299e1 | 62 | |
| pspatel321 | 30:91af74a299e1 | 63 | FanPump fan1; |
| pspatel321 | 30:91af74a299e1 | 64 | FanPump fan2; |
| pspatel321 | 30:91af74a299e1 | 65 | FanPump pump1; |
| pspatel321 | 30:91af74a299e1 | 66 | FanPump pump2; |
| pspatel321 | 38:8efacce315ae | 67 | |
| pspatel321 | 38:8efacce315ae | 68 | float* onThreshold; |
| pspatel321 | 38:8efacce315ae | 69 | float* overCurrent; |
| pspatel321 | 38:8efacce315ae | 70 | float* startDelay; |
| pspatel321 | 38:8efacce315ae | 71 | float* stopDelay; |
| pspatel321 | 30:91af74a299e1 | 72 | }; |
| pspatel321 | 30:91af74a299e1 | 73 | |
| pspatel321 | 30:91af74a299e1 | 74 | #endif |
