Converting decimal value from trc data file

This forum covers issues concerning multiple software products.
Locked
danienpark
Posts: 5
Joined: Mon 24. Aug 2020, 10:30

Converting decimal value from trc data file

Post by danienpark » Mon 24. Aug 2020, 10:42

Hello,
I get the data from my microprocessor to my deskop PC using PEAK CAN USB. I trace the data on PEAK CAN view software then save it as a trc file. But in this data, it is not in normal value. My data are voltage, current values. I have ten parameters, I get ten values of these each parameters (voltage, current, angle, etc..) in one sampling period (10 kHz). For example A0 is current, A9 is angle. I gave ten data bloew for one period.

1) 51331.7 Rx 00A0 4 42 0C B2 64
2) 51331.8 Rx 00A1 4 42 0C C5 3D
3) 51331.9 Rx 00A2 4 3F 10 5F 79
4) 51332.0 Rx 00A3 4 3E A5 19 36
5) 51332.1 Rx 00A4 4 42 1C 17 2E
6) 51332.2 Rx 00A5 4 40 9B D2 F3
7) 51332.3 Rx 00A6 4 40 40 00 00
8) 51332.4 Rx 00A7 4 40 80 00 00
9) 51332.5 Rx 00A8 4 40 A0 00 00
10) 51332.6 Rx 00A9 4 3E 91 40 B4

My aim is to convert this hex data do decimal data and draw it to see the voltage and current values. I try to convert it using online hex to decimal converter but it gives me very big number, not correct.
What kind of conversion should I use ?
Can you suggest me a simple and easy way to convert the data and draw it ?
I gave 10 values above for one period. If I get 2 seconds data, how can I separate the parameters (A0 ,A1,...,A9) from ech other in trc file ?

Regards,

Park-Kim-İl

M.Maidhof
Support
Support
Posts: 1303
Joined: Wed 22. Sep 2010, 14:00

Re: Converting decimal value from trc data file

Post by M.Maidhof » Mon 24. Aug 2020, 11:17

Hi,

with the optional available PCAN-Explorer 6 it will be possible to create a symbol file, so that your raw CAN data will be converted into a human readable display for your current and voltage values. To create a symbol file for your CAN bus signals, you must first get the information how those current and voltage values are decoded in your CAN messages.

regards

Michael

danienpark
Posts: 5
Joined: Mon 24. Aug 2020, 10:30

Re: Converting decimal value from trc data file

Post by danienpark » Fri 28. Aug 2020, 15:33

Dear Michael,
I created signals and symbols. I set the parameters for the current as follows: ( I could not add the image, I inserted a google drive link)
From ADMIN Pictures could be very simply add - see "Attachmnets" - external Links, specially to Drop Boxes, are for securety reasons not allowed an are removed

And I set symbol file parameters as in the photo :
NOT ALLOWED

After creating symbol file and signals, I go to Peak CAN explorer, and added a USB CAN device connection and assigned the symbol file to this connection.

I added a Line Writer Window and select signal as Current. I inserted a photo URL related to the Line Writer Window below:
NOT ALLOWED

When I start the receiving signal values from USB CAN , I can see the data in the trace window as in the first message in this post. But I can not see the signal as in Decimal value or any other type, in the graphic. I also use Plotter window, I can not see anythink.
When I change the offset value from 50 to any other value, offset value can bee seen in Line Writer Window.
I am looking for the problem, Is it about data type come from my microcontroller to my PC ? I think my data is 32bit floating point , hex format as in the first message in this post. But I can see the data in trace window simultaneously.
Can you give me some idea or etc..?

One of te boot code in my microcontroller is below :

CANTXMsg1.ui32MsgID = 0xA0; //message ID
CANTXMsg1.ui32MsgIDMask = 0; //no mask
CANTXMsg1.ui32Flags = MSG_OBJ_NO_FLAGS;
CANTXMsg1.ui32MsgLen = sizeof(CANPACK1);
CANTXMsg1.pucMsgData = CANPACK1; //ptr of buffer

Regards

danienpark
Posts: 5
Joined: Mon 24. Aug 2020, 10:30

Re: Converting decimal value from trc data file

Post by danienpark » Fri 28. Aug 2020, 16:46

Dear Michael,
I created signals and symbols. I set the parameters for the current as in the attachment photo named "current".
And I set symbol file parameters as in the attachment photo named "symbol".

After creating symbol file and signals, I go to Peak CAN explorer, and added a USB CAN device connection and assigned the symbol file to this connection.

I added a Line Writer Window and select signal as Current. I inserted a photo in the attachment named "peakexolorer" Line Writer Window.

When I start the receiving signal values from USB CAN , I can see the data in the trace window as in the first message in this post. But I can not see the signal as in Decimal value or any other type, in the graphic. I also use Plotter window, I can not see anythink.
When I change the offset value from 50 to any other value, offset value can bee seen in Line Writer Window.
I am looking for the problem, Is it about data type come from my microcontroller to my PC ? I think my data is 32bit floating point , hex format as in the first message in this post. But I can see the data in trace window simultaneously.
Can you give me some idea or etc..?


Some extra info:

I think my data frame is DT: CAN or J1939 data frame. I got this info from CSC file as below:

Number Time (ms) Bus Direction Type ID (hex) Length D1 D2 D3 D4
1 0.000 1 Rx DT 00A1 4 42 09 B6 9B
2 0.000 1 Rx DT 00A2 4 41 3D 0C 2F
3 0.200 1 Rx DT 00A3 4 40 C4 19 16
4 0.300 1 Rx DT 00A0 4 42 0B C2 01



One of te boot code in my microcontroller is below :

CANTXMsg1.ui32MsgID = 0xA0; //message ID
CANTXMsg1.ui32MsgIDMask = 0; //no mask
CANTXMsg1.ui32Flags = MSG_OBJ_NO_FLAGS;
CANTXMsg1.ui32MsgLen = sizeof(CANPACK1);
CANTXMsg1.pucMsgData = CANPACK1; //ptr of buffer

Regards
Attachments
symbol.png
symbol.png (85.68 KiB) Viewed 994 times
peakexplorer.png
peakexplorer.png (140.34 KiB) Viewed 994 times
current.png
current.png (87.81 KiB) Viewed 994 times

M.Maidhof
Support
Support
Posts: 1303
Joined: Wed 22. Sep 2010, 14:00

Re: Converting decimal value from trc data file

Post by M.Maidhof » Mon 31. Aug 2020, 10:09

Hi,

first of all you must know how the data is decoded in the CAN message. So please check in your code how the data is set into the "CANPACK1" pointer. I don't think that it is a floating point value. You also mix up hex and decimal values for your symbols. While your trace file shows hex values of 0xA1, 0xA2 for your CAN IDs, you use 0x161 hex in the symbol file (161 dec = 0xA1 hex, and 0x161 hex is 353 dec)!

regards

Michael

danienpark
Posts: 5
Joined: Mon 24. Aug 2020, 10:30

Re: Converting decimal value from trc data file

Post by danienpark » Mon 31. Aug 2020, 18:00

Hello Micjael,
In one period, I get 4 variables (A0,A1,A2,A3).
A0 is dc current
A1 is dc votlage
A3 is sinus voltage
A4 is triable signal

And two periods in the trice data is given below: ( 4 is data length)

1) 3385.442 4 Rx 00A0 - 4 42 0C 9A 88
2) 3385.570 4 Rx 00A1 - 4 42 0B 4D 79
3) 3385.655 4 Rx 00A2 - 4 41 9D 36 7C
4) 3385.740 4 Rx 00A3 - 4 3D C3 5C F0
5) 3385.868 4 Rx 00A0 - 4 42 0C 27 1D
6) 3385.954 4 Rx 00A1 - 4 42 0B F7 8E
7) 3386.082 4 Rx 00A2 - 4 41 B9 7D 2B
8) 3386.167 4 Rx 00A3 - 4 3E 62 5C 6C

You asked in the previous post to check CANPACK1 in my code. The data is defined in my code as below:
unsigned char CANPACK1[4];
unsigned char CANPACK2[4];
unsigned char CANPACK3[4];
unsigned char CANPACK4[4];


I change the Data Type of Current as unsigned in the "Signals" section. And, I set Standart frame in the Symbol section as seen in the attached photo. Can ID is 0A0.

I would like to be sure that my problem is about setting the parameters in the symbol or signal files. Because I can see the data simultaneously in the trace window. So boud rate and bit rate are ok I think.

I tried different data type and length in the signal section, but the problem is still available, I can not see the current or voltage values in the grafic line or plotter simultaneously, even if I can see in the trace window simultaneously.

Do you think the problem is data type? Or The software is 30 days trial, but I have 25 more days, problem can be software (PCAN Explorer).

Note that:
I save the trace data as a text file then I write a code to separate A0,A1,A2 and A3, then convert it to hex to decimal in Matlab using the function : typecast(uint32(hex2dec(m1(i))),'single');. Using this function I can draw the data but it takes more time. m1(i) is the data in hexformat like 42 0C 9A 88.

Regards,
Attachments
symbolfile.png
symbolfile.png (236.43 KiB) Viewed 923 times

M.Maidhof
Support
Support
Posts: 1303
Joined: Wed 22. Sep 2010, 14:00

Re: Converting decimal value from trc data file

Post by M.Maidhof » Tue 1. Sep 2020, 12:37

Hi,

to interpret the CAN data correctly, you need to know how your current and voltage signals are decoded in your CAN messages. This could be signed, unsigned, 8bit, 10bit, 12bit, 16bit, little endian, big endian and so on. So please check how the data is coded into the CAN message, then you could use the same way to decode it using a symbol file in PCAN-Explorer.

The problem is not related to the trial version. A trial versions have no restrictions regarding the use of the software.

regards

Michael

danienpark
Posts: 5
Joined: Mon 24. Aug 2020, 10:30

Re: Converting decimal value from trc data file

Post by danienpark » Thu 3. Sep 2020, 16:30

Dear Michael,
Many thanks for your reply.
Actually I tried all combinations in the symbol file to select data type (such as bit, char, raw, float, double etc.. ).

I get this data "42 10 E3 86" from trace file (trc) using Peak Explorer or PeakCan Viewer.

One of my data in trace window is ( I gave also in the previous posts): 42 10 E3 86. When I use typecast(uint32(hex2dec(4210E386)) in Matlab , it converts to float value 36. This is my real voltage value. But before using this function in Matlab, I should convert the data "42 10 E3 86" to text and remove the spaces between characters. I also use an online converter (hex to float converter: https://gregstoll.com/~gregstoll/floatt ... 49IWCgeTVU]) , it gives 36.

The CAN data is defined as unsigned char and the data length is 4 in DSP code as (unsigned char CANPACK1[4];). So I think these "42 10 E3 86" are characters and each character is 4 bit , totally 8x4=32 bit.
In the trace file, I thought that this data "42 10 E3 86" is char. But When I select data type as char , length 32 bit in Signal file, I do not get any value in plot window. I also change the data type as double, float etc it does not give any result. When I select float, the data is like in square vawe format at high frequency.

I attached some photos related to Signals, Symbols and Receive, Trannmit window. The data shown in Receive window is raw data, because I select the data type as raw in signal file.

My questions:
What kind of data is used to plot the values in Line Writer Window or Plot Window ? Because when I import trace data using Tolls>>Plotter>>Import From traces, then I select trc file, there is no any signal on the plot window.

I also use different combinations, standard, extended etc. The problem not solved.

Can you give me some idea or suggestion please ?

Sorry for the long message.

Regards,
Attachments
trace.png
trace.png (59.39 KiB) Viewed 852 times
Symbol_Vd.png
Symbol_Vd.png (91.64 KiB) Viewed 852 times
Signal_Vd.png
Signal_Vd.png (80.41 KiB) Viewed 852 times
Receive_Transm.png
Receive_Transm.png (85.89 KiB) Viewed 852 times

User avatar
U.Wilhelm
Sales & Support
Sales & Support
Posts: 1187
Joined: Fri 10. Sep 2010, 19:34

Re: Converting decimal value from trc data file

Post by U.Wilhelm » Fri 4. Sep 2020, 08:51

simply read the last answer from Michael - you need to know how the Data inside the CAN Frame (max. 8 Bytes) are decoded, if you have this knowledge, you could use it in.
The PCAN-Explorer could decode also float (4 Byte IEEE 754 single-precision binary floating-point format) - Simply define the Signal as float - 4 byte and decode. PCAN-Explorer will show the real Value.

We do not understand which probem you have inside PCAN-Explorer ... how you decode it in your software is up to you - we talk about 4 simple Bytes - not more not less.
But this have nothing to do with our product - these are software development basics and should be answered in other programming forums - not here.

We will close this topic now. If you have any additional question related to the product itself, please start a new topic or send an e-mail to our support.
Thank you
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------

Locked