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 C,
Downloaded, will try tomorrow.
E
Hi E,
If the image attached is ok, then it is working. I needed to comment out all of the SPI section, for SIM.
Thanks.
C.
 

Attachments

  • TEST.jpg
    TEST.jpg
    70.7 KB · Views: 248
hi C,
I would move the SPIPrepare outside the main loop. say just before the start label.
There is one point which is bugging me, does the LONG need to be right shifted 4 times, as p_xlsb is always zero.
Read the d/s and let me know
E
SPIPrepare
start:

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

'''''''Gosub cmd5110 'init lcd temp rem out
WaitMs 10
Call clear()
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'simulated BMP Regs values
p_xlsb = 0x40 'low byte
p_lsb = 0xe2
p_msb = 0x01 'high byte
p_xlsbnlsb = 0x00
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

main:
'###################################################################
''' Gosub get_neo 'Reads NMEA DATA temp rem out
PORTD.4 = 1 'CHIP SELECT 5110 OFF
WaitMs 100 'Does CS need time to switch? [SHORTEN OR REMOVE THIS LINE]
PORTD.5 = 0 'CHIP SELECT [hpa] ON

Goto test1 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

SPICSOn
SPISend 0xf4 'Control reg addr
SPISend 0x03 'Normal mode
SPISend r_p_xlsb 'READ ADDR PRESSURE xlsb from BMP280
SPIReceive p_xlsb 'Least sig BYTE
SPISend r_p_lsb 'READ ADDR PRESSURE lsb from BMP280 MID
SPIReceive p_lsb 'mid sig Byte
SPISend r_p_msb 'READ ADDR PRESSURE msb from BMP280 MOST
SPIReceive p_msb 'Most sig BYTE
SPICSOff
PORTD.5 = 1 'CHIP SELECT OFF[hpa][SPI]

test1:
'dummy values from SP reads ''''''''''''''''''''''''''''''''''''''''''''''''''
p_xlsb = 0x40 '''' NOTE: low nibble always zero
p_lsb = 0x23
p_msb = 0x01
''' is 74560 as decimal

'Join all PRESS bytes as long
p_xlsbnlsb.LB = p_xlsb
p_xlsbnlsb.HB = p_lsb
p_msbnlsbnxlsb.LW = p_xlsbnlsb
p_msbnlsbnxlsb.HW = p_msb

'ASCII serial out of Bytes,Word or Single
Hserout "BMP LONG Value=", #p_msbnlsbnxlsb, CrLf

msg1 = #p_msbnlsbnxlsb
Hserout "BMP as ASCII=", msg1, CrLf, CrLf
 

Attachments

  • A004.gif
    A004.gif
    6 KB · Views: 261
Hi E,
As expected:)
EDIT: Unimportant: I moved all of the XLSB to the right [p_lsbnxlsb.HB] in the variables.
C
 

Attachments

  • 74560.jpg
    74560.jpg
    117.3 KB · Views: 256
Last edited:
hi C,
I suspect you may have to shift all the value right by 4.??
If so a simple edit.
image shows before and after shift
E
'ASCII serial out of Bytes,Word or Single
Hserout "BMP LONG Value=", #p_msbnlsbnxlsb, CrLf

msg1 = #p_msbnlsbnxlsb
Hserout "BMP as ASCII=", msg1, CrLf, CrLf

p_msbnlsbnxlsb = ShiftRight(p_msbnlsbnxlsb, 4)


'ASCII serial out of Bytes,Word or Single
Hserout "BMP LONG Value=", #p_msbnlsbnxlsb, CrLf

msg1 = #p_msbnlsbnxlsb
Hserout "BMP as ASCII=", msg1, CrLf, CrLf
 

Attachments

  • A007.gif
    A007.gif
    3.4 KB · Views: 246
Hi E,
Working in SIM, now shows values=74560 and 4660.

Would you expect this to work with the 5110? The 5110 doesn't start!
C
 

Attachments

  • 18LF4520 8MHz X4 5110 GPS BMP280 140118 1300 TEST.bas
    10.3 KB · Views: 248
hi C,
Ensure that the 5110 is initialised.
Have been looking at the BMP d/s, look at this image etc.
E

test1:
'test values from Datasheet
''0x7EED0 [ 20 bit left shifted 4] = 519888 decimal

''''''''''''''''''''''''''''''''''''''''''''''''''
p_xlsb = 0xd0 '''' NOTE: low nibble always zero
p_lsb = 0xee
p_msb = 0x07

