MCP3425 sample
Dependencies: AQM0802 MCP3425 mbed
See http://developer.mbed.org/users/yasuyuki/notebook/MCP3425/
Revision 0:5999cefe7380, committed 2014-10-15
- Comitter:
- yasuyuki
- Date:
- Wed Oct 15 14:40:22 2014 +0000
- Commit message:
- first release
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AQM0802.lib Wed Oct 15 14:40:22 2014 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/yasuyuki/code/AQM0802/#6fa303916aa8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MCP3425.lib Wed Oct 15 14:40:22 2014 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/yasuyuki/code/MCP3425/#b7bc51be525f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Oct 15 14:40:22 2014 +0000
@@ -0,0 +1,61 @@
+//**********************
+// A/D Converter
+// MCP3425 sample for mbed
+//
+// Voltage=(Vin+)-(Vin-)
+// Voltage Range:-2.048V to 2.048V
+// Resolution:2.048V/0x7FFF=62.5uV, 16bits
+// Sampling Per Second
+// 240 SPS, 12bits
+// 60 SPS, 14bits
+// 15 SPS, 16bits (default)
+//
+// (C)Copyright 2014 All rights reserved by Y.Onodera
+// http://einstlab.web.fc2.com
+//**********************
+#include "mbed.h"
+#include "AQM0802.h"
+#include "MCP3425.h"
+
+#if defined(TARGET_LPC1768)
+I2C i2c(p28,p27);
+#endif
+// for TG-LPC11U35-501
+#if defined(TARGET_LPC11U35_501)
+I2C i2c(P0_5,P0_4);
+#endif
+// for Nucleo
+#if defined(TARGET_NUCLEO_F401RE)
+I2C i2c(D14,D15);
+#endif
+
+AQM0802 lcd(i2c);
+MCP3425 mcp3425(i2c);
+
+
+int main() {
+
+ char msg[10];
+ short a;
+ float v;
+
+ sprintf(msg,"MCP3425");
+ lcd.locate(0,0);
+ lcd.print(msg);
+ wait(1);
+
+ while(1) {
+
+ a = mcp3425.get();
+ sprintf(msg,"dat=%X",(unsigned short)a);
+ lcd.locate(0,0);
+ lcd.print(msg);
+ v = (float)a*2.048/0x7FFF;
+ sprintf(msg,"%f",v);
+ lcd.locate(0,1);
+ lcd.print(msg);
+ wait(1); // Do not exceed 15SPS with 16bits
+ }
+
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Oct 15 14:40:22 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file