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.
Revision 2:19d0fb7468ba, committed 2016-08-14
- Comitter:
- lzbpli
- Date:
- Sun Aug 14 05:11:52 2016 +0000
- Parent:
- 1:58b6efe82b46
- Child:
- 3:e2d2d429d5bb
- Commit message:
- max31865 Examples
Changed in this revision
--- a/main.cpp Wed Jan 27 14:50:17 2016 +0000
+++ b/main.cpp Sun Aug 14 05:11:52 2016 +0000
@@ -1,47 +1,42 @@
#include "mbed.h"
-
-InterruptIn event(USER_BUTTON);
-DigitalOut myled(LED1);
-Serial pc(SERIAL_TX, SERIAL_RX);
-
-int go_to_sleep = 0;
+#include "MAX31865.h"
-void pressed()
-{
- pc.printf("Button pressed\n");
- go_to_sleep = go_to_sleep + 1;
- if (go_to_sleep > 3) go_to_sleep = 0;
-
-}
+Serial pc(SERIAL_TX, SERIAL_RX);
+MAX31865_RTD rtd(MAX31865_RTD::RTD_PT100,D11, D12, D13, D10);
int main()
{
- int i = 0;
-
- pc.printf("\nPress Button to enter/exit sleep & deepsleep\n");
-
- event.fall(&pressed);
+ // int i = 0;
+ rtd.configure( true, true, false, true, MAX31865_FAULT_DETECTION_NONE,
+ true, true, 0x0000, 0x7fff );
while (1) {
+ rtd.read_all( );
- if ((go_to_sleep == 0) || (go_to_sleep == 2)) {
- pc.printf("%d: Running\n", i);
- myled = !myled;
- wait(1.0);
- }
+ if( rtd.status( ) == 0 ) {
+ double temperature1 = rtd.temperature( );
+ pc.printf( " T = %f deg C \r\n",temperature1);
- if (go_to_sleep == 1) {
- myled = 0;
- pc.printf("%d: Entering sleep (press user button to resume)\n", i);
- sleep();
+ } else
+ {
+ pc.printf( "RTD fault register: %d :\r\n",rtd.status( ));
+ if( rtd.status( ) & MAX31865_FAULT_HIGH_THRESHOLD ) {
+ pc.printf( "RTD high threshold exceeded\r\n" );
+ } else if( rtd.status( ) & MAX31865_FAULT_LOW_THRESHOLD ) {
+ pc.printf( "RTD low threshold exceeded\r\n" );
+ } else if( rtd.status( ) & MAX31865_FAULT_REFIN ) {
+ pc.printf( "REFIN- > 0.85 x V_BIAS\r\n" );
+ } else if( rtd.status( ) & MAX31865_FAULT_REFIN_FORCE ) {
+ pc.printf( "REFIN- < 0.85 x V_BIAS, FORCE- open\r\n" );
+ } else if( rtd.status( ) & MAX31865_FAULT_RTDIN_FORCE ) {
+ pc.printf( "RTDIN- < 0.85 x V_BIAS, FORCE- open\r\n" );
+ } else if( rtd.status( ) & MAX31865_FAULT_VOLTAGE ) {
+ pc.printf( "Overvoltage/undervoltage fault\r\n");
+ } else {
+ pc.printf( "Unknown fault; check connection\r\n" );
+ }
}
+ wait(1);
- if (go_to_sleep == 3) {
- myled = 0;
- pc.printf("%d: Entering deepsleep (press user button to resume)\n", i);
- deepsleep();
- }
-
- i++;
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/max31865.lib Sun Aug 14 05:11:52 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/lzbpli/code/max31865/#ae18c7b91185
--- a/mbed.bld Wed Jan 27 14:50:17 2016 +0000 +++ b/mbed.bld Sun Aug 14 05:11:52 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/6f327212ef96 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c \ No newline at end of file