Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to use Multiple Serial Ports?

Status
Not open for further replies.

ANTI_HACKER

Member level 3
Member level 3
Joined
Sep 1, 2012
Messages
56
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,722
I am designing gps and gsm based vehicle tracking system using atmega16 as the MC. Atmega16 has single uart port while i need two uart ports to connect gps and gsm simultaneously what shoud i do two connect both with atmega16?
Thanks in Advance!
 

Hello!

If your system has only 1 UART, I think you have only one solution: use a switch chip to multiplex
your signals. But at the end, it might be a more expensive solution than choosing another chip
with 2 UARTs. And it will take more space on the PCB, and it might be not as reliable as a solution
with 2 UARTs.

Dora.
 

Another possible cost effective option is the implementation of a software UART or softUART, although they tend to offer limited BAUD rates.

You would need to connect the device requiring the higher baud rate, most likely the GSM modem and then use the softUART for the GPS.

Some GPSs can be configured to operate at lower BAUD rates which would be preferable.

Other options include I2C/SPI to UART bridge devices, several manufactures offer these devices including NXP and Maxim. However as Dora suggested the cost to implement these options could easily exceed the cost of using another MCU with more UARTs.

SC16IS740/750/760



Unfortunately, both softUARTs and the multiplexing, as Dora suggested, have their drawbacks.

And while the I2C/SPI to UART devices offer superior performance and reliability, they can significantly increase the cost of the design.

I would seriously consider selecting a different MCU which offers two UARTs.

BigDog
 

its very simple, you can do it by using relays, it worked for me.
 
  • Like
Reactions: DrWhoF

    DrWhoF

    Points: 2
    Helpful Answer Positive Rating
Data from GPS does not arrive at faster rate as 1-per-sec, so you have plenty of time to retrieve data from gsm.
I'd use normal AND or NAND gates and 1or2 microcontroller pins to select which device is connected to the UART.
 
  • Like
Reactions: IanP

    IanP

    Points: 2
    Helpful Answer Positive Rating
Hello!

@bigdog: indeed, I forgot the soft UART solution.

Beside this, I would not recommend a relay. As it is a mechanical device, it will get
damaged very quickly.
Suppose that you do the following process:
- Set to GPS
- Wait for data, and get one data frame
- Set to GSM
- Send data

You will do this process every time the GPS gets new data. Once per second for older
modules, a lot more for recent modules.
If you switch your relay on and off 100 000 times a day, you will have no relay anymore
after a few days. (OK, one day is 86400 seconds only, not 100 000).
Beside this, the power consumption of a relay is quite high compared to a multiplexer.
On top of that, I don't know the voltage of your application, but the 3.3V relays are not
so common. I have used some made by Omron in the past (they have a 3V version).
Add to that the fact that a relay is huge and probably more expensive than a 2-UART MCU...
And last point: when setting a relay on or off, there are chances that you get glitches
on your data line.
For that kind of application, a relay seems close to the worst possible solution.

You can have an MCU with 2 UARTs for less than 2 USD these days.

Dora.
 
Of course it largely depends on your locale, however I can buy an ATMEGA162, which is basically an upgraded ATMEGA16 with two UARTs, for slightly more than an ATMEGA16.

BigDog
 

check out my circuit.. it worked for me.


**broken link removed**
 

check out my circuit.. it worked for me.


**broken link removed**

it wont be a robust solution.. it would be bettre to use soft uart or just use a micro with 2 uarts. Relays would get damaged after some time . further more it will produce lot of noise in the circuit. Using 2 usarts wont waste the data as well.
 

Hi
For Connecting the 2nd serial u can use the separate ic which is supporting the serial communication through the interrupt, with the Micro controller,
and more over u just go through the following data sheet which ia capable for 2nd uart communication.


Device : MC16C550
 

It would be better to go for softuart. For this project (if you have enough space and speed) gps can be connected to softuart and gsm modem can be connected to hardware uart. I had done a similar project with M32 long time ago.
 
  • Like
Reactions: IanP

    IanP

    Points: 2
    Helpful Answer Positive Rating
If you do implement a softUART I would suggest keeping the BAUD rate at 9600 or lower, actually 4800 usually works well with a MCU like the AVR.

A BAUD rate of 9600 usually requires several tweaks before the softUART provides any degree of reliability implemented on a 16MHz AVR.


BigDog
 
  • Like
Reactions: IanP

    IanP

    Points: 2
    Helpful Answer Positive Rating
If you do implement a softUART I would suggest keeping the BAUD rate at 9600 or lower, actually 4800 usually works well with a MCU like the AVR.

The GPS' default speed is 4800, so that should work ok ..
IanP
 
  • Like
Reactions: DrWhoF

    DrWhoF

    Points: 2
    Helpful Answer Positive Rating
While I believe that once was the case, some of the new GPS modules actually default at 9600, although the modules BAUD rates are typically configurable to 4800.

Example, Reference Page 2:
VENUS634FLPx 65 Channel Low Power GPS Receiver

BigDog
 
  • Like
Reactions: DrWhoF

    DrWhoF

    Points: 2
    Helpful Answer Positive Rating
it wont be a robust solution.. it would be bettre to use soft uart or just use a micro with 2 uarts. Relays would get damaged after some time . further more it will produce lot of noise in the circuit. Using 2 usarts wont waste the data as well.

but it worked perfectly for me, and i didnt face any noise problem in circuit also.
 

everything i made it in a program itself, so whenever i want to receive or transmit a signal, i made some perfect delay for enabling the relays. that delay calculation is very important.
 

Can you give a brief understanding of how to use the softuart? I mean how would I connect a software with the hardware? I'll search it up but give me some basic knowledge how should i use the softuart for my gps
P.S. my gps bydefault runs on 9600baud
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top