Friday, June 22, 2012

Week 2 Day 5

Today is awesome. Yixin Gu is awesome. We now have a complete prototype that is fully functional. Here is some completely inaccurate code to express my feelings... (It's like a nerdy haiku.)



int Yixin = 1 gagillion;
int Zac = 3;
int YCode = 0;
int ZCode - 0;

Void Loop() {
ZacAttempt(Zac);

While (Yixin > Zac) {
   YCode ++;
   Yixin += Ycode;
   Serial.println("Yixin is responsible for fixing all the code.");
}

int ZacAttempt(Zac) {
   If (ZCode = true){
     Zac ++;
   }
}

There. Homage complete. The short version is that I hit a wall and my code was needlessly complex. Yixin was able to get something clean and quick out of the snarl and it works/looks great. "If I had more time I'd of made it shorter." definitely applies here. Here is the completed code for the three probes together.


#include <SoftwareSerial.h>                                                    //add the soft serial libray
#define rxpin 2                                                                //set the RX pin to pin 2
#define txpin 3                                                                //set the TX pin to pin 3

SoftwareSerial myserial(rxpin, txpin);                                         //enable the soft serial port
String inputstring = "";                                             //a string to hold incoming data from the PC
String sensorstring = "";                     //a string to hold the data from the Atlas Scientific product boolean input_stringcomplete = false;                      //have we received all the data from the PC boolean sensor_stringcomplete = false;       //have we received all the data from the Atlas 
                                                                  //Scientific product
  void setup(){                                                                //set up the hardware
     Serial.begin(38400);                            //set baud rate for the hardware serial port to 38400
     myserial.begin(38400);                           //set baud rate for software serial port to 38400
     inputstring.reserve(5);                          //set aside some bytes for receiving data from the PC
     sensorstring.reserve(30);   //set aside bytes for receiving data from Atlas Scientific product
     }      void serialEvent() {                                              //if the hardware serial port receives a char
               char inchar = (char)Serial.read();                               //get the char we just received
               inputstring += inchar;                                           //add it to the inputString
               if(inchar == '\r') {input_stringcomplete = true;}                //if the incoming character is                         
                                                                                         //a <CR>, set the flag
              }      void loop(){                                                                   //here we go....
       if (input_stringcomplete){                     //if a string from the PC has been recived in its entierty 
      myserial.print(inputstring);                           //send that string to the Atlas Scientific product
      inputstring = "";                                                        //clear the string:
      input_stringcomplete = false;                                            //reset the flage used to tell if we 
                                                                          //have recived a completed string from the PC
      } 
  while (myserial.available()) {                                   //while a char is holding in the serial buffer
         char inchar = (char)myserial.read();                                  //get the new char
         sensorstring += inchar;                                               //add it to the sensorString
         if (inchar == '\r') {sensor_stringcomplete = true;}                   //if the incoming character 
                                                                                                //is a <CR>, set the flag
         }

   if (sensor_stringcomplete){           //if a string from the Atlas Scientific product has been 
                                                      //received in its entirety
       Serial.print(sensorstring);             //use the hardware serial port to send that data to the PC
       sensorstring = "";                                                      //clear the string:
       sensor_stringcomplete = false;                                          //reset the flag used to tell if we 
                                                                                       //have received a completed string 
                                                                                       //from the Atlas Scientific product
      }}
Here is the user interface.

Code accomplished. That is not all, though. We also have a a working prototype of the probe cluster. Want to see? Of course you do.






Pretty impressive, right? Look at that soldering work. That's pretty intimidating. Here I am explaining what's going on with all this stuff.




After my spiel Dr. Fu came in and approved the sensor cluster and data sink assembly which means we are go for production. They are ordering all the parts to assemble five full sensor cluster nodes plus a data sink. I'm pretty excited about getting to roll this out so we can start collecting real data. Here is a picture of the meeting when Dr. Fu told every one we were doing a great job.


After the kudos we started talking about where we were headed and what our next steps are.



Now that we know our sensor network is functioning it is time to start collecting data. That will begin on Monday. We will begin collecting data under controlled conditions in the lab so we can compare the data our sensor suite gathers versus other commercially available solutions. Once we have a feel for how accurate it is under lab conditions we will move out to the field and cross our fingers. To test this sensor cluster in the lab we will eventually drop it into our table top model. Since that is not complete yet we need another option. That option is pretty simple... an aquarium. Joe and I cleaned one out and got it set to run so that we can drop in plants and minnows on Monday and start probing!




No comments:

Post a Comment