rs232


Closed Thread
Results 1 to 21 of 21

Thread: rs232

Hybrid View

  1. #1
    Join Date
    Jun 2009
    Posts
    17

    Default rs232

    hi ive connected a gps unit up direct to my serial port via a max232 chip

    but i'm only seeing the nmea string when i toggle the power on and off to the rs232 chip, anyone have any idea why this is

    i'm using the attached schematic

    i did have the unit connected to a pic micro waiting for a particular nmea string so i could parse it but the pic wasn't seeing anything, so thought i would connect it directly to the serial port just to see if its outputting anything
    Attached Images Attached Images  

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I missread that. Do not use an inverter chip with the gps.
    It is not needed with the PC and post your code too.
    Last edited by mackrackit; - 27th June 2009 at 14:58. Reason: Missread
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Oops, This is assuming you mean that you are connecting your gps to your PIC chip, and not your computer. If you are just connecting your gps to your computer, no need for a max232 chip.

    I've used the max232 chip with gps before. If you are using a standard GPS to PC serial cord, you will need to either swap your wires 7 and 8 on the max232 chip, or insert a null modem adapter on your gps cable.
    Attached Images Attached Images  
    Last edited by ScaleRobotics; - 27th June 2009 at 16:33.
    http://www.scalerobotics.com

  4. #4
    Join Date
    Jun 2009
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    hi

    sorry if my original post was confusing i typed it in a rush lol


    first of all i connected my gps unit directy to a pic micro then using serin2 and wait, i waited for a particular nmea sentence to parse it etc, and the pic was just waiting it never could see even a $ sign coming from the gps unit,

    so then...

    got rid of the pic and i connected the gps unit directly to my pc's serial port via an rs232 chip, and viewed the data via microcode studio serial communicator

    but the data would only be sent to the pc when i applied and removed power to the rs232 chip repeatedly if that makes sense.


    below is the basic code i created just to see if the gps unit was transmitting data to the pic.


    Code:
     @ device  pic16f870,WDT_OFF            'Watch Dog Timer Disabled
     @ device  pic16f870,PROTECT_OFF        'Code Protect Off
     @ device  pic16f870,XT_OSC             'Using External Oscillator
     @ device  pic16f870,BOD_on            'Brown Out Timer Disabled 
     @ device  pic16f870,PWRT_on          'Power On Timer Disabled
     @ device  pic16f870,LVP_OFF            'Low Voltage Programmed Disabled
    
    
    
    
    define OSC 20
    
    'TRISA = %11111111 
    'TRISC = %00000000
    
    'ADCON0.0=0
    'ADCON1=7 ' ALL PINS SET TO DIGITAL
    
    
    'Pin Assignments
    
    
    GPIO0 VAR PORTA.0
    NC VAR PORTA.4
    TX var portb.5
    RX VAR PORTA.2
    Reset var porta.1
    GPIO4 var porta.5  
    
    'Variables
    
    gps_data var byte
    
    
    HIGH PORTC.0
    PAUSE 200
    LOW PORTC.0
    PAUSE 200
    
    SEROUT2 PORTC.1,16468,["GPS TEST$123456"]
    
    pause 500 'allow gps module to init
    
    
    
    
    
    'if gpio4=0 then high portc.3'(red)
    
    
    reset_unit:
    
    low reset
    
    pause 100
    
    high reset
    
    
    MAIN:
    
    
    serin2 TX,16468,[WAIT("$GPGGA"),str gps_data\6]
    
    
    
    PAUSE 200
    
    HIGH PORTC.0
    PAUSE 200
    LOW PORTC.0
    PAUSE 200
    
    SEROUT2 PORTC.1,16468,[str gps_data\6]
    
    GOTO MAIN
    Last edited by rondo2; - 27th June 2009 at 20:04.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Sounds about right for the PC, data getting through as the
    232 chip was powering up and down.
    232 chip is not needed with the PC and if you are
    using SERIN2 then run the PIC in inverted mode.
    Keep it simple...
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Jun 2009
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Sounds about right for the PC, data getting through as the
    232 chip was powering up and down.
    232 chip is not needed with the PC and if you are
    using SERIN2 then run the PIC in inverted mode.
    Keep it simple...
    are you talking about communicating from the pic to the pc, in this instance i was not using a rs232 chip, but when soley connecting the gps unit directly to the serial port i was using a rs232 chip if i bypassed the chip i just got garbage on the screen.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Now I think I may see the problem. I will assume your GPS unit sends data at 4800?
    Here is a snippet from one of my programs. No 232 chip.
    Code:
    SERIN2 PORTB.1,16572,[WAIT("$GPGGA"),WAIT(","),DEC2 H,DEC2 M,DEC2 S,_
    
            WAIT(","),DEC2 ND,DEC2 NM,WAIT("."),DEC3 NMD,WAIT(",N,"),_
    
            DEC3 WD,DEC2 WM,WAIT("."),DEC3 WMD]
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rondo2 View Post
    Code:
    gps_data var byte
    
    serin2 TX,16468,[WAIT("$GPGGA"),str gps_data\6]
    Your gps_data is defined as a single byte. You want an array to work with, so you should define it as something like:

    Code:
    gps_data var byte[6]
    http://www.scalerobotics.com

  9. #9
    Join Date
    Jun 2009
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scalerobotics View Post
    Your gps_data is defined as a single byte. You want an array to work with, so you should define it as something like:

    Code:
    gps_data var byte[6]


    hi thanks for pointing that out but still nothing.

    i changed my code to serin2 TX,84,[WAIT("$GPGGA"),WAIT(","),DEC2 H,DEC2 M,DEC2 S]


    PAUSE 200

    HIGH PORTC.0
    PAUSE 200
    LOW PORTC.0
    PAUSE 200

    SEROUT2 PORTC.1,16468,[dec2 H, dec2 M, dec2 S]

    GOTO MAIN

    still nothing

    the gps module is connected properly it is receiving 3.3v so unsure whats going on

    do you no if it must have a backup battery, because at the moment i don't have that pin connected to anything

  10. #10
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    What's your hardware setup? Got a picture? Can you show the whole code? I wonder what your TX pin is doing with the serial in, but I can't tell from here.

    The code you just posted is not inverted, so I assume you have the max232 back in?
    http://www.scalerobotics.com

Similar Threads

  1. Universal remote and Rs232
    By Michael in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 7th February 2010, 17:55
  2. UART vs software RS232
    By Michael in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 5th September 2008, 18:27
  3. RS232 into 2 PC ports
    By manxman in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th August 2008, 13:33
  4. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 20:39
  5. RS232 to Weigand
    By Stevenindon in forum Serial
    Replies: 0
    Last Post: - 6th April 2006, 04:35

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts