HEX To Time Conversion

Hi, I want to ask, about time conversion.

I have captured Serial RS-232 data and got HEX value (01 FF). I have tried to convert the HEX value but, I don't understand about this time conversion.
And I want convert these HEX Data to Minutes, Thank you...

This is a Screen Shot of the Timescale and Range

Value Of Hex Data :

0x1FF == 511 decimal

1 == 1/4 second

511 == 511/4 seconds == 127.75 seconds

127.75 seconds / 60 == 2.129 minutes

What do I win?

@anon57585045 Thanks for your suggestion, I'll try again to match this data with the translated result file.

and how about this ? can you help me

Hex Data:

converting US gal to Liter

Not unless you explain what these tables are, where they come from, and how they are generated.

Also what a "translated result file" is, what is performing the translation, what kind of translation is being performed...

In short, please completely describe your application.

Are you asking for help with this? To do it, you multiply US gal by a constant.

Also to convert the hex fuel data:
https://www.binaryconvert.com/convert_float.html

@anon57585045 Actually im trying to convert data from machine activity, Caterpillar Mining Equipment 777E,
All data is HEX, From VIMS telemetry port. In telemetry it can be accessed by serial RS-232 and they use the RPC Protocol, the shop manual document is very limited on explanation, and I don't understand this conversion.
The Translated File Automaticaly generated By VIMS and the output file is .csv

So, are you saying you just don't understand digital numeric data formats? If not, what do you actually want?

Here is a better converter page:
https://www.h-schmidt.net/FloatConverter/IEEE754.html

You have 5.85055685043 gallons of fuel.

Is that the source of the tables you posted? Can you capture and read or post the raw data from the device?

@anon57585045 No, that's not the source table from what I posted, There are several methods to retrieve data. the first to download manually using an application from the dealer (And this takes a very long time to download, the output data is a .csv file). The second way, it is done by capturing via the Telemetry Port that has been provided from the Machine (this way data retrieval can be done in real-time, but with RAW HEX data).

This is a RAW data what i captured,
01 62 00 01 00 0f 01 ff 05 64 04 24 00 09 00 ba 08 20 00 15 05 36 40 bb 37 c3 30 30 35 32 38 00 00 37 e0 ac 18 c0

Document from VIMS Telemetry Port


Ah, much better information. It's easy to convert hex to binary and store it in variables. So you can decode the RAW stream. What have you tried so far? You posted a table explaining the purpose of every byte in the message stream. So that is no mystery.

Are you trying to write a program, or just convert a few values manually? You didn't say at all. You also didn't say whether an Arduino is involved, or if so, which one.

Did you search for information about RPC?
https://www.google.com/search?q=RPC+Protocol

How did you obtain the RAW data? It looks like that must have been successful, since you posted it.

Hi @anon57585045,

the question is what RAW HEX data are ...

The description looks like binary data transfer where the data are just represented in hex format.

Does it really make any sense to transmit the data as ASCII characters?

If it is binary and a fixed protocol (as implied by the last information) a simple struct should do it...

1 Like

It is 5.85.

How?
Sketch:

void setup()
{
  Serial.begin(9600);
  float y;
  long *ptr;
  ptr = (long*)&y;
  *ptr = 0x40BB37C3;
  Serial.print(y, 2); //shows: 5.85
}

void loop() {}

No, it's the output from a tractor. It makes sense that it's ASCII, that is very common. The question is self answered, because an explanation of the meaning of the data was posted in a table.

I agree about the struct, that is what I would use.

Not Yet :smiling_face_with_tear: ,
I'm just trying to retrieve data using the RS232 Serial Converter, future plans I will using Arduino Mega 2560 to directly retrieve the data.

Plugged into a PC, can I assume?

@GolamMostafa Thank you, tomorrow I will write the code and I will post it here.

1 Like

If you expect it to be portable to other architectures besides the Mega, don't use the type punning method presented. It's quick and dirty, it works. However, it is not guaranteed to work on all machines because it uses undefined C/C++ storage methods.

It's a great example, though... it can get you started.

The correct way is to use exclusively arithmetical methods based on features of C/C++ that are officially defined.

A tidbit - you can use strtoul() with the right parameters, to read hex values into a variable.

Maybe this link which I found googling for "RPC vims tpms cycle" can be helpful

http://base.galileosky.com/articles/#!en-documentation/connecting-and-working-with-vims

At least it mentions three different message types which had to be taken care of and lead to different structs

Yes, and endian-ness is something to be careful about too.