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.
No, why?
All calculations are made with single variables.
You get bytes from BMP280 and they will be combined to long or words and then converted to singles before the calculation.
This part is still missing from the program.
Hi J,
I've got 2x 'DIM t as' but I'm struggling with combining my program with your CALC program, so -don't go away-- :)
C.
 
No, why?
All calculations are made with single variables.
You get bytes from BMP280 and they will be combined to long or words and then converted to singles before the calculation.
This part is still missing from the program.
Hi again J,
I'm still having problems with P and PR. will you confirm that there is a 'p' and a 'pr' please?
C.
 
There is only pr, because P is a reserved keyword by Oshonsoft.
I don't know what it is used for.
Hi J,
That's a relief! I've changed all reference to 'p' to 'pr' and for my reading comfort, all of the 't' to 'tp'
Thanks,
C.
 
Hi,
Here's the CALC program combined with an earlier TEMP an PRESS program, It's a bit long for me and I'd appreciate someone giving it a proof read please, especially the use of BYTE, WORD, LONG, STRING etc in conjunction with the Oshonsoft rules. Is it generally ok?

The program from J, on #436 gives the correct reading on the 5110 using the dig_T1 to P9 examples.
NOTE: Because 'P' as in the program can't be used because it is an Oshonsoft
'reserved keyword' 'PR' has been used for PRESS. and TP for TEMP.

The program is showing readings on the 5110, but they're all over the place. The TEMP is affecting PRESS far too much.
C.
 

Attachments

  • 18LF4520 BMP280 5110 PCB TEST 310118 1700.bas
    19.2 KB · Views: 162
Last edited:
I took a quick look.
We have talked many times, that values in the dig_t1 - dig_p9 contain signed integers, which should be handled correctly.
Oshonsoft can't handle them directly.

In the calculations adc_t and adc_p were singles.
Now they are longs ( 20 bit )
The resolution will be lost in first divide, adc_p / 16384

Is the SPI with BMP280 working correctly?
I could try to make the t1-t3, p1-p9 part + calculations.
I think the program can be made much shorter.
 
Hi J and E,
J, See what E comes up with, thanks.

E, Just remembered!
EDIT:
dig_t1.LB = dig_t1_lb
dig_t1.HB = dig_t1_hb
dig_t1 = dig_t1.HB * 265 + dig_t1.LB
dig_t2.LB = dig_t2_lb
dig_t2.HB = dig_t2_hb
dig_t2 = dig_t2.HB * 265 + dig_t2.LB
dig_t3.LB = dig_t3_lb
dig_t3.HB = dig_t3_hb
dig_t3 = dig_t3.HB * 265 + dig_t3.LB
dig_p1.LB = dig_p1_lb
dig_p1.HB = dig_p1_hb
dig_p1 = dig_p1.HB * 265 + dig_p1.LB
dig_p2.LB = dig_p2_lb
dig_p2.HB = dig_p2_hb
dig_p2 = dig_p2.HB * 265 + dig_p2.LB
dig_p3.LB = dig_p3_lb
dig_p3.HB = dig_p3_hb
dig_p3 = dig_p3.HB * 265 + dig_p3.LB
dig_p4.LB = dig_p4_lb
dig_p4.HB = dig_p4_hb
dig_p4 = dig_p4.HB * 265 + dig_p4.LB
dig_p5.LB = dig_p5_lb
dig_p5.HB = dig_p5_hb
dig_p5 = dig_p5.HB * 265 + dig_p5.LB
dig_p6.LB = dig_p6_lb
dig_p6.HB = dig_p6_hb
dig_p6 = dig_p6.HB * 265 + dig_p6.LB
dig_p7.LB = dig_p7_lb
dig_p7.HB = dig_p7_hb
dig_p7 = dig_p7.HB * 265 + dig_p7.LB
dig_p8.LB = dig_p8_lb
dig_p8.HB = dig_p8_hb
dig_p8 = dig_p8.HB * 265 + dig_p8.LB
dig_p9.LB = dig_p9_lb
dig_p9.HB = dig_p9_hb
dig_p9 = dig_p9.HB * 265 + dig_p9.LB

C.
 
Last edited:
hi C,
OK, I will wait untill you repost.
E
 
Here is my new version for calculations.
Remove all variables from your program that read or send pressure/ temperature data from/to bmp280, but needs the spi definitions + CS and SPIon / SPIoff and BMP280 configuration.
I have used again single variables in the calculations, because they make it easy to convert signed integers to signed singles.
This compiles ok, but something may be missing.
 
Found a couple of errors.
Hi J and E,
Thanks it looks good.
I'll combine it with the main program and post it.
EDIT: Where 'pr' has been used instead of 'p', I will change 't' to 'tp' for ease of reading, for me.

E,
Perhaps wait till I've posted this new program, before deep editing. Although if you spot something obvious, let me know.
C.
 
Last edited:
Hi,
Here is the EDITED CALC before combining into main program, compare it to #452 CALC. Is it ok.

Check the SPI routines including the addresses of TEMP and PRESS, they may have been reversed?

C.
 

Attachments

  • CALC BMP280 EDITED [01.02.2018].bas
    4.1 KB · Views: 158
I may have it wrong, but why did you change the reading of t1-p9 values from BMP280 ?
I assumed, that sending an address to BMP280 and then doing SPIreceive, we get a value from that address. Is that not right?

In the for next loop, i + hex value is address and data is put to a table b(i). You have reversed it and the index is i+i ?

For Dig_t and Dig_p values they is no need doing these multiplications by 256, just for example dig_t1 = t1 is enough.

Is it necessary to do CS= 0 CS=1 inside the loop?

Edit: I am sorry, it is my fault
Reading the t1-p9 values to table b() should be:

For i = 0 To 23
SPISend 0x88 + i
SPIReceive data
b(i) = data
Next i
 
Last edited:
There were more errors.
Add SPIsend, SPIreceive to this.
 

Attachments

  • Pressure_temperature2.bas
    3 KB · Views: 162
Hi J,
I realised that my version of the for/next loops aren't correct!

Yes, SENDing an address to BMP280 and then doing SPI-RECEIVE, we get a value from that address, is true.

I found by experiment, that the CS needs to be between each SEND/RECEIVE, I can try taking it out later, once it's running. The D/S suggests 'burst READ' but I couldn't get it to work.

I don't think I've used your elegant way of b(i) to save a long program list before, so I bow to your experience.
How I see it is, that '0x88 +1 is, SEND/RECEIVE, then repeats the same 23 times. I'll continue to use the LOOPs as you suggest, till told otherwise.

For i = 0 To 23
SPISend 0x88 + i
SPIReceive data
b(i) = data
Next i

OK, regarding the '*256' I'll remove them.

I did reverse the 0xf7 TEMP LOOP and 0xfa PRESS LOOP, will you let me know if I'm correct, please?

NOTE: This is quite advanced for me, but I'm enjoying it, I hope you are too, and I'm sure we'll succeed.
C.
 
How did you reverse Temp & Press loops?
b(0) is MSB, b(1) is LSB and b(0) is XLSB

These loops should be ok on my latest version
 
I found, that SPIsend don't accept hex value + i as a parameter.
Has to be byte variable.
Added Dim adr as Byte
Fixed here.
 

Attachments

  • Pressure_temperature2.bas
    3.1 KB · Views: 155
How did you reverse Temp & Press loops?
b(0) is MSB, b(1) is LSB and b(0) is XLSB

These loops should be ok on my latest version
Hi J,
C.
 

Attachments

  • TEMP-PRESS.jpg
    TEMP-PRESS.jpg
    116.3 KB · Views: 181
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top