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
DC_DC/DC_DC.cpp@10:db13782f05d9, 2014-10-19 (annotated)
- Committer:
- martydd3
- Date:
- Sun Oct 19 22:46:46 2014 +0000
- Revision:
- 10:db13782f05d9
- Parent:
- 6:6a04210a3f4f
- Child:
- 12:e0adb697fcdb
Copied Kiran's calculations for monitoring batttery currents; To do: Test on car, Xbees, 10 Hz Can Message (what data is needed?)
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| martydd3 | 6:6a04210a3f4f | 1 | #include "mbed.h" |
| martydd3 | 6:6a04210a3f4f | 2 | #include "DC_DC.h" |
| martydd3 | 6:6a04210a3f4f | 3 | |
| martydd3 | 6:6a04210a3f4f | 4 | FanPump *fanPump; |
| martydd3 | 6:6a04210a3f4f | 5 | CANBuffer *tx_DC_Buffer; |
| martydd3 | 6:6a04210a3f4f | 6 | bool status; |
| martydd3 | 6:6a04210a3f4f | 7 | |
| martydd3 | 10:db13782f05d9 | 8 | DigitalOut dc_pin(p20); |
| martydd3 | 10:db13782f05d9 | 9 | |
| martydd3 | 6:6a04210a3f4f | 10 | DC::DC(FanPump *fp, CANBuffer *can){ |
| martydd3 | 6:6a04210a3f4f | 11 | status = false; |
| martydd3 | 6:6a04210a3f4f | 12 | dc_pin = !status; |
| martydd3 | 6:6a04210a3f4f | 13 | tx_DC_Buffer = can; |
| martydd3 | 6:6a04210a3f4f | 14 | fanPump = fp; |
| martydd3 | 6:6a04210a3f4f | 15 | } |
| martydd3 | 6:6a04210a3f4f | 16 | |
| martydd3 | 6:6a04210a3f4f | 17 | bool DC::is_on(){ |
| martydd3 | 6:6a04210a3f4f | 18 | return status; |
| martydd3 | 6:6a04210a3f4f | 19 | } |
| martydd3 | 6:6a04210a3f4f | 20 | |
| martydd3 | 6:6a04210a3f4f | 21 | void DC::set(bool s){ |
| martydd3 | 6:6a04210a3f4f | 22 | status = s; |
| martydd3 | 6:6a04210a3f4f | 23 | if(!status){ |
| martydd3 | 6:6a04210a3f4f | 24 | fanPump->shutdown_all(); |
| martydd3 | 6:6a04210a3f4f | 25 | } |
| martydd3 | 6:6a04210a3f4f | 26 | |
| martydd3 | 6:6a04210a3f4f | 27 | dc_pin = !status; |
| martydd3 | 6:6a04210a3f4f | 28 | } |
| martydd3 | 6:6a04210a3f4f | 29 | |
| martydd3 | 10:db13782f05d9 | 30 | void update_dcdc(const void *arg){ |
| martydd3 | 6:6a04210a3f4f | 31 | char data[4] = {0}; |
| martydd3 | 6:6a04210a3f4f | 32 | while(1){ |
| martydd3 | 6:6a04210a3f4f | 33 | data[0] = status; |
| martydd3 | 6:6a04210a3f4f | 34 | CANMessage txMessage(TX_DC_DC_ID, data, 4); |
| martydd3 | 10:db13782f05d9 | 35 | tx_DC_Buffer->txWrite(txMessage); |
| martydd3 | 6:6a04210a3f4f | 36 | |
| martydd3 | 6:6a04210a3f4f | 37 | Thread::wait(100); //10 Hz update |
| martydd3 | 6:6a04210a3f4f | 38 | } |
| martydd3 | 6:6a04210a3f4f | 39 | } |
| martydd3 | 6:6a04210a3f4f | 40 | |
| martydd3 | 6:6a04210a3f4f | 41 | void DC::start_update(){ |
| martydd3 | 10:db13782f05d9 | 42 | Thread update_thread(update_dcdc); |
| martydd3 | 6:6a04210a3f4f | 43 | } |
