Editing BioBoard/Documentation/Optical loss

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 90: Line 90:
After assembling the probe, you'll need to wire it up to some kind of microcontroller; we've used an Arduino clone called [http://www.ladyada.net/make/boarduino/ BoArduino], and will use that as example, but you can use any type you like. Start out by connecting the 5V and GND pins on the Arduino to the power (+ / red) and ground (- / blue / black) strips on the breadboard. Then wire the LED to 5V and GND across a 150Ω resistor. Now connect the collector lead on the phototransistor to 5V, and the emitter lead to an empty strip on the breadboard, then wire that strip to the A1 pin on the Arduino with a connector, and to ground with a 100Ω resistor. If you've built the bonus version, you'll also need to wire your BubbleShaker to 5V and GND. Then you're ready to hook the Arduino board up to your computer, program it and start recording.
After assembling the probe, you'll need to wire it up to some kind of microcontroller; we've used an Arduino clone called [http://www.ladyada.net/make/boarduino/ BoArduino], and will use that as example, but you can use any type you like. Start out by connecting the 5V and GND pins on the Arduino to the power (+ / red) and ground (- / blue / black) strips on the breadboard. Then wire the LED to 5V and GND across a 150Ω resistor. Now connect the collector lead on the phototransistor to 5V, and the emitter lead to an empty strip on the breadboard, then wire that strip to the A1 pin on the Arduino with a connector, and to ground with a 100Ω resistor. If you've built the bonus version, you'll also need to wire your BubbleShaker to 5V and GND. Then you're ready to hook the Arduino board up to your computer, program it and start recording.


In order to program the the BoArduino, you have to download and install the [http://arduino.cc/en/Main/Software Arduino software] first. Once this is done, you're ready to connect your board - in some cases, this requires a special cable, so make sure you've got the right one! Now open this [https://github.com/BioBridge/BioBoardArduinoCode/blob/master/NIR_sensor_demo.pde Arduino sketch] and hit upload. Open the serial monitor to see the print-out of the data being transmitted from the probe, which ought to look more or less like this: @NIR:0:0.99$.
In order to program the the BoArduino, you have to download and install the [http://arduino.cc/en/Main/Software Arduino software] first. Once this is done, you're ready to connect your board - in some cases, this requires a special cable, so make sure you've got the right one! Now open the Arduino program, copy the code in the box below into the blank sketch, and hit upload. Open the serial monitor to see the print-out of the data being transmitted from the probe, which ought to look more or less like this: @NIR:0:0.99$.
 
//
// This Arduino sketch reads our custom NIR absorption sensor.
//
// This code is part of the BioBridge Project.
//
//
//  author: rolf van widenfelt (c) 2011
//
// revision history:
//
//  apr 25, 2011 - rolf
//    identify this probe.  (needed for BioBoard protocol)
//
//  apr 17, 2011 - rolf
//    created.
//    ADC code seems to work.. still need to connect actual sensor and document connections!
//
//
// code modification:
//  you will need to set some calibration points... (FILL THIS IN!!)
//
// description:
//  this sketch will periodically output a short string that contains the NIR transmittance
//  along with some other fields that indicate which probe (0) is being read.
//  the string should look like this for a transmittance of 99% :
//
//    @NIR:0:0.99$
//
//  this is output periodically.  (in this case, every 5 sec)
//
//  In the case of an error, an "E" message is output instead of the temperature, like this:
//
//    @TC:0:EBADVALUE$
//
//  note that these data packets are output to the serial console window at 19200 baud.
//  also, when the sketch first starts, it identifies the software and version, like this:
//
//    @ID:BIOBOARD:TESTBATCH1:1.1$
//
//  that's it!
//
static const char ProjectName[] = "TESTBATCH1";
const int analogNIRPin = A0;  // analog input pin that the NIR phototransistor circuit is connected to
// CALIBRATION SETTINGS
#define IMAX 4.9    /* max phototransistor current with IR LED on (no obstructions, just 1inch air) */
#define IMIN 0.02    /* dark current (NOTUSED) */
#define VMAX 5.0    /* arduino voltage = 5.0v */
#define ADCMAX 1023    /* highest ADC value */
#define IMAXI (ADCMAX*IMAX/VMAX)  /* highest ADC value we expect from our sensor */
#define IMAXI_INV (1.0/(ADCMAX*IMAX/VMAX))  /* inverse (this avoids a divide during runtime) */
void setup(void)
{
  // start serial port
  //Serial.begin(9600);
  Serial.begin(19200);
  Serial.print("\n\r@ID:BIOBOARD:");
  Serial.print(ProjectName);
  Serial.print(":0.1$\n\r");
  // configure ADC to use external 5v reference (default)
  analogReference(DEFAULT);
  // just in case, throw away 1st ADC read
  (void) analogRead(analogNIRPin);
  // identify this probe
  Serial.print("@PR:NIR:0$\n\r");
}
void printNIR()
{
  int sensor = analogRead(analogNIRPin);
  float sample = IMAXI_INV * sensor;
  if (sensor > IMAXI + 10) {
    Serial.print("EBADVALUE");    // oops, value is clearly wrong, so output an "E" message.
  } else {
    Serial.print(sample);
  }
  // XXX debug - we output raw ADC value as well
  Serial.print(":");
  Serial.print(sensor);
}
void loop(void)
{
  delay(2500);
 
  Serial.print("@NIR:0:");
  printNIR();
  Serial.print("$\n\r");
}


=Calibrating=
=Calibrating=


Please note that all contributions to Noisebridge are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Noisebridge:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)