Difference between revisions of "Galileo"

From Earlham CS Department
Jump to navigation Jump to search
(Code)
(Code)
Line 100: Line 100:
  
 
=Code=
 
=Code=
 +
==XYZ + tilt using arrays, v0.24==
 
<code>
 
<code>
 +
// having trouble using an array of char arrays
 +
 
// include directives
 
// include directives
 +
// #include <string>
 +
//#include <Ethernet.h>
 +
//#include <IoTkit.h>
 +
#include <sstream>
 
#include <string>
 
#include <string>
 
using namespace std;
 
using namespace std;
  
 
// pin declarations
 
// pin declarations
const int pin_horizontalY = 5;
 
const int pin_vertical = 6;
 
const int pin_horizontalX = 7;
 
 
const int pin_temp = A0;
 
const int pin_temp = A0;
const int pin_flame = A0;
 
 
const int pin_magnet = 4;
 
const int pin_magnet = 4;
const int pin_magnet_digital = 0;
 
  
 
// delay on loop
 
// delay on loop
 
const int delay_time = 100;
 
const int delay_time = 100;
 +
 +
// output separators
 +
char csv[] = ", ";
 +
char columns[] = " | ";
  
 
// sensors
 
// sensors
Line 123: Line 129:
 
int flame;
 
int flame;
  
// tilt sensors
+
// xyz sensors
int vertical;
+
const int size = 3;
int v_last;
+
int pin[] = {0, 1, 2};
int horizontalX;
+
boolean val[size];
int hX_last;
+
boolean last[size];
int horizontalY;
+
boolean change[size];
int hY_last;
 
  
int c = 0; // count of occurred changes
+
//IoTkit iotkit;
  
 
// intializing pin modes
 
// intializing pin modes
// currently ignored for whatever reason
 
 
void setup() {
 
void setup() {
   Serial.begin(9600);
+
   Serial.begin(115200);
 +
 
 +
  //iotkit.begin();
 +
  //iotkit.registerMetric("x", "string", "X Change");
 +
 
 
   pinMode(pin_temp, INPUT);
 
   pinMode(pin_temp, INPUT);
 
   //pinMode(pin_magnet, INPUT);
 
   //pinMode(pin_magnet, INPUT);
   pinMode(pin_vertical, INPUT);
+
    
  pinMode(pin_horizontalX, INPUT);
+
  for(int i = 0; i < size; i++) {
   pinMode(pin_horizontalY, INPUT);
+
    pinMode(pin[i], INPUT);
 +
   }
 
}
 
}
  
 
void loop() {
 
void loop() {
 +
  setArray(change, size, false);
 +
 
 
   readTemp();
 
   readTemp();
   readVertical();
+
   readAxes();
  readHorizontalX();
 
  readHorizontalY();
 
 
   //readMagnet();
 
   //readMagnet();
   output();
+
   output(change, size, csv);
 
    
 
    
 
   delay(delay_time);
 
   delay(delay_time);
Line 156: Line 165:
  
 
void readFlame() {
 
void readFlame() {
   flame = analogRead(pin_flame);
+
   //flame = analogRead(pin_flame);
   float f = flame * (5.0 / 1023.0);
+
   //float f = flame * (5.0 / 1023.0);
   Serial.print("flame ");
+
   //output("F ", f);
  Serial.print(flame);
 
 
}
 
}
  
Line 167: Line 175:
 
   temp = ((temp*9)/5) + 32;
 
   temp = ((temp*9)/5) + 32;
 
   temp = temp / 10.0;
 
   temp = temp / 10.0;
   Serial.print(" temp ");
+
   //output("T ", temp);
  Serial.print(temp);
 
 
}
 
}
  
Line 174: Line 181:
 
   magnet = analogRead(pin_magnet);
 
   magnet = analogRead(pin_magnet);
 
   //magnet -= 460;
 
   //magnet -= 460;
   Serial.print("magnet ");
+
   //output("M ", magnet);
  Serial.print(magnet);
 
 
}
 
}
  
void readVertical() {
+
void readAxes() {
   vertical = digitalRead(pin_vertical);
+
   for(int i = 0; i < size; i++) {
  //Serial.println(vertical);
+
     val[i] = digitalRead(pin[i]);
 
 
  if(vertical != v_last) {
 
     v_last = vertical;
 
    c++;
 
 
      
 
      
     Serial.print(" Z ");
+
     //change[i] = val[i];
     Serial.print(c);
+
     if(val[i] != last[i]) {
 +
      change[i] = true;
 +
      last[i] = val[i];
 +
    }
 
   }
 
   }
 
}
 
}
  
