View previous topic :: View next topic |
Author |
Message |
Leandro
Joined: 18 Feb 2014 Posts: 12 Location: Brasil
|
The data is correct? |
Posted: Sat Jul 26, 2014 11:51 am |
|
|
This code returns this date:
Time: -128:8:2
Date: -37/66/-60
Latitude: 0.00 Ä
Longitude: 0.00 ×
Speed: 0.00 knots
Data saved!
in visual GPS I see 9 satellites and receive the coordinates, but with this code I don't receive nothing... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Sat Jul 26, 2014 3:02 pm |
|
|
Not totally surprised as you have a 2 second delay in the timer ISR !!
rule #1. ISRs MUST be short and fast ! NO delays, NO printing,NO math.
rule #2. Rule #1 MUST be obeyed!
also don't try anything else UNTIL the 'receive GPS data' code is working 100%.
always build upon known working code.
hth
jay |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Jul 27, 2014 3:45 am |
|
|
I'm confused: Yamenn == Leandro?
Most likely reason for the latest code to fail is the use of gets() to retrieve the GPS data. gets() will read all data up to the first character containing a zero value. The GPS lines normally end with a CR + LF characters. What then happens is that you read in way too many characters and overwrite other variables in RAM.
But perhaps you are not communicating with a real GPS device? What device are you talking too (brand and type number) ?
The project is not very difficult to do but has small details that care and knowledge of what you are doing. This type of project has been done so many times that I don't want to post an example program here. Just Google and learn from those other implementations. Then come back and we can help you make it work on the PIC.
And last, please post your compiler version number. You can find it at the top of the .LST file for your project. It will be in the project
directory after a successful compilation. The number looks something like: 4.123 |
|
|
Leandro
Joined: 18 Feb 2014 Posts: 12 Location: Brasil
|
|
Posted: Sun Jul 27, 2014 8:19 am |
|
|
Sorry, I confuse the topics, the code which use is of page http://www.ccsinfo.com/forum/viewtopic.php?t=45827&highlight=
I try the code of this page and have errors...
I use CCS 4.104
The pic is a 18f4550
The GPS is Blox NEO-M6 and this working on visual gps in a test on pc.
I'm looking for codes to run in a week and found nothing, usually I find the codes are for MikroC and MPLAB .. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Sun Jul 27, 2014 8:35 am |
|
|
2 things from the GPS datasheet I just downloaded sent warning flags to me....
1) startup time is 26 SECONDS. So I'd think your PIC program needs almost a 1/2 minute to 'twiddle it's thumbs' BEFORE any real data can come from the GPS unit.
2) GPS unit is a 3 volt device.Are you trying to run the PIC at 3 volts? If so it's way out of spec !!!
We need more info about your real hardware configuration as you can't run that PIC at 3 volts or the GPS at 5 volts!!!
hth
jay |
|
|
Leandro
Joined: 18 Feb 2014 Posts: 12 Location: Brasil
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Sun Jul 27, 2014 9:15 am |
|
|
Ok.. BUT the PIC is running at 5 volts, expecting '1's to be 5 v NOT 3 v from the GPS.
From PIC 4550 datasheet, parameter D041, ST input MUST be a minimum of 80% of Vdd which is 4 volts ( .8* 5).
hth
jay |
|
|
Leandro
Joined: 18 Feb 2014 Posts: 12 Location: Brasil
|
|
Posted: Sun Jul 27, 2014 9:22 am |
|
|
Yes, I'm using 5v on pic and 5v on the GPS module, it has a regulator for 3V. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Sun Jul 27, 2014 9:29 am |
|
|
yes...BUT the data signals from the GPS are THREE volts !!! NOT enough to be a logical '1' for the PIC.
You might, and I stress 'might' get 'some' data that's good IF the PIC likes <4 v as a high AND the GPS LDO is really >3.6 v.
You either need to buffer the data from the GPS to proper 5v logic levels or use the 'L' version of the 4550 which will run at 3 volts.
You've got the 'classic' mismatched 5V PIC with 3V peripheral problem.
hth
jay |
|
|
Leandro
Joined: 18 Feb 2014 Posts: 12 Location: Brasil
|
|
Posted: Sun Jul 27, 2014 9:34 am |
|
|
I understand, I go try use a MAX232 onboard on my development board. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Jul 27, 2014 3:20 pm |
|
|
No!!! Do NOT use a MAX232 without testing!
It you might kill your hardware.
A MAX232 will convert to output voltages of +10V and -10V, way out of specifications as input for the PIC.
I did not read the specifications for your GPS receiver, but most likely it has output voltages from 0 and 3.3V
The classic problem now is that with a PIC running at 5V the 'high' voltage of 3.3V is not high enough for the PIC to be seen. See Temtronic's post, the PIC input with Schmitt Trigger requires minimum 4V.
Note: a pin with TTL type input would have worked with the 3.3V but that is not how Microchip designed the UART. Schematics used for the Arduino chips do have a TTL input.
Converting PIC 5V to 3.3V is easy, just a resistor voltage divider.
The other way around, to convert 3.3V to 5V can be done in many ways but MAX232 is not one of them. Read Microchip Tips & Tricks, Chapter 8 for several example circuits.
If I'm mistaken and your GPS module is outputting +10V and -10V, only then you should use the MAX232. |
|
|
|