Help needed GPS calculation!

For general Flowcode discussion that does not belong in the other sections.
jgu1
Posts: 777
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 670 times
Been thanked: 175 times

Help needed GPS calculation!

Post by jgu1 »

Hi all!

In another project where I have to calculate the distance by measure the speed from a GPS I have made a program to try to get it work, but no luck.

I found a formel for this on the web: Distance = Speed * time in minute / 60

I use an ESP32 and ILI9341spi with touch. Work perfect.

First I get the speed from the GPS Work!
Then I add the speed every 30 second and count every time to get the average speed.
I also made in interrupt for counting the minute I use in the calculation to get the distance.

Finally I press in the screen to get the result/distance, but only get a 0. Spend a lot time. of course I have done something wrong. Please any advice :D

Thank´s in advance.

Br jorgen
Attachments
ESP32 ILI9341 GPSAFloat.fcfx
(40.92 KiB) Downloaded 501 times

Steve-Matrix
Matrix Staff
Posts: 1472
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 204 times
Been thanked: 349 times

Re: Help needed GPS calculation!

Post by Steve-Matrix »

The order of precedence of multiply and divide is the same, and so the divide in your formula could happen before the multiply. If you are using integer variables, then the following could happen:

Say speed = 100 and time = 20, then distance = 100 * 20 / 60 = 100 * (20 / 60) = 100 * 0 = 0.

To get around this, you could make sure the multiply is forced to be evaluated first by using brackets around (speed * time). Or a more accurate way (if speed is not essential) would be to use floating point variables (in which case you should also force constants like 60 to be floats by writing them as 60.0).

Of course, there could be something else going on in your program. But the above may help.

jgu1
Posts: 777
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 670 times
Been thanked: 175 times

Re: Help needed GPS calculation!

Post by jgu1 »

Hi Leigh!

Many thank´s Leigh. It's been many years since I went to school. :lol: I'm trying to change the calculations.

Br Jorgen

jgu1
Posts: 777
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 670 times
Been thanked: 175 times

Re: Help needed GPS calculation!

Post by jgu1 »

Sorry wrong person, I mean Steve. :lol:

Jorgen

Steve-Matrix
Matrix Staff
Posts: 1472
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 204 times
Been thanked: 349 times

Re: Help needed GPS calculation!

Post by Steve-Matrix »

Thanks, Jorgen. :)

monie
Posts: 73
Joined: Wed Oct 19, 2022 4:06 pm
Has thanked: 1 time

flowcode v9 gps click bl0106

Post by monie »

Image
Er der nogen der har FlowcodeV9 Coder, så jeg kan afprøve GPS click enheden som vist på billedet nedenfor?
Does anyone have Flowcode 9 Codes so I can test the GPS click device as shown in the picture below?

Jeg benytter EBlocks2 dsPIC Programmer BL0032-1
I use EBlocks2 dsPIC Programmer BL0032-1

Uses Display type: 20 x 4 Using the LCD diaplay

Med venlig hilsen
Monie
Attachments
GPS click.jpg
GPS click.jpg (110.21 KiB) Viewed 5380 times

chipfryer27
Valued Contributor
Posts: 1528
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 353 times
Been thanked: 549 times

Re: Help needed GPS calculation!

Post by chipfryer27 »

Hi

As far as I am aware, the default configuration for the module is to use NMEA, which is the protocol used in the Flowcode Generic GPS component (available under Comms).

Unfortunately I don't have a module to try, but I'd maybe look at connecting using UART which may mean "mapping" the component Rx pin to suit.

Sorry I can't be of more help.

Regards

monie
Posts: 73
Joined: Wed Oct 19, 2022 4:06 pm
Has thanked: 1 time

Re: Help needed GPS calculation!

Post by monie »

Thank you very much for replying.
But I would like the GPS device to work on: dsProgrammer dsPIC BL0032-1 is it possible?

chipfryer27
Valued Contributor
Posts: 1528
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 353 times
Been thanked: 549 times

Re: Help needed GPS calculation!

Post by chipfryer27 »

Hi

I don't have the module nor that Programmer.

However it appears you are using a BL0106 "Click Board"too. That board takes standard MikroElektronica "Click" modules and allows connection to Eblocks such as your BL0032.

If you download the Eblock datasheet

https://www.matrixtsl.com/resources/fil ... asheet.pdf

You will find the BL0106 schematic on page 9 and the BL0032 on page 44.

From the BL0106 schematics it shows the corresponding Port Connections to the "Click" connections.

Port 0 = uC Rx/Click Tx
Port 1 = uC Tx / Click Rx
etc

Therefore if you were to plug your BL0106 into Port B of the BL0032, you would receive whatever was being sent from the Click on Port B0 and to send to the Click you would use Port B1.

When you start a New Project you will be selecting your BL0032 as the target. If you then plug in your BL0106 into Port B (you can use any Port) and add the Generic GPS component to your Dashboard Panel, under Properties you will be able to select the Pin to use as the Receive.

Capture.JPG
Capture.JPG (84.97 KiB) Viewed 5329 times

I only used Port B as an example, you could use whatever you wish.

I don't have those boards / modules so whilst the above illustrates how to "connect" pins/ports of your Click/Programmer board, I'm not saying it will work straight away. You may need to send config to the Click or such like and for that you may need to use the UART component instead (connected as above etc).

Hope this helps a little and good luck. Let us know how you get on.

Regards

monie
Posts: 73
Joined: Wed Oct 19, 2022 4:06 pm
Has thanked: 1 time

Re: Help needed GPS calculation!

Post by monie »

Hello all Flowcode users

Does anyone have an example of Flowcode V9 codes so I can test the GPS-click device as shown in the picture?

Regards

Post Reply