'Join all PRESS bytes as long
p_xlsbnlsb.LB = p_xlsb
p_xlsbnlsb.HB = p_lsb
p_msbnlsbnxlsb.LW = p_xlsbnlsb
p_msbnlsbnxlsb.HW = p_msb

'ascii serial out of bytes,Word Or Single
Hserout "UnShifted BMP LONG Value=", #p_msbnlsbnxlsb, CrLf
msg1 = #p_msbnlsbnxlsb

Hserout "BMP as ASCII=", msg1, CrLf, CrLf

p_msbnlsbnxlsb = ShiftRight(p_msbnlsbnxlsb, 4)

'ascii serial out of bytes,Word Or Single
Hserout "Shifted BMP LONG Value=", #p_msbnlsbnxlsb, CrLf
msg1 = #p_msbnlsbnxlsb
Hserout "BMP as ASCII=", msg1, CrLf, CrLf
 

Attachments

  • A008.gif
    A008.gif
    15.5 KB · Views: 249
  • A010.gif
    A010.gif
    4.7 KB · Views: 257
hi C,
Have you seen the corrective maths calculations required to get a pressure value in Pa.???:woot:
A010.gif
 
Hi E,
Got the 5110 going after 'initialisation'
Using the BMP280 for reading, should I get anything at 'ALT='? At the moment, it starts with '1372' and quickly changes to '524288' and doesn't change even when at altitude (up stairs)
I would like to see the 'ALT=' result change, before looking at the calculation to hPa, we may not need it, if we use < and >. For now anyway.
C.
 
hi C.
The 524288 is the test value from the d/s.
Use the SPI read values and Rem out the test values.
E
 
hi C,
May I ask, how do you intend using the Barometric pressure value in your project.?
E
 
Hi E,
First I would like to see the P_number rising and lowering, so as I can get a feel for it, in the simplest way possible.
Next I would add a Compass module in a similar fashion.
Then try to translate the readings to PWM used in RC control.
Then put it in a Tricopter and have it hovering a set height off the ground aiming a particular direction.
Once all that is done, I hope to refine it, each section at a time.
There are lots of details to refine, and for me, it would be 'perhaps' a waste of time to do it all during the module testing stage.
An exmple of this is: Altitude readings change with the temperature, and the BMP280 has a 'Temp' reading to add into any calculation, but for this project I can't tell till if it's needed till it's flown.
C.
 
hi C,
Barometric pressure changes due to the weather pattern.
Unless you have fixed Base station measuring ambient pressure as a correction factor, how will you calculate the Alt of the model?
E
 
hi C,
Barometric pressure changes due to the weather pattern.
Unless you have fixed Base station measuring ambient pressure as a correction factor, how will you calculate the Alt of the model?
E
Hi E,
True.
I would place the module on the ground press a button, and take the reading then compare height readings from the first one. A test for 1Mtr 2Mtr etc will give numbers, then I'll see what's needed as I go along. I hope to be able to fly by eye, so for now interpretation calulations, may not be necessary.
C.
 
Hi,
[ON PCB, not SIM] I've tried WRITEing to one of the 'P' registers and the '#p_msbnlsbnxlsb' result changes, so it appears that it is set up correctly, but as soon as I don't WRITE, and only READ, I only get the ALT=524288 READing.
SEE: The lines with !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
C.
'#########################################################################
Const r_p_xlsb = 0xf9 'READ ADDR PRESSURE xlsb from BMP280 LEAST
Const w_p_xlsb = 0x77 'WRITE ADDR PRESSURE xlsb from BMP280 LEAST
Dim p_wxlsb As Byte '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
p_wxlsb = 0 '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Const r_p_lsb = 0xf8 'READ ADDR PRESSURE lsb from BMP280 MID
Const r_p_msb = 0xf7 'READ ADDR PRESSURE msb from BMP280 MOST
'##########################################################################
Disable High
Disable Low
Include "fontsml.bas" 'This 'FONT' file nust be in the same folder as this program code
msg1 = ""
Hseropen 9600
Hserout "Ready!", CrLf
SPIPrepare
start:
'do a lcd Reset
Gosub rst_lcd '5110 states very early RESET is important
SPIPrepare
Gosub cmd5110 'init lcd<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
WaitMs 10
Call clear()
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'simulated bmp regs values
''p_xlsb = 0x40 'low byte
''p_lsb = 0xe2
''p_msb = 0x01 'high byte
''p_lsbnxlsb = 0x00
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

