1. 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.
    Dismiss Notice

HSERIN SERIN SERIN2

Discussion in 'Oshonsoft' started by camerart, Apr 28, 2014.

  1. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    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 (text):

    '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
     

    Attached Files:

  2. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,322
    Likes:
    11
    Location:
    Dorset UK.
    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
     
  3. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    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: Apr 29, 2014
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,322
    Likes:
    11
    Location:
    Dorset UK.

    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
     
  6. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    How is the PIC connected to the PC.? you MUST have a level shifter example, MAX232 IC.
    E
     
  7. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,322
    Likes:
    11
    Location:
    Dorset UK.
    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: Apr 29, 2014
  8. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    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
     
  9. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,322
    Likes:
    11
    Location:
    Dorset UK.
    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: Apr 30, 2014
  10. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    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
     
  11. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,322
    Likes:
    11
    Location:
    Dorset UK.
    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
     

    Attached Files:

    Last edited: Apr 30, 2014
  12. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    Thats an old photo, showing the links on the LCD D0,1,2,3 and no Contrast pot.?
    E
     
  13. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,322
    Likes:
    11
    Location:
    Dorset UK.
    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
     

    Attached Files:

    Last edited: Apr 30, 2014
  14. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    Are you waiting for any reply from me.?
    I am reading thru the NEO d/s.
    E
     
  15. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,322
    Likes:
    11
    Location:
    Dorset UK.
    Hi E, No, I was just checking a few things before going out.
    C
     
  16. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,322
    Likes:
    11
    Location:
    Dorset UK.
    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
     
  17. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    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
     

    Attached Files:

    Last edited: May 1, 2014
  18. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,187
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    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.
     

    Attached Files:

    Last edited: May 1, 2014
  19. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,322
    Likes:
    11
    Location:
    Dorset UK.
    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 E,
     
  20. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,322
    Likes:
    11
    Location:
    Dorset UK.
    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.
     

    Attached Files:

  21. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,322
    Likes:
    11
    Location:
    Dorset UK.
    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.
     

Share This Page