A Technology Blog About Code Development, Architecture, Operating System, Hardware, Tips and Tutorials for Developers.

Showing posts with label HARDWARES. Show all posts
Showing posts with label HARDWARES. Show all posts

Saturday, November 6, 2010

GPS with JGPS - Setup Testing

3:12:00 PM Posted by Satish , , No comments
I am playing around the GPS module since quite some time and got a new JGPS java api to interact with. I have a serial out put GPS module. Check out my GPS setup. This particular API has got a very good interface for USB, Serial and bluetooth GPS devides.This has native API for both Unix and windows platform. In unix plat form this supports both linux and solaris. This API has got a very meaning full instruction to setup in unix environment. As I have my java comm API already setup to windows and I have the USB - Serial driver for windows, I tested in windows rather than ubuntu.

This api works on the top of java comm api. I was controlling my GSM/ GPRS modem through  the IO channels using java comm api. In the older versions of jGPS, the io interaction to the GPS module was through Java comm api and the jGPS was only the formatter. But this new release integrated the Java comm api with it again with some additional interface like bluetooth.

So general architecture is as follows.

GPS Module - Serial/ USB/ Bluetooth Interface - Java Comm API (JAVA+Native API[OS specific]) - jGPS API (JAVA)

Following is a simple program to register to one of the event and get notified for the lat/lng.

Source


package org.satish.practice;



import com.uf.gps.Descriptor;
import com.uf.gps.GPSListener; 
import com.uf.gps.GPSEvent; 
import com.uf.gps.Position;
import com.uf.gps.protocols.NMEA.NMEAHandler; 
import com.uf.gps.Connection; 
import com.uf.gps.ConnectException; 
import javax.comm.SerialPort;

public class myApp implements GPSListener { 
public myApp () { 

NMEAHandler nh = null; 
/* Initialize a connection handler on the RS232 interface */ 
try { 
nh = new NMEAHandler(1,"myApp","COM6",9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); 
} catch (ConnectException x) { 
// Something is going wrong

/* Enable reception of GPSEvents */ 
nh.registerListener( this ); 
}

public static void main(String[] args) throws ConnectException { 
myApp my = new myApp(); 
}

public void actionPerformed(GPSEvent ev) { 
Position p = null; 
/*
* public GPSEvent (Connection src, int transactiontype, int datatype, Object
* data)
*/ 
/* src: connection handler, maybe there's more than one defined */
/* transactiontype: is one of BEGIN_TRANS, END_TRANS, _TRANS */ 
/* datatype: one of the _CLASS constants, which classifies a data type */ 
/* data: the GPSObject */ 

if (ev.getTransType() == GPSEvent.POS_TRANS) { 
p = (Position) ev.getData(); 

/* Every high level class has lots of properties */
Descriptor wa = p.getProperty("LONGITUDE"); 
Descriptor wb = p.getProperty("LATITUDE"); 

/* wa.getValue of class Double */ 
String lon = wa == null ? "" : (String) wa.getValue().toString(); 

/* wb.getValue of class Double */ 
String lat = wb == null ? "" : (String) wb.getValue().toString(); System.out.println( "Latitude/Longitude = [" + lat + "][" + lon + "]" ); 
} else if (ev.getTransType() == GPSEvent.WPT_TRANS) { 
// .................................................. 
}
}
}


Output

Latitude/Longitude = [12.957963999999999][77.67056266666667]

Latitude/Longitude = [12.957963999999999][77.67056266666667]
Latitude/Longitude = [12.957967][77.67056366666667]
Latitude/Longitude = [12.957967][77.67056366666667]
Latitude/Longitude = [12.957972][77.67056166666667]
Latitude/Longitude = [12.957972][77.67056166666667]
Latitude/Longitude = [12.95797][77.67056366666667]
Latitude/Longitude = [12.95797][77.67056366666667]
Latitude/Longitude = [12.957965][77.67056366666667]
Latitude/Longitude = [12.957965][77.67056366666667]
Latitude/Longitude = [12.957963][77.67056366666667]
Latitude/Longitude = [12.957963][77.67056366666667]
Latitude/Longitude = [12.957961999999998][77.67056466666668]
Latitude/Longitude = [12.957961999999998][77.67056466666668]
Latitude/Longitude = [12.957961999999998][77.67056466666668]
Latitude/Longitude = [12.957961999999998][77.67056466666668]
Latitude/Longitude = [12.95796][77.67056666666667]
Latitude/Longitude = [12.95796][77.67056666666667]
Latitude/Longitude = [12.957958999999999][77.67056866666667]
Latitude/Longitude = [12.957958999999999][77.67056866666667]
Latitude/Longitude = [12.957958999999999][77.67056966666667]
Latitude/Longitude = [12.957958999999999][77.67056966666667]
Latitude/Longitude = [12.957961999999998][77.67057066666668]
Latitude/Longitude = [12.957961999999998][77.67057066666668]
Latitude/Longitude = [12.957958999999999][77.67057266666667]
Latitude/Longitude = [12.957958999999999][77.67057266666667]


I will still be playing around the API and keep posting too.

Thursday, October 28, 2010

NMEA GPS Reads

8:58:00 PM Posted by Satish , , No comments
GPS modules typically put out a series of standard strings of information, under something called the National Marine Electronics Association (NMEA) protocol. More information on NMEA standard data strings can be found at this site.
GPS receiver gives the reading starting with the following strings and each string appended data has its own significant.
  • $GPGGA: Global Positioning System Fix Data
  • $GPGSV: GPS satellites in view
  • $GPGSA: GPS DOP and active satellites
  • $GPRMC: Recommended minimum specific GPS/Transit data
Each of these sentences contains a wealth of data. For example, here are a few instances of the $GPRMC string.
eg1. $GPRMC,081836,A,3751.65,S,14507.36,E,000.0,360.0,130998,011.3,E*62 eg2. $GPRMC,225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68
225446 Time of fix 22:54:46 UTC A Navigation receiver warning A = Valid position, V = Warning 4916.45,N Latitude 49 deg. 16.45 min. North 12311.12,W Longitude 123 deg. 11.12 min. West 000.5 Speed over ground, Knots 054.7 Course Made Good, degrees true 191194 UTC Date of fix, 19 November 1994 020.3,E Magnetic variation, 20.3 deg. East *68 mandatory checksum
eg3. $GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70
1 2 3 4 5 6 7 8 9 10 11 12
 
1 220516 Time Stamp 2 A validity - A-ok, V-invalid 3 5133.82 current Latitude 4 N North/South 5 00042.24 current Longitude 6 W East/West 7 173.8 Speed in knots 8 231.8 True course 9 130694 Date Stamp 10 004.2 Variation 11 W East/West 12 *70 checksum
eg4. for NMEA 0183 version 3.00 active the Mode indicator field is added
$GPRMC,hhmmss.ss,A,llll.ll,a,yyyyy.yy,a,x.x,x.x,ddmmyy,x.x,a,m*hh
Field #
1 = UTC time of fix 2 = Data status (A=Valid position, V=navigation receiver warning) 3 = Latitude of fix 4 = N or S of longitude 5 = Longitude of fix 6 = E or W of longitude 7 = Speed over ground in knots 8 = Track made good in degrees True 9 = UTC date of fix 10= Magnetic variation degrees (Easterly var. subtracts from true course) 11= E or W of magnetic variation 12= Mode indicator, (A=Autonomous, D=Differential, E=Estimated, N=Data not valid) 13 = Checksum
The full documentation you can get here.

Sunday, October 24, 2010

GPS Receiver Module - iW-GPS-01

6:06:00 PM Posted by Satish , , 2 comments
Got iW-GPS-01(with Active Antenna) and iWave's GPS Platforms. The GPS board is mounted on a GPS platform with serial out and has a external antenna. The board has got a serial port and a power input.The board operates on 5 - 35 V input.

Full specification attached here.

Reads I got from Hiper Terminal.

$GPGSA,A,3,14,06,24,03,30,31,21,22,,,,,2.1,1.0,1.8*3D
$GPGSV,3,1,12,31,72,201,17,22,47,056,15,24,38,314,26,14,37,004,24*72
$GPGSV,3,2,12,18,26,093,,30,26,106,24,06,17,219,25,25,16,084,19*73
$GPGSV,3,3,12,19,14,265,,21,13,150,22,03,13,232,27,16,06,191,*7C
$GPRMC,181611.000,A,1257.7947,N,07740.3910,E,0.16,57.21,231010,,,A*54
$GPVTG,57.21,T,,M,0.16,N,0.3,K,A*38
$GPGGA,181612.000,1257.7948,N,07740.3910,E,1,08,1.0,916.6,M,-88.4,M,,0000*75
$GPGSA,A,3,14,06,24,03,30,31,21,22,,,,,2.1,1.0,1.8*3D
$GPRMC,181612.000,A,1257.7948,N,07740.3910,E,0.40,131.00,231010,,,A*69
$GPVTG,131.00,T,,M,0.40,N,0.7,K,A*0D
$GPGGA,181613.000,1257.7946,N,07740.3911,E,1,08,1.0,917.4,M,-88.4,M,,0000*78
$GPGSA,A,3,14,06,24,03,30,31,21,22,,,,,2.1,1.0,1.8*3D
$GPGSV,3,1,12,31,72,201,17,22,47,056,14,24,38,314,26,14,37,004,24*73
$GPGSV,3,2,12,18,26,093,,30,26,106,24,06,17,219,25,25,16,084,19*73
$GPGSV,3,3,12,19,14,265,,21,13,150,22,03,13,232,27,16,06,191,*7C
$GPRMC,181613.000,A,1257.7946,N,07740.3911,E,0.74,149.98,231010,,,A*6E
$GPVTG,149.98,T,,M,0.74,N,1.4,K,A*06


Some pictures of my setup.





Let play around it. 

Wednesday, June 23, 2010

GSM MODEM WITH MY GSM PHONE

10:02:00 PM Posted by Satish , , , , 6 comments

INTRODUCTION TO GSM MODEM:

A GSM modem is a wireless modem that works with a GSM wireless network. A wireless modem behaves like a dial-up modem. The main difference between them is that a dial-up modem sends and receives data through a fixed telephone line while a wireless modem sends and receives data through radio waves. Computers use AT commands to control modems. Both GSM modems and dial-up modems support a common set of standard AT commands.

MOBILE PHONE OR GSM MODEM:


In general, a GSM/GPRS modem is recommended for use with a computer to send and receive messages. This is because some mobile phones have certain limitations comparing to GSM/GPRS modems. Using my Nokia 3110C, I am not able to receive any messages to my computer. And also I noticed the phone always run out battery in no time. But there are some phones in the market which support all the AT commands. Here is the list of AT Commands supported by the Nokia phones.

SETUP THE MOBILE PHONE AS GSM MODEM:

1. Connect your mobile phone to a computer and set up the corresponding wireless modem driver.
2. Run MS HyperTerminal by selecting Start -> Programs -> Accessories -> Communications -> HyperTerminal.
3. In the Connection Description dialog box, enter a name and choose an icon you like for the connection. Then click the OK button.
-->

4. In the Connect To dialog box, choose the COM port that your mobile phone is connecting to in the Connect using combo box. For example, choose COM1 if your mobile phone is connecting to the COM1 port. Then click the OK button.
Note:
Sometimes there will have more than one COM port in the "Connect Using" combo box. To know which COM port is used by your mobile phone, follow the procedure below:
a. Go to Control Panel -> Phone and Modem Options".
b. Then click the Modems tab. In the list box, you can see which COM port the mobile phone or GSM/GPRS modem is connected to.
5. The "Properties" dialog box comes out. Enter the correct port settings for your mobile phone. Then click the OK button.
Note:
To find the correct port settings that should be used with your mobile phone, one way is to consult the manual of your mobile phone. Another way is to check the port settings used by the wireless modem driver that you installed earlier.
To check the port settings used by the wireless modem driver, follow these steps:
a. Go to Control Panel -> Phone and Modem Options -> Modems tab.
b. Select your mobile phone in the list box.
c. Click the "Properties" button.
d. The Properties dialog box appears. Click the Advanced tab and then click the Change Default Preferences button.
e. The Change Default Preferences dialog box appears. The Port speed field on the General tab corresponds to HyperTerminal's "Bits per second" field. You can also find the setting for flow control on the General tab. On the Advanced tab, you can find the settings for data bits, parity and stop bits.
6. Type AT in the main window. A response OK should be returned from the mobile phone or GSM/GPRS modem. Type AT+CPIN? in the main window. The AT command AT+CPIN? is used to query whether the mobile phone is waiting for a PIN (personal identification number, i.e. password). If the response is +CPIN: READY, it means the SIM card does not require a PIN and it is ready for use. If your SIM card requires a PIN, you need to set the PIN with the AT command AT+CPIN=[PIN].

Now the mobile phone is configured to work as a GSM modem.
JAVA CONFIGURATION FOR COM PORT:

As the modem is connected to the COM port of the computer, you have to use Java Communications API.
Sun provides an API extension for communicating with parallel and serial ports, specifically for Solaris and Windows environments. The API can be found here. There are also third party APIs and an open source implementation, which works on several platforms including Linux. You can download the Java Communications API from here.

INSTALLING THE JAVA COMMUNICATIONS API IN WINDOWS ENVIRONMENT:

Among the items that you download from Sun are three very important files:
1. comm.jar
2. win32com.dll
3. javax.comm.properties

For the JVM to recognize the serial ports, proper placement of these files is important. And have found the following installation methods to be effective:

1. comm.jar should be placed in:

    %JAVA_HOME%/lib
    %JAVA_HOME%/jre/lib/ext

2. win32com.dll should be placed in:

    %JAVA_HOME%/bin
    %JAVA_HOME%/jre/bin
    %windir%System32

3. javax.comm.properties should be placed in:

    %JAVA_HOME%/lib
    %JAVA_HOME%/jre/lib

Now Java is correctly configured to interact with the COM ports. Now it is the time to write a program to send and receive message.

SENDING AND RECEIVEING SMS:

For sending and receiving SMS I am using the following procedure.

1. Connecting to the COM port where the modem is connected.
2. Registering the listener for serial port event.
3. Using the following set of AT commands to send the SMS.

            AT (To check the modem)
            OK (Response - modem connected)

            AT+CMGF=1 (To set the text messaging mode)
            OK (Response - text messaging mode set successfully)

            AT+CSCA="+979797979796464" (To set the message center)
            OK (Response - message center is set properly)

            AT+CMGS="+91021482048023" (To set the recipient no and open the message writing prompt)
            >my test message + [Ctrl+z] ("Ctrl+z" is to come out of the message writing prompt)
            OK             
            CMGS: +919886599334 (Message sent)
    
4. As we have registered to the serial port events, when ever any data will come to the serial port the implemented method will print the data to the console. It is applicable for receive message also.

If you are using the GSM/GPRS modem, then lot of other features of phone like call receiving, making a call, call forwarding, answering machine etc can be developed for any enterprise application. 

SHARED ITEMS:

1. Source Code or you can fork at GitHub.