Go Down

Topic: Trouble in acquiring NEO6M GPS data through S-Function builder at simulink usin (Read 410 times) previous topic - next topic

praneethshub

I have connected NEO6M GPS module to Arduino Mega 2560 and programmed using TinyGPS++ library's "Device Example" and i getting proper data at serial port.

NEO6MGPS to ArduinoMega2560
Vcc           3.3volts
GND           GND
TX            Pin10
RX            Pin9

My need is to display only the latitude and longitude information through writing NEO6M driver S-function at matlab

I have created S-function for NEO6M-GPS for ArduinoMega2560 at Matlab to output latitude longitude alone from TinyGPS++ "Device Example" code with following:

Code: [Select]
Initilization:

No of discrete states:1
Sample mode: Discrete
Sample time value: 0.1

Data Properties:

Two "Output ports" are defined latitude & longitude of data type int32

Libraries:

# ifndef MATLAB_MEX_FILE
#define ARDUINO 100
#include <Arduino.h>
#include "TinyGPS++.h"
#include "TinyGPS++.cpp"
#include "SoftwareSerial.h"
#include "SoftwareSerial.cpp"
TinyGPSPlus gps;
SoftwareSerial ss(10, 9);
#endif

Outputs:

    if(xD[0] == 1)
    {
      #ifndef MATLAB_MEX_FILE
      while (ss.available() > 0)
      gps.encode(ss.read()); 
      if (gps.location.isValid())   
      {
        latitude[0]=gps.location.lat();
        longitude[1]=gps.location.lng();   
      }   
      else   
      {
        Serial.print("0");   
      }
      #endif
    }

Discrete Update:

    if(xD[0]!=1)   
    {   
      # ifndef MATLAB_MEX_FILE   
      Serial.begin(115200);     
      ss.begin(9600);   
      # endif   
      xD[0]=1;   
    }




Note: I am successful in building the s function and changing the wrapper name to .cpp and editing with addition of extern "C" at appropriate lines. And able to deploy on target hardware.

Code: [Select]
"### Done invoking postbuild tool."  "### Successfully generated all
binary outputs." AVR Memory Usage
---------------- Device: atmega2560 Program:   11082 bytes (4.2% Full) (.text + .data + .bootloader) Data:       1066 bytes (13.0% Full)
(.data + .bss + .noinit)



During live simulation run i don't observe any output in the scope/display.

My question is do i have any logical errors in writing code at "output" part of s-function or misplacing the code at other fields of s-function ?

I am okay to change my library, all i need is latitude and longitude displayed at simulink. Please do suggest necessary changes to be made.





Go Up