Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPS automatic baud rate detection #4

Open
pjalocha opened this issue Oct 10, 2014 · 1 comment
Open

GPS automatic baud rate detection #4

pjalocha opened this issue Oct 10, 2014 · 1 comment

Comments

@pjalocha
Copy link
Contributor

could be done by switching between several standard rates as long as no valid NMEA frames are detected. Once the NMEA frames start arriving the speed should stay.
Algorithm is easy and should achieve correct speed within 10-20 seconds.

It can be very convenient, as one needs not to check eveyr time if the GPS speed matched the configured tracker speed.

@pyrog
Copy link
Contributor

pyrog commented Nov 24, 2016

Could use one of following algorithms:

STM32 boot loader baud rate detection

"Bootloader measures the signal length between rising edge of first 1 bit in 0x7F to the falling edge of the last 1 bit in 0x7F to deduce the baudrate value"

Source: STM32 microcontroller system memory boot mode

First character received by the STM32 boot loader:
0111 11110x7F
_<------>

First NMEA sentence sended by the GPS
$GPGGA,184155.422,,,,,0,00,,,M,0.0,M,,0000*5E

0010 01000x24$
__<--->__

The pattern to measure could be
0010 01000x24$
0100 01110x47G
0101 00000x50P
0100 01110x47G
0100 01110x47G
0100 00010x41A

0010 0100 0100 0111 0101 0000 0100 0111 0100 0111 0100 0001

Detect a pattern sended at differents speed

// s is the first string received at 115200
 
switch (s) {
case 'OGN':
  baudrate = 115200;
  break;
case '`b#�':
  baudrate = 57600;
  break;
case '`sÌrÈ':
  baudrate = 38400;
  break;
…
}
  • GPS send at 115200 bauds, tracker receive at 115200
OGN Tracker Console.
$PSRF150,1*3E
$GPGGA,193512.912,,,,,0,00,,,M,0.0,M,,0000*51
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
  • GPS send at 115200 bauds, tracker receive at 57600

b#� ¤��á§Çäb!ᧁ��§@ó$ �¦󆦥æ¥ÆÆÆÄ楄ÆFƆ�FÆƄ��@ó$ �ÆÆÆÆÆÆÆæb$ "�󆆦¥æ¥ÆÁÆÆÆ楅�¤ÆfƇEó$ �¦󆦥æ¥ÆÆÆÄ楄ÆFƆ�FÆƄ��Aó$ �ÆÆÆÆÆÆÆæb$ "�󆆦¥æ¥ÆÁ

  • GPS send at 115200 bauds, tracker receive at 38400 bauds
    sÌrÈ=̤ÿàªpbડ¨�ábbqrppRpRbàqó¨ᨊurrrrrb¡¨j±X�ñ99±+8i(ý¨񱨊ábbprppRpRbàqó¨ᨊurrrrrb¡¨j±XGð99±+8i(ý�çÁ=ó𱈨�ábâqbavpñaRqprapRàq!rèᨊõâbbbbbrrâqrq⡨j????X�0°±\ruâbññqrÃ�çÁ{ó∨�ábòpbavpñ¡???
    `
  • GPS send at 115200 bauds, tracker receive at 19200 bauds
zFÿþþXR                                                                      
         JBþHJ                                                               
               JPXþ                                                          
                     HH                                                      
                       þHJJJZþ°yHXBZJRJX                                     
                                          �BXJHXJRHX        
                                                     RüBXXBþ
                                                            HJRHX
                                                                  RüXJ
                                                                       B
                                                                      þHBRþXBR

If the GPS don't start with the same string, "simply" use a repeating pattern i.e. ($GPGGA,󆦥æ¥ÆÆÆ,ább)

GPS Autobaud algorithm on Arduino

https://github.com/rob42/FreeboardPLC_v1_2/blob/master/Gps.cpp#L89-L148

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants