Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

HSERIN SERIN SERIN2

Status
Not open for further replies.
hi C,
Cleaned up the draft prog, added some comments.
Note: the UART print out, the '*' are output when the sync char '$' is missed, the string is dumped.

E
Code:
'software uart receives data stream at 9600 baud And when char $ is detected we capture all bytes
'in array str1 until LF code.
'Then send these To the PC via hardware UART at 9600 baud

'COPY and PASTE this string.
'$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47?

'GGA Global Positioning System Fix Data
'123519            fix taken at 12: 35: 19 utc
'4807.038,N             Latitude 48 deg 07.038' N
'01131.000,E              Longitude 11 deg 31.000' E
'1 Fix quality: 0 = invalid
'1 = GPS fix (SPS)
'2 = dgps fix
'3 = PPS fix
'4 = Real ovle Kinematic
'5 = Float RTK
'6 = esovlated (dead reckoning) (2.3 feature)
'7 = Manual Input mode
'8 = Simulation mode
'08 Number of satellites being tracked
'0.9 Horizontal dilution of position
'545.4,M              Altitude, Meters, above mean sea level
'46.9,M              Height of geoid (mean sea level) above WGS84 ellipsoid
'empty field) ovle in seconds since last DGPS update
'empty field) dgps station id number
'* 47 the checksum data, always begins with *

Define SIMULATION_WAITMS_VALUE = 1

Define CONF_WORD = 0x3f41  'XTL
Define CLOCK_FREQUENCY = 4  'Changed from 12

AllDigital

Dim chr As Byte
Dim rxi As Byte
Dim txo As Byte
Dim ovl As Byte
Dim str1(42) As Byte  'save the data stream we need in here

Define LCD_DREG = PORTB  'Port for LCD Data
Define LCD_DBIT = 4  'Use upper 4 bits of Port
Define LCD_RSREG = PORTA  'Port for RegisterSelect (RS) bit
Define LCD_RSBIT = 2  'Port Pin for RS bit (pin9)
Define LCD_EREG = PORTA  'Port for Enable (E) bit
Define LCD_EBIT = 4  'Port Pin for E bit (pin7)
Define LCD_BITS = 4  'Using 4-bit bus
Define LCD_LINES = 4  'Using 2 line Display
Define LCD_CHARS = 16  'ADDED
Define LCD_COMMANDUS = 2000  'Command Delay (uS)
Define LCD_DATAUS = 50  'Data Delay (uS)


CMCON = 7
OPTION_REG.7 = 0  'Enable Pull-Up's
CMCON = 7
OPTION_REG.7 = 0  'Enable Pull-Up's

TRISA = %00000000
TRISB = %01000000
INTCON.GIE = 1  'enable Global Intr
INTCON.PEIE = 1  'enbale Peripheral Intr

'''Lcdinit  ' LCD not used in SIM

Hseropen 9600

PIE1.RCIE = 1  'enable UART RXD Interrupt

Hserout "Ready - await  $", CrLf, CrLf

main:
'do whatever
Goto main

End                                             

On Interrupt
Save System

Hserin chr
If chr = "$" Then  'test for string start character
rxi = 0  'rx data cntr
ovl = 0  'over flow counter
Endif

str1(rxi) = chr  'save chr in str1 buffer
rxi = rxi + 1  'inc buffer pointer

If chr = "?" Then  'test for LF code*** change to 0X0A in PIC prog
Hserout "Latitude: "
For txo = 14 To 15  'pick off Lat
Hserout str1(txo)
Next txo
Hserout "Deg "
For txo = 16 To 23
Hserout str1(txo)
Next txo
Hserout CrLf

Hserout "Longtitude: "
For txo = 25 To 27  'pick off Long
Hserout str1(txo)
Next txo
Hserout "Deg "
For txo = 28 To 35
Hserout str1(txo)
Next txo
Hserout CrLf

Hserout "Altitude: "
For txo = 46 To 52  'pick of Alt
Hserout str1(txo)
Next txo
Hserout CrLf
Endif

ovl = ovl + 1  'inc the over flow counter for every INTR
If ovl > 70 Then  'string is corrupt to dump it
For ovl = 0 To 70
str1(ovl) = "*"  'over write buffer with asymbol of your choice
Next ovl
rxi = 0  'reset counters
txo = 0
Endif

PIR1.RCIF = 0
Resume
 

Attachments

  • AAesp03.gif
    AAesp03.gif
    19.9 KB · Views: 414
Hi,
This is a revised ISR, it uses the string location to pick off the N,E and M data

Code:
On Interrupt
Save System

PIR1.RCIF = 0

Hserin chr
If chr = "$" Then 'start
rxi = 0
Endif

str1(rxi) = chr
rxi = rxi + 1

If chr = "?" Then 'temp LF
For txi = 14 To 23
Hserout str1(txi)
Next txi
Hserout CrLf

For txi = 25 To 35
Hserout str1(txi)
Next txi
Hserout CrLf

For txi = 46 To 52
Hserout str1(txi)
Next txi
Hserout CrLf
Endif

Resume

Hi E,

Thanks, I'll add it into the program, and test it.

The program works ok in the simulator, but not in the circuit, and I get the same result as you show in the UART sim interface

I found I had the PORT incorrectly set as the input is RB1 TRISB %00000010

Just to check that you realise this won't be connected to a PC when running in ernest? All the calculations will be inside the PIC, and the LCD for information. What do I need to change to use LCD and not the output pin? (RB2)

Cheers, C
 
hi C,
Just replace Hserout with Lcdout for str1(txo)

I dont know what you mean.?
What do I need to change to use LCD and not the output pin? (RB2)
E

EDIT:
If you mean what to do with TXD PORTB.2 pin, just leave it unconnected, if you dont want a TXD uart output.
 
Last edited:
hi C,
Just replace Hserout with Lcdout for str1(txo)

I dont know what you mean.?
What do I need to change to use LCD and not the output pin? (RB2)
E

EDIT:
If you mean what to do with TXD PORTB.2 pin, just leave it unconnected, if you dont want a TXD uart output.

E,
First, I like your 'breaking string into chunks' routine, informative. Also braking it into the desired sections, thanks.

I did try replacing Hserout with LCDout earlier, and the LCD does work in the simulator. I was wondering if this is something to do with it not being able to work in the circuit. I'll try again.

C
 
hi C,
How is the PIC connected to the PC.? you MUST have a level shifter example, MAX232 IC.
E
 
hi C,
How is the PIC connected to the PC.? you MUST have a level shifter example, MAX232 IC.
E
Hi E,
The PIC is only connected while it's being programed.
I don't have a level shifter, because the PIC is only connected to the GPS module, sending NMEA data to the RX pin. I can see digits changing every second (The period expected) on the LCD, with earlier (not working properly) programs. I read that level shifters aren't always needed. If you think I should add one I will.
C
 
Last edited:
Hi C,
I thought you said the demo program would work in Oshonsoft but not in a PIC.??

If the PIC when programmed receives RXD [received data] OK and you can see it it on the LCD OK, where is the problem.?

Perhaps I am misunderstanding you.:(
Eric
 
Hi C,
I thought you said the demo program would work in Oshonsoft but not in a PIC.??

If the PIC when programmed receives RXD [received data] OK and you can see it it on the LCD OK, where is the problem.?

Perhaps I am misunderstanding you.:(
Eric

Hi E,

The programs, before you started helping me:
In the Oshonsoft simulator, would print anything in "" on the LCD, but at that time I didn't know how to input a data stream. Then I programmed the PIC and moved it to a circuit with only a GPS sending NMEA data to pin 7 (RX) and an LCD screen (Just for testing). This would show changing numbers all in the same square. I think this shows the PIC is receiving data and showing it on the screen ok, but I will double check today. Having said that! At the sim stage without the ability of putting in data, I might be mistaken.

The programs since your help:
In the sim they showed the data stream on the LCD, which obviously changed as you developed the program. Then once in the separate circuit, shows no sign of life.
EDIT: Just programmed a PIC to flash a LED = RX input. It flashed once/second as expected. I could see the varying intensity, depending on the data coming in.
C
 
Last edited:
hi C,
Did you Rem out the Define SIMULATION_WAITMS_VALUE = 1 before you programmed the PIC.?
also do you have a datasheet for the GPS NMEA module so that I can check the RS232 levels.?

If you have a photo of the layout it would be helpful

E
 
hi C,
Did you Rem out the Define SIMULATION_WAITMS_VALUE = 1 before you programmed the PIC.?
also do you have a datasheet for the GPS NMEA module so that I can check the RS232 levels.?

If you have a photo of the layout it would be helpful

E

Hi E,
Yes, but I do forget sometimes:)
As requested:
EDIT I tried a toggle LED inside the LOOP, and it flashes in time with the GPS. (I used a logic probe)

C
 

Attachments

  • NEO-6_DataSheet_(GPS.G6-HW-09005).pdf
    865.9 KB · Views: 599
  • PICLCD.jpg
    PICLCD.jpg
    278.9 KB · Views: 432
Last edited:
hi C,
Thats an old photo, showing the links on the LCD D0,1,2,3 and no Contrast pot.?
E
 
hi C,
Thats an old photo, showing the links on the LCD D0,1,2,3 and no Contrast pot.?
E

Hi E,

True:facepalm:,

Here's one straight from the lab! Running one of my earlier programs. Both attached. Note the top number is changing, after a while it settles down to one number.
EDIT: D0,1,2,3 are not connected! I noticed and changed the incorrect TRISB pin to $00000010
C
 

Attachments

  • XTL GPS LCD 16F648A 270414 1500.txt
    1.9 KB · Views: 380
  • PICLCD.jpg
    PICLCD.jpg
    284.3 KB · Views: 440
Last edited:
hi C,
Are you waiting for any reply from me.?
I am reading thru the NEO d/s.
E
 
Hi E,
I've just had a thought, and failed to find a clear answer! I am only using TX plus +v and 0v, so no RX. This might not work! Do I need an RX for feedback to the GPS?
C
 
hi C,
As far I can see from the d/s for GPS module, it does not require RS232 'handshaking' to operate.

I checked the d/s for any requirement that GPS may for setting up/initialising, it just says CFG-COM1 and COM0 should be High, hard wired.

Looking at the NMEA Message Strings it does not show the $GPGGA header string you are using in your program.????

Read Section 1:16 of the d/s I have outlined in Red

Eric

EDIT:
I would advise the follow test.
Connect the NEO6 module to your PC via level shifter,[MAX232] use the PC 's Hyper Terminal to read and display exactly what is coming from the NEO

Or contact Ublox and confirm with them
 

Attachments

  • AAesp01.gif
    AAesp01.gif
    56.6 KB · Views: 415
Last edited:
hi C,
I have tracked down the lea-6/neo-6 hardware integration manual, attached, I would suggest you use this reference.

Eric

EDIT:
Added the u-blox Receiver Protocol pdf.
You should now have all the information you require.

If I am reading the d/s correctly, the UART on the module needs to be initialised.
 

Attachments

  • LEA-6_NEO-6_HardwareIntegrationManual_(GPS.G6-HW-09007).pdf
    2.3 MB · Views: 773
  • AAesp03.gif
    AAesp03.gif
    15.6 KB · Views: 407
  • AAesp02.gif
    AAesp02.gif
    9.5 KB · Views: 415
  • u-blox6_ReceiverDescriptionProtocolSpec_(GPS.G6-SW-10018).pdf
    3.7 MB · Views: 485
Last edited:
Hi Eric,

Thanks for tracking down the integration manual, and reading it.

Handshake OK.

I don't understand 'CFG-COM1 and COM0 should be High, hard wired'

I see the GGA string is there (hope I'm correct) No 4 in the list on AAesp01.gif. All sentences begin with $GP then the chosen type. I'll re-check!

I'll search for the GPS initialisation.

And try the MAX232 hyper-terminal suggestion.

And report back:)

Thanks, Camerart.





hi C,
As far I can see from the d/s for GPS module, it does not require RS232 'handshaking' to operate.

I checked the d/s for any requirement that GPS may for setting up/initialising, it just says CFG-COM1 and COM0 should be High, hard wired.

Looking at the NMEA Message Strings it does not show the $GPGGA header string you are using in your program.????

Read Section 1:16 of the d/s I have outlined in Red

Eric

EDIT:
I would advise the follow test.
Connect the NEO6 module to your PC via level shifter,[MAX232] use the PC 's Hyper Terminal to read and display exactly what is coming from the NEO

Or contact Ublox and confirm with them
Hi E,
hi C,
I have tracked down the lea-6/neo-6 hardware integration manual, attached, I would suggest you use this reference.

Eric

EDIT:
Added the u-blox Receiver Protocol pdf.
You should now have all the information you require.

If I am reading the d/s correctly, the UART on the module needs to be initialised.
hi C,
I have tracked down the lea-6/neo-6 hardware integration manual, attached, I would suggest you use this reference.

Eric

EDIT:
Added the u-blox Receiver Protocol pdf.
You should now have all the information you require.

If I am reading the d/s correctly, the UART on the module needs to be initialised.
hi C,
I have tracked down the lea-6/neo-6 hardware integration manual, attached, I would suggest you use this reference.

Eric

EDIT:
Added the u-blox Receiver Protocol pdf.
You should now have all the information you require.

If I am reading the d/s correctly, the UART on the module needs to be initialised.
hi C,
I have tracked down the lea-6/neo-6 hardware integration manual, attached, I would suggest you use this reference.

Eric

EDIT:
Added the u-blox Receiver Protocol pdf.
You should now have all the information you require.

If I am reading the d/s correctly, the UART on the module needs to be initialised.
 
Hi E,

The module I have looks like this:

So I'm sure the set-up will be different to what the manual says, as it has only +V 0V RX and TX to connect to, also this might be a Chinese clone, and who knows what that might bring. Normally 'stuff' usually works ok!

C.
 

Attachments

  • NEO-6M.jpg
    NEO-6M.jpg
    5.5 KB · Views: 398
I read that there is a LED on the GPS circuit that flashes once it has locked onto a satellite, and after a few seconds from switching on, this happens.

I also read that to get 9600 Baud rate, 4MHz crystal is not the best. Whether that's true is another thing! but I'm exploring this area at the moment.

Camerart.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top