main:
'###################################################################
Gosub get_neo 'Reads NMEA DATA<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
PORTD.4 = 1 'CHIP SELECT 5110 OFF
WaitMs 100 'Does CS need time to switch? [SHORTEN OR REMOVE THIS LINE]
PORTD.5 = 0 'CHIP SELECT [hpa] ON
WaitMs 100
''Goto test1 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
SPICSOn
SPISend 0xf4 'Control reg addr
SPISend 0x00 '3 'Normal mode
'******************************************************************
'SPISend w_p_xlsb 'READ ADDR PRESSURE xlsb from BMP280!!!!!!!!!!!!!!!!!!!!!!!!!
'SPISend p_wxlsb 'Least sig BYTE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'*********************************************************************
SPISend r_p_xlsb 'READ ADDR PRESSURE xlsb from BMP280
SPIReceive p_xlsb 'Least sig BYTE>>>>>>>>>>>>>TEST<<<<<<<<<<<<<<<<<
SPISend r_p_lsb 'READ ADDR PRESSURE lsb from BMP280 MID
SPIReceive p_lsb 'mid sig Byte
SPISend r_p_msb 'READ ADDR PRESSURE msb from BMP280 MOST
SPIReceive p_msb 'Most sig BYTE
SPICSOff
WaitMs 500
PORTD.5 = 1 'CHIP SELECT OFF[hpa][SPI]
 
hi C,
Visually comparing the value you read and the example value in the d/s, they are very close, it may be working.??

You have to do the maths in #327 in order to get a actual Pa value.

E
 
hi C,
Visually comparing the value you read and the example value in the d/s, they are very close, it may be working.??

You have to do the maths in #327 in order to get a actual Pa value.

E
Hi E,
I accept that for a Pa value or an altitude in Mtrs, would need a calculation, also the reading needs compensation from other aspects, but I would have though before that I should be able to READ the pressure register addresses and get readings that move as I raise the module. This is what I'm trying to do first.
What I tried was to WRITE to one of the register addresses and it shows a difference other than 524288, but when I try to get the module to output actual DATA it always shows 524288.
C.
 
Hi,
I'm just looking at the control register 0xF4. Here the MODE and sampling settings for TEMP and PRESS are set. I've tried setting it to 0x1F which I think enables PRESS and sets the sample rate high, with the TEMP diasbled and the MODE setting to Normal.
I get a reading of 550720.
C.
 
hi C,
Have you tried converting readings from the BMP280 to Pa.?
For ref only, this is the fiddling I had to do with Oshonsoft when I used the BMP180.
It is a I2C reading method.
E

rd_pressure:
I2CWrite sda, scl, 0xee, 0xf4, 0x34
WaitMs 5
I2CRead sda, scl, 0xef, 0xf6, ph, pm, pl
presraw = ph * 256 + pm

'cal the pressure
b6 = b5 - 4000
b62 = b6 * b6 / 4096

x1 = (b2 * b62) / 4096
x2 = ac2s * b6 / 2048
x3 = x1 + x2

b3 = ((ac1 * 4 + x3) + 2) / 4

x1 = ac3s * b6 / 8192
x2 = (b1 * b62) / 65536
x3 = ((x1 + x2) + 2) / 4

b4 = ac4 * (x3 + 32768) / 32768
b7 = (presraw - b3) * 50000
pp = (b7 / b4) * 2
''pp = (b7 * 2) / 4
x1 = (pp / 256) * (pp / 256)
x1 = (x1 * 3038) / 66536
x2 = (-7357 * pp) / 65536

pps = pp + (x1 + x2 + 3791) / 16
pps = pps / 10
b2aval = pps
Gosub bin2asc
Lcdcmdout LcdLine3Home
Lcdout "P1 ", ascbfr4, ascbfr3, ascbfr2, ascbfr1, ".", ascbfr0, "mb"
Hserout "P1 ", ascbfr4, ascbfr3, ascbfr2, ascbfr1, ".", ascbfr0, "mb", CrLf
Hserout CrLf
Return
 
Hi E,
Blimey!
I try my hardest to have the simplest programs, that I can get away with, as something like that would overwhelm me.
So far, I haven't got any readings to convert to anything yet:(
I'll remember where your conversion is for when I do need it though, thanks.
C
 
Status
Not open for further replies.
Back
Top