Arduino-Powered GPS Speedometer

You can easily interface a GPS chip like this one with an an Arduino micro-controller and make some pretty cool projects. I decided to make a simple speedometer/odometer for my bike. For this to work, we need to retrieve the relevant data from the GPS module, then process it using the Arduino before outputting it to the LCD screen. The device will also need to be powered by a battery so we can carry it around freely. 

The receiver has two serial pins which send and receive data, both of which are connected to ports on the Arduino that have been programmed to send(TX) and receive(RX) serial data. 

We can send commands to the receiver using the Arduino's TX pin to set things like the GPS update rate and so on. For example, the following line sets the update rate to 5 hertz:

#define PMTK_SET_NMEA_UPDATE_5HZ  "$PMTK220,200*2C" 

Now, the module reads out strings of data in NMEA sentences five times a second to the Arduino that look like this:

$GPRMC,092751.000,A,5321.6802,N,00630.3371,W,0.06,31.66,280511,,,A*45

Each value separated by a comma represents, in order, 
      1   092751     Time Stamp
      2   A          validity - A-ok, V-invalid
      3   5321.6802  current Latitude
      4   N          North/South
      5   00630.3371 current Longitude
      6   W          East/West
      7   0.06       Speed in knots
      8   31.66      True course
      9   280511     Date Stamp
      10  A*45       checksum

You can do a lot of things with this data, but we'll just be using the speed.
It is easy enough to parse through the string with our code to pick out the data we want.
Here is a simple function that isolates the different data by using the commas as separators.

void dataParse(int section) {    
  char nextChar;
  int commas = 0;
  resetReturn();
  for (int x = 0; x <= dataStr.length(); x++) {
    nextChar = dataStr.charAt(x);
    if (nextChar == ',') {
     commas++;
     continue;
    }
    if (commas == section) {
  returnStr.concat(nextChar);
    }
    else if (commas > section) {
 break;
    }
  }  
}
Since we want the speed for the odometer, we will parse for the data after the 7th comma.The full code can be found here. To make things easy, we'll hook up the Arduino to an LCD screen via Serial LCD. With Serial LCD, the Arduino can drive an LCD screen with only a single serial wire. With the LCD connected, we're set.

Now all that's needed is the power, which you can do pretty easily by hooking it all up to a
9V battery.

Light Bulb Spectroscopy

In college I had the opportunity to play around with the spectrometer after I had finished my work in the lab. We had used it earlier in the year to observe the Hydrogen-Deuterium isotope shift and the emission spectra of some different gases, but some of us wondered what would happen if we used it to measure the emissions of a simple light bulb.

So one day I brought in two small incandescent bulbs from Radio Shack, one rated at 1.5 volts and another at 12 volts, powered them up, and began to measure the spectra.

12v Lamp                                           1.5v Lamp


Measuring the emissions of light bulbs


The spectrometer measures the intensity of each wavelength by turning incident photons into current. The more intense the light, the more current. This current was then converted into a voltage which was measured with a voltmeter, thus the intensity is scaled in volts. I set the spectrometer to sweep through the wavelengths slowly, so I could get a high resolution curve. Eventually, I got the spectra for the two lamps:


9V lamp spectrum
1.5V lamp spectrum

I was surprised by the data. Assuming the bulbs had tungsten filaments, it seemed logical that the spectra would resemble a black body spectrum. Seeing that the light bulbs emissions peaked somewhere in the orange-yellow area (~620 nm), I estimated that the bulb's filament was reaching a temperature of about 4800 K. Considering that tungsten melts at 3600 K, this couldn't be correct. Also, incandescent light bulbs are supposed to peak in the IR region...that's why they get so hot! I plotted the theoretical spectrum of black body at that temperature using Planck's law so that I could have something to compare my spectra to:

Emissions of a perfect black body at 3600 K


Overall the observed spectra differ substantially from the theory. Comparing the spectra of the lamps to the black body spectrum indicates that something is either absorbing or reflecting a substantial amount of light in the 350-580 nm range (violet, blue and green emissions); the bulbs are dominantly red-yellow. In addition, the bulbs peak at a very low frequency compared to the black body spectrum.

Considering that tungsten is to good approximation a black body radiator and is often used to calibrate spectrometers, I can only assume that the differences between the expected and observed results lie in the spectral sensitivity of the spectrometer's detector, or the source is not a tungsten filament.

Measuring the Absorption of Colored Dyes
The colored slide is placed in
front of the spectrometer

I also brought in some food coloring to try to observe some absorption. I placed a glass slide filled with a small amount of dye in between the light source (I used the 1.5V light bulb) and the spectrometer slit. I recorded the spectra for a both red and green dyes and compared them to the original spectrum of the 1.5V lamp.


Blue: Original (No Slide)
Red: Red Slide
Green: Green Slide
Subtracting the new measurements from the original, I came up with the absorption spectra for each of the two dyes.

