CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problem with calling a char from GPS and writing to LCD
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Thu Nov 24, 2005 5:23 pm     Reply with quote

PCM programmer wrote:
1. My test program is set at 9600 baud. Did you change it back to the 4800 baud rate which is used by your GPS?


Yes, I did.

Quote:
2. Also, I'm not sure what the purpose of your program is.


I started with something more useful but when it didn't work I started simplifying to try to troubleshoot the problem. I ended up with just trying to get one character into the PIC and out to the LCD.

I've since tried getting a character from the keyboard and printing it to a terminal program and that doesn't work either so I'm starting to suspect the hardware.

I had changed out a resistor and shorted out a diode on the MCLR pin to try to get the board to work with the MachX ICD. Perhaps that's affected the operation of the UART.

Harry
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Sun Nov 27, 2005 3:52 pm     Reply with quote

Hi PCM, hope you're still with me on this.

What I did was transfer this exercise onto another board and it works using a terminal program as you demonstrated with your board. So I guess the problem was a hardware issue on the Picmicro 28/40 board.

However, now, when I hook up my GPS to the serial port (and change the baud rate to 4800) it doesn't work....that is, a character from the GPS is not displayed on the LCD. A printf statement before the fgetc() statement does display it's output on the LCD.

Anything else I can try or does anyone have any insight into why this doesn't work?

Thanks....Harry
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 27, 2005 4:25 pm     Reply with quote

Can you post the manufacturer and part number of your GPS ?
If possible, post a link to the web page where the data sheet or
other specs can be downloaded.
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Sun Nov 27, 2005 4:31 pm     Reply with quote

The GPS is a Garmin 12MAP. Here is a website with all the info:

http://www.garmin.com/products/gps12map/

Harry
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 27, 2005 5:04 pm     Reply with quote

Quote:
it works using a terminal program

You said in an earlier post that the GPS can talk to your PC.
So both units work OK with the PC.

To let your GPS and PIC board talk to each other, you need to
build a cable with a DB-9 connector on each end that looks like this:
One end of the cable plugs into the PIC board, and the other end
plugs into the GPS.
Code:

PIC   GPS
DB9   DB9
pin   pin

 2     3

 3     2

 5     5   (ground)

All other pins are not used.

This cable will allow the Tx pin on the GPS to go to the Rx pin on the PIC
board, and vice versa. The pin 5 to pin 5 connection provides the
common ground.
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Sun Nov 27, 2005 6:53 pm     Reply with quote

The cable has been put together from the original GPS cable that worked with the terminal program and the rs232 cable from the CCS prototyping board that I'm using so it should work.

I've just checked the pinouts and they look OK....2, 3 and 5. And rs232 is on C6 and C7.

I'm finished for tonight, I'll get back at it tomorrow afternoon.

Thanks....Harry
GDetienne



Joined: 20 Sep 2003
Posts: 47
Location: Brussel - Belgium

View user's profile Send private message

Idea
PostPosted: Mon Nov 28, 2005 2:04 am     Reply with quote

I have a application with Pic (876A) and GPS. I read NMEA from differents GPS. If your PC can read directly the differents sentences, don't forget that the Garmin can send the format RS232F (level 0 and 5V) and not RS232C(-12 and + 2V). You must use a Max 232 or use "Invert" in your #RS232( ) declaration.
Don't forget also that the GPS send 6 NMEA sentences every second.

I hope that can help you.
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Mon Nov 28, 2005 2:04 pm     Reply with quote

Well, I've tried again with no success.

Here's where I stand right now.

1. The GPS will output NMEA data to a terminal program on my laptop using a Garmin cable.

2. The 16F877 will input characters from a terminal emulator to the PIC and print them to an LCD. This is being done on a CCS software prototyping board using the RS232 cable that came with the board.

3. Using a gender changer I've connected the 2 working cables...that should ensure proper hookup. I've connected the GPS to the rs232 port on the board that is connected to PIN_C6 and PIN_C7. No characters show up on the LCD when I run the program.

Either the fgetc() function is not getting a character or the fprint() function is not outputting the character. Or I'm missing something else. Confused

GDetienne...if you have an LCD in your setup could you try to run my code? Or conversly, if you have a snippet of code that you know will put a character(s) into a variable could you pass it on to me to try?

Thanks....Harry
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 28, 2005 2:48 pm     Reply with quote

Quote:
Using a gender changer I've connected the 2 working cables...
that should ensure proper hookup

Are you using a RS232 gender changer like the one shown in this link ?
http://www.cablestogo.com/product.asp?cat%5Fid=1701&sku=02782
If so, I have that kind and they don't swap pins 2 and 3. They are
"straight-through" connectors. Pin 1 goes to Pin 1, etc.

I suggest that you trace through the circuit between the Tx pin on the
GPS and the Rx pin on the PIC, and ensure that they are really connected
to each other properly. Also verify that a common ground exists.
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Mon Nov 28, 2005 3:51 pm     Reply with quote

PCM programmer wrote:
Are you using a RS232 gender changer like the one shown in this link ?
http://www.cablestogo.com/product.asp?cat%5Fid=1701&sku=02782

That looks like the one that I am using.
Quote:

I suggest that you trace through the circuit between the Tx pin on the
GPS and the Rx pin on the PIC, and ensure that they are really connected
to each other properly. Also verify that a common ground exists.


I've actually tried that and ran into trouble at the board end. The rs232 cable has a 2.5 mm audio type jack at one end to connect to the board and to the max 232 chip. In case you know how these are brought up to the chip, the end of the audio connector was connected to GPS 1 and DB pin 3(Rx), the middle to GPS 2 and DB pin 2 (Tx)and the base to GPS 3 (ground) and DB pin 5. I'll try a table.
Code:

             GPS       DB9          Gender Changer            DB9       Audio Jack
Rx           1          3            3          3             3           tip
Tx           2          2            2          2             2          middle
GND          3          5            5          5             5           base

Think I could screw anything up by just physically exchanging pins 2 and 3 at one of the junctions and trying that?

Thanks....Harry
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 28, 2005 4:19 pm     Reply with quote

Your GPS and the PIC board are configured as "DCE" devices.
They work OK with the PC, which is configured as a "DTE" device.

But to now connect the two DCE devices together, you need what's
known as a "null-modem" cable. That cable swaps pins 2 and 3.
(Ground must still go from pin 5 to pin 5).

If you don't want to build or buy a null-modem cable, then you
need to alter your hardware connections, perhaps on the PIC board
so that you swap pins 2 and 3. But keep in mind that once you do
that, you can't just connect the PIC board to the PC anymore.
It will work with GPS-to-PIC board, but not PIC board-to-PC.
Harry Mueller



Joined: 17 Oct 2005
Posts: 116

View user's profile Send private message

PostPosted: Mon Nov 28, 2005 4:46 pm     Reply with quote

Thanks for the explanation, PCM. That was my problem and solving it sure feels good.

Thanks again.....Harry
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group