void readHorizontalX() {
+
void setArray(boolean arr[], int size, boolean val) {
   horizontalX = digitalRead(pin_horizontalX);
+
   for(int i = 0; i < size; i++) {
  //Serial.println(horizontalX);
+
     arr[i] = val;
 
 
  if(horizontalX != hX_last) {//(horizontalX != hX_last) {
 
     Serial.print(" X ");
 
    hX_last = horizontalX;
 
 
 
    c++;
 
    Serial.print(c);
 
 
   }
 
   }
 
}
 
}
  
void readHorizontalY() {
+
string blank = "      ";
   horizontalY = digitalRead(pin_horizontalY);
+
void output(boolean arr[], int size, char sep[]) {
  //Serial.println(horizontalY);
+
   stringstream os; // output stream;
 
    
 
    
   if(horizontalY != hY_last) {
+
   for(int i = 0; i < size; i++) {
     Serial.print(" Y ");
+
     if(arr[i])
     hY_last = horizontalY;
+
      os << "change";
 +
    else
 +
      os << "     ";
 +
      
 +
    //if(i != size - 1)
 +
      os << sep;
 +
  }
 
    
 
    
    c++;
+
  os << temp;
    Serial.print(c);
+
 
   }
+
  Serial.println(os.str().c_str());
 +
 
 +
  stringstream oc; // output command
 +
  oc << "printf \"" << os.str().c_str() << "\\n\" >> output.dat";
 +
   //oc << "printf " << os.str().c_str() << " >> output.dat \n";
 +
  system(oc.str().c_str());
 +
 
 +
  //Serial.println(oc.str().c_str());
 
}
 
}
  
// trying to automate logging
+
void outputIOTkit() {
// want to set it as a global flag
+
  //iotkit.send("x", change[0]);
// string isn't working currently
 
void print() {//string id) {
 
    c++;
 
    Serial.print(c);
 
    Serial.print(" ");
 
    //Serial.print(id);
 
    Serial.println();
 
 
}
 
}
 +
</code>
  
void output() {
+
==Accelerometer, v0.1==
  //Serial.print("X: " + horizontalX);
+
Available in the google drive.
  Serial.println();
 
}
 
</code>
 
  
 
=Specs=
 
=Specs=

Revision as of 16:36, 22 March 2014

The Galileo is a fusion of a Linux PC running Intel's architecture and an Arduino. The purpose is to provide the benefits of a pc (connectivity, power, storage, ports) with the benefits of an Arduino (an open-platform hardware interface.)

This page specifically discusses the Galileo. Anything Arduino-specific should get relegated to here.

Notes

NOTES!

Photos

This is a photo.
This is a description.
This is a photo.
This is a description.
This is a photo.
This is a description.
This is a photo.
This is a description.
This is a photo.
This is a description.

Design Philosophy

  • Change one thing at a time.
  • Check if it works after every change.
  • When success has been reached, repeat it: do it again.
  • When success has been repeated, replicate it: have others do it.

Failure List

Having problems?

  1. Are you using Galileo's arduino ide?
  2. Are you using the right pin number? Is it analog or digital?
  3. Is your pin mode set correctly?
  4. Is the ground and power connected correctly?
    • order is power, ground, and then input/output
  5. Do you have pin terminators on all power columns?
  6. If too many sensors are connected, you might run out of power. Try reducing the number of sensors.
  7. Talk to scientists.
  8. Research if your sensor needs a resistor. (330m or 10k)
  9. If nothing else works, try a different breadboard or a different arduino or replacement sensors.
  10. If still having trouble, ask Ben.

Info Dump

IoTkit handles ethernet transactions. It connects to a host and sends a packet with [string, val] where val is the value you wish to send. You can save information locally and push it to a server later. A watch battery can be used to preserve machine state between power-on's. [validate]

There are no packages installed on Intel's Linux distro.

There's an interface for C++ that lets you access the Arduino.

Always connect the power first.

When flashing the firmware, YOU MUST HAVE THE POWER CONNECTED. Otherwise you risk bricking the board.

There are example sketches for every sensor included in Intel's sensor kit. Where? Good question.

Costs $60+ as of 2/5/14. Purchase is currently cheapest at [Micro Center] and [Amazon].

Resources

[Getting Started]

[Comprehensive Overview]

[BSP Build Guide]

[FAQ] (useful)

[Release Notes] (supported software/hardware and bugs)

[Intel Maker forums]

Downloads

[Software Packages]

[Drivers]

Installation

You're impossible to please. Read the documentation from [Intel] or [Sparkfun] instead.

Disasters

These are notes and observations after research.

Earthquake

  • occur due to movement in tectonic plates
  • only seconds of notice, 5-10 seconds
  • [p waves] are much faster than [s waves] and the actual waves that cause the earthquake.
    • earthquakes travel at about the same speed as data networks
  • can be measured by motion (on surface or underground) and pressure (underground)
    • downside of underground monitoring is 1) power and 2) transmission
      • can use repeaters or solar power to solve these issues
    • advantage of being underground is distance from noise (such as animals and humans) and being closer to the source of the earthquake
    • being attached to or submersed in denser materials is good (?)

Resources

[introduction]

[wave types]

Tsunami

  • in the deep sea pressure sensors are used to measure the relatively small sea-level change (in centimeters)
  • nearer to shore, where waves start to form, altitude could be measured by buoy
  • travel at hundreds of miles per hour
  • tsunami headquarters in Hawaii
  • notification could be minutes to hours in advance depending on distance from source of tsunami
  • height/speed of wave reduces with distance

Code

XYZ + tilt using arrays, v0.24

// having trouble using an array of char arrays

// include directives // #include <string> //#include <Ethernet.h> //#include <IoTkit.h>

  1. include <sstream>
  2. include <string>

using namespace std;

// pin declarations const int pin_temp = A0; const int pin_magnet = 4;

// delay on loop const int delay_time = 100;

// output separators char csv[] = ", "; char columns[] = " | ";

// sensors float temp; int magnet; int magnet_digital; int flame;

// xyz sensors const int size = 3; int pin[] = {0, 1, 2}; boolean val[size]; boolean last[size]; boolean change[size];

//IoTkit iotkit;

// intializing pin modes void setup() {

 Serial.begin(115200);
 
 //iotkit.begin();
 //iotkit.registerMetric("x", "string", "X Change");
 
 pinMode(pin_temp, INPUT);
 //pinMode(pin_magnet, INPUT);
 
 for(int i = 0; i < size; i++) {
   pinMode(pin[i], INPUT);
 }

}

void loop() {

 setArray(change, size, false);
 
 readTemp();
 readAxes();
 //readMagnet();
 output(change, size, csv);
 
 delay(delay_time);

}

void readFlame() {

 //flame = analogRead(pin_flame);
 //float f = flame * (5.0 / 1023.0);
 //output("F ", f);

}

void readTemp() {

 temp = analogRead(pin_temp);
 temp = (temp * 500) / 1024.0;
 temp = ((temp*9)/5) + 32;
 temp = temp / 10.0;
 //output("T ", temp);

}

void readMagnet() {

 magnet = analogRead(pin_magnet);
 //magnet -= 460;
 //output("M ", magnet);

}

void readAxes() {

 for(int i = 0; i < size; i++) {
   val[i] = digitalRead(pin[i]);
   
   //change[i] = val[i];
   if(val[i] != last[i]) {
     change[i] = true;
     last[i] = val[i];
   }
 }

}

void setArray(boolean arr[], int size, boolean val) {

 for(int i = 0; i < size; i++) {
   arr[i] = val;
 }

}

string blank = " "; void output(boolean arr[], int size, char sep[]) {

 stringstream os; // output stream;
 
 for(int i = 0; i < size; i++) {
   if(arr[i])
     os << "change";
   else
     os << "      ";
   
   //if(i != size - 1)
     os << sep;
 }
 
 os << temp;
 
 Serial.println(os.str().c_str());
 
 stringstream oc; // output command
 oc << "printf \"" << os.str().c_str() << "\\n\" >> output.dat";
 //oc << "printf " << os.str().c_str() << " >> output.dat \n";
 system(oc.str().c_str());
 
 //Serial.println(oc.str().c_str());

}

void outputIOTkit() {

 //iotkit.send("x", change[0]);

}

Accelerometer, v0.1

Available in the google drive.

Specs

  • 400mhz cpu
  • 256mb ram
  • 32gb micro sd
  • 10/100 ethernet
  • PCI Express mini-card with PCIe 2.0
  • USB host and device
  • 5v/3.3v power
  • same Arduino pin layout