This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Interfacing CD4052 with 2 uarts in 8051

Hey all,

I am doing a project on Vehicle Tracking System using GPS and GSM Modem.The 2 devices aforementioned communicates with 8051uC. But since there is only 1 UART in 8051 i have to use a analog multiplexer i.e CD 4062. I want to know how to interface it with GPS, GSM, and 8051.

Also it would be grateful if anyone could tell me how to parse output of GPS and how initialize a GPS receiver to that it starts giving me the GPRMC

Parents
  • Oh no, here we go again!

    Since a fundamental part of your project is communicating with two serial devices, why not just use a processor with two UARTs?!

    Plenty exist: http://www.keil.com/dd/search_parm.asp

    "i have to use a analog multiplexer"

    Even if you do decide to make life difficult for yourself by using a multiplexer, Why does it have to be analogue?

    This school assignment comes up regularly - use the 'Search' facility on this site to find previous discussions here, and Google (or other search engine) to find them elsewhere...

Reply
  • Oh no, here we go again!

    Since a fundamental part of your project is communicating with two serial devices, why not just use a processor with two UARTs?!

    Plenty exist: http://www.keil.com/dd/search_parm.asp

    "i have to use a analog multiplexer"

    Even if you do decide to make life difficult for yourself by using a multiplexer, Why does it have to be analogue?

    This school assignment comes up regularly - use the 'Search' facility on this site to find previous discussions here, and Google (or other search engine) to find them elsewhere...

Children
  • Use a chip with two serial ports. Only then will you be able to receive data from the GSM at the same time that your GPS emits data. Using a chip with a single UART when multiple UARTS are needed is so 1980.

    See the documentation for your specific GPS to figure out what init strings you need to send to it.

    Decoding a GPRMC string should be a quite trivial operation. The checksum is trivial. Splitting it into individual parameter fields is trivial. Converting the individual fields is trivial. So really no need to post a lot of source that has been written with possibly different requirements in mind.

  • Hey thnx
    Can u all name a few uC's in the MCS51 / 52 range having 2 UARTS

  • Also can u provide me with some sample codes for GPS data parsing and GSM serial communication with a uC

  • Could you not manage to follow the link that I gave you earlier?

  • You haven't stated what GPS device(s) you're considering - so how can anyone give you a "sample" of how to parse the unknown data format(s) from unknown GPS device(s)?!

    Have you actually taken any time at all to study the documentation for the GPS device(s) you're considering, and thought about how you might parse whatever data format(s) it/they provide...?

    Here's a link to get you started: www.lmgtfy.com

    Similarly for the GSM device...

    Here's the general process for interfacing anything to anything else:

    www.8052.com/.../160143

  • I would be using a SIM300 GSM modem and a GPS receiver
    with SiRFstarIIe-chip-set.......Now can I have the sample codes.please
    Also I think irrespective of what GPS receiver u choose the output is just the same. All I want from the GPS is the RMC data

    Also if u could suggest me a better GPS which highly accurate and also affordable at the same time I would be grateful.

  • I would be using a SIM300 GSM modem and a GPS receiver
    with SiRFstarIIe-chip-set.......Now can I have the sample codes.please
    Also I think irrespective of what GPS receiver u choose the output is just the same. All I want from the GPS is the RMC data

    Also if u could suggest me a better GPS which highly accurate and also affordable at the same time I would be grateful.

  • No one (who actually knows what they are doing) is going to give you the code that you are looking for.

    The point of this assignment, and school in general, is to get YOU to learn how to do things for YOURSELF.

    You are correct that most GPS modules output a NMEA serial data stream, but YOU have to learn how to parse and handle that data.

    May of the people here are happy to help if you get stuck on a problem and are able to clearly articulate that problem and what you have done to try and fix it. None of us are interested in doing your homework for you.

    ND

  • See you are getting me all wrong. I wasn't even expecting you to do my homework and mind you It would be me that would be doing it all . I was just seeking info on how to parse the data because GPS' output would be a long string and and the data registers in 8051 would all be 8 bits so how would i manage saving such a long String.
    Just provide me with the logic and i'll definitely will reply you when I get the whole code written..
    By the way thanks but pls be there when i'm stuck somewhere PLSSSS

  • So. Now you asked a specific question.

    One possible route (and the possibilities are legio):

    char my_nmea_string[NMEA_BUF_SIZE];
    
    if (!strncmp(my_nmea_string,"$GPRMC",6)) {
        // almost there. just continue to gnaw characters
        // one at a time until reaching end of string
        ...
    }
    


    Or you can have the interrupt code (normally not so good idea but depends on what interrupt load you have, and timing requirements) have a state machine and process each receievd character based on current state. If currently waiting for a number you just check if character is field separator or part of the number.

    Whatever you do, you just have to process the received data character-by-character. Optionally after having collected a full text line in a buffer (and possibly verified the checksum). Just remember that the line break and the $ can be very handy for synchronizing if you start listening in the middle of a line.

    About processors with multiple UART - check parametric search on this web site. Finds a lot of chips with multiple UART:

    And you are correct that the parsing of a $GPRMC string looks similar even with different GPS - I already mentioned that earlier. So your general skills at programming should be able to solve the problem. Most C solutions that works on a PC would work on a 8051 too for the specific case of handling an $GPRMC string. And it's quite easy to process the $GPRMC string in assembler to.

    A creative developer sees possibilities. What possibilities have you identified?

  • See you are getting me all wrong.

    I don't think we are. We're getting that you consistently ignore all advice you've been given, keep asking the same questions over and over instead, and insist on the answers being given in one form, and one form only: pre-fabricated source code.

    It would be me that would be doing it all

    No, it wouldn't. It would be you piecing other people's work together at best.

    I was just seeking info

    No, you weren't. You were expressly seeking for source code.

    By the way thanks but pls be there when i'm stuck somewhere

    You're royally stuck already, and people have already tried to help you with that by pointing out the problem to you --- only to be summarily ignored.

  • See actually i am new to serial communication Ive been working with uC's for about a year or so but never did anything related to serial communication. Please try to understand. The reason why i was asking for the code was because i would have got an idea by that way.It would have alright ifyou could have just replied me not with the GPS' output but any random program related to serial communication. I think you misunderstood me and I misunderstood you. Lets close that chapter. And mark a new beginning

  • 5 minutes looking around on this site - or looking around on your computer - should give you a good starting ground for serial communication.

    Processing $GPRMC strings doesn't have anything to do with serial communication. You could just as well have received the data from a file on a memory card or have the strings hard-coded in the source code.

    When writing software, you partition your problem into smaller pieces until you have pieces small enough for you to handle. Receiving data, and decoding data is definitely two separate pieces. And processing NMEA strings is also possible to see as multiple tasks.
    - Locating record separators (i.e. individual text lines)
    - Computing checksum
    - Splitting line into individual fields
    - Decoding the contents of the different fields
    - Using the decoded data in an application-specific way.

  • Yes - you start by following the links you've already been given, and doing a bit of study and research.

    "Ive been working with uC's for about a year or so but never did anything related to serial communication"

    I find that quite amazing - to have gone a whole year and done nothing with serial comms!

    Really, serial comms is a very, very, very common part of microcontroller/embedded systems!

    After "blinky", a "hello, world" program on the UART must be one of most developer's first programs.

    You really should have no problem at all finding plenty of examples of it!

    Start on this very website:
    http://www.keil.com/download/
    http://www.keil.com/books

    and take it from there...

  • Ive been working with uC's for about a year
    doing what?

    Erik