(edit sidebar)
Intro to Physical Computing Syllabus

Research & Learning

Other Class pages

Shop Admin

ITP Help Pages
Tom's pcomp site
DanO's pcomp site


Data Logger

uLog & OpenLog - Tutorials of DataLogger from Sparkfun

uLog
uLog
openLog
openLog


Overview

  • This tutorial is intended to provide information and comparison of uLog and openLog.
  • uLog is a tiny analog logging device from Sparkfun. The uLog have an onboard flash memory mated with a ATtiny24.

It don’t need a microcontroller, but can only take data on three analog in.

  • OpenLog is an open source data logger, available from SparkFun.

It takes serial data and write into a microSD card. It can be connected to a microcontroller, such as Arduino.

Features

 uLogopenLog
sizesmallsmall
analog inputs30
power supply3.3v3.3v to 12v
onboard switchyesno
onboard memoryflash ICmicroSD
memory size16MBup to 2GB(FAT16 ONLY)
sample rate50Hzviable
logging time2 hours logging spacedepends on battery
battery usage4mA per hour8ma idle | 18mA full speed(need power for another microcontroller)


Parts

For uLog you will need to have the following parts:

  • 3.3v USB to Serial Adapter(FTDI breakout/cable) or Arduino
  • uLog
  • wires
  • one photocell or other sensors

For openLog you will need to have the following parts:


HOW TO LOG DATA

uLog


Connect to your battery, you will see the red light flashes. Then connect your sensor to one of the three input pins, use your breadboard to help you wire it up. Turn on the on/off switch on the back to log the data. (''Remember, don’t wire any thing on the Tx/Rx when you log your data, any wire on them will cause the Logger into configuration mode''). The uLog only has 16MB space for data, it automatically append the new data into the ends and overrides the old one (from the beginning) if the memory full.

openLog
OpenLog can log data, but don’t have any analog inputs. It take whatever serial inputs and write it down into the mircoSD card. It defaults to 9600bps. So you need a microcontroller like arduino to read the sensor data and pass them to openLog using serial. In openLog, you can have more file controls on the SD card side, like log into different file…etc. I’ll take a photocell as an example:


You notice from the diagram above, you connect your Rx pin to Tx pin, Tx pin to Rx pin. To test it out, simply choose an example code from arduino: File->Exmaples->Analog->AnalogInSerial. Then openlog will log your data line by line into your microSD card. As long as you are sending out at 9600bps, openLog will log it.

HOW TO CONFIG THE OPENLOG

OpenLog conmes configured to receive at 9600bos by default, and will log new data to a file. However, if you need to change the configuration, use these instructions:

Wire your openLog with USBtoSerial Adapter or using Arduino. (Check the uLog section below for how to wire it using USBtoSerial adapter) If you use Arduino, connect your Rx pin on arduino to Rx pin on openLog, Tx to Tx. Here is the diagram how to wire it.(you need to upload a blank code or any code without serial communication).


you can use any serial program(such as Coolterm or Cornflake) to configure it. Here are the steps you take once you’ve got the serial port open:

  • type “Control + z to get into the configuration mode”
  • ….config it…. check the command set for more details
  • type “set”
  • type 1 to get into ‘LOG’ Mode.

NOTE: OpenLog requires a 2GB or smaller SD card, formatted as FAT16. On Windows, OSX Disk Utility only configures cards for FAT32, not FAT16. To configure your SD card for FAT16, follow these steps from the Adafruit forum:

To format the SD card, you will need the path to the SD card device and the SD card device number. 1. Insert the SD Card into a card reader. 2. Find the SD card's device number. If you don't know how to find the device number of the SD Card, here is one way to do it:

  • Open Disk Utility
  • Highlight the SD Card device (upper icon), not the SD Card volume (lower icon)
  • Click Erase at the top of the window
  • Select Volume Format: MS-DOS (FAT) Click Erase... > Click Erase
  • The SD Card Volume Name will change to the UNIX device number e.g. "disk5s1". Note this number as it will change by itself to "Untitled". It is now formatted in MS-DOS FAT 32. We need to reformat it in FAT 16.

