26
Jun

Welcome To My Arduino Blog


If you don't know what Arduino is, start here: Arduino site

Google it and you'll find a plethora of information and project sites. It's quite a remarkable little piece of "open hardware" electronic awesomeness that inspires unrelentingly. If you're a hack like me you won't be disappointed. Powerful for its size and cost, and extemely easy to learn and use.

Please register using the Log In link in the upper right corner. Feel free to leave comments by clicking on the post title.

My projects...

First up: Scooterputer


Scooterputer is a trademark of Schulz Design


free b2evolution skin
26
Jun

Scooterputer

Scooterputer Image


I spend a fair amount of time zipping around town on my scooter, and thought it would be cool to add a voltage monitor to warn when the battery might need recharging. Waiting until the electric starter no longer works is somehow lacking. So after an evening with an Arduino Duemilanove, I had a simple programmable voltage divider with 3 LEDs indicating battery low, good, and charging. Done.

That's when I saw Liquidware's very cool TouchShield Slide OLED display with touch screen. It was telling me it wanted to be on my scooter. It's a bit overkill for just battery status, so I added temperature and time/date readouts. I went to Sparkfun.com and found a DS18B20 temperature sensor and a DS1307 RTC chip. Perfect. Oh wait, what's this...an accelerometer? Sweet! Hey, a GPS chip...

So a few weeks later, here's what my battery voltage indicator is looking like:

Scooterputer Display


You can see in the first photo that the TouchShield display is separated from the Duemilanove / Cell Module / Sensor shields. These are installed "under the hood" of my scooter and provide power and signals to the display module via a standard 8-wire ethernet cable. This keeps the sensors (accelerometer, GPS, cell module, etc.) with the scooter making it functional even without the removable external display, as we'll see later. (NOTE: this photo was taken before the display was fully mounted inside the enclosure, and is shown without the protective rubber boot.)


Features

  • Battery voltage indicator
  • Time and date
  • Temperature
  • Lean gauge with resettable max L-R indicators
  • Current speed
  • Resettable max speed indicator
  • Odometer
  • 2 resettable trip meters
  • Latitude and longitude readouts
  • Compass heading readout
  • GSM/GPRS quad-band cellular module


Schematic


Visual Schematic


Sensor Shield


The sensors are mounted on a Proto Shield PCB from Ladyada's Adafruit Industries (which is also where I get my Duemilanoves). Most of the wiring was done using 30 gauge Kynar solid wire, with heavier gauge used for some power and ground connections. Good mechanical connections are important considering the shock and vibrations this will be subjected to.

Sensor Shield - Top
Sensor Shield - Top

Sensor Shield - Bottom
Sensor Shield - Bottom

I went with breakout boards for the surface mount chips. They take up a bit more real estate on the PCB but are very easy to solder and save a lot of construction time. Note the DS1307 RTC on the underside...the profile is still low enough to allow the parts to fit nicely in the open space between boards when stacked. I soldered a right-angle pin header directly to the pads of the GPS breakout board, and straight pin headers on the others.

GPS/RTC Breakout
GPS/RTC Breakout

You might be wondering why I even included the RTC chip since time-of-day and date can be gotten from the GPS data. The DS1307 RTC chip also has 56 bytes of non-volatile RAM. I'm using these registers for storing the trip meter and odometer values so they can be restored between power cycles.

The GPS uses pins 0 and 1 for its TxD and RxD signals to communicate to the Duemilanove. The TouchShield Slide also uses these pins for downloading sketches. The "Program Switch" is used to disconnect the TouchShield Slide from these pins when not downloading so they're free for use by the GPS. Fortunately the TouchShield Slide uses pins 2 and 3 during normal operation, which I'm driving with digital I/O pins 4 and 5 on the Duemilanove.

Three devices require serial communications (GPS, TouchShield Slide, and Cell Module), and it was a real challenge getting the Duemilanove to support these at data rates needed for the desired performance. Having the GPS, running at 9600 baud, use the hardware serial port (pins 0 and 1) proved to be the best approach. The TouchShield Slide (19200 baud) and Cell Module (4800 baud) use digital I/O pins, and Mikal Hart's NewSoftSerial library for 'software' interrupt driven serial communications was invaluable in getting these to play nicely together.

The GPS chip is powered by the 3.3v regulator. The 10k resistor and 1N914 diode circuit on the serial RxD line of the chip are used to dampen the 5v signal from the Arduino hardware TxD line used to send data to the chip. When that line is high, the diode doesn't conduct allowing the 10k pull up resistor to apply a 3.3v high to the GPS RxD input. When it's low, the diode conducts and the line sinks through the TxD driver pulling the line down. The .7 volt drop across the diode is still sufficient for a low to be recognized by the GPS RxD input. A schottky diode with a .2v drop might be an improvement here, but the 1N914 seems to work fine. The GPS is rarely receiving data anyways - data is usually sent only one time to initialize the NMEA sentences to be sent, the baud rate, and the update cycle rate.


Display


The TouchShield Slide is mounted on another Proto Shield PCB. The CAT-5 connector is wired to the PCB using solid telephone wire to provide power and ground, and to connect the RxD and TxD signals from the Duemilanove to the display. Another line is brought up to drive the beeper.

Display Shield
/DisplayShield 2

/DisplayShield 3

The display assembly is mounted in an enclosure I found at boxenclosures.com, part #40-12-NO-R-BL. It's a perfect size for the TouchShield Slide, once the inside bosses were removed with a Dremel tool. I cut out an opening for the display/touchscreen using a plastic cutter tool, and added a 1/16" gasket I cut from a sheet of neoprene to seal it.

Box Enclosures also has a nice protective rubber boot for the enclosure, which is shown in the scooter photos below.

Display Enclosure With Gasket
/DisplayShield 5


Cell Module


The SM5100B GSM/GPRS Cell Module just needs a SIM card and antenna. The antenna can be obtained from Sparkfun.com and attaches to the wire with the red cap covering the connector.

Cell Module
Cell Module

The Cell Module shield and Sensor shield plug in to the Duemilanove, stacked one on the other. The Duemilanove is programmed to reply to text messages made to the cell with a return text message containing latitude/longitude data, heading, speed, and a time stamp. The GPS latitude and longitude coordinates can be entered online to see the location on a map, such as using touchmap.com. I can also use this to capture my precise location when riding in an unfamiliar area. One of the spare buttons on the display could be used to tell the Scooterputer to text a cell phone with this information.

The Duemilanove is also programmed to send the text message to my cell phone when it initializes. This serves as kind of a scooter "LoJack". If the scooter is ever borrowed without permission, it will notify me each time it starts, and as long as it is running it can be texted to obtain its present location. Recovery and bad-guy-in-jail are just a text message away. Of course now my wife can text my scooter any time she wants to find out what I'm up to (note to self: add a pass phrase to the incoming message).

I also have it programmed to forward any incoming calls to my personal cell.

The display is not needed for any of these features. Also note that the Cell Module is optional. The Sensor shield can be plugged directly into the Duemilanove if the telecommunication features are not desired.

Duemilanove/Cell/Sensor
Duemilanove/Cell/Sensor


Calibrating


Very little is needed for calibration. Check out the source code to see how simple it is. Debug #defines are included to selectively send the sensor values to the Arduino serial monitor during operation. The scaling and mapping can then be tweaked as needed while observing the output.

The ranges for the accelerometer readings are easily obtained by analyzing the analog input data. I found full range to be 453 to 580 for both the X and Y axis, which is 127 units with a center around 516. I arbitrarily took 20 off each end and mapped these to -90 to +90 for the Lean Gauge values.

The Lean Gauge display is designed to show the current real time values in bright green, and the max L-R readings are maintained on the background in dark green. These can be reset by pressing the Lean button on the display.

The Battery Voltage Indicator ranges were set by varying the voltage applied from a bench power supply. The top of the indicator is calibrated to 14.0v and the bottom 10.0v, again by mapping the values coming in the analog input to the 0 - 100 range expected by the Battery Voltage Indicator. With a strong battery, at idle the indicator floats within the green zone and at speed it just gets into the orange. When the battery is weak and the indicator falls into the red zone, the red area flashes at a 500 msec rate from bright red to dark red.

Calibrating The Battery Voltage Indicator
Calibrating BVM


The Haversine formula is used to calculate the distance traveled for the odometer and trip meters, using lat/lon data returned from the GPS. This seems to track the odometer on the scooter fairly close as long as I'm not riding in tight circles or zigzags. Since I don't ride while intoxicated, this should work fine for the trip meters but I have my doubts about the long term accuracy for use as an odometer. Time will tell, and I expect I'll be tweaking the algorithm to calibrate for improved accuracy.

As an alternative, I experimented some with a hall-effect sensor triggered by a magnet attached to the wheel. I'm confident this would be very effective as a speedometer and odometer, but have decided to go strictly with the GPS for now. If you're interested, let me know and I can post the hall-effect sensor circuit and sketch. (Update 08/25/2010: added link below to circuit diagram and test sketch)


Source Code and Antipasto IDE

Scooterputer.zip - sketches for Arduino Duemilanove and TouchShield Slide

Liquidware Antipasto - Antipasto Arduino IDE (supports Arduino Duemilanove and TouchShield Slide)

HallEffectSensorTest.zip - circuit and test sketch for Hall Effect sensor


Scooter

Scooterputer Mounted Under The Hood
Scooter Under Hood 1

Scooterputer Mounted Under The Hood
Scooter Under Hood 2

Scooterputer Display with RAM Mount
Scooter Display RAM Mount

Scooterputer Display
Scooter Display

Scooter Walkaround




Links


www.arduino.cc - start here
www.adafruit.com/ - get lots of great Arduino stuff here. Ladyada rocks!
www.liquidware.com - TouchShield Slide
www.liquidware.com/antipasto_arduino_ide - Antipasto Arduino IDE
www.sparkfun.com - components: accelerometer chip, GPS chip, RTC chip, temperature sensor, cell module, and much more
www.boxenclosures.com/index.html - nice project cases
arduiniana.org - NewSoftSerial and TinyGPS libraries. Mikal rocks too.
itouchmap.com/latlong.html - mapping GPS coordinates
www.hhhh.org/wiml/proj/nmeaxor.html - NMEA sentence checksum calculator
www.movable-type.co.uk/scripts/latlong.html - useful latitude/longitude formulas
www.ram-mount.com - mounting systems for cars, motorcycles, scooters, ATVs, etc.
www.genuinescooters.com - awesome scooters!


Scooterputer is a trademark of Schulz Design


free b2evolution skin