Wednesday, March 30, 2011

GPS Logger + uBlox5 GPS


My parts finally arrived. I ordered a GPS logger from Adafruit and a uBlox5 GPS from DIY drones. Ublox has a program uCenter used to configure the uBlox5 GPS. The uCenter user guide is here. The GPS comes with an adapter so that it is compatible with the EM-406 type cable. So it works with the data logger which was designed for the EM-406.

Tonight I soldered the components on the data logger board and fired it up with a FTDI cable. The uBlox5 ran at 9600bps. You can get it setup in several different ways from DIY drones and I chose standard NMEA, because the code from Adafruit parses NMEA sentences.

The Arduino serial monitor started spitting our NMEA without a hitch. I was kind of surprised that it just worked.

I chose the uBlox because its very highly regarded by the people over at diydrones and it has a refresh of 4hz, and resolution with WAAS of 2 meters.

Saturday, March 26, 2011

I2C sensors - Compass

I've already posted about the compass that I'll be using in the boat. But as with anything there is more to it that just the specific part. In fact we have several options when it comes to tilt compensation compasses.
  • LSM303, $30, I2C, no internal calculations, accuracy depends...
  • HMC6343, $150, I2C, tilt compensation calculated internally, accuracy of 2 degrees
  • OS5000-s, $260, RS232, tilt compensation calculated internally, accuracy of 0.5 degrees
As I said earlier I'll probably go with the HMC6343. So lets talk about I2C and the Arduino. Most of this information was taken from tronixstuff. Another great tutorial is at Robot Electronics.
  • I2C uses pins A4 for SDA (data) and A5 for SCL (clock)
  • I2C needs Arduino librarywire.h>
  • The default (factory) HMC6343 7-bit slave address is 0x32 for write operations, or 0x33 for read operations.
  • The compass requres pull-up resisters on SDA and SCL to 3.3v and supply voltage of 3.3v
  • The Arduino has built in pull-up resisters on A4, A5, but it is to 5v...
To get the correct logic and supply voltage to the HMC6343 it looks like you can use a logic level converter at least at $1.95 they don't cost much...

I initially thought that I could use 3 wires for each of my sensors and use servo connectors. Now I'm starting to realize that most of the sensors take more connections that that. I2C components require 4 wires.

More Resources on Arduino I2C and Level Shifting

Tuesday, March 22, 2011

Paddlewheel Speed Sensor + Wind Vane Question

Here is the paddlewheel. Its a vacuform plastic housing with an acylic paddlewheel. The rod is the same carbon fiber that I used for the anemometer. I already have all the sensors working with the arduino so now all I have to do is put the pieces together.

The question I've been wrestling with is: How do you average reading from the wind vane? Say you have 5 readings at varying degrees (from 0-360). For example; 10, 5, o, 355, 340. A simple average will be wrong because the readings wrap around a circle... Glen addressed this, but there are special cases that don't work in his solution. For instance when you have a reading like: 5,5,5,270,270.

Resources:

Sunday, March 20, 2011

Anemometer Nearly Done

This is the most high-tech pinwheel I've ever made. Sealed ball bearing (with flange), Aluminum tube, Carbon fiber rod, heat molded .02" plastic cups, and cast transparent (ortho) acrylic. The cups are probably a little small at about 1in diameter. I'd like the anemometer to be sensitive to 1 knot (or less if possible) because these little boats don't sail in heavy winds. But testing larger cups later would be very easy.

I finally got the photo reflective sensor working as well. It needed a 10k resistor. My problem was that I fried the first one. I guess I hooked something up wrong... Anyway at $2 each, not a biggie. But I only ordered 3 from china, so I don't want to have to wait 3 weeks for shipping again.

All my sensors have been tested WORKING! with the Arduino. Now its assembly time. Then calibration... Then putting the code for each sensor into one sketch with attachinterrupt() for the photo interrupters and damping for the wind vane.

Saturday, March 19, 2011

Finally got the photo interrupter working!

A photo of my working photo interrupter. Here is the trick to getting a new photo interrupter working (tipped off by this thread). There are 2 sides to the gate; the transistor and the emitter.

Phototransistor:
  • look at the datasheet and see which side is the emitter and which is the collector.
  • start by setting up the phototransistor as an analog input analogread() will output values from 0-1023
IR emitter:
  • look at the datasheet to see how much voltage and current the LED can handle. Mine was 50mA
  • Hook up the LED to that output. In my case digital I/O gives 5V and 40mA.
Test:
  • watch the serial monitor I started off getting values that ranged from 0 to 3, then after fiddling with resistors (taking away the resistor to the emitter and adding a 10K to the transistor).
  • Got to the point where I read 10-20 when the gate was blocked and 1010-1020 when the gate is open. (my Photo interrupter took a 10K resistor, my Photo Reflective Sensor will take a 100k or 1m resistor all I have is 10K resistors and 5 of them in series brought the reading up to 400)
  • Now change the code from analogRead() to digitalRead() (and switch the input wire) see if you get 111100001110001111 when you move something between the gate.
Resources:
Here is the test code that I used:

int val;

void setup()

{

pinMode(13, OUTPUT);
pinMode(2, INPUT);

Serial.begin(9600); // sets the serial port to 9600

digitalWrite(13, HIGH);
}

void loop()

{

val = digitalRead(2); // read digital input pin 2
//val = analogRead(0); // read analog input pin 0

Serial.print(val); // prints the value read
Serial.print(" "); // prints a space between the numbers

delay(100); // wait 10ms for next reading

}

Friday, March 18, 2011

SiRFIII GPS Logger Shield


The output from the EM-406a is in NMEA sentences. Each sentence starts with a '$'. There are a bunch of sentences that it can spit out, but only a few that we are interested in. For example sentences look at the EM-406a Manual.

Interesting sentences:
  • RMC-Recommended Minimum Specific GNSS Data, message 103,04
  • - this has all the basic data that you'd want for a boat; lat, long, speed (in knots)
  • VTG-Course Over Ground and Ground Speed, message 103,05
  • - this will give us the heading relative to magnetic north. That way we can directly compare the reading from the compass
Adalady has written code to test the GPS Sheild. There is also code for recording the GPS data and up to 3 analog inputs.

Telemetry Using Xbee Modules

For telemetry the Xbee appears to be the option. Adalady has a great tutorial on wiring up the arduino with an XBee for point-to-point communication using a $10 board available from Adafruit.com

DIYdrones.com also has board for connecting the XBee and some documentation. However, for a newbee like me it was a little sparse.

On the computer side of things all you appear to need is an FTDI cable (for either system).

Wiring the XBee to the arduino AND being able to reset the arduino remotely can be found here.

For communication over XBee the Arduino appears to need the NewSoftSerial library.