CAN Signal unpacking using DBC

12 views (last 30 days)
Oliver Grimmett
Oliver Grimmett on 13 Feb 2017
Answered: Corentin OGER on 19 Nov 2019
Hi, the program I am writing takes in CAN signals from a source, then unpacks certain required signals and displays them. Currently it filters the incoming messages to the required message (since all required signals are on one message). Then unpacks the signals one by one.
The issue is that the signal start bit, bit length and byte order all have to be entered by the user for each signal required. These details are already in the DBC file so is it not possible to pull them from this? Or give a list of signals and allow the user to select the ones they require.
Thanks

Answers (1)

Corentin OGER
Corentin OGER on 19 Nov 2019
Hello Oliver,
I have a very similar issue, I wonder if you have found the solution to this problem.
I have series of CAN message objects containing a variety of messages, each carrying several signals (in the 100,000s of elements each) from previous recordings. I also have the corresponding database so I can convert to physical values (volts, rpm...)
Here is what I have managed so far:
Attach the database to my Raw messages:
attachDatabase(AllMessages, db); %AllMessages = large log of mixed CAN messages, db = my database
Extract a single message ID into a new object:
Extract_BMS = extractAll(AllMessages,'BMS_RN1'); %Returns a CAN message object with only 'BMS_RN1' messages
Access all signals from a single message as physical values: (in this example, message number 4321)
Extract_BMS(1,4321).Signals
ans =
struct with fields:
HVIsolationImpedance: 1000000
BMS_InterlockHVconnector_v2: 2
BMS_HVNetworkVoltage_v2: 374.5000
HVBatInstantCurrent_v2: 3.6250
HVPowerConnection: 1
BMS_InterlockServicePlug_v2: 2
Acces a single signal physical value:
MyVoltage = Extract_BMS(1,4321).Signals.BMS_HVNetworkVoltage_v2 %Extract voltage from frame 4321
MyVoltage =
374.5000
However, I can't find an elegant way of returning a large array of physical values, something like this:
>> VoltageArray = Extract_BMS(1,1:999).Signals.BMS_HVNetworkVoltage_v2
Expected one output from a curly brace or dot indexing expression, but there were 999 results.
I could make a loop for each signal in each message and fill arrays element by element, but there has to be a better way.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!