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.

PIC plus-5110 LCD-GPS-BMP280-HMC5983

Status
Not open for further replies.
Hi,
If all the above is ok, I would like to add one of these next:

I believe it may be tricky as there ae calculations etc.

C.
 

Attachments

  • BMP280 Barometer module.jpg
    BMP280 Barometer module.jpg
    7.7 KB · Views: 265
Hi,
For different modules, each use a SPI different 'CS' (Chip select) PIN on the PIC. I even tried commenting out the two 'CS' SPI lines in the program, but the 5110 still worked.

I tried changing the:
Define SPI_CS_BIT = 5 'CS choice 5110=4 BMP280=5
but it made no difference. I assume the 'CS' hasn't been implemented yet.

I think each module will need it's own variable so that each can be addressed as needed.

C.
 
hi C,
Which version of the SPI settings are you using,?
E
'SPI yours
Define SPI_CS_REG = PORTD
Define SPI_CS_BIT = 4
Define SPI_SCK_REG = PORTC
Define SPI_SCK_BIT = 3
Define SPI_SDI_REG = PORTC 'not used, but left in so OSH does not burp
Define SPI_SDI_BIT = 4
Define SPI_SDO_REG = PORTC
Define SPI_SDO_BIT = 5
Symbol lcd_reset = PORTC.1
Symbol lcd_mode = PORTC.0 '1=DATA ,0=COMMAND

'mine
'Define SPI_CS_REG = PORTC 'porta
'Define SPI_CS_BIT = 2
'Define SPI_SCK_REG = PORTC
'Define SPI_SCK_BIT = 3
'Define SPI_SDI_REG = PORTC 'not used, but left in so OSH does not burp
'Define SPI_SDI_BIT = 4
'Define SPI_SDO_REG = PORTC
'Define SPI_SDO_BIT = 5
'Symbol lcd_reset = PORTA.4
'Symbol lcd_mode = PORTA.5 '' PORTC.2 '1=DATA ,0=COMMAND [D/C]
 
hi C,
Was the 9110 LCD still updating or did it retain the last old reading,with the CS lines commented out.?
It should retain the last reading.
E
 
Hi E,
I'm using my SPI settings.

With both define CS lines commented out, the 5110 keeps updating as normal. I tried putting a line:
PORTD.4 = 1 '0=ON 1=OFF #################################################
in the program which works, but I haven't figured out the new LOOP system yet. Once I do I'll add a button to test switching the 5110 ON/OFF

With a voltage meter on the 5110 CS PIN, it shows 3.3V but blips as the GPS updates.

C.
 
Last edited:
Hi,
With both define CS lines commented out, switching PORTD.4 =1 or 0 switches the 5110 ON/OFF. (and clears screen)
PIN out 18LF4520 5110_CS = RD4 BMP280_CS = RD5
C.
 
Hi,
Here's the latest program, which shows updating GPS, TIME and LOCATION on the 5110.

I find that working on shorter sections of code is better for me, and have made INCLUDES for each module and process.

It compiles and works. Each module needs it's own CHIP SELECT (Which I have included on each INCLUDE), but I noticed that at least one of the CS isn't 'capitalising' as usual when compiling. I'm not quite sure where the CS should be, for each module.

C.
 

Attachments

  • 18LF4520 8MHz X4 5110 SML NEO8 BMP280 080118 0930.bas
    3 KB · Views: 282
  • fontsml.bas
    3.9 KB · Views: 271
  • get_dir.bas
    3.7 KB · Views: 272
  • get_hpa.bas
    111 bytes · Views: 255
  • get_lcd.bas
    2 KB · Views: 267
  • get_neo.bas
    2.1 KB · Views: 265
hi C,
You do not have to change the extension to .txt, the forums accept .bas
E
 
hi C,
It compiles OK, which CS does not capitalise.?
E
 
hi C,
It compiles OK, which CS does not capitalise.?
E
Hi E,
In each of the INCLUDES I added a switch ON at the start and OFF at the end. None of them are 'capitalising' Perhaps all CS should be in the main program as each module is called?

Also there is : 'Gosub rst_lcd' which is important. Does it need reseting each time the 5110 is called? [I hope this is a correct use of CALL]

C.
 
Hi,
I've found lots of mistakes, just correcting them.

EDIT: This works.
Still correcting:)


main:

PORTD.5 = 0 'CHIP SELECT ON[hpa] [SPI]
Gosub get_hpa 'Reads BMP280
PORTD.5 = 1 'CHIP SELECT OFF[hpa][SPI]
PORTD.4 = 0 'CHIP SELECT ON [5110] [SPI]
Gosub get_lcd 'Writes to LCD
PORTD.4 = 1 'CHIP SELECT OFF [5110] [SPI]

Goto main

C.
 
Last edited:
hi C,
The gosub rst_lcd is only called once at power up.
I do not see any non cap' CS.?
E
 
hi C,
The gosub rst_lcd is only called once at power up.
I do not see any non cap' CS.?
E
Hi E,
gosub rst_lcd'
Did you look in each of the INCLUDES? They were at the start and the end of each, but I've removed them now and placed them in the MAIN LOOP. (Will update #287) later. They now switch in SIM.
C
 
hi C,
I checked all the INC files, all OK.
I would suggest that the INC file code for the module you are currently developing be placed in the main code listing.
Only when the module has been fully debugged would I move it into its own INC file.
You may have noticed when compiling when a, IF or ENDIF , etc is missing the editor displays the end of the INC listing.
E
 
hi C,
I checked all the INC files, all OK.
I would suggest that the INC file code for the module you are currently developing be placed in the main code listing.
Only when the module has been fully debugged would I move it into its own INC file.
You may have noticed when compiling when a, IF or ENDIF , etc is missing the editor displays the end of the INC listing.
E
Hi E,
Good.

BMP280 in MAIN.

I've connected the BMP280 to the PCB.
I don't think I need any calculations at the moment, only and input from (I think) the 3x BYTES at 3x different addresses.
First I'm trying to figure out how the GPS gets the ALT (stralt). I don't see a CSV count. Then I'll try changing it to the BMP280 once I get a value.

EDIT: Just found CASE12

C.
 
Last edited:
Hi,
Just tried this:
The GPS now shows 3x lines.
Nothing shows in the 4th line. I would expect at least the 'ALT ='
This was a quick test, without much checking of the electronics, just to see if it would work first time, but NO.
C
 

Attachments

  • 18LF4520 8MHz X4 5110 SML GPS BMP280 090118 1030.bas
    4.2 KB · Views: 291
  • fontsml.bas
    3.9 KB · Views: 286
  • get_dir.bas
    3.6 KB · Views: 232
  • get_hpa.bas
    43 bytes · Views: 287
  • get_lcd.bas
    2 KB · Views: 238
  • get_neo.bas
    2.1 KB · Views: 247
Last edited:
hi C,
You have changed the sub routine names in the Main, it will not compile with yesterdays INC's
E
 
Hi,
I now get 4x lines on 5110, with GPS updating.
On line 4 it shows AL

It won't accept 'read_data' because it isn't a STRING.

Here are the two relevant sections:

'#########################################################################
Const r_data = 0xf9 'READ ADDR lsb from BMP280
Dim read_data As Byte
'##########################################################################
Disable High
Disable Low

Include "fontsml.bas" 'This 'FONT' file nust be in the same folder as this program code
'''Include "get_dir.bas" 'This 'COMPASS' file nust be in the same folder as this program code
Include "get_neo.bas" 'This 'GPS' file nust be in the same folder as this program code
Include "get_hpa.bas" 'This 'ALTIMETER' file nust be in the same folder as this program code
Include "get_lcd.bas" 'This '5110 LCD' file nust be in the same folder as this program code

msg1 = ""
Hseropen 9600
Hserout "Ready!", CrLf

start:
'do a lcd Reset
Gosub rst_lcd '5110 states very early RESET is important

SPIPrepare
Gosub cmd5110 'init lcd
WaitMs 10
Call clear()

main:
'########################################################################
Gosub get_hpa 'Reads BMP280[[KEEP INSIDE MAIN TILL WORKING]]
Gosub get_neo 'COMMENT OUT AND ALTI SHOWS

PORTD.5 = 0 'CHIP SELECT ON[hpa] [SPI]
SPIPrepare
SPICSOn
SPISend 0xf9
SPIReceive read_data
SPICSOff
PORTD.5 = 1 'CHIP SELECT OFF[hpa][SPI]

msg1 = msg1

PORTD.4 = 0 'CHIP SELECT 5110 ON
Gosub get_lcd 'WRITES TO LCD
PORTD.4 = 1 'CHIP SELECT 5110 OFF


'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'From OSH
'For addr = 0 To 10
'SPICSOn
'SPISend 0x03
'SPISend addr
'SPIReceive data
'SPICSOff
'Lcdcmdout LcdClear
'Lcdout "Read From EEPROM"
'Lcdcmdout LcdLine2Home
'Lcdout "(", #addr, ") = ", #data
'WaitMs 500
'Next addr

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

'#######################################################################
[[[IN GET_NEO]]]
'PORTD.6 = 0 'CHIP SELECT ON
'Gosub get_dir 'READs COMPASS
'PORTD.6 = 1 'CHIP SELECT OFF

msg1 = "TIM=" + strtim '5110
Call wr_msg(0, 0, msg1)

msg1 = "LAT=" + strlat '5110
Call wr_msg(0, 1, msg1)

msg1 = "LON=" + strlong '5110
Call wr_msg(0, 2, msg1)

msg1 = "AL=" '+ read_data 'stralt'5110
Call wr_msg(0, 3, msg1)
Goto main
C.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top