Once you have the device number of the SD Card, you need the path to the SD card device.
3. For my Mac, the path to devices is "/dev". In a terminal window: type "cd /dev" and hit the "Return" key to go to the "dev" directory. Then type "ls" (with a lower case L) and "Return" key. You should see the SD Card device number listed.

Formatting the SD Card in FAT 16:
4. In Disk Utility, highlight the SD Card device and click Unmount at the top, not Eject. The desktop icon of the SD card will disappear.
5. Go to the Terminal window. Be careful to type the following command with the correct letter case and spacing. Again, make sure you type the correct device number and path as you can very easily erase your hard drive in UNIX. Type the command:

newfs_msdos -F 16 (path to SD Card device)/(SD Card device number)

e.g. newfs_msdos -F 16 /dev/disk5s1

and hit the "Return" key.

6. If you get just a new prompt (or a prompt with some warnings, e.g. below), the command executed successfully. You can remove the SD Card; it is now formatted in FAT 16. You can verify this in Disk Utility after mounting the SD Card. If you get some instructions on the newfs_msdos command with a new prompt, the command did not execute. Make sure you enter the command with the correct case and spacing. Hint: to re-enter a previous command you typed, hit the up arrow repeatedly. For more information, type: "man newfs_msdos". Scroll with arrow keys. Type "q" to quit and return to prompt.


To Read the Log Data out, simply use the microSD card reader to read the card.

HOW TO READ LOG DATA FROM ULOG

Use a USB to Serial adapter to wire your uLog. Need 3.3 voltage one, not 5 voltage.( If you don’t have one, you can use your arduino instead, need to upload a code without any serial communications, check the diagram in openLog section above for how to wire it up). Here is how your wire it using USB to Serial Adapter. Notice Rx to Tx, Tx to Rx.


Basically, if you send ‘r’ to your serial port, the uLog will send all the logged data, if you send ‘e’ to your serial port, the uLog will erase the memory. Based on Tom Igoe’s processing code, I filter the noise data and convert hex into integers. Run the sketch, type ‘r’ in the opened window to read the data, type ‘e’ to erase the data.


import processing.serial.*;

Serial myPort; // instance of the serial library String dataString = ""; // string of data for each set of readings String[] data = {""}; // array to save strings to a file boolean reading = false; // whether or not you're reading from the logger

String filename = "datalog.txt"; // string to save the file to int lineCount = 0; // count of the number of lines in the file

void setup() {

  // open the serial port:
  myPort = new Serial(this, Serial.list()[0], 38400);
  // flush the serial buffer:
  myPort.clear();

}

void draw() {

}

void serialEvent(Serial myPort) {

  // get a byte:
  int inByte = myPort.read();
  // do something different depending on what the byte is:
  switch(inByte) {
  case '?':          // response prompt
    // if you're already reading from the logger,
    //save the results to a file:
    if (reading) {
      saveStrings(filename, data);
      // you're done reading:
      reading = false;
      // print the linecount:
      print("lineCount: " + lineCount + "\0\r");
    }
    // print the prompt:
    println(char(inByte));
    break;
  case '\r':      // carriage return at the end of each line:
    // make sure you have at least four characters:
    if (dataString.length() > 4) {
      //filter the data and covert from hex to integer
      String[] t = splitTokens(dataString);
      String newData = ""; 
      try{
        for(int m = 0; m < t.length; m ++){
          if(t[m].length() == 4){
            int value = unhex(t[m]);
             newData = newData + ' ' + value;  
          }
        }
      }
      catch(Exception e){
        break;
      }      
      // add this string to the data array:
      data = append(data, newData);
      println(newData);
      // increment the line count:
      lineCount++;
    }
    // clear the string variable for the next string:
    dataString = "";
    break;
  case '\n':        // newline: get rid of them
    break;
  default:    // any other character:
    // add character to the string:
    dataString += char(inByte);
    break;
  }

}

void keyReleased() {

  if (key == 'r') {
    reading = true;
    println("Reading from logger...");
    // send keystroke to the logger
    myPort.write(key);
  }

  if (key == 'e') {
    println("erasing data from logger...");

    // you're erasing all the data on the logger
    // wait until the LEDS stop flashing before you disconnect it!
    // send keystroke to the logger
    myPort.write(key);
  }

}

  Edit | View | History | Print | Recent Changes | Search Page last modified on February 08, 2011, at 04:30 PM