Red slide absorption spectrum
Green slide absorption spectrum
The red dye seemed to be more effective at blocking a wide range of non-red light, whereas the green dye block wavelengths specifically in the 600-650nm range. Despite the odd spectra of the lamps, the absorption spectra produced predictable results.

Conclusions


Since both of the bulbs I used produced the same unusual spectrum, I was sure the bulbs weren't defective. I did some research online to try to explain the shape of my spectra in the first part of the lab. Most of the spectra I found for light bulbs looked like black body curves, like the theory predicts. I did manage to find one website which had a spectrum similar to mine. The bulbs were designed for small hobbyist electronics projects, so it is possible that they weren't typical incandescent bulbs.

On the positive side, the absorption part of the experiment was successful, even if the results were a little noisy. 

FM Transmitter


I found a schematic for a short range (~100 ft) FM radio transmitter a few weeks ago and thought I'd give it a try. Building the circuit is relatively simple and can be built for around $10-15. 

Here is the schematic with all of the components you'll need labelled, with some details below:


C1 and L1 are chosen according to the desired carrier frequency (see below)
For the transistors I used three 2N3904's, although any three NPN transistor should work.
For the antenna, I just used a long wire. 
The microphone is an electret microphone. I believe they sell these at RadioShack.
All the other components are straightforward. 

Setup

By the looks of it, the circuit works in four stages:

STAGE 1: Getting the audio signal

First, the audio signal to be transmitted needs to be converted to an electrical signal. This is accomplished easily by putting 9V across the electret microphone and resistor in series. The output of this voltage divider is a conversion of our air pressure amplitude wave (sound wave) to voltage amplitude wave, which is what we want.

Sound fluctuations are converted into voltage fluctuations.


 More information about how the electret mic can be found here.

STAGE 2: Preamp 

The signal is AC coupled by sending the output of stage 1 through the 22nF capacitor and then is sent through what I think is a common-emitter amplifier which just amplifies the signal. 


STAGE 3: FM Modulation

The next step is to modulate the amplified signal, because the signal we have at this point is too low of frequency to be useful to radio. We need to encode the information of our low frequency signal into a higher frequency signal called a carrier frequency using procedure known as modulation. In radio this is done either with frequency modulation (FM) or amplitude modulation (AM), but this circuit will use frequency modulation. This video does a great job of explaining the basic concepts of FM and AM modulation. 

The circuit formed by L1 and C1 in parallel is a tank circuit which creates our carrier frequency. In the schematic, I left these values unspecified because the choice of the carrier is up to you. The circuit resonates at a frequency of 

From Wikipedia
So if you used L1 = 30nH and C1 = 82pF your carrier frequency would be about 100Mhz. If you wanted, you could also replace C1 with a variable capacitor, so you could vary the carrier frequency on the spot. I would be careful into deviating too far from the above values, even if the C to L ratio is right the frequency you want. My thought is that if C is too big(or small) then the modulation may be affected by the relative ratio of C1 to the .2nF capacitor below it, as discussed below.


Red box: Creates carrier frequency
Green box: Modulates the carrier frequency

The carrier, generated by the tank circuit  is then modulated by the capacitor connected between the transistor's collector and emitter. By the looks of it, the modulation is caused by the competing impedences of the transistor and the capacitor in parallel.

As the input increases, more current is allowed to flow through the transistor, which shunts the .2nF capacitor, effectively reducing the total capacitance seen by L1 in the tank circuit, causing the carrier frequency to increase slightly (check the equation above). If the input is low, not much current flows through the transistor, so the .2nF adds to the capacitance of the LC circuit thus lowering the frequency of the carrier. This is frequency modulation in action.

STAGE 4: Outputting the modulated signal

After the information from the microphone has been encoded into our carrier signal, all that is left to do is to output the signal to an antenna. In between the modulator and the antenna is (what I'm told) a buffer that shields the L/C tank from disturbance from the antenna.


Assembling

As mentioned above, building this transmitter is very simple. I managed to fit the entire thing on a small prototype board. The design I was following used a 33pF capacitor for C1 and a coiled wire with 4 turns for L1 (just take a wire and coil it around a screwdriver four times). This produced a carrier of 90.7 MHz.

Note: the inductance of the coil is dependent on the geometry of the coil, so you can change the inductance (and consequently the carrier frequency) by bending the coil a bit. If you choose to coil the inductor up yourself, make sure the coil is protected if you want a stable carrier.      

    
Coil used for L1.
Completed circuit mounted on a breadboard.
Using my car's radio, I was able to measure a maximum output range of about 100 feet. Be careful. The FCC limits unlicensed broadcasting to 200 feet in the US according to this page. Too much more power and you risk fines.

Implications


Overall the sound quality was decent, though not as clear as the commercial stations. The range was a little underwhelming but I think it could be extended using a longer antenna (I used a 5 inch long wire). On the other hand, not much more range is needed unless you want to break the law.

One cool thing about the prototype board is that it has an adhesive on the back. Assuming you have a place to strap on the 9V battery, you could stick this anywhere.