Arduino GPS clock using NMEA protocol

GPS for accurate synchronization and  position measurement must use precise clock, so GPS satellites are equipped with atomic clocks. Clock accuracy is amazing ± 1 second in 1 million years. Using GPS module is available not only acquire position, speed, bet also time and date, so in this post I’ll explain how to do it.

GPS clock consist of old Sirf II GPS module, MAX 232, Arduino Mega and LCD display (Hitachi HD44780).

Sirf II module has RS-232 interface for communication and it can be  connected to PC Com port. Atmega in Arduino board has  UART interface. RS-232 basically is the same UART, only zeros and ones voltage levels are different. To match levels MAX232 driver is used. Today’s GPS modules have UART port, so there isn’t any need for MAX232.

Arduino in this project doesn’t have clock function it just pass time and date from GPS module to display. It works that way because GPS module has internal RTC(Real time clock) it’s not accurate, but it is synchronized to GPS system.

As you can see from video GPS module RTC is sychronised before GPS fix happens, but GPS fix is only one indicator that shows that clock is synchronised.
Continue reading

Digital voltmeter – Arduino and PC (Visual C++) comunication via serial port

Today I will show how to make digital bridge between Arduino and PC: control analog – digital converter and send measured data to PC. Windows application will be created using Visual C++ 2008 Express.

Voltmeter demo software is very simple, and here is a lot room for improvement, but I just wanted to show basics how to control com port and execute data exchange between PC and Arduino.

Continue reading

Very simple Arduino capacitance meter using 16 bit timer and analog comparator

As You could see from video it requires only one external resistor. Meter is very simple, but obviously not very accurate or wide range. Theoretically it could measure in 10 nF – 160 µF range.

How it Works?

Circuit formed from resistor and capacitor (RC circuit) has time constant, it shows time needed to discharge capacitor via resistor to ~37% it’s initial voltage. Calculation of time constant is very simple t=R*C . For 1 k resistor and 47µF capacitor it’s 47ms.

My capacitance meter fully charges capacitor, when 16 bit timer is started and capacitor is discharging via resistor (1 k). Capacitor is connected to analog voltage comparator(pin 5), as capacitor voltage drops bellow 1.1 V occurs analog comparator interrupt which triggers timer interrupt.  If resistor is constant, discharge time and capacitance dependency is linear, therefore if You know one rated capacity capacitor discharge time, You could easily calculate another capacitor’s capacitance by measuring time.

Because timer uses only one  /64 clock prescaler measurement range is very narrow. To have wider range there is a always way to make  programmable prescaler, which changes if capacitor value is out of range, or discharge capacitor via range of different resistors.

Also keep in mind that resistor’s resistance depends on environment temperature, consequently and on LCD display showed capacitance. To fix this temperature dependency referenced capacitor should be used. In this case every time both capacitors are charged and discharged separately, but via the same resistor. Capacitance proportion is calculated and if referenced capacitor capacitance is know measured capacitor’s value can be calculated just by division or multiplying.

It’s time for program’s code.

Continue reading

Arduino 4 digits 7 segments LED countdown timer with buzzer

After sorting out  how works 16 bit hardware timer it is time for 4 digits countdown timer. Having 16 bit timer and  7 segments LED code from earlier only were remaining to write timer’s modes (run/setup) and button’s control code.  After putting  all code to one place there is countdown timer with properties below:

  • Maximum 99 minutes 59 seconds countdown interval
  • 1 second resolution
  • Sound indication with buzzer for finished countdown
  • LED indicates running timer, or relay instead  for powering external devices for some period of time
  • 2 buttons to set timer and start/pause/reset.

This time without additional code quotation, please find some code explanation within code, so code bellow.

Continue reading

Cheap and used Sirf II e LP GPS Module from Ebay

I have idea to build precise clock, and GPS module is here because GPS satellites has atomic clock on board. I have chosen particularly this module, because it was the cheapest, that I could find on internet, only 15 USD with free shipping. While new GPS module costs 60 USD, thought You could find completed GPS  navigator for 70 USD.

Module has simple 5 wires connection. It’s powered from 5V, but can also work form 3.3V power supply. Data from/to device flows via well known RS-232 interface’s RX and TX data lines. Module can be directly connected to PC using RS-232 (com port), but is also needs 5V power source, USB works well. RS232 have the same data structure as UART, but voltage levels are different, so it  can’t be connected directly to microcontroller, logic level converter MAX232 must be used.

Module use standard NMEA-0183 standard interface for data transmission. One reason it’s good, because module outputs data continuously  without any request, so really it can be used only one RS232 data line.

Cold start (18 minutes until GPS fix)

To test bought GPS module I had connected it to my desktop PC RS232 port. It’s very easy to test. because seller send my with documentation and test software – GPS Diagnostics V1.05. It decrypts data in NMEA format and shows it in user friendly way.

18 minutes elapsed until I got location from module, at so called Cold start. Cold start means, that GPS module doesn’t have primary  data about time, and location, so it is impossible to calculate which of 24 satellites are in module “view”.  In this scenario module searches for signal of all 24 satellites, consequently it takes some time. Seller recommended to test device with clear view of sky, but I placed module near open window, so it is why 18 minutes 🙂

After 7 minutes I got data from 2 satellites, no location info still, but UTC date and time from satellite.

After 18 minutes location is found.

Here is module’s best result – 6 satellites, but still near open window.

Warm start (5-6 seconds)

Module saves date, time and location information in memory. Next time it is turned on it uses that information for faster GPS fix. With built in RTC (Real time clock) used time is current, not the same as was when module last time worked.

2010.10.14 update.

There is  GPS module pinout instructions from seller:

  1. Black (GND)
  2. Red (+5V)
  3. White (GPS RX Data input)
  4. Green (GPS TX Data output)
  5. Black (Shield, GND)
  6. No connect.