Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

AVR(ATMEGA32) and GPS

Status
Not open for further replies.

zahra63

New Member
Hi,
I have a GPS pack that send serial data with "NMEA" format.I'm going to connect it to an AVR MCU (atmega32). The baud rate of the GPS output (nmea) is 4800 . I set the baud rate but I did'nt get the correct answer. I changed the frequency and after that data changed too but srill it was wrong. What should I do?
Should I chang the frequency or baud rate?
 
Assuming you've got the AVR set to correctly read 4800?, then there's nothing to change - either it's right, or it's not!.

Assuming it is right?, the data might need inverting? - If you're using a software UART you can simply do it in software, if it's a hardware UART you most probably need a hardware inverter.
 
I checked my GPS out data in the hyper terminal and I got the correct answer . And what do you mean about inverting?please explain it.
 
MAX232's invert the polarity of the data passing through them, so UART's are generally designed to use inverted signals, and the MAX232 inversion corrects it. If you're not using a MAX232, then you need an inverter of some kind.

My PIC RS232 tutorial goes into more detail, the PIC part might not help you much, but the RS232 part will.
 
But I'm reading data from a PS2 port of the GPS which doesn't need to be inverted.I connected the GPS to the MCU by using this port.
the GPS has got a female ps2 port which is connected to it directly and a cable for connecting tothe pc that has got 3 head, one of them is male ps2 for the GPS and another male PS2 for power and a rs232 for data.
and we show the information in a LCD.
 
If the output from the GPS can go directly to the PC then it must be correct RS232 polarity (assuming there's no inverter and level converter in the lead?), so add a MAX232 to your AVR serial pins.
 
the female ps2 that we used it, has got 2 kind of data that one of them is rs232 and another one is TTL , we connected the TTL level pin to the MCU.
 
Try using a Resistor (say 10k) and a 5v1 zener to pull the level of the RS232 output to 5Volts. Now feed this signal into the Atmel, if it all works well, then the TTL output is probably inverted :(

GPS RS232--------[10k]--O-------ATMEL Input
_____________________~ |
____________________~ ----
___________________~ |5v1|
____________________~ ----
_____________________~ |
____________________~ 0V

Sorry about the _ and ~, editor won't allow just spaces :(

You could also try the other method of inverting the TTL output, either through a logic gate or a transistor/resistor arangement.


Sorry, I have never played with Atmels, although I must get around to it!

Hope this helps.
 
Last edited:
Matt(Pic progger) said:
Sorry about the _ and ~, editor won't allow just spaces :(

Should have used the 'Code' button, this prevents the browser removing the spaces!.

Code:
GPS RS232--------[10k]--O-------ATMEL Input
                        |
                      ----
                      |5v1|
                      ----
                        |
                       0V
 
Ok, thanks for the advice, if I can find the code button, I will use it ;)

Also I should have drawn the circut a bit nicer...... but CBA in the end ;) :)
 
I checked all pins with a scope and the TTL level pin (TXD and RXD) are positive (0 to 5) so I don't have to invert them ,
 
zahra63 said:
I checked all pins with a scope and the TTL level pin (TXD and RXD) are positive (0 to 5) so I don't have to invert them ,

They are going to be positive regardless, but which level represents a '1' and which a '0'.
 
Hi

Give type and brand of your GPS receiver and we will check it out for you in the datasheet. however, you wrote:

I checked my GPS out data in the hyper terminal and I got the correct answer . And what do you mean about inverting?please explain it.

As, many already has pointed out, if you could connect the GPS directly to a PC and monitor it on hyperterminal, then you do need an level converter in between the AVR and GPS.

Best regards
Z
 
Hi,
My GPS is GM-R500 evermore .
As I said , my GPS generates 2 kinds of information , TTL level and RS232 level.
I use the TTL level , but I'm not sure if it is inverted or not.I have to check it.
 
zahra63 said:
Hi,
My GPS is GM-R500 evermore .
As I said , my GPS generates 2 kinds of information , TTL level and RS232 level.
I use the TTL level , but I'm not sure if it is inverted or not.I have to check it.

Add a MAX232 to your AVR serial port, and use the RS232 level - that way you KNOW it's all correct. You can also then connect the AVR/MAX232 to your PC and use HyperTerminal to test it.
 
Looking at the specification for your unit it says (and I admit I missed the point in your earlier posts) that this unit has PS/2 and RS232 and USB.

Well the PS/2 protocol, accroding to this page....
https://www.networktechinc.com/ps2-prots.html
Has a parity bit before the stop bit, you will need to deal with this, possiby you have not set parity on the PC? Mind you I am not 100% sure you can feed PS/2 data into a serial port (even with level shifting etc), is it standard serial Comms?? Anyone??

Anyway, do what Nigel said, you should be fine ;)

Oh, and here is another page to get you really confused about circuits for inverting RS232 ;)


Hope this helps!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top