Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Problem in reading serial port


  • Please log in to reply
3 replies to this topic

#1 Krmped

Krmped

    New Member

  • Members
  • Pip
  • 5 posts

Posted 05 February 2012 - 05:01 PM

I am working on my first NetDuino+ project, and it has been a joy so far. The project: Supervision of an old Volvo Penta MD7A marine diesel in my sailboat: RPM, cooling water temperature, cooling water flow rate (both fresh and sea water) and GPS (mostly for time). The idea is to display the data on a LCD and sound an alarm, if it gets too hot, and to store data on the SD card.
Temperature and RPM is OK, but I am now trying to connect a GlobalSat BR-355 GPS receiver to COM1 on the NetDuino+. Unfortunately I only receive garbled data.
I have checked the settings of the port, and I believe it is OK. I have installed an old PC as an eaves-dropper on the serial data line and I log the following (correct – GPS has no fix) data starting with GPS power up:

$PSRFTXT,Version:GSW3.5.0_3.5.00.00-SDK-3EP2.01 *46
$PSRFTXT,Version2:F-GPS-03-1006231*2A
$PSRFTXT,WAAS Enable*66
$PSRFTXT,TOW:  58582*27
$PSRFTXT,WK:   1674*61
$PSRFTXT,POS:  3514706 779953 5247342*10
$PSRFTXT,CLK:  95996*27
$PSRFTXT,CHNL: 12*73
$PSRFTXT,Baud rate: 4800*65
$GPGGA,161851.213,,,,,0,00,,,M,0.0,M,,0000*5C
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,161851.213,V,,,,,,,050212,,,N*43
$GPGGA,161852.150,,,,,0,00,,,M,0.0,M,,0000*5B
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,161852.150,V,,,,,,,050212,,,N*44
$GPGGA,161853.150,,,,,0,00,,,M,0.0,M,,0000*5A
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,161853.150,V,,,,,,,050212,,,N*45
$GPGGA,161854.150,,,,,0,00,,,M,0.0,M,,0000*5D
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,161854.150,V,,,,,,,050212,,,N*42
$GPGGA,161855.150,,,,,0,00,,,M,0.0,M,,0000*5C
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,3,1,12,07,71,104,,13,38,087,,16,15,030,,23,10,092,34*76
$GPGSV,3,2,12,10,55,172,,08,55,193,,05,49,291,,02,22,237,*7B
$GPGSV,3,3,12,26,16,269,,04,06,207,,06,03,044,,03,03,057,*74
$GPRMC,161855.150,V,,,,,,,050212,,,N*43
$GPGGA,161856.150,,,,,0,00,,,M,0.0,M,,0000*5F
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,161856.150,V,,,,,,,050212,,,N*40
$GPGGA,161857.150,,,,,0,00,,,M,0.0,M,,0000*5E
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,161857.150,V,,,,,,,050212,,,N*41
$GPGGA,161858.150,,,,,0,00,,,M,0.0,M,,0000*51
$GPGSA,A,1,,,,,,,,,,,,,,,*1E


But when I read it from the serial port on the ND+ I get the following bytes (not the same as above):

155 92 37 137 233 57 211 102 166 166 153 230 153 52 101 99 153 154 101 101 153 102 52 101 103 101 153 154 44 154 166 102 38 230 102 51 166 204 76 204
 154 93 154 230 154 38 230 154 102 204 52 101 154 89 154 153 103 52 101 154 89 154 154 230 230 230 102 205 153 151 121 61 155 92 37 165 57 211 57 211
 230 154 51 102 154 103 102 154 103 50 154 154 154 154 154 154 154 154 154 154 154 154 53 103 95 121 61 155 92 101 150 94 154 103 50 103 101 230 153 52
 101 99 153 154 42 154 101 101 153 102 52 101 103 101 153 154 44 154 166 102 38 230 102 51 166 204 76 204 154 93 154 154 154 166 153 102 166 102 230 154
 154 154 44 53 100 103 121 61 155 92 37 137 233 57 211 102 166 166 153 166 153 52 101 99 153 154 101 101 153 102 52 101 102 102 101 154 44 154 166 102
 38 230 102 19 166 230 76 230 93 154 230 154 38 230 154 154 102 204 52 101 154 89 154 153 103 52 101 154 89 154 154 230 230 230 102 205 95 121 61 155
 92 37 165 57 211 57 211 230 154 51 102 154 103 102 154 103 50 154 154 154 154 154 154 154 154 154 154 154 154 53 103 95 121 61 155 92 101 150 94 154
 103 50 103 101 166 153 52 101 99 153 154 42 154 101 101 153 102 52 101 102 102 101 154 44 154 166 102 38 230 102 19 166 230 76 230 154 93 154 154 154
 166 153 102 166 102 230 154 154 154 44 53 100 50 121 61 155 92 37 137 233 57 211 102 166 166 153 102 102 83 166 204 153 154 101 101 153 102 52 101 103
 102 204 154 44 154 166 102 38 230 102 51 38 230 166 204 154 93 154 230 154 38 230 154 102 204 52 101 154 89 154 153 103 52 101 154 89 154 154 230 230
 230 102 205 153 102 121 61 155 92 37 165 57 211 57 211 230 154 51 102 154 103 102 154 103 50 154 154 154 154 154 154 154 154 154 154 154 154 53 103 95
 121 61 155 92 101 150 94 154 103 50 103 101 102 102 83 166 204 153 154 42 154 101 101 153 102 52 101 103 102 204 154 44 154 166 102 38 230 102 51 38


Many of the received characters are greater than 127, which is incorrect and the reason why (I guess) I cannot use the encoding without exceptions.
More info: The GPS is powered from the ND+’s 5 volt. I experimented quite a bit with baud rates, stop bits, timeouts, data bits etc., but no luck.

Here is my code:

namespace Serial_Port_test
{
    public  class Constants{
         public const  int  MaxVal = 40;
    }

    public class Program
    {
        static SerialPort com;
        static byte[] ByteBuffer = new byte[Constants.MaxVal];
        static int index = 0;

        public static void Main()
        {
            com = new SerialPort(SerialPorts.COM1, 4800, Parity.None, 8, StopBits.One);
            com.DataReceived += new SerialDataReceivedEventHandler(com_DataReceived);
            com.Handshake = Handshake.None;
            com.Open();

            Thread.Sleep(Timeout.Infinite);
        }

        static void com_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            byte[] bytes = new byte[1];
            com.Read(bytes, 0, bytes.Length);
            ByteBuffer[index++] = bytes[0];

            if (index >= Constants.MaxVal)
            {
                string line ="";

                for (int i = 0; i < Constants.MaxVal; i++)
                {
                    line = line + " " + ByteBuffer[i].ToString();
                }
                Debug.Print(line);
                index = 0;
            }
        }
    }
}


Any ideas as to what could be the problem?

Best regards,
Kristian
Copenhagen

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 05 February 2012 - 05:33 PM

Hi Kristian, Is the GPS receiver sending serial data at TTL voltages (0-3.3V or 0-5V) or at RS232 voltages (-1tV to 15V)? It's possible that you're accidentally feeding excessive voltages into pins 1/2. If you've been plugging the serial cable directly into your PC...you'll need an RS232-TTL serial adapter (or RS232 shield) for your Netduino. Welcome to the Netduino community, Chris

#3 Krmped

Krmped

    New Member

  • Members
  • Pip
  • 5 posts

Posted 19 February 2012 - 09:24 PM

Hi Chris. You were right. I have now installed a RS232 shield, and the ND+ now reads correctly the NMEA sentences. Best regards, Kristian.

#4 bene331

bene331

    New Member

  • Members
  • Pip
  • 4 posts
  • LocationDenmark

Posted 20 February 2012 - 08:13 PM

Hi Kristian of Copenhagen Trigged by your project I have to a comment. I am also making ND+ for a sailboat project (in Frederikssund) monitoring the battery states of the service package. But to my comment. Having added a PC serial port to the NMEA data directly I killed info to the other instruments. Even the NMEA differential signal should be similar to the RC232 it is not. The PC dragged the NMEA signal level down and my auto rudder failed. I added an opto coubler that did the trick. Just a cheap solution. By the way: do you have an already made NMEA intepreter function I can have. Henning of Jyllinge




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.