CanTool shows zero for physical value

6 ビュー (過去 30 日間)
Joost 2011 年 5 月 9 日
As a master student Automotive Engineering Science, i'm investigating the Vehicle Network Toolbox which i'm going to use for a project.
The Vehicle Network Toolbox Simulink demos are working fine, however I am experiencing a problem using the canTool for viewing live CAN message data:
I simulate a CAN message using the 'CAN Pack'-block, attaching a *.dbc database file to it, and transmit it via a Virtual Channel (using the 'CAN Transmit'-block). The Min and Max value of the signals in the database are correctly indicated in the 'CAN Pack'-block as -Inf and Inf (infinite). (Although in the *.dbc database these values are both indicated as zero, because only numerical values can be used).
The problem is that when I visualize the data send on this Virtual Channel using the canTool, all signals in the signal show a Physical Value of zero, whereas the raw data indicates that there is a non-zero signal.
However, if I change the default values of the minimum and maximum value of the signal in the database file to a non-infinite number (for example -1000 and 1000), the canTool correctly show the Physical Values which are non-zero for the signals in the message.
Since I am completely new with the Vehicle Network Toolbox, I may have overlooked something, but at this point I cannot figure out what.
Could someone please tell me if (and how) this problem can be solved?
Since the database file which I have to use eventually, contains more than 250 message- and signal-data, I'm not eager to change all the maximum and minimum values (which are all set to infinite).
Thanks in advance,
P.S. I'm using Matlab version 2010b and Vehicle Network Toolbox version 1.3


Shankar Subramanian
Shankar Subramanian 2011 年 5 月 11 日
You can create a channel in MATLAB, start it to receive the messages on the network.
% Create Channel - Virtual Channel 2
% (Assuming Simulink is sending on Channel 1)
canch = canChannel('Vector', Virtual 1', 2);
% Set CAN channel online
Once online, the CAN channel canch is set to send and receive messages. You can see the number of messages received so far by typing canch in command line.
canch =
Summary of CAN Channel using 'Vector' 'Virtual 1' Channel 2.
Channel Parameters: Bus Speed is 500000.
Bus Status is 'ErrorActive'.
Transceiver name is ''.
Serial Number of this device is 0.
Initialization access is allowed.
No database is attached.
Status: Online.
18 messages available to receive.
0 messages transmitted since last start.
0 messages received since last start.
Filter History: Standard ID Filter: Allow All | Extended ID Filter: Allow All
You can use the receive command to receive your messages.
% Receive all messages.
msgs = receive(canch, Inf);
% Attach database.
database = canDatabase('DATABASENAME.dbc');
attachDatabase(msgs, database);
You can save the received messsages to a MAT-file using the save command so that you can analyze them later.
Additionally, you can set filters in your channel to receive specific message IDs. You can find other available CAN functions in the following page.
  1 件のコメント
Joost 2011 年 5 月 20 日
Hi Shankar,
Thanks for your comprehensive and clear explanations!


その他の回答 (3 件)

Arnaud Miege
Arnaud Miege 2011 年 5 月 10 日
I think the problem is because the min/max values are specified as zero in the database, which is interpreted as the signal having a max value of zero and also a min value of zero, therefore being equal to zero. At least, that's how I understand it.
If you can't specify +/-Inf in the database (I'm not that familiar with CAN databases), then you'd have specify a finite value. This can probably be automated with MATLAB, rather than having to do it by hand, but I'm not too sure how to go about it.

Shankar Subramanian
Shankar Subramanian 2011 年 5 月 10 日
Yes, your understanding is correct that the min/max values of 0 is causing the physical values of signals to be shown as 0. At this point you will have to update the min/max for the signals in CANdb++ editor.
On the other side - what does your application do? If you want to use Simulink and you want to log signal values, you can extract them using CAN unpack block and save the signal values using To Workspace or To File block. In this case, you may not need to update the DB file as the min/max used in Simulink is -Inf/Inf. If you want to do post analysis in MATLAB you can load the saved variables/file in command line.

Joost 2011 年 5 月 11 日
Thanks for your answers.
I still think it's a bit strange that in the 'CAN Unpack'-block the min and max values are correctly indicated as -Inf and Inf. Also, the data output of this block shows the expected (non-zero) signal value, while the canTool is indicating a physical value of zero. Is this because the canTool 'under the hood' is using the literal values indicated in the database (which are both zero)? Can I in this case consider this as a bug?
Shankar, your suggestion of using a 'To Workspace or 'To File' for saving the signal data is an option but I think with this, I cannot log all data (of 250+ signals) in one shot or can I? I would have to make a 'CAN Unpack'-block for each message and add an output for each signal in the message. Or is there another option to achieve this?
I think that logging data with the canTool in this respect is a lot easier, as the canTool is able to save a *.mat file which contains all signal data of all messages transmitted by the vehicle (both raw data as the physical values).
Since one of the goals of the project is to log the message data from the vehicle and display and analyze it either realtime or afterwards, it would be of great interest to me if there is a way to log all data simultaneously (either with the canTool or using another method).
  1 件のコメント
Joost 2011 年 5 月 11 日
Well, I managed to change all zeros for the min and max values in the database to a non-zero (finite number) so I now can use the canTool again for logging data.
Nevertheless, I am still interested in why the canTool does not interpret the min and max values of zero the same as the 'CAN Unpack'-block does (thus interpret zero as infinite). Also I am still interested in how to log all messages at once without using the canTool. I think I could use the Vehicle Network Toolbox functions in MATLAB in a for-loop to log all messages together, but I have not yet figured it out how to do it.


Community Treasure Hunt

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

Start Hunting!

Translated by