- SF800 Solar Speicher Tutorial         
Ergebnis 1 bis 10 von 12

Thema: RP6 im Space

Hybrid-Darstellung

Vorheriger Beitrag Vorheriger Beitrag   Nächster Beitrag Nächster Beitrag
  1. #1
    Erfahrener Benutzer Robotik Einstein Avatar von Dirk
    Registriert seit
    30.04.2004
    Ort
    NRW
    Beiträge
    3.803
    @Spacecam:
    Ich werde am Wochenende mal schauen, ob ich ein "Basis-Programm" für dich zum Testen hinkriege.
    Melde mich dann ...
    Gruß
    Dirk

  2. #2
    Erfahrener Benutzer Robotik Einstein Avatar von Dirk
    Registriert seit
    30.04.2004
    Ort
    NRW
    Beiträge
    3.803
    @Spacecam:
    So, hier ein kurzes Programm, das auf dem LCD der M32 einige Daten des GPS-Moduls anzeigt.
    Das Programm ist ein "Parser", der aus dem Datenstrom die Teile herausschneidet, die du brauchst.
    Code:
    /* 
     * ****************************************************************************
     * RP6 ROBOT SYSTEM - RP6 CONTROL M32 Examples
     * ****************************************************************************
     * Example: NL-552ETTL
     * Author(s): Dirk
     * ****************************************************************************
     * Description:
     * Now we will use the UART to read data from the NL-552ETTL GPS module
     * (ELV No. 94241) with the u-blox5 UBX-G5000-BT GPS chipset.
     *
     * The NL-552ETTL TX pin (4) has to be connected to RP6 CONTROL pin RXD
     * (PROG_UART: 2). The internal pullup resistor of RXD should be
     * deactivated!
     *
     * ****************************************************************************
     * NMEA 0183 short description:
     * 1. GPRMC:
     * $GPRMC,213938.000,A,5108.3356,N,00951.0774,E,0.00,79.64,061012,,,A*53
     * Index: 1          2 3         4 5          6 7    8     9        12CS
     *   1    = UTC of position [hhmmss.sss]
     *   2    = Data status (A=ok, V=void)
     *   3    = Latitude of fix [ddmm.mmmm]
     *   4    = N or S
     *   5    = Longitude of fix [dddmm.mmmm]
     *   6    = E or W
     *   7    = Speed over ground in knots
     *   8    = Track made good, degrees true
     *   9    = UT date [ddmmyy]
     *   10   = Magnetic variation degrees (Easterly var. subtracts from true course)
     *   11   = E or W
     *   12   = Mode indicator (NMEA V2.3):
     *          A=Autonomous mode
     *          D=Differential mode
     *          E=Estimated (dead-reckoning) mode
     *          M=Manual input mode
     *          S=Simulated mode
     *          N=Data not valid
     *   CS   = Checksum
     *
     * 2. GPVTG:
     * $GPVTG,79.64,T,,M,0.00,N,0.0,K,A*31
     * Index: 1     2  4 5    6 7   8 9 CS
     *   1    = Track made good
     *   2    = Fixed text 'T' indicates that track made good is relative to true north
     *   3    = Track degrees
     *   4    = M=Magnetic
     *   5    = Speed over ground in knots
     *   6    = Fixed text 'N' indicates that speed over ground is in knots
     *   7    = Speed over ground in kilometers/hour
     *   8    = Fixed text 'K' indicates that speed over ground is in kilometers/hour
     *   9    = Mode indicator (A,D,E,M,S,N)
     *   CS   = Checksum
     *
     * 3. GPGGA:
     * $GPGGA,213938.000,5108.3356,N,00951.0774,E,1,04,5.3,158.5,M,46.2,M,,0000*52
     * Index: 1          2         3 4          5 6 7  8   9       11   12 14   CS
     *   1    = UTC of position
     *   2    = Latitude of fix
     *   3    = N or S
     *   4    = Longitude of fix
     *   5    = E or W
     *   6    = GPS quality indicator:
     *          0=invalid
     *          1=GPS fix (SPS)
     *          2=DGPS fix
     *          3=PPS fix
     *          4=Real Time Kinematic
     *          5=Float RTK
     *          6=estimated (dead reckoning) (NMEA V2.3)
     *          7=Manual input mode
     *          8=Simulation mode
     *   7    = Number of satellites in use [not those in view]
     *   8    = Horizontal dilution of position (HDOP)
     *   9    = Antenna altitude above/below mean sea level (geoid)
     *   10   = Meters  (Antenna height unit)
     *   11   = Geoidal separation (Diff. between WGS-84 earth ellipsoid and
     *          mean sea level.  -=geoid is below WGS-84 ellipsoid)
     *   12   = Meters  (Units of geoidal separation)
     *   13   = Age in seconds since last update from diff. reference station
     *   14   = Differential reference station ID#
     *   CS   = Checksum
     *
     * 4. GPGSA:
     * $GPGSA,A,3,02,04,10,07,,,,,,,,,7.4,5.3,5.1*33
     * Index: 1 2 3  4  5  6          15  16  17  CS
     *   1    = Selection mode:
     *          M=Manual, forced to operate in 2D or 3D
     *          A=Automatic 2D/3D
     *   2    = Mode:
     *          1=no fix
     *          2=2D
     *          3=3D
     *   3-14 = IDs of SVs used in position fix (null for unused fields)
     *   15   = PDOP
     *   16   = HDOP
     *   17   = VDOP
     *   CS   = Checksum
     *
     * 5. GPGSV:
     * $GPGSV,3,1,12,02,36,301,37,04,53,235,21,05,03,294,,07,35,170,29*79
     * $GPGSV,3,2,12,08,04,187,28,10,56,290,36,13,88,106,20,16,12,076,*7D
     * $GPGSV,3,3,12,20,23,118,11,23,50,067,,29,03,351,12,30,16,048,22*70
     * Index: 1 2 3  4  5  6   7  8  9  10   12 13 14  15 16 17 18  19 CS
     *   1    = Total number of messages of this type in this cycle 
     *   2    = Message number 
     *   3    = Total number of SVs in view 
     *   4    = SV PRN number
     *   5    = Elevation in degrees, 90 maximum 
     *   6    = Azimuth, degrees from true north, 000 to 359 
     *   7    = SNR, 00-99 dB (null when not tracking) 
     *   8-11 = Information about second SV, same as field 4-7 
     *   12-15= Information about third SV, same as field 4-7 
     *   16-19= Information about fourth SV, same as field 4-7
     *   CS   = Checksum
     *
     * 6. GPGLL:
     * $GPGLL,5108.3356,N,00951.0774,E,213938.000,A,A*5C
     * Index: 1         2 3          4 5          6 7 CS
     *   1    = Latitude of fix
     *   2    = N or S
     *   3    = Longitude of fix
     *   4    = E or W
     *   5    = UTC of position
     *   6    = Data status (A=ok, V=void)
     *   7    = Mode indicator (A,D,E,M,S,N)
     *   CS   = Checksum
     *
     * COMMENTS:
     * a) Each sentence (line) begins with '$'.
     * b) Each sentence (line) ends with '*', followed by the checksum (two
     *    chars building an 8-bit HEX number) and terminated by <CR><LF>.
     * c) The checksum (CS) is calculated by XOR of all chars between '$' and '*'.
     * d) The max. sentence (line) length is 82 chars (including <CR><LF>).
     * e) Further infos:
     *    -> http://www.nmea.org/
     *    -> http://www.kowoma.de/gps/zusatzerklaerungen/NMEA.htm
     *    -> http://de.wikipedia.org/wiki/NMEA_0183
     *    -> http://aprs.gids.nl/nmea/
     *
     * ############################################################################
     * The Robot does NOT move in this example! You can simply put it on a table
     * next to your PC and you should connect it to the PC via the USB Interface!
     * ############################################################################
     * ****************************************************************************
     */
    /*****************************************************************************/
    // Includes:
    #include "RP6ControlLib.h"   // The RP6 Control Library. 
            // Always needs to be included!
    /*****************************************************************************/
    // Variables:
    uint8_t ch;
    char item[12];
    /*****************************************************************************/
    // NL-552ETTL functions:
    char parseBuffer[256];
    uint16_t parseBuffer_length = 0;
    uint8_t parseBuffer_pos = 0;
    /**
     * Clears the parseBuffer 
     */
    void clearParseBuffer(void)
    {
     parseBuffer_pos = 0;
     parseBuffer_length = 0;
    }
    /**
     * Writes received byte data into buffer parseBuffer and returns if a full
     * NMEA sentence has been received. Then the buffer is terminated with 0.  
     * Returns 0 if a sentence has been detected and buffer is ready.
     * Returns 1 if no sentence has been received yet
     * Returns 2 if buffer overflow occured 
     */
    uint8_t parseNMEAsentence(char *sentence, uint8_t data)
    {
     static uint8_t startflag = false;
     static char last_data[10];
     uint16_t length = 0;
     uint8_t i = 0;
     if(data == 0) return 1;
     while (sentence[i++]) length++;
     if(length > 10) length = 10;
     for(i = 0; i < 9; i++) last_data[i] = last_data[i + 1];
     last_data[9] = data;
     parseBuffer[parseBuffer_pos] = data;
     parseBuffer_pos++;
     parseBuffer_length++;
     if(parseBuffer_pos > 254) {
      clearParseBuffer();
      startflag = false;
      return 2;
     }
     if(!startflag && (strstr(last_data, sentence) != NULL)) { // Chosen sentence start
      for(i = 0; i < length; i++) {
       parseBuffer[i] = sentence[i];
      }
      parseBuffer_pos = length;
      parseBuffer_length = length;
      startflag = true;
     }
     if(startflag) {
      if(data == '\r') {    // Chosen sentence end
       parseBuffer[parseBuffer_pos] = 0;
       last_data[9] = 0;
       startflag = false;
       return 0;
      }
     }
     return 1;
    }
    /**
     * Outputs true, if the NMEA sentence in parseBuffer is intact,
     * else returns false.
     */
    uint8_t checkNMEAsentence(void)
    {
     uint8_t i, cs;
     char cs_str[3];
     if(parseBuffer_length < 18) return false;
     if(parseBuffer_length > 82) return false;
     if(parseBuffer[0] != '$') return false;
     if(parseBuffer[parseBuffer_length - 4] != '*') return false;
     cs = parseBuffer[1];
     for(i = 2; i < (parseBuffer_length - 4); i++) {
      cs ^= parseBuffer[i];   // Calculate checksum
     }
     itoa(cs, &cs_str[0], HEX);
     strupr(&cs_str[0]);    // cs as uppercase chars
     if((cs_str[0] != parseBuffer[parseBuffer_length - 3])
      || (cs_str[1] != parseBuffer[parseBuffer_length - 2])) return false;
     return true;
    }
    /**
     * Outputs a result string containing the data with index of the NMEA
     * sentence in parseBuffer.
     */
    void parseNMEAitem(char *result, uint8_t index)
    {
     uint8_t index_cnt, buffer_idx, result_idx;
     index_cnt = index;
     buffer_idx = 6;
     while(index_cnt) {
      if(parseBuffer[buffer_idx++] == ',') index_cnt--;
     }
     result_idx = 0;
     while ((parseBuffer[buffer_idx] != ',')
      && (parseBuffer[buffer_idx] != '*')) {
      result[result_idx++] = parseBuffer[buffer_idx++];
     }
     result[result_idx] = 0;
    }
    
    /*****************************************************************************/
    // Main function - The program starts here:
    int main(void)
    {
     initRP6Control(); // Always call this first! The Processor will not work
           // correctly otherwise. 
     initLCD(); // Initialize the LC-Display (LCD)
          // Always call this before using the LCD!
     setLEDs(0b1111);
     mSleep(500);
     setLEDs(0b0000);
     // Write a text message to the LCD:
     showScreenLCD("################", "################");
     mSleep(1500);
     showScreenLCD("<<RP6  Control>>", "<<LC - DISPLAY>>");
     mSleep(2500); 
     showScreenLCD("   NL-552ETTL", "Example Program");
     mSleep(2500);
     clearLCD(); 
     while (true) {
      clearParseBuffer();
      clearReceptionBuffer();
      while(parseNMEAsentence("$GPGGA", ch)) {
       ch = readChar();
      }
      if(checkNMEAsentence()) {
       setCursorPosLCD(0, 0);  // line 1
       parseNMEAitem(item, 3);
       writeStringLCD(item);
       parseNMEAitem(item, 2);
       writeStringLCD(item);
       writeCharLCD('m');
       parseNMEAitem(item, 9);
       writeStringLCD(item);
       setCursorPosLCD(1, 0);  // line 2
       parseNMEAitem(item, 5);
       writeStringLCD(item);
       parseNMEAitem(item, 4);
       writeStringLCD(item);
       writeCharLCD('s');
       parseNMEAitem(item, 7);
       writeStringLCD(item);
       writeCharLCD('q');
       parseNMEAitem(item, 6);
       writeStringLCD(item);
      }
      else {
       showScreenLCD("Sentence NOT OK!", "----------------");
      }
      mSleep(10000);
     }
     return 0;
    }
    Du lädst das Programm in die M32 und startest es. Dann Stecker vom PROG_UART abziehen und den TX-Pin des GPS-Moduls (Pin 4) mit Pin 2 des PROG_UART Steckers verbinden. Dann warten, bis Daten angezeigt werden.
    Viel Erfolg!
    Gruß
    Dirk

Ähnliche Themen

  1. Gerücht: Dead Space 3 in ewigem Eis
    Von Roboternetz-News im Forum Neuigkeiten / Technik-News / Nachrichten / Aktuelles
    Antworten: 0
    Letzter Beitrag: 27.09.2011, 09:20
  2. bin am verzweifeln mit out of sram space
    Von graffiti im Forum Basic-Programmierung (Bascom-Compiler)
    Antworten: 6
    Letzter Beitrag: 09.04.2009, 13:35
  3. Byte Variable - out of SRAM space
    Von Barthimaeus im Forum Basic-Programmierung (Bascom-Compiler)
    Antworten: 5
    Letzter Beitrag: 19.11.2007, 14:17
  4. HS-Space / TS-Space (HSL/TSL)
    Von troede im Forum Software, Algorithmen und KI
    Antworten: 0
    Letzter Beitrag: 04.09.2006, 21:10
  5. Verstrahlte AVRs in space
    Von tobimc im Forum AVR Hardwarethemen
    Antworten: 21
    Letzter Beitrag: 01.10.2005, 20:55

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

fchao-Sinus-Wechselrichter AliExpress