PDA

View Full Version : rs232



rondo2
- 27th June 2009, 14:51
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

mackrackit
- 27th June 2009, 14:54
I missread that. Do not use an inverter chip with the gps.
It is not needed with the PC and post your code too.

ScaleRobotics
- 27th June 2009, 15:50
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.

rondo2
- 27th June 2009, 19:58
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.




@ 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

mackrackit
- 27th June 2009, 20:04
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...

rondo2
- 27th June 2009, 20:11
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.

mackrackit
- 27th June 2009, 20:43
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.


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]

rondo2
- 27th June 2009, 20:58
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.


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]

according to the datasheet its 9600


would my test code work tho were i input the next 6 characters afer "GPGGA"

then use serout2 str gps_data\6] would str gps_data\6 show the next 6 characters even it was a comma or dollar sign etc?

mackrackit
- 27th June 2009, 21:14
then use serout2 str gps_data\6] would str gps_data\6 show the next 6 characters even it was a comma or dollar sign etc?
It should work.
can you post the data sheet for the GPS module you are using

rondo2
- 27th June 2009, 21:22
datasheet attached.

BobP
- 27th June 2009, 22:42
Hi,

As it runs off 3.3v here is a PDF on interfacing it. Hope it helps.
http://www.crownhill.co.uk/datasheets/ZX4120%20GPS.pdf

Bob

rondo2
- 27th June 2009, 22:50
Hi,

As it runs off 3.3v here is a PDF on interfacing it. Hope it helps.
http://www.crownhill.co.uk/datasheets/ZX4120%20GPS.pdf

Bob

hi,

i've got the pdf and ive refered to it alot when i got stuck, thats y i can't understand why its not working hmmm

ScaleRobotics
- 28th June 2009, 08:53
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:



gps_data var byte[6]

rondo2
- 28th June 2009, 16:24
Your gps_data is defined as a single byte. You want an array to work with, so you should define it as something like:



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

ScaleRobotics
- 28th June 2009, 17:58
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?

rondo2
- 28th June 2009, 22:59
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?

hi

my brother has my cam at the moment, i will get it off of him tomorrow.

quick question - i'm using a 16F870 will it accept voltages as low as 3.3v on an I/O pin

dragons_fire
- 30th June 2009, 01:20
What does C.0 do? does it flash an LED?

if its used for something else, then it might be a good idea to ad an LED and make it flash on and off as your program runs. I find that it helps me know where the program is getting hung up or if its running at all..

One other thing, and im not sure if its right or not, but wheni use an external osc i need to set it to HS not XT.

rondo2
- 30th June 2009, 20:31
What does C.0 do? does it flash an LED?

if its used for something else, then it might be a good idea to ad an LED and make it flash on and off as your program runs. I find that it helps me know where the program is getting hung up or if its running at all..

One other thing, and im not sure if its right or not, but wheni use an external osc i need to set it to HS not XT.


hi yes portc.0 is used to flash an led, so i know its recieving serial data.

the pic micro it self is running as it output's a test message to the pc's serial port and that is sent fine

rondo2
- 30th June 2009, 20:32
Also

i measured the voltage on the pin which transmits the serial data fron the gps module, and it was only 1.5v, now is that normal.

the pic micro will not see the data at such low levels will it ?

Archangel
- 30th June 2009, 22:54
i'm using a 16F870 will it accept voltages as low as 3.3v on an I/O pin
Data Sheet: "Wide operating range 2.0 to 5.5v . . . " I would make my own headaches small and run the
pic and gps on 3.3v, 1 supply 1 headache 2 supplies 2 . . .


Also

i measured the voltage on the pin which transmits the serial data fron the gps module, and it was only 1.5v, now is that normal.

the pic micro will not see the data at such low levels will it ?

3 ways to get fish, buy fish, learn to fish, beg fish at the dock ... to learn to fish you have to observe others
even if their fishing is not what you want today. I mean by this, read posts that do not apply to what you are doing today <br>
Look at the GPS data sheet, it's pretty thin I admit. Your GPS unit communicates @ 9600 b True, which means it is
"active low" as stated in the data sheet. This means it does not supply +5 or +3.3 on that port. Where does it get it? From the
pullup resistor, you are going to put on that line to the 3.3v supply. True requires a pullup whereas Inverted
would like to idle low with a pulldown.


hi thanks for pointing that out but still nothing.

i changed my code to serin2 TX,<font color = red>84</font color>,[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


84 sets serin2 to Driven true 32852 sets it to open true. Try the open true setting


@ device pic16f870,BOD_on

turn this OFF until everything else works and turn on PWRTE ON, it just gives the power supply a little time to stabalise before the PIC boots


@ device pic16f870,XT_OSC 'Using External Oscillator

I honestly do not if this will cause problems given your 20 mhz define, since you are using an external OSC, but why chance it ?
I would make it HS, might not change anything, except you will know for sure that is NOT a problem.

rondo2
- 1st July 2009, 01:06
Data Sheet: "Wide operating range 2.0 to 5.5v . . . " I would make my own headaches small and run the
pic and gps on 3.3v, 1 supply 1 headache 2 supplies 2 . . .



3 ways to get fish, buy fish, learn to fish, beg fish at the dock ... to learn to fish you have to observe others
even if their fishing is not what you want today. I mean by this, read posts that do not apply to what you are doing today <br>
Look at the GPS data sheet, it's pretty thin I admit. Your GPS unit communicates @ 9600 b True, which means it is
"active low" as stated in the data sheet. This means it does not supply +5 or +3.3 on that port. Where does it get it? From the
pullup resistor, you are going to put on that line to the 3.3v supply. True requires a pullup whereas Inverted
would like to idle low with a pulldown.


84 sets serin2 to Driven true 32852 sets it to open true. Try the open true setting


@ device pic16f870,BOD_on

turn this OFF until everything else works and turn on PWRTE ON, it just gives the power supply a little time to stabalise before the PIC boots


@ device pic16f870,XT_OSC 'Using External Oscillator

I honestly do not if this will cause problems given your 20 mhz define, since you are using an external OSC, but why chance it ?
I would make it HS, might not change anything, except you will know for sure that is NOT a problem.

HI Joe,

the open true serial settings fixed it

thanks a lot