Connecting 2GPS module With ATMega64

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello

 

i want to connect 2 UBLOX NEO 7M GPS Module with 2 usart port with ATMEGA64 and showing their data on 4*20 LCD. But i have a problem about reading data from this 2 Module simultaneously in codevision AVR.

CAN You help me about this issue???

Last Edited: Tue. Jul 16, 2019 - 07:42 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to the Forum.

 

Obviously you need to start with one GPS module.

 

Do you have the LCD up  and running?

 

Can your read (stream) GPS data to it?

 

Once you can do that, then work on your GPS data parser, to capture desired data, and display it on the LCD.

 

When you have one gps up and running, then think about adding the second unit.

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sina.asaian wrote:
from this 2 Module simultaneously
Define "simultaneously". Obviously:

reading1 = GPS.read(1);
reading2 = GPS.read(2);

is quite possible but "simultaneously" is trickier. What you can do is implement two RXC receive interrupts - one for each GPS so that the reception of the individual characters in the message strings alternates.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Or you could do something like this in your main loop:

 

if (UartA character ready) Handle character from UART A
if (UartB character ready) Handle character from UART B

Handle character would likely be adding it to a buffer. Then you can inspect the buffers to decide if its time to do something like write to the display.

The largest known prime number: 282589933-1

It's easy to stop breaking the 10th commandment! Break the 8th instead. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i started atmega64 with one avr and saw latitude and longtitude on LCD. i want to devide 2GPS data which received from 2 GPS module in codevision and showing latitude and longtitude of each GPS in lcd separately. my main problem is a code which receive data from each gps module which connected with usart and save received data in string.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i want to devide 2GPS data

At the end of the day the GPS are simply going to be input from UART0 or UART1 in the AVR code. The data is already divided. So you put the characters from UART0 into one buffer and the characters from UART1 into another buffer. When either reaches the "end of sentence" you then pass the whole buffer full to your NMEA parsing routines to pick out the Lat/Long. If the buffer is for UART0 you show it on the display for one GPS and if it the buffer for UART1 you show the result in the other display position.

 

It would actually be quite tricky to combine both!

 

Or were you perhaps relying on the fact that Codevision by default has just ONE of the UARTs connected to the POSIX stdio functions and you are using those to access the data?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i used scanf code in my codevision code for reading data from usart and i don't know scanf command reading the data from usart0 or usart1. i want a code or command that can read the information of each uart separately.

I am not very professional in avr and I got stuck on this issue.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

how can i write a code with this strategy in codevisin AVR (C Language) :

 

if (UartA character ready) Handle character from UART A
if (UartB character ready) Handle character from UART B
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The STDIO functions (getchar/putchar/puts/printf/scanf/etc) can only be attached to one UART at a time so you may need to wind back a bit. The lower level interface to the uarts are going to be simply get and put functions. So you may want to access at that level rather than scanf. If you really need to use scanf then for one of the UARTs consider buffering the characters separately until you have a compete NMEA sentence than use sscanf() rather than scanf() on the buffered characters.

EDIT: OK a quick Google brought me back to Freaks and this thread:

 

https://www.avrfreaks.net/forum/gets-second-uart-port

 

Answers from Lee Theusch will be definitive so if he says that in a dual UART system that there are  putchar0()/getchar0(), and putchar1()/getchar1() then that will be the case. So for one of the UARTs just use getcharN(). Build a buffer then pass that to your NMEA parser. Actually to be homogeneous I guess you want to do both channels in the same way so you can use the same parsing technique for both. So you might want to skip "stdio" and just do get getcharN()/getsN()

Last Edited: Thu. Jul 18, 2019 - 11:13 AM