This example program utilizes the MAX31856 mbed library available from Maxim Integrated at the following link: https://os.mbed.com/teams/Maxim-Integrated/code/MAX31856/
Fork of MAX31856_example_program by
main.cpp@2:296485923589, 2017-07-26 (annotated)
- Committer:
- DevinAlexander
- Date:
- Wed Jul 26 18:46:23 2017 +0000
- Revision:
- 2:296485923589
- Parent:
- 1:b58719a76fc3
- Child:
- 3:a99a4367c909
before fixing the LOGs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DevinAlexander | 0:456e9e702d57 | 1 | #include "mbed.h" |
DevinAlexander | 1:b58719a76fc3 | 2 | #include "MAX31856.h" |
DevinAlexander | 1:b58719a76fc3 | 3 | //#include "USBSerial.h" |
DevinAlexander | 1:b58719a76fc3 | 4 | //#include "SDFileSystem.h" |
DevinAlexander | 1:b58719a76fc3 | 5 | |
DevinAlexander | 1:b58719a76fc3 | 6 | |
DevinAlexander | 1:b58719a76fc3 | 7 | /* |
DevinAlexander | 1:b58719a76fc3 | 8 | //---------------------------------------------------------- |
DevinAlexander | 2:296485923589 | 9 | #include "max32630fthr.h" |
DevinAlexander | 1:b58719a76fc3 | 10 | //Define serial ports |
DevinAlexander | 1:b58719a76fc3 | 11 | // Hardware serial port over DAPLink |
DevinAlexander | 1:b58719a76fc3 | 12 | Serial daplink(P2_1, P2_0); |
DevinAlexander | 1:b58719a76fc3 | 13 | // Virtual serial port over USB |
DevinAlexander | 1:b58719a76fc3 | 14 | //USBSerial microUSB; |
DevinAlexander | 1:b58719a76fc3 | 15 | //---------------------------------------------------------- |
DevinAlexander | 1:b58719a76fc3 | 16 | //SPI Interfaces |
DevinAlexander | 1:b58719a76fc3 | 17 | //SPI testSPI(SPIO MOSI,SPIO MISO,SPIO SCK); |
DevinAlexander | 1:b58719a76fc3 | 18 | SPI testSPI(P5_1, P5_2, P5_0); |
DevinAlexander | 1:b58719a76fc3 | 19 | //---------------------------------------------------------- |
DevinAlexander | 1:b58719a76fc3 | 20 | //Define featherboard |
DevinAlexander | 1:b58719a76fc3 | 21 | MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); |
DevinAlexander | 1:b58719a76fc3 | 22 | //---------------------------------------------------------- |
DevinAlexander | 1:b58719a76fc3 | 23 | //Thermocouples |
DevinAlexander | 1:b58719a76fc3 | 24 | MAX31856 Thermocouple(testSPI, P3_2, CR1_TC_TYPE_K, CR0_FILTER_OUT_60Hz, CR1_AVG_TC_SAMPLES_1, CR0_CONV_MODE_NORMALLY_ON); |
DevinAlexander | 1:b58719a76fc3 | 25 | */ |
DevinAlexander | 1:b58719a76fc3 | 26 | |
DevinAlexander | 1:b58719a76fc3 | 27 | |
DevinAlexander | 1:b58719a76fc3 | 28 | |
DevinAlexander | 1:b58719a76fc3 | 29 | |
DevinAlexander | 1:b58719a76fc3 | 30 | //---------------------------------------------------------- |
DevinAlexander | 1:b58719a76fc3 | 31 | //Define serial ports |
DevinAlexander | 1:b58719a76fc3 | 32 | // Hardware serial port over DAPLink |
DevinAlexander | 1:b58719a76fc3 | 33 | Serial daplink(USBTX, USBRX); |
DevinAlexander | 1:b58719a76fc3 | 34 | |
DevinAlexander | 1:b58719a76fc3 | 35 | //SPI Interfaces |
DevinAlexander | 1:b58719a76fc3 | 36 | //SPI testSPI(SPIO MOSI,SPIO MISO,SPIO SCK); |
DevinAlexander | 1:b58719a76fc3 | 37 | SPI testSPI(P6_1, P6_2, P6_0); |
DevinAlexander | 1:b58719a76fc3 | 38 | //---------------------------------------------------------- |
DevinAlexander | 2:296485923589 | 39 | //------------- |
DevinAlexander | 1:b58719a76fc3 | 40 | //Thermocouples |
DevinAlexander | 1:b58719a76fc3 | 41 | MAX31856 Thermocouple(testSPI, P6_3, CR1_TC_TYPE_K, CR0_FILTER_OUT_60Hz, CR1_AVG_TC_SAMPLES_1, CR0_CONV_MODE_NORMALLY_ON); |
DevinAlexander | 1:b58719a76fc3 | 42 | |
DevinAlexander | 1:b58719a76fc3 | 43 | |
DevinAlexander | 1:b58719a76fc3 | 44 | |
DevinAlexander | 1:b58719a76fc3 | 45 | |
DevinAlexander | 1:b58719a76fc3 | 46 | |
DevinAlexander | 1:b58719a76fc3 | 47 | |
DevinAlexander | 0:456e9e702d57 | 48 | |
DevinAlexander | 0:456e9e702d57 | 49 | DigitalOut led1(LED1); |
DevinAlexander | 1:b58719a76fc3 | 50 | DigitalOut led2(LED2); |
DevinAlexander | 1:b58719a76fc3 | 51 | |
DevinAlexander | 0:456e9e702d57 | 52 | // main() runs in its own thread in the OS |
DevinAlexander | 0:456e9e702d57 | 53 | int main() { |
DevinAlexander | 1:b58719a76fc3 | 54 | // testSPI.format(8,3); |
DevinAlexander | 1:b58719a76fc3 | 55 | float temperature_TC, temperature_CJ; |
DevinAlexander | 1:b58719a76fc3 | 56 | // setThermocoupleType(CR1_TC_TYPE_K); |
DevinAlexander | 1:b58719a76fc3 | 57 | // setEmiFilterFreq(CR0_FILTER_OUT_60Hz); |
DevinAlexander | 1:b58719a76fc3 | 58 | // setNumSamplesAvg(CR1_AVG_TC_SAMPLES_1); |
DevinAlexander | 1:b58719a76fc3 | 59 | // setConversionMode(CR0_CONV_MODE_NORMALLY_ON); |
DevinAlexander | 1:b58719a76fc3 | 60 | // spi.format(8,3); |
DevinAlexander | 0:456e9e702d57 | 61 | while (true) { |
DevinAlexander | 0:456e9e702d57 | 62 | led1 = !led1; |
DevinAlexander | 2:296485923589 | 63 | wait(0.2); |
DevinAlexander | 1:b58719a76fc3 | 64 | temperature_TC=Thermocouple.readTC(); |
DevinAlexander | 2:296485923589 | 65 | temperature_CJ=Thermocouple.readCJ(); |
DevinAlexander | 1:b58719a76fc3 | 66 | daplink.printf("MAX31856 TC = %f Celsius MAX31856 CJ = %f Celsius \n\r",temperature_TC,temperature_CJ); |
DevinAlexander | 1:b58719a76fc3 | 67 | |
DevinAlexander | 1:b58719a76fc3 | 68 | |
DevinAlexander | 0:456e9e702d57 | 69 | } |
DevinAlexander | 0:456e9e702d57 | 70 | } |
DevinAlexander | 0:456e9e702d57 | 71 |