Josh Goldberg / Mbed 2 deprecated count_pills

Dependencies:   Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
jgoldberg
Date:
Fri Dec 12 01:18:01 2014 +0000
Parent:
0:15d3cdafd311
Commit message:
Updated calibration values for small breadboard

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
util.cpp Show annotated file Show diff for this revision Revisions of this file
weight.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Dec 11 21:54:03 2014 +0000
+++ b/main.cpp	Fri Dec 12 01:18:01 2014 +0000
@@ -16,8 +16,12 @@
     myled1 = 1; //red off
     myled2 = 1; //green off
     myled3 = 1; //blue off
-    
+    //uint16_t val;
+    //uint16_t val_avg;
     while(1) {
+        //val = myADC.read_u16();
+        //val_avg = mvgAvg(val, 0);
+        //pc.printf("raw: %d  avg: %d\n\r", val, val_avg);
         number_pills = measure_pills();
         //pc.printf("Number of pills: %d\n\r", number_pills);
         wait(0.05);
--- a/util.cpp	Thu Dec 11 21:54:03 2014 +0000
+++ b/util.cpp	Fri Dec 12 01:18:01 2014 +0000
@@ -2,7 +2,7 @@
 #include "util.h"
 
 uint16_t mvgAvg(uint16_t val, int reset) {
-    const uint32_t len = 25;
+    const uint32_t len = 50;
     static uint16_t vals[len] = {0};
     static uint32_t ind = 0;
     static uint32_t full = 0;
--- a/weight.cpp	Thu Dec 11 21:54:03 2014 +0000
+++ b/weight.cpp	Fri Dec 12 01:18:01 2014 +0000
@@ -3,7 +3,7 @@
 
 static const int batches = 5; // number of times you will add batch_size number of pills for calibration
 static const int batch_size = 10; // number of pills added per batch for calibration
-static uint16_t cal_vals[batches + 1] = {23758, 24221, 24672, 25124, 25588, 26034}; // = {0}; // initialize to zero if re-calibrating
+static uint16_t cal_vals[batches + 1] = {23102, 23547, 23993, 24494, 24960, 25390}; // = {0}; // initialize to zero if re-calibrating
 // calibration for 4,5  {23748, 23986, 24216, 24460, 24674};
 // calibration for 5,10 {23758, 24221, 24672, 25124, 25588, 26034};
 static int calibrated = 1; // change to 0 to re-calibrate
@@ -25,7 +25,7 @@
         myled2 = 0;
         pc.printf("Measuring...\n\r");
         mvgAvg(0,1);
-        for (int i = 0; i < 60; i++) { //will measure for ~3 seconds
+        for (int i = 0; i < 100; i++) { //will measure for ~5 seconds
             val = myADC.read_u16();
             val_avg = mvgAvg(val, 0);
             pc.printf("%d\n\r", val_avg);