Jump to content
The mkiv Supra Owners Club

Maths expert? Have a go at this please!


Chris Wilson

Recommended Posts

My ecu outputs seven decimal place GPS coordinates as two 16 bit channels and the data reading software then combines them using maths to give a degree based GPS coordinate to generate a track map.

 

Below are two samples, one raw data from the ecu as two 16 bit channels, the other the GPS coordinate in degrees after the software has done the maths wizardry. Can anyone work out what it's doing to the raw date to combine them to make the correct coordinate please? I can't....

 

ECU output: GPS Latitude HW : 8015

GPS Latitude LW : -13983

 

Maths gives : Coordinate 52.8870988 degrees latitude

 

########################

 

ECU output : GPS Longitude HW : -364

GPS Longitude LW : 14387

 

Maths gives : Coordinate -2.6401195 degrees longitude

 

 

Thanks!

Link to comment
Share on other sites

KInd of what I was wondering. High something and low something I would guess, but it is just a guess. I also don't know what type of coordinate system those numbers could be in. It must be some kind of recognised system otherwise the software (unless it's by the same manufacturer as the ECU) wouldn't be able to decode it to good ol' degrees. WGS84 gets mentioned quite a lot when talking about GPS, but googling WGS84 didn't help. :(

 

Edit: I'm clearly out of my league. I'm out.

Link to comment
Share on other sites

Hi Chris

 

I would expect that you need to join the high and the low words together to make one 32 bit word. It's probably easier to work in hex or binary when doing this. I would then expect that the least significant bit of this 32 bit word will represent a very small fraction of a degree. You just need to multiply the 32 bit number by this LSB value to get the real world measurement. Be careful with handling negative numbers during the conversion.

 

You may also find that the conversions for longitude and latitude are different as the latitude only needs to encode +/- 90 degrees whereas the longitude needs to handle +/- 180 degrees. If you haven't got an answer tonight, I'll have another look for you.

 

Andy

Link to comment
Share on other sites

All I can say is the hardware won't allow transmission of 32 bit data on the serial port, so they somehow split it up into two sets of 16 bit, then rejoin it in the software using maths. The end result is degrees, minutes and seconds to seven decimal places. I am collecting the data from the CAN BUS of the ecu, and logging it in a none Motec data logger. The data logger's software has powerful maths functions, so once I can see how Motec split and rejoin the data streams I should be able to duplicate it in the other software. They also split the GPS time data stream into two 16 bit channels, this may be easier, example below, the time does not take into account British Summer Time offset, by the way.

 

GPS Time HW : 1614

GPS Time LW : -8040

 

GPS Time (combined) : 105832.600

 

 

Actual time was 10.58 AM and 32.600 seconds.

 

Thanks everyone.

Link to comment
Share on other sites

Right I've figured out that LW = LoWord and HW = HiWord.

 

This is a way of splitting a long number into 2.

 

The trick is getting them back to one number which I thought was easy but it's proving hard as I can't get the figure you're looking for lol.

Link to comment
Share on other sites

Err, no, sorry mate, I don't. I apppreciate the trouble you have gone to, I have tried to open the file in Open Office, with macros enabled, but it comes up as an empty sheet.

 

On another forum someone posted this:

 

 

###############################

 

8015*2^16 (shift left 16 bits)

+ -13983 (add on the second word)

/ 10^7 (7 decimal place fixed point)

=52.5

 

Pretty close!

 

 

and

 

-364*2^16 (shift left 16 bits)

+ 14387 (add on the second word)

/ 10^7 (7 decimal place fixed point)

=-2.384

 

Again pretty close.

 

It's just putting together the 16-bit words. It looks like both words are 2's complement - it doesn't work if you assume it is two halves of a 32-bit 2's complement word.

 

 

######################################

 

Is this similar to your calculations Scott? Cheers.

Link to comment
Share on other sites

Err, no, sorry mate, I don't. I apppreciate the trouble you have gone to, I have tried to open the file in Open Office, with macros enabled, but it comes up as an empty sheet.

 

On another forum someone posted this:

 

 

###############################

 

8015*2^16 (shift left 16 bits)

+ -13983 (add on the second word)

/ 10^7 (7 decimal place fixed point)

=52.5

 

Pretty close!

 

 

and

 

-364*2^16 (shift left 16 bits)

+ 14387 (add on the second word)

/ 10^7 (7 decimal place fixed point)

=-2.384

 

Again pretty close.

 

It's just putting together the 16-bit words. It looks like both words are 2's complement - it doesn't work if you assume it is two halves of a 32-bit 2's complement word.

 

 

######################################

 

Is this similar to your calculations Scott? Cheers.

 

 

Very similar, yes. Mine is exact though :p

Link to comment
Share on other sites

So you come up with the exact same Long and Lat figures as the Motec software's manipulation of the data then? Because although the poster on the other forum says his is "close", it may be in numeric terms fairly close, but in geographic terms it's hundreds of miles out. Not in sunny Shropshire, but somewhere out in the North sea :) If I posted a screenshot of the maths input page could I impose on you to see if you could write your maths out in a way that could be in-putted to the page? Thanks ;)

Link to comment
Share on other sites

So you come up with the exact same Long and Lat figures as the Motec software's manipulation of the data then? Because although the poster on the other forum says his is "close", it may be in numeric terms fairly close, but in geographic terms it's hundreds of miles out. Not in sunny Shropshire, but somewhere out in the North sea :) If I posted a screenshot of the maths input page could I impose on you to see if you could write your maths out in a way that could be in-putted to the page? Thanks ;)

 

Unfortunately I didn't do the maths mate, I made the program do it for me ;)

 

The program is doing exatly what the guy has done, only infinite decimal places etc hence why it is more accurate.

 

I'll try the program here and see what it does.

Link to comment
Share on other sites

Fantastic, well done! But how do you get from 52.5322593 to 52.8870988333333 ? Thank you very much Scott, you are my hero, once I have worked out how to set up the maths channel that's the coordinates sorted!

 

Because the first figure is given as a decimal point from 10, rather than minutes and seconds. The 0.5322 etc has to be divided by 0.6 to convert it to minutes & seconds.

 

:)

Link to comment
Share on other sites

Got it! Thanks. You have been a really great help!!

 

Right, let's give Scott a break, who is up for trying to create a maths "thing" to do this automagically? Here's a screenshot of the maths feature in the GEMS software. I have called the channel to be created GPS LAT and have started by entering the GPS LAT HW channel, which should automatically enter the raw figures for that channel in as they are read. Screenshot below.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. You might also be interested in our Guidelines, Privacy Policy and Terms of Use.