Mce Trackme User Eng

Embed Size (px)

Citation preview

  • 8/12/2019 Mce Trackme User Eng

    1/38

    MCE TrackMe (GPS) 2013

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    Tracking system, telemetry and remote controlthrough cellular network.

    electronicsmc

  • 8/12/2019 Mce Trackme User Eng

    2/38

    We are a team of professionals that work with passion so as to ensure that our clients

    have always a innovative product. We take care of all the details involved in the

    fabrication of all our tools. All of our products are designed and assembled in Argentina.

    This product counts with 1 year warranty.

    More products at:

    http://www.mcelectronics.com.ar/desarrollos

    Alejandro Airoldi

    Responsable for Quality Control

    Quality Assurance

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

  • 8/12/2019 Mce Trackme User Eng

    3/38

    Introduction

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    TrackMe (GPS) is a telemetry system and remote control through cellular network. It

    possesses a GPS and a GSM module. It can transmit through GSM or GPRS, plus it counts

    with acceleration, light and temperature sensors. The battery is charged via USB and it

    has the possibility to store the coordinates in the internal memory of the PIC18F26J50microcontroller.

    TrackMe (GPS) 2013 includes complete projects programmed in CCS. Plus, examples to

    decode the GPS NMEA frames, receive commands trough

    text messages , use the accelerometer and present the information on

    a map using GoogleMaps !

  • 8/12/2019 Mce Trackme User Eng

    4/38

    Layout version 2013

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    (+) Size comparison

    with a cellular phone.

    54 mm

    85mm

  • 8/12/2019 Mce Trackme User Eng

    5/38

    Components Distribution

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    Connector for

    SIM Card

    USB for battery charge and

    data transfer.

    Charge

    indicator LED

    GPS Antenna

    GSM Antenna

    (removable)

    Power

    indicator LED

    Expansion

    Header

    Panic push

    button

  • 8/12/2019 Mce Trackme User Eng

    6/38

    Expansion Header

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    SIM908

    Module

    SPEAKER P

    SPEAKER N

    MIC P

    MIC N

    BAT

    BAT

    +3V3

    +3V3GND

    GND

    XOUT

    YOUT

    ZOUT

    IO5

    IO4

    IO3

    IO2

    IO1

    GSM TX

    GSM RX

    RING

    GSM STATUS

    GSM NET

    GSM ON

    GPS TX

    GPS RX+3V3

    PANIC

    LDR

    TEMP

    NC

    PGD

    PGC

    GND

    +3V3

    MCLR

    PICKit 2,

    PICKit 3 or

    another

    compatible

    programmer

  • 8/12/2019 Mce Trackme User Eng

    7/38

    Switches and LEDs

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    NET

    READY

    Flashes every 2sec

    when the device

    registers to the

    cellular network

    (must have an active

    chip).

    It lights up when

    the SIM908

    module is ready

    to operate.

    The RF switch can power

    on/off the SIM908 module

    while the rest of the board is

    still working.

    RF

    MAIN

    ON

  • 8/12/2019 Mce Trackme User Eng

    8/38

    Microchip Analog Devices

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    TC1262-3.3

    ANALOG

    Charger for

    Li-ion

    batteries of

    each cell.Includes

    current

    censing and

    protection

    against

    inverse

    discharge.

    TC1047

    3.3v

    3.3v

    Analog temperature sensor

    10mV/C

    VBATVIN

    MCP73838

    VBAT

    PIC

    18F26J50

  • 8/12/2019 Mce Trackme User Eng

    9/38

    Accelerometer

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    NC

    AN2 X OUT

    AN3 Y OUT

    AN4 Z OUT

    GND

    3.3V

    NC

    NC

    NC

    NC

    NC

    NC

    NC

    3.3V

    Freescale MMA7368L

    It includes a 3 axis analog accelerometer (X OUT, Y OUT, Z OUT). They are connected

    directly to the PIC analog channels.

    1.5g Three Axis Low-g Micromachined Accelerometer

    PIC Analog

    channels

    Change rate: 800mV/G

    Z

    Y

    X

  • 8/12/2019 Mce Trackme User Eng

    10/38

    Accelerometer

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    NC

    X OUT

    Y OUT

    Z OUT

    GND

    3.3V

    NC

    NC

    NC

    NC

    NC

    NC

    NC

    3.3V

    Freescale MMA7368L

  • 8/12/2019 Mce Trackme User Eng

    11/38

    SIM908 GSM Module

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    GSM

    SIM908

    Quad-band : GSM850, EGSM900,

    DCS1800, PCS1900

    GPRS multi-slot : Class 10 / Class 8

    Noise Suppression

    Echo Cancelation

    Sleep mode current consumption:

    1.5mA

  • 8/12/2019 Mce Trackme User Eng

    12/38

    GSM Module Connections

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    SIM CARD

    RFIN

    ANT

    PIC 18F26J50

    SIM TX

    SIM RX

    GSM

    SIM908

    SIM BUS

    1,8 - 3v

    PWRKEY

    NETSTATUS

    The SIM908 module connects to the PIC through SIM TX (RP0) and SIM RX (RP1) pins. It

    also needs the antenna connector and SIM Card to operate.

  • 8/12/2019 Mce Trackme User Eng

    13/38

    SIM908 GSM Module

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    The SIM908 module needs a 0 on the PWRKEY pin to start. In this case the board has a

    common emitter transistor (inverter), for which we must switch the PIC RC1 pin (GSMON)

    to 1 to turn on the module.

    PWRKEY

    Low > 1s. Delay > 2s.

    STATUS

    The module will automatically shut down (STATUS = low) when supply

    voltage is detected outside the 3.3 < VBAT < 4.6 range or when the

    temperature is over 85C.

    However 0.1v under the limits it sends warnings through the USART.

  • 8/12/2019 Mce Trackme User Eng

    14/38

    AT Commands

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    The GSM Module is controlled via commands through the USART.

    These commands are denominated AT commands.

    The AT commands allows you to make phone calls, text messages, consult the module

    parameters, measure the cellular signal and set all the SIM900 configurations.

    Conversation type communication. The answer must be received before the next

    command is sent.

    AT (Attention)

  • 8/12/2019 Mce Trackme User Eng

    15/38

    Synchronization

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    By default it is autobauding enabled. To synchronize the PIC speed with the SIM908 an

    A must be sent and up to 3 to 5 seconds must be waited. Then we send the AT

    command before initiating communication Once synchronized the SIM900 responds

    OK

    ATGSM

    SIM908PIC

    18F26J50

    Autobauding Range: 1200 bps to 115200 bps (N,8,1)

    A

    OK

  • 8/12/2019 Mce Trackme User Eng

    16/38

    Basic Commands

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    ATI

    SIMCOM_Ltd

    SIMCOM_SIM900

    Revision:1008B10SIM900S32_(SPANSION)SIMCOM_Ltd

    AT+GSN // IMEI number from the SIM900

    355117001566879

    OK

    AT+CSQ // Signal level [rssi,ber]

    rssi (0= -113dBm o 1= -111dBm o 2 a 30= -109dBm a -53dBm o 31= -51dBmo >/99 no se conoce). ber (% bit error rate)

    [17,0]

    These commands can be sent through the HyperTerminal (using the USB-GSM driver

    included) or through the microcontroller without using the PC.

  • 8/12/2019 Mce Trackme User Eng

    17/38

    Basic Commands

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    ATD51065802; Make a phone call - SIM908 dials 51065802

    AT+CLIP=1 // Show the number of the incoming call (Caller ID)

    OK

    RING

    +CLIP: 51065802",129 // Incoming call number 51065802

    OK

    ATH // Hang up

    RING

    ATA // Attend incoming call

    OK

  • 8/12/2019 Mce Trackme User Eng

    18/38

    Send a SMS

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    Sending of the SMS to 51065802

    AT+CMGF=1 // Selecting of text mode

    AT+CMGS=51065802 // Phone number and 0x0D

    > YOUR MESSAGE // Write the message and 0x1A

    Returns the position in the memory of sent

    OK+CMGS: 123

  • 8/12/2019 Mce Trackme User Eng

    19/38

    Recieve an SMS

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    Reception of SMS

    AT+CMGF=1 // text modeAT+CNMI=2,2,0,0,0 // doesnt save in memory, it sends it through

    USART

    When a message comes it sends it through TX automatically !

    +CMT: 12345678,,28/05/10,11:20:28+32

    Hello World

  • 8/12/2019 Mce Trackme User Eng

    20/38

    SIM908 GPS Module

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    GPS Receiver bases on the 42

    channels SIRFstarIII

    Consumption less than 77 mA

    NMEA protocols or SiRF

    Rapid Acquisition of satellites

    30 s.

    Tracking Sensibility :

    -160dBm

    GPS

    SIM908

  • 8/12/2019 Mce Trackme User Eng

    21/38

    GPS Module Conections

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    VANT

    VRF = 2.85v

    RFIN

    PIC 18F26J50

    GPS TX

    GPS RX (*)

    GPS

    SIM908

    ON

    ANT LNA

    The GPS Module connects to the PIC through the GPS TX (RP3) and GPS RX (RP4) pins. It

    needs the antenna and the LNA (Low Noise Amplifier) to operate.

    (*) GPS RX is used to request other

    frames or vary the reception

    interval from the PIC.

  • 8/12/2019 Mce Trackme User Eng

    22/38

    NMEA Frame

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    NMEA 0183 is a protocol through which the navigational and terrestrial instruments can

    communicate. Its been defined, and controlled, by the National Marine Electronics

    Association.

    In the NMEA frame we have information such as position, velocity, movement direction,UTC hour, satellite position, intensity of incoming and data control.

  • 8/12/2019 Mce Trackme User Eng

    23/38

    Basic NMEA frame

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    The $GPRMC frame includes basic tracking information and its the one were going to

    use to determine the position and other data as velocity, direction and hour.

    RecommendedMinimum

    Message

    UTC Hour

    04:03:02.663 AM

    $GPRMC,040302.663, A,3939.7, N,10506.6,W, 0.27, 358.86,200812,*1A

    A = Active (at least 3 satellites), V = InvalidA

    N = North, S = SouthN

    W = West, E = EastW

    Latitude 3939.7'

    Longitude 10506.6'

    Velocity meassured in Knots

    1 knots = 1.85200 kilometers

    Movement direction

    (azimuth) 358.86

    Date 20/08/12

    Checksum*1A

    Program to decode the NMEA

  • 8/12/2019 Mce Trackme User Eng

    24/38

    Program to decode the NMEA

    frame

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    TrackMe GPS includes a program (SirfDemo) to decode the NMEA frame and show

    information graphically. We must open the HyperTerminal and select GPS mode (option

    2), then we open the SirfDemo software at 4800 bps and click Connect to visualize the

    information in real time.

    Program to decode the NMEA

  • 8/12/2019 Mce Trackme User Eng

    25/38

    Program to decode the NMEA

    frame

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    At least 3 satellites are required to determine the position. In this case all the satellites

    are in red which means that there still isnt enough signal.

    The GPS must have a clear view to the sky so as to work properly.

  • 8/12/2019 Mce Trackme User Eng

    26/38

    Examples and Applications

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    All the examples are programmed in C for the CCS compiler. The complete code can be

    found along with the board files. Next well describe the basic rutines.

    The shaded represents code lines.

  • 8/12/2019 Mce Trackme User Eng

    27/38

    Examples and Applications

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    void inicializacionSIM900(void)

    { int cont;

    delay_ms(1000);

    puts("A",SERIAL_GSM); //to synchronize the SIM900 baudrate

    delay_ms(300);

    putchar(0x0d,SERIAL_GSM);

    delay_ms(3000);

    for(cont=0;cont

  • 8/12/2019 Mce Trackme User Eng

    28/38

    Examples and Applications

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    #define X_ADC 2 // Define the analog channel

    #define Y_ADC 3

    #define Z_ADC 4

    #define TEMP_ADC 11

    set_adc_channel(X_ADC); // Select the channel sith the multiplexor

    delay_ms(3); // Define a delay of 3 ms to charge the lecture capacitor

    eje_x=read_adc(); // Save the value in the variable

    set_adc_channel(Y_ADC);

    delay_ms(3);

    eje_y=read_adc();

    set_adc_channel(Z_ADC);

    delay_ms(3);

    eje_z=read_adc();

    set_adc_channel(TEMP_ADC);

    delay_ms(3);

    temperature=read_adc();

    Read analog channels

    In this example the analog channels of the accelerometer and temperature sensor are

    selected and the values are stored in variables (definition isnt showed in the box)

    l d l

  • 8/12/2019 Mce Trackme User Eng

    29/38

    Examples and Applications

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    sprintf(string_temp,"Temp=%1.2f C ",grados);

    fprintf(SERIAL_GSM,"AT+CMGS=\"1512345678\"\r"); // put here the cell phone number that receives the SMS

    delay_ms(200);

    fputs(string_temp,SERIAL_GSM);

    delay_ms(100);

    fprintf(SERIAL_GSM,"%c",0x1a);

    output_high(led);

    while(input(PANIC)==0);

    Send the temperature through SMS

    The complete example consists in reading the TC1047 sensor, convert the tension value

    to degrees and send it through SMS when the panic button is pressed. In this fragment

    we see that data must be passed as string, for which we convert the degrees variablefrom float to string with sprintf. The same applies when sending the measures of the

    accelerometer.

    E l d A li i

  • 8/12/2019 Mce Trackme User Eng

    30/38

    Examples and Applications

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    if ( kbhit (SERIAL2) ) // Waiting for new data in USART2

    {

    e=0;

    e=getchar(SERIAL2); //Characters are stored in variable e

    switch(e)

    {

    case 10: // Waiting for new line feed

    if(cbuffGPS[0]=='$' && cbuffGPS[1]=='G' && cbuffGPS[2]=='P' && cbuffGPS[3]=='R' && cbuffGPS[4]=='M' &&cbuffGPS[5]=='C' && cbuffGPS[18]=='A' ) //Validates if the data is valid (detect at least 3 satellites)

    {

    PIN_ON(LED);

    strcpy(cbuffGPS2,cbuffGPS); // The complete $GPRMC frame is stored in cbuffGPS2

    }

    xbuff=0;

    flag=0;

    break;default:

    cbuffGPS[xbuff++]=e;

    if(xbuff>(lenbuffGPS-1))

    xbuff=lenbuffGPS;

    }}

    Read and save GPS NMEA frame

    The idea is to read and save a valid frame in a variable, so as to process it later and send

    it as a GoogleMaps link.

    E l d A li ti

  • 8/12/2019 Mce Trackme User Eng

    31/38

    Examples and Applications

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    if(cbuffGPS2[0]=='$' && cbuffGPS2[1]=='G' && cbuffGPS2[2]=='P' && cbuffGPS2[3]=='R' && cbuffGPS2[4]=='M' &&

    cbuffGPS2[5]=='C')

    {

    strncpy(latg,&cbuffGPS[20],2); // convert to googlemaps coordinatesstrncpy(latm,&cbuffGPS[22],7);

    strncpy(longg,&cbuffGPS[32],3);

    strncpy(longm,&cbuffGPS[35],7);

    latitudgoogle=(atof(latm))/60;

    longitudgoogle=(atof(longm)/60);

    sprintf(&latitud[1],"%.6f",latitudgoogle);latitud[0]=latg[0];

    latitud[1]=latg[1];

    sprintf(&longitud[2],"%.6f",longitudgoogle);

    longitud[0]=longg[0];

    longitud[1]=longg[1];

    longitud[2]=longg[2];

    }

    Convert to GoogleMaps format

    We must obtain latitude and longitude from the $GPRMC frame (cbuffGPS2), plus

    convert the values to decimal coordinates. Later they are stored in latitude and

    longitude variables.

    E l d A li ti

  • 8/12/2019 Mce Trackme User Eng

    32/38

    Examples and Applications

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    fprintf(SERIAL_GSM,"AT+CMGS=\"1512345678\"\r"); // put here the cell phone number that receives the SMS

    delay_ms(200);

    printf("http://maps.google.com/maps?q=-%s,+-%s+(TrackMe esta aqui)",latitude,longitude);

    delay_ms(100);

    fprintf(SERIAL_GSM,"%c",0x1a);output_high(led);

    while(input(PANIC)==0);

    Sending a GoogleMaps compatible link

    All we have to do is include the latitude and longitude variables, with the appropriate

    format, inside the GoogleMaps URL.

    User receives a SMS with a

    link that shows the location of the board.

    E l d A li ti

  • 8/12/2019 Mce Trackme User Eng

    33/38

    Examples and Applications

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    Sending data through GPRS

    We can send the information to GoogleEarth in real time through GPRS. The trick

    consists in sending the complete NMEA frame (without processing) to a TCP server.

    Then in the server, which can be our computer, we run an application that allows us tore transfer the received data through TCP to a Virtual COM Port. Finally we open

    GoogleEath and select that virtual port as data entry.

    This way we can see in real time the position and speed of the board in a GoogleEarth

    map.

    Examples and Applications

  • 8/12/2019 Mce Trackme User Eng

    34/38

    Examples and Applications

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    Storing data in the PIC internal memory

    Its also possible to store the complete frame in the PIC18F26J50 program memory and

    then convert this information to KML in the PC to open it with GoogleEarth or

    GoogleMaps.

    Loading the PIC firmware

  • 8/12/2019 Mce Trackme User Eng

    35/38

    Loading the PIC firmware

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    To load a new program to the PIC18F26J50, first we must conect the programmer to

    the 6 programming pins, open the program for the PICKit2 and select File->Import

    HEX

    The manufacture file is mce_trackme_2012.hex and it can be found inside the server

    Firmware folder. Then we click Write and the legend Programacin exitosa must

    appear concluded the verification.

    Loading the PIC firmware

  • 8/12/2019 Mce Trackme User Eng

    36/38

    Loading the PIC firmware

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    Its possible to change the register CONFIG settings without the need of recompiling

    the project, clicking on Configuration.

    The connecting and programming procedure is identical for the PIC18F26J50.

    Its also possible to use MPLAB in case of possessing a PICKIT 3 or ICD3.

  • 8/12/2019 Mce Trackme User Eng

    37/38

  • 8/12/2019 Mce Trackme User Eng

    38/38

    mcelectronics

    Buenos Aires - Argentina

    Septiembre 2012

    MCE TrackMe (GPS)

    Manual REV: 09042012

    Austria 1760 - OF 8

    Ciudad de Buenos Aires (1425).

    BA. Argentina.

    (011) 3531-4668

    www.mcelectronics.com.ar

    [email protected]

    www.mcelectronics.com.ar

    MCE TrackMe (GPS) - mcelectronics.com.ar 2012

    http://www.mcelectronics.com.ar/http://www.mcelectronics.com.ar/