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: MAX31855 SDFileSystem mbed
main.cpp@9:c97cd10b11ac, 2016-04-13 (annotated)
- Committer:
- DanielBlomdahl
- Date:
- Wed Apr 13 20:14:37 2016 +0000
- Revision:
- 9:c97cd10b11ac
- Parent:
- 8:882ccc7bbc8a
- Child:
- 10:f5d4d5e30b9b
Before Larkin Intervention on 30 minute timer
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| DanielBlomdahl | 2:a2966bf82e8c | 1 | |
| DanielBlomdahl | 0:42e8fa13c7a9 | 2 | #include "mbed.h" |
| DanielBlomdahl | 2:a2966bf82e8c | 3 | #include "MAX31855.h" |
| DanielBlomdahl | 6:76e8649a643f | 4 | #include "SDSaveFunction.h" |
| DanielBlomdahl | 0:42e8fa13c7a9 | 5 | |
| DanielBlomdahl | 2:a2966bf82e8c | 6 | Serial pc(USBTX,USBRX); |
| DanielBlomdahl | 2:a2966bf82e8c | 7 | SPI spi(NC,PTD3,PTD1); |
| DanielBlomdahl | 7:9032b52be810 | 8 | SPI sdspi(PTE3,PTE1,PTE2); |
| DanielBlomdahl | 9:c97cd10b11ac | 9 | DigitalIn eject(PTA4); // INT2 |
| DanielBlomdahl | 9:c97cd10b11ac | 10 | DigitalOut greenLed(LED2); |
| DanielBlomdahl | 9:c97cd10b11ac | 11 | DigitalOut redLed(LED1); |
| DanielBlomdahl | 2:a2966bf82e8c | 12 | |
| DanielBlomdahl | 2:a2966bf82e8c | 13 | MAX31855 thermometer1(spi,PTC4); |
| DanielBlomdahl | 2:a2966bf82e8c | 14 | MAX31855 thermometer2(spi,PTC3); |
| DanielBlomdahl | 7:9032b52be810 | 15 | AnalogIn solarPanel(PTB2); |
| DanielBlomdahl | 1:8116bd9d3c46 | 16 | Timer t; |
| DanielBlomdahl | 0:42e8fa13c7a9 | 17 | |
| DanielBlomdahl | 7:9032b52be810 | 18 | |
| DanielBlomdahl | 0:42e8fa13c7a9 | 19 | int main() |
| DanielBlomdahl | 0:42e8fa13c7a9 | 20 | { |
| DanielBlomdahl | 9:c97cd10b11ac | 21 | greenLed = 1; |
| DanielBlomdahl | 9:c97cd10b11ac | 22 | redLed = 0; |
| DanielBlomdahl | 1:8116bd9d3c46 | 23 | float temp1, temp2; |
| DanielBlomdahl | 1:8116bd9d3c46 | 24 | float lastTime = 0; |
| DanielBlomdahl | 1:8116bd9d3c46 | 25 | float dt = 0.5; |
| DanielBlomdahl | 7:9032b52be810 | 26 | float voltage = 0; |
| DanielBlomdahl | 7:9032b52be810 | 27 | float halfHour = 0; |
| DanielBlomdahl | 1:8116bd9d3c46 | 28 | t.start(); |
| DanielBlomdahl | 6:76e8649a643f | 29 | mountSDCard(); |
| DanielBlomdahl | 6:76e8649a643f | 30 | openDataFile(); |
| DanielBlomdahl | 7:9032b52be810 | 31 | float timeReset = 0; |
| DanielBlomdahl | 6:76e8649a643f | 32 | while (halfHour<=6) { |
| DanielBlomdahl | 9:c97cd10b11ac | 33 | if (eject == 0) { |
| DanielBlomdahl | 9:c97cd10b11ac | 34 | greenLed = 0; |
| DanielBlomdahl | 9:c97cd10b11ac | 35 | redLed = 1; |
| DanielBlomdahl | 9:c97cd10b11ac | 36 | break; |
| DanielBlomdahl | 9:c97cd10b11ac | 37 | } |
| DanielBlomdahl | 9:c97cd10b11ac | 38 | |
| DanielBlomdahl | 9:c97cd10b11ac | 39 | else if (t.read()>lastTime+dt) { |
| DanielBlomdahl | 7:9032b52be810 | 40 | lastTime = t.read(); |
| DanielBlomdahl | 7:9032b52be810 | 41 | timeReset = 30*60*halfHour+lastTime; |
| DanielBlomdahl | 7:9032b52be810 | 42 | temp1 = thermometer1.read(); |
| DanielBlomdahl | 9:c97cd10b11ac | 43 | wait(.02); |
| DanielBlomdahl | 7:9032b52be810 | 44 | temp2 = thermometer2.read(); |
| DanielBlomdahl | 9:c97cd10b11ac | 45 | voltage = solarPanel.read(); |
| DanielBlomdahl | 8:882ccc7bbc8a | 46 | pc.printf("Voltage %f\t Temp1 %f\t Temp2 %f\t Time %f\r\n", voltage, temp1, temp2, lastTime); |
| DanielBlomdahl | 7:9032b52be810 | 47 | |
| DanielBlomdahl | 8:882ccc7bbc8a | 48 | writeData(lastTime, temp1, temp2, voltage); |
| DanielBlomdahl | 7:9032b52be810 | 49 | if (t.read()>=30*60){ |
| DanielBlomdahl | 7:9032b52be810 | 50 | halfHour++; |
| DanielBlomdahl | 7:9032b52be810 | 51 | t.reset(); |
| DanielBlomdahl | 7:9032b52be810 | 52 | } |
| DanielBlomdahl | 7:9032b52be810 | 53 | } |
| DanielBlomdahl | 7:9032b52be810 | 54 | |
| DanielBlomdahl | 7:9032b52be810 | 55 | |
| DanielBlomdahl | 6:76e8649a643f | 56 | } |
| DanielBlomdahl | 6:76e8649a643f | 57 | closeDataFile(); |
| DanielBlomdahl | 0:42e8fa13c7a9 | 58 | } |
