EcoCoder Manual - 4.9.1
EcoCoder Manual - 4.9.1
EcoCoder Manual
V4.9.1
Contact us:
Web: http://www.ecotron.ai
Email: [email protected]
[email protected]
Tel: +1 562-758-3039
+1 562-713-1105
Model Reference
8/11/2019 4.8.4 Ted Wang
Section
Update “build
02/11/2021 4.9.0 model” button, Jake Li
FNVM demo
Update “Simulink
04/12/2021 4.9.1 C-code generation Eric Huo
issue”
Contents
11.1 Q1. The m file exported from DBC by ‘EcoCAN’ can’t be used ................................. 216
11.2 Q2. Model created by ‘EcoCoder_Prj’, emulation or code generation error ........... 216
11.3 Q3. ‘CAN’ module is blank after being configured ....................................................... 216
11.5 Q5. How to update application model to be compatible with updated EcoCoder .. 217
11.6 Q6. Is there a way to get rid of popping up folder of generated file? ....................... 219
11.7 Q7. Is there a way to access project file in C code? .................................................... 220
11.8 Q8. C code generation by Simulink is not accepted by compilers. .......................... 221
EcoCoder is an advanced auto code generation library added on top of Simulink generic
libraries. It links the user’s Simulink models directly to Ecotron target controller.
EcoCoder encapsulates the low level driver software, or basic software, also abstracts the
specific hardware, like Freescale or Infineon microprocessor-based controllers. It enables
the controls engineer to develop their control systems completely in MATLAB/Simulink
environment.
Plus, EcoCoder is only an add-on package on top of Simulink. It enables engineers to
maximize the usage of Simulink generic library. It adds the necessary library blocks which
bridge the gap between application software and the specific controller hardware.
Meaning the application software will not be dependent on the specific hardware, and
you can port your models to any other hardware which supports the Simulink. In short,
you are not stuck with EcoCoder by using it.
Features:
• Auto-code generation of Simulink/Stateflow models using Embedded
Coder/Stateflow Coder
• Calibration using EcoCAL or other CCP based software
• Programming using EcoFlash through CAN bus
• OTA upgrade of application software
• Available for both prototyping and production
• Manual C-code integration is available in addition to model-based design (MBD)
with Simulink/EcoCoder
Benefits:
• Control engineers can be freed from time-consuming learning curve of hardware,
C programming, and specific microprocessor settings
• Responsive support services from Ecotron
• Application software development is isolated from a specific hardware, and it
has transparency and easy migration to other platforms.
Memory 2 GB or higher
Mandatory Components:
• MATLAB
• Simulink
• MATLAB Coder
• Simulink Coder
• Embedded Coder
Highly recommended components to be installed:
• Stateflow
• Stateflow Coder
Note: some of the MATLAB versions (old) may require extra configurations to make the
EcoCoder work. Contact us if you have compatibility issues.
• VCU
• Test Harness*
• Ecotron CAN (USB-CAN Adapter) *
* Test harness is available from Ecotron; however, users can also make their own by using recommended
connector parts.
* Ecotron CAN needs to be compatible with CAN Calibration Protocol (CCP). Third party adaptors like Kvaser
5. Ecotron USB-CAN adapter Driver, or other CAN adapter Driver, such as Kvaser
product
7. EcoCoder Setup.msi
The corresponding relationship between the MATLAB version and the supported MinGW
version:
MATLAB version Supported MinGW version
2. If you follow the step 1 and other versions are called by default during compilation,
you will need to uninstall other versions of CodeWarrior.
2. Choose MinGW-w64
Note: If the user uses MinGW-GCC as the Stateflow complier, proceed to the
next step.
5. Add environment variables
MATLAB 32-bit system comes with a ‘LCC’ compiler which supports Stateflow automatic
code generation. MATLAB 64-bit system does not provide compiler. To use Stateflow
coder, it is necessary to install a third-party C++ Compiler that supports MATLAB 64-Bit
version.
https://www.mathworks.com/support/sysreq/previous_releases.html
3. For Windows 64-bit system, refer to the page titled: ‘Windows 64bit’.
4. After finishing the compiler installation, follow the steps in previous section to
Note: Please keep MATLAB closed during the entire installation and licensing process.
1. Double-click ‘EcoCoder 56xx Vx.x.x Setup.msi’, click ‘Next’ at the following screen.
3. Click ‘Next’.
4. Choose the version of MATLAB you want to install EcoCoder to, then select
‘Install EcoCoder to selected MATLAB version’, click ‘OK’. You can also install
5. Click ‘Close’.
6. After successfully install it, the icon ‘EcoCoder Loader’ will appear on the desktop.
EcoCoder Loader will be used to generate the license file and activate EcoCoder.
7. If you run MATLAB then, it will prompt message ‘EcoCoder has been installed
installed to MATLAB.
https://youtu.be/CiChf1_JZcw
https://www.nxp.com/support/developer-resources/run-time-software/s32-design-
studio-ide/s32-design-studio-ide-for-power-architecture-based-mcus:S32DS-
PA?tab=Design_Tools_Tab
NXP provides it for free, but you need to register your own account.
http://tdm-gcc.tdragon.net/download
And this is the step where you can copy and paste the path:
Add two directories where powerpc-eabivle-gcc.exe and make.exe are located to the
environment variables. Split them by semicolon. Add at the end of the Variable value:
C:\NXP\S32DS_Power_v2017.R1\utils\msys32\usr\bin;C:\NXP\S32DS_Power_v2017.R1\
Cross_Tools\powerpc-eabivle-4_9\bin
In case you're not comfortable with video, here are the text steps:
If you use any MPC5744 based unit, you need to install the S32DS as a compiler, such as
S32DS_Power_Win32_v2017.R1_b171019.exe, which can be downloaded from the NXP
official website for free. After installing EcoCoder and S32DS_Power_Win32, you also
need to use EcoCoder to select the path of makefile and add two directories where
powerpc-eabivle-gcc.exe and make.exe are located to the environment variables.
2. Click Browse, choose makefile under e200_ew12, for example, the full path is:
For EH2175A/EH2275A/ EAXVA03, the installation of HighTec TriCore tool chain is required.
After the installation of HighTec TriCore Tool Chain, users need to specify the makefile
Then in the pop-up window, click “Browse”, locate the “make.exe” in the HIGHTEC
1.1\bin\make.exe”
If target is GWRH850, CS+ should be installed as a compiler, for example, you can install
CSPlus_CC_Package_V70000.exe. After installation, you need to add the directory where
the file CubeSuite+.exe is located to the system environment path, then restart MATLAB.
Regarding how to add environment variables, please refer to the operations in Link
S32DS_Power_Win32 to EcoCoder.
There are two ways to activate EcoCoder and other Ecotron software.
1. Dongle
The hardware dongle released by Ecotron can activate software once it is plugged in PC.
2. ‘.dat’ file
‘.dat’ file is linked to Windows SN, meaning the ‘.dat’ file is bound to a specific PC and not
allowed to be transferred to another PC. New ‘.dat’ file must be issued if customer shift
to new PC.
Note: all Ecotron software would ‘remember’ license once it is activated even after it is
upgraded to new version. It is mandatory to use Windows Add/Remove programs to
uninstall all previously installed versions of EcoCoder. For safety concern, please install
new version to same folder as previous EcoCoder.
3. Click ‘Export’.
3. Click ‘Browse’.
5. Open license file, for example, select ‘EcoCoder_license.dat’, then select ‘Open’.
6. Click ‘OK’. The activation is successful if the pop-up window is displayed as following.
The purpose of this chapter is to give users a quick start to use EcoCoder for control system
development. If you don’t have any Simulink model yet, and want to have something to
start with, or if you want to port your existing Simulink models into EcoCoder platform,
this is a quick start. Because EcoCoder will provide an outline (a basic EV control model)
3. A model ‘DemoTest.mdl’, and a ‘.m’ file as shown in the following figure will be
button in Simulink task bar, ‘.a2l’, ‘.mot’, ‘.cal’ file would be generated.
(Note: for the latest version of EcoCoder, if users choose CCP type as
If the ‘CodeWarrior’ window pops up, do not manually intervene, it will automatically
As shown in below picture, you can find the generated ‘.mot’, ‘.cal’, and ‘.a2l’ files.
The EcoCoder library is an add-on library in Simulink. EcoCoder library mainly provides
interfaces for application software to handle I/Os, VCU power, communication and
calibration / measurement setup, etc.
Under the ‘General Parameters’ tab, this block defines the specific model of Ecotron VCU
Place this block in application model, usually at the top level, to select the VCU model for
users’ application. The ‘Advanced Parameters’ tab enables the user to work with part of
the ROM and RAM memory addresses. If you would like to do the adjustment regarding
all the addresses, please contact Ecotron Tech Support, otherwise, please keep it as
default.
Block Parameters:
trigger*
In most cases, there are voltage dividing and shifting circuits on the target VCU hardware,
they map the physical voltages being measured into the range that the microcontroller
chip(s) can read, usually 0 to 5V. The resolution at which this pre-processed voltage by
dividing circuits can be measured depends on the controller chip, usually 10 or 12 bits
(1023 or 4095 maximum value, respectively). A reading of 0 represents the minimum
voltage specified for these external circuits and a maximum value (1023 or 4095)
represents the highest specified voltage.
This EcoCoder block outputs values of the A/D converter channel connected to
corresponding physical pin. The output value of this block is the output of AD converter
chip (10- or 12-bits binary value).
EcoCoder has predefined input voltage range and resolution of each channel, please refer
1 10 500 000111110100
2 12 500 00000111110100
Block Parameters:
This block enables user to read the physical voltage at the physical pin on the connector,
and block output data type is fixed-point.
Block Parameters:
1. Analog input channel: Choose analog channel.
2. Input type: Channel type of the voltage input, 4 types are supported: ‘0-5V‘, ‘0-12V‘,
‘0-24V‘ and ‘Custom Voltage Ratio’.
3. AD Resolution: Please refer to the datasheet of VCU for resolution selection.
4. Custom Voltage Ratio: This option is available for the fourth input type ‘Custom Voltage
Ratio’ only. Previously, every voltage input type has fixed resistor divider, as a result, the
user just needs to select voltage type. Different resistor divider is introduced in new
hardware datasheet, which gives the introduction of new input type and this input option.
5. Reference Voltage: By default, it will be set as 5V. Please do not change.
Block Output:
Volt: Physical value of input voltage of specified channel; unit: V; ‘single’ data type.
(*) Every channel has its unique configuration defined in firmware, please refer to
datasheet of VCU and select correct setting for the channel
This block enables user to read the physical voltage at the physical pin on the connector,
and block output data type is float-point.
Block Parameters:
1. Analog input channel: Choose analog channel.
2. Input type: Channel type of the voltage input, 4 types are supported: ‘0-5V‘, ‘0-12V‘, ‘0-
24V‘ and ‘Custom Voltage Ratio’.
3. AD Resolution: Please refer to the datasheet of VCU for resolution selection, since
different VCUs have different AI channels setup.
4. Custom Voltage Ratio: This option is available for fourth input type ‘Custom Voltage
Ratio’ only. Previously, every voltage input type has fixed resistor divider, as a result, the
user just needs to select voltage type. Different resistor divider is introduced in new
hardware, which explain the introduction of new input type and this input option.
5. Reference Voltage: By default, it will be set as 5V. Please do not change.
Block Output:
Please Refer to Chapter 5 CAN theory of Ecotron before using EcoCoder CAN blocks.
Chapter 5, combined with CAN bus communication protocol, will give the user
This block is used to initialize the CAN bus configurations. Including CAN channel enable,
CAN ID filtering, baud rate settings.
Parameter:
1) CAN Channel: CAN channel selection
3) CAN ID Filter Enable: When filtering is enabled, the CAN bus is only receiving CAN
messages with a specific ID.
a. Note: if the CAN ID Filter is not enabled, both extended and regular frame will
be received.
6) CAN Filter (uint32 Hex): Filters ID. It is a 16-bit variable; user needs to use this with CAN
ID Filter (uint32 Hex)
8) CAN TxBuffer Size: send buffer for CAN transmission, minimum value is 2
11) CAN FD Nominal Sample Point: number of sample points for CAN FD bus, 10,000
represents 100%
12) CAN FD Data Baud Rate (kbps): CAN FD data baud rate
13) CAN FD Data Sample Point: the number of CAN FD Data Sampling points, 10,000
represents 100%
Example:
If a bit in the CAN ID Mask is set to 0, means the CAN node does not care whether if this
bit is 1 or 0 in a CAN ID.
1. Example 1
a. MASK(4-bit): b1101
b. FILTER(4-bit): b1111
If a bit in the CAN ID Mask is set to 1, means the CAN node does care whether if this bit is
1 or 0 in a CAN ID.
This block is used to define the VCU wake-up CAN message, it is only supported by
Copyright ECOTRON LLC www.ecotron.ai Page 51
EcoCoder Manual
several new VCU models. For more information, please consult Ecotron support.
Parameters:
1) CAN Channel: Selecting CAN channel number for this function.
2) Wake-up Mode: Setting the wake-up mode, including Disable (disable CAN wake
up function), All Frames (any frame on the specified bus can wake VCU up), and
Specific Frames (User specify the frame that can wake up the VCU).
3) Baud Rate: CAN baud rate set up.
4) ID Extended: If checked, the specified VCU-waking-up message will have to use
extended CAN ID. If not checked, the message has to use standard CAN ID.
5) ID Setting: Specify the ID here for the wake-up message.
6) ID Mask: The mask for VCU-waking-up message ID.
7) Data Setting Enable: If checked, not only a specific waking-up message ID is
needed, but the user also needs to specify the data in the message. Only
message with matching ID and data can wake up the VCU. Data can be specified
in the following blank.
8) Data Length: Set the wake-up message data length. Only when the data length
of the wake-up message matches this value, the message can wake up the VCU.
9) Data Mask: The mask for wake-up message data. The message data bitwise AND
with this mask value, if one or more bit of the result of bitwise AND is (are) not
0, the message can wake up the VCU.
This block provides CAN messages receiving and unpacking functions. It requires a .m file
of CAN message definition to help unpack CAN messages. The generation process
Block Parameters
Message counter, if
checked: every time the
Show Message Count Port Check box
message is received, the
counter increments by 1.
This block is to read CAN messages. Decode CAN messages into signals. All the decoded
signals are inherited backwards. This block does not support .dbc files, but it supports .m
files converted from .dbc files.
Parameter:
1) Select CAN Channel State: Select CAN Channel state, including Connected, Disconnected
and DisconnectedOnlyData options.
a. Connected: output port is disabled, messages are directly sent to the channel
3) Select M file: select the m file from DBC converting tool. Click OK then double click the
block to select specific message.
5) Show Message Available Port: check to show the message availability port, output 1
when read a valid message.
8) Enable Custom Variable Name Rules: enable custom variable name rules.
a. Rules: change the letter after the second underscore from lowercase to upper
case, remove the second underscore in the variable name.
Input:
When the channel state is “Disconnected”, the input ports are listed as below. There is no
port available when the channel state is “Connected”.
1) Enable: Enable CAN message decoding
7) Function Packaging:
a. Parameterless: use C functions without parameter. This option has high code
execution efficiency.
b. Parameterized: use C functions with parameters. This option offers more stable
compilation.
Output:
1) The signal needs to be transmitted. The unit should be the actual physical unit.
Input Data Type: Inherit Check box If checked: the data type of
the signal is inherited from
Block Inputs:
Signals to be sent out.
Block Outputs (if ‘Disconnected’ is selected under ‘Select CAN Channel State’):
1. Remote: frame type- 1 is remote frame, 0 is standard frame
2. Extended: frame type- 1 is extended frame, 0 is standard frame.
3. ID: message ID.
4. Length: message data length.
5. Data: message data
This block is used for sending CAN messages. It takes the .m file converted from .dbc file
and send CAN messages accordingly.
Parameter:
1) Select CAN Channel State: Select CAN Channel state, including Connected, Disconnected
and DisconnectedOnlyData options.
a. Connected: output port is disabled, messages are directly sent to the channel
3) Select M file: select the m file from DBC converting tool. Click OK then double click the
block to select specific message.
6) Function Packaging:
d. Parameterless: use C functions without parameter. This option has high code
execution efficiency.
e. Parameterized: use C functions with parameters. This option offers more stable
compilation.
Input:
1) The signal needs to be transmitted. The unit should be the actual physical unit.
Output:
2) When channel state is at “Disconnected”:
Block Parameters:
1) CAN channel: CAN channel selection.
2) CAN ID: The ID of the message to be received.
3) Extended: Message type to be received. If checked: extended frame. Otherwise,
standard frame.
4) Data Length: The data length of the to-be-received message.
5) Sample Time: Define the task scheduling time of this block being triggered.
Block Outputs:
1) Message Available: Flag for message availability, 1 stands for message valid and
available.
2) Remote: Flag for frame type, 1 stands for remote frame. 0 stands for data frame.
3) Extended: Flag for frame type, 1 stands for extended frame. 0 stands for standard
frame.
4) ID: Message ID.
5) Length: Message data length.
6) Data: Message data.
Block Parameters:
1) CAN Channel: Channel selection
2) Sample Time: Define the task scheduling time of this block.
Block Inputs:
1) Remote: Flag for frame type, 1 stands for remote frame. 0 stands for data frame.
2) Extended: Flag for frame type, 1 stands for extended frame. 0 stands for standard
frame.
3) ID: Message ID.
4) Length: Message data length.
5) Data: Message data.
Block Parameters:
1) CAN Channel: CAN channel selection.
2) Data Length: Message data length, in bytes.
3) CANID: The ID of the message to be sent. HEX value.
4) Frame Type: Drop-down list for frame type selection.
Block Inputs:
1) data: The message data to be sent.
This module can be used to count the number of frames received by specified CAN
channel.
Block Parameters
Block Output:
cnt: If the selected channel receives one frame, cnt value increments by 1.
This module can be used to switch CAN operating mode between ‘listen only’ and
‘normal’.
Block Parameters
Block Input:
Trigger signal: the signal input to trigger the execution of this block.
Block Parameter:
1) Signal (Array): the signal definition matrix of CAN frame.
Block Inputs:
1) Data: the message data to be unpacked.
Block Outputs:
1) Unpacked signals from the CAN data.
Pack CAN signals to CAN message, usually used together with Send CAN Data block.
Block Parameters:
1) Out Signal (Array): The definition array of the signals to be packed.
Block Inputs:
1) Signals to be packed, values are in HEX.
Block Output:
1) Data: the packed CAN message data.
Block Parameters:
1) CAN Channel: Channel selection
Block Parameter:
Block Output:
4) ID: message ID
Block Parameters:
1) CAN Channel
Block Input
CAN MESSAGE2NormalType
Along with Transmit CAN Message block, this block can pack and send message
MATLAB R2018b (or higher version) since the CAN Pack works more efficiently in the
later versions.
Block Input:
Block Output:
3) id
4) length
5) data
CAN NormalType2NormalType
Along with Receive CAN Message block (or Receive CAN Raw With Trigger), this
block can unpack and receive message with Simulink Embedded Coder by execute the
block is recommended to use in MATLAB R2018b (or higher version) since the CAN
Block Input:
3) id:
4) length
5) data
Block Output:
Block Parameter:
1) CAN Channel
Block Output:
3) ID: message ID
8) Data:Data Output Port Width function can be used to set up the port width.
This block can be used to send CAN FD data. Along with Send CAN Message
block, it can send certain signal value when the channel is disconnected or
DisconnectedOnlyData.
Block Parameter:
1) CAN Channel
2) Data Length
3) Sample Time
Block Input:
2) ID
4) Data: Data Output Port Width function can be used to set up the port width.
This block can turn off CAN Wake-up in when powered off
Block Parameter:
2) CAN Channel
The SCI mode includes SCI_RxData and SCI_TxData. Currently, only SCI_A channel is
supported.
SCI Definition
Block Parameters:
3. SCI Channel: Communication channel selection.
4. SCI_Enable: Enable selected channel.
5. SCI Baud rate: Channel baud rate setup.
Copyright ECOTRON LLC www.ecotron.ai Page 73
EcoCoder Manual
This block enables the VCU to read data from specific SCI port.
Block Parameter:
SCI_Channel: SCI communication channel selection.
Block Outputs:
1. f (): Flag for receiving data. If data received, the flag will be 1. This signal can
be used as a trigger signal.
2. Data: Output received 8-bit data.
Block Parameter:
SCI_Channel: SCI channel selection.
Block Input:
Data: The 8-bit data to be sent out.
These blocks are used for measuring digital input/output. Including Switch Input, Switch
Switch Input
This block reads the physical voltage level of digital input channels and output Boolean
Block Parameters:
KeyOn Input
KeyOn signal is recommended to be used for powering up and shutting down the VCU.
For different VCUs, KeyOn signal inputs are different (refer to the VCU datasheet to
confirm the KeyOn signal input type) - if KeyOn signal is digital input, leave the
configuration as default; If KeyOn signal is read through analog input channel, user will
have to configure factor according to voltage divider parameter - for this parameter,
please refer to VCU datasheet.
Block Parameters
Switch input channel Drop-down list Only one channel selectable for KeyOn
KeyOn Hysteresis Volt Numeric voltage is larger than the sum of ‘Key
Switch Output
Block Parameters
IPM Read
This block is used for monitoring frequency input from specific channel. Output is period
of the signal, can be used for calculating the frequency.
Parameter:
1) IPM Channel: digital channel selection
Output:
2) Period: period of specific channel, 1 means 0.1ms.
This block defines the frequency range and accuracy of PWM IOs. If it is not
implemented in the model, the accuracy will be default value, 1 Hz.
Block Parameters:
1) Frequency Range: Frequency range selection, changes in this option will alter the
frequency range and accuracy of all the frequency related block in the model.
2) Frequency Accuracy: Accuracy adjustment. Value in the box means the unit
frequency for outputs/inputs of frequency related blocks. For example, if the
Frequency Accuracy is 0.01 Hz, it means that when frequency related block
outputs/inputs value is 5, the actual physical frequency value is 5x0.01Hz = 0.05
Hz.
IPWM Read
Block Parameter:
1) Select IPWM Channel: PWM inputs channel selection
Block Outputs:
1) freq: the input PWM frequency of the signal. The unit is related to PWM IO
Frequency Range Definition
2) duty: the input PWM signal duty cycle. 0-10000 in this block is 0-100%
This module is used to initialize the configuration of the switch input channel using
interrupt mode to measure frequency and duty cycle.
Block Parameter:
1) IPWM Channel
2) IPWM Enable
3) Trigger Type: Including rising edge and falling edge.
This module is used to measure the frequency and duty cycle of the switch input
channel using interrupt mode.
Block Parameter:
1) IPWM Channel
Block Output:
2) tEff: Specifies the effective level time of the channel signal, in (us).
Note: When the trigger mode is rising edge trigger, the effective level time refers to
Copyright ECOTRON LLC www.ecotron.ai Page 81
EcoCoder Manual
high level time; when the trigger mode is falling edge trigger, the effective level time
PWM Definition
This module is used to initialize the OPWM channel. All H-bridge, high-side, and low-
side channels can be initialized and only have OPWM function after setting.
Block Parameter:
1) OPWM channel
2) OPWM Enable
3) OPWM FRQ: The channel initialization frequency, the unit is related to the
4) OPWM Duty: The channel initialization duty cycle, where 0-10000 corresponds
to 0-100%.
Note: The duty cycle refers to the percentage of the total on and off time when the
channel is open.
PWM Output
Block Parameters:
corresponds to 0-100%.
PPM Read
Block Parameter:
1) PPM channel
Block Output:
1) data
Switch Internal
This module is a switch control inside the software. If it is 1, the system is powered
on; if it is 0, you need to refer to the state of other wakeup sources to determine whether
Block Parameter:
WakeUp Input
Block Parameters
H-bridge Definition
Block Parameters
from A->B.
more information)
block.
H-bridge Output
Block Parameters
block.
INA226 Definition
Block Parameter:
1) OPWM Channel
3) Number of averages
Block Parameter:
1) OPWM Channel
Block Output:
Block Parameter:
1) OPWM Channel
Block Output:
Block Parameter
2) Decoder Input1
3) Decoder Input2
Block Parameter
Block Output:
1) frq:Frequency in Hz
2) cnt:For a square wave counter, if the phase state stPhase is 1, it will increase
This module can be used to set the initial value of quadrature decoding square wave count
Block Parameter:
Block Output:
Block Parameter
Block Output:
Block Parameters
Block Parameters
Block Output:
1. St: (status)
Value Description
0 Normal
1 Error
6 Busy
Block Parameters
Block Outputs:
1) Available: output of 1 means data is valid, otherwise invalid.
2) Date: receiving data
Block Parameters
mode
Block Input:
1) Date: sending data
Task Trigger
Definition / initialization blocks need to be executed when the VCU power on, for
All other blocks/subsystems should be triggered by this block, for task prioritization and
scheduling.
Block Parameters
If two tasks are assigned to the same task type, then the user needs to specify priority of
the two tasks to determine execution order. Please refer to the example in the following
priority.html
* For CAN bus applications, they are recommended to be set up in 10ms tasks.
Task Monitor
Block Parameters
NXP5606: 150,000
NXP5744: 5,000
TC297: 200,000
TC397: 100,000
Block Output:
There are two types of Non-Volatile Memory. The first type is NVM, and the second type
is Fixed NVM. Data stored in NVM will not be lost between power cycles. Data stored in
Fixed NVM will not be lost after the VCU is programmed.
For more information and demo, please refer to Appendix A.
This Fixed NVM Definition block will only be executed once, during the first power-up
process of VCU application software, every time after the .mot file being flashed into
VCU.
Block Parameters
Block Parameters
Block Output:
The value of corresponding variables.
Block Parameters:
NVM Definition
This block is used to initialize NVM variables and specify the NVM variable initialization
method after every time the VCU being programmed by .mot file.
Block Parameters:
in .mot:
Block Parameters:
User-defined variable
Description Alpha-numeric text
description
Read NVM
Description:
Block Parameters:
Block Output:
The NVM variable value
Write NVM
This module is used for writing regular NVM variables into RAM. To save changed variables
into VCU flash between power cycles, users need to use another block ‘Store All NVM
Data’.
Block Parameters:
If checked:
When this module is triggered, all NVM variable data will be written from RAM to flash,
It is recommended to call this block before VCU power-off. And please do not call this
block too frequently. For example, if a 5ms task is assigned to this block, flash would
quickly burn out because flash memory blocks have life span, and frequent
programming/erasing of memory block will cause program/erase cycles running out.
Block Parameters:
The module reads NVM data from ROM (flash) back to RAM.
It is recommended to call this block when VCU powers on. This block can be triggered by
‘Task_ini’.
Block Parameter:
Use this block to read the address mapped in RAM section for NVM. Use the offset
parameter to read specific address in the flash. Do not use [0] for arrays for the output.
Parameter:
1) Variable Name: the name of the variable.
Output:
1) addr: the address of the variable
This block can realize the hardware diagnosis of supported LSO, HSO and H-bridge.
Please refer to VCU datasheet for the channels that support diagnostic functions.
Block Parameters:
Block Output:
DTC:The diagnostic trouble code of the specified channel. An error code is 1 byte of
data, each bit represents different error type. A bit is set to 1 when certain error is
occurred.
Bit 3 Overheating
Bit 6 Overload
Bit 7 Others
DTC Parser
Block Parameters:
Block Input:
DTC: The diagnostic trouble code.
Block Output:
bool: If the output value is one, the specific fault selected in the Block Parameter
happened; If output value is 0, the fault did not happen.
Block Parameters:
Output:
1) DTC: Output 1 represents error detected, output 0 represents error not detected
This block can clear the H-bridge channel faults, the trigger type to trigger this block is
rising edge.
Block Parameters:
Input:
1) Triger signal: set to 1 to clear all DTC
This block is used for reading the DTC summary from TLF35584.
Output:
1) DTC: DTC summary from TLF35584.
Note:
1) For more information about specific error codes, please refer to TLF35584 manual.
This block is used to read the quantity of the DTC code from TLF35584.
Output:
1) Num: the number of error code.
Note:
1) For more information about specific error codes, please refer to TLF35584 manual.
Parameter:
1) SpecificDTC Number: Read error code from the specific index. To read multiple error
codes, used multiple blocks to specify each error code index.
Note:
1) Since the number of error code produced by TLF35584 at any given time is unknown. It
is recommended to initialize the array for DTC code based on the number of DTC codes
to be read.
3) For more information about specific error codes, please refer to TLF35584 manual.
Calibration Definition
Block Parameters:
Read Calibration
Block Output:
Calibration variable value.
Write Measurement
Block Parameters:
variable
unit
Block Input:
To-be-measured variable.
variable
unit
Block Input:
To-be-measured variable.
Block Output:
Same as input. (This block is used for variable measurements, it does not change variable
values).
Override Probe
Block Parameters:
1. Base Variable Name: user-defined name of the overriding variable.
2. Override Calibration Initial Value: initial value of the calibration variable.
3. Override Enable Initial Value:initial value of control signal.
4. Data Type: data type of calibration variable.
5. Unit: user-defined measurement variable unit
6. Description: the description of the variable.
Block Input:
Variable to be overridden.
Output:
If control signal is 1, the output of the block would be the overriding calibration variable
value;
If the control signal is 0, the output of the block would be the same as the input. (No
overriding)
This block defines 1-D look-up table. 1-D look-up table supports online calibration.
Block Parameters
This block defines 2-D look-up table, 2-D look-up table supports online calibration.
Block Parameters:
Breakpoints 1
Numeric (Matrix) Breakpoints 1 variable data
data(Row)
Breakpoints 2
Numeric (Matrix) Breakpoints 2 variable data
data(Column)
This module is used for checking the calibration data at the VCU power-on process. If there
is any corrupted calibration data, the controller software will enter an infinite loop to avoid
potential catastrophic results due to corrupted calibration data.
Block Parameters:
Enable Calibration Data Check: If checked: enable the function.
Output:
f() : Flag for checking calibration data. If there is a problem with the calibration
data, the flag will be set to 1. This signal can be used as a trigger signal.
This block integrates power-off logic control and operations. It can be regarded as a
reference/demo design of VCU power-off logic. Users are encouraged to understand the
block first by looking down mask and then make necessary modification to the block for
customized implementations.
Block Parameters
Key Off Threshold Volt(V) Numeric than this value, KeyOn signal is
interpreted as ‘0’.
process fails.
Shutdown Power
Block Parameters
Parameter:
1) Set the waiting time(ms): set the waiting time before powering off the controller.
Input:
1) Trigger signal: set 1 to power off the controller.
Note:
This block will be powered off when there is no other wake up signals’ presence.
Block Parameters
The block specifies the CAN channel that wakes up the VCU.
Block Parameters
VCU.
Watchdog Definition
Block Parameters
Software Reset
This block is used for triggering VCU software reset. If this block is called, the VCU software
Block Parameters
Input:
1) Trigger Signal: send reset signal if the trigger signal is 1
By calling the block, VCU main controller 32-bit free-running counter value will be read.
The value can be used to calculate time interval between certain events or to generate
random numbers, etc.
Block Output:
System free counter value.
Block Parameters
corresponding channel.
input Boolean
0: turning off power for
corresponding channel.
Parameter:
1) Stack Overflow Detection Enable: Check to enable the stack overflow detection.
1) flg: Output 1 indicates stack overflow detected. Output 0 indicates stack overflow is not
detected.
Read BootID
Output:
1) Uint32(4): 4 variables in unit32
Hardware Reset
This block is used for resetting the controller on the hardware level.
Parameter:
1) flg: send hardware reset command when reset flag is set to 1
4.12 CCP
Description:
This block is used for setting up CCP related slave station definitions
Block Parameters
Simple:
need to be loaded.
Configurable:
are needed.
Data Acquisition (DAQ) PID Numeric The first PID in the DAQ list.
This block is used to add authentication for calibration, the encryption algorithm of
which can be customized. It also generates DLL file based on the user-provided seeds.
The DLL file name is the name of MOT file plus "_CAL".
This block is used to add authentication to the data measurement, the algorithm of which
can be customized. It also generates DLL file based on the seeds. The DLL file name is the
name of MOT file plus "_DAQ".
This block is used to add authentication to the data flash, the algorithm of which can
be customized. It also generates DLL file according to the seeds. The DLL file name is
the name of MOT file plus "_PGM".
This is a demo block for generating seeds. It is valid when the CCP Type of the Fixed CCP
Slave Definition block is chosen to be “Configurable”. This module is implemented using
the CCP Get Seed Trigger and CCP Set Seed blocks, it can be used as a demonstration
Seed&Key function. This block is built for helping users to understand the process of
seedkey generation. Users can customize this block as they need.
This is getting seed task trigger block. It is valid when the CCP Type of the Fixed CCP
Slave Definition block is chosen “Configurable”. Please refer to the CCP Generate Seed
Demo block for details.
This is setting seed block. It is valid when the CCP Type of the Fixed CCP Slave Definition
block is chosen “Configurable”. Please refer to the CCP Generate Seed Demo block for
details.
Note that this block can only work with some specific VCU models. If the VCU that the
user is working on does not support this function, there will be a pop-up notice when
using this block.
The module reads the Hex values of the angular acceleration of the three axes of the
gyroscope and outputs the raw data in uint16.
Raw data need to be multiplied by a slope of 0.05 and an accounted for an offset of -
819.15 to give the acceleration physical value in deg / sec.
Note that this block can only work with some specific VCU models. If the VCU that the
user is working on does not support this function, there will be a pop-up notice when
using this block.
The module reads the angular acceleration of the three axes of the gyroscope and the
output is physical value in deg / sec, data type is single.
This block is used for the online programming parameter definition. Note that this block
can only work with some specific VCU models. If the VCU that the user is working on does
not support this function, there will be a pop-up notice when using this block.
Users can use more than 1 of these blocks in their Simulink model to make multiple CAN
channels support online programming function.
Block Parameters:
Note: if you have more than 1 VCU on one CAN bus and you want to flash one of them,
you need to change the CRO and DTO both in this block and in EcoFlash to make them the
same, like shown below.
The SeedKey function prevents unknown mot/hex files from being flashed to the VCU. The
customer can use this block to define their own “password”. The DLL file and the MOT file
will be generated at the same time when the building and compilation process is finished.
The DLL file can be loaded in EcoFlash to authenticate the flashing process. Without this
DLL file you generate, the data on VCU cannot be erased via EcoFlash. Please refer to the
EcoFlash manual for more details.
This block can define and modify the flashing key. If the parameters keep unchanged, the
default parameters will be used for flashing (0x12-0x34-0x56-0x78-0x9A-0xBC). If changed,
the new parameters in the module will be used for generating the DLL file.
Parameters:
1.Enable Custom Algorithm: Enable the user-defined algorithm. If enabled, you can use a
piece of C code to define key algorithm. If not, the key will be defined by setting the
parameters.
2. Parameter1 - Parameter6: Key flash setting, 6-byte key.
After automatically compiling and generating code, system will generate DLL file for key
flash. EcoFlash will load the DLL file to match the key, if successfully matched, the flash is
authenticated. Please refer the EcoFlash manual for details.
Enter the UDS programming mode by this block, which enables controller to update
the program through the UDS protocol.
Read OTP
Block Parameters:
Block Outputs:
data: The data read from OTP area.
st: Data reading status, 0 stands for data reading successfully.
Block Parameters:
Block Input:
Offset (byte): the start position offset.
Block Output:
data: The data that has been read from OTP area.
st: Data reading status, 0 stands for data reading successfully.
Write OTP
Block Parameters:
Block Parameters:
data
Block Parameters
Block Output:
Data output
Data
This block is the same as the “Read Data by Address” block, except for the method of
specifying the address is changed. For this block, the address is specified by block input
signal.
Block Parameters
Block Output:
Data output
data
Block Parameters
Read EEPROM
Parameter:
1) Data length: the length of the data to be read
Input:
1) addr: the address of the data to be read
Output:
1) data: data read from EEPROM
Write EEPROM
Parameter:
1) Select Trigger Type: trigger type selection
Input:
1) addr: the address to be written on
Output:
1) St: output status. Output 0 when data read successfully
Record Cache Size (Record) Numeric The number of the cached record message.
Block Output:
Numeric Output state, refer to Appendix Table 1.
st
Block Input:
Record id
id
Block Input:
1. id 1. The id of records to be read
2. type
2. st Appendix Table 1
1. id 2. Type of records to be
2. type written
Block Input:
The record ID to be read and parsed
Record ID
Block Output:
Output state, refer Appendix Table 1
st
This block is used for determining whether if the EEPROM emulation area need to be
erased.
Output:
1) Flg: output 1 when the emulation area needs to be erased. Ouput 0 when the
emulation area does not need to be erased.
This block is used for erasing the EEPROM emulation area. This block needs to be used
with “EEPROM Emulation Area Need to Erase” block.
Input:
1) Trigger: input 1 to erase the emulation area
Output:
1) St: current state, please refer to the appendix for details
Parameter:
1) Data Length (Byte): Data length in byte
3) Minimum Address: no writing will be done when the address value is lower than this
minimum value
4) Maximum Address: no writing will be done when the address value is higher than this
maximum value
Input:
1) en: enable the writing operation
Output:
1) data
This block can get address based on variable name. Use this block to work with arrays
efficiently. Be careful on the array index boundary.
Parameter:
1) Variable Name: the name of the variable
Output:
1) addr: the address of variable
Rising Edge
Parameter:
1) Initial Condition is true: initialization option, check the box to initialize the value as 1.
Falling Edge
Parameter:
1) Initial Condition is true: initialization option, check the box to initialize the value as 1.
This block helps user to reprogram the controller online by reset the controller using
Copyright ECOTRON LLC www.ecotron.ai Page 162
EcoCoder Manual
software.
Parameter:
1) CCP Boot Online Programming: Check for enabling online programming
2) CCP Boot CAN Channel: Select CCP channel for online programming
4) CCP Boot CRO ID Extended: Select extended CRO frame for online programing
5) CCP Boot Station Address: Select CCP address for online programming station
6) CCP Boot CRO Data length: Set CCP CRO data length
8) UDS Boot CAN Channel: select UDS CAN channel for online programing
10) UDS Boot CRO ID Extended: Set extended CRO frame for UDS online programming
11) UDS Boot CRO Data Length: Set UDS CRO data length for online programming
This block can reset the controller hardware for online programming.
Parameter:
1) CCP Boot Online Programming: Check for enabling online programming
2) CCP Boot CAN Channel: Select CCP channel for online programming
4) CCP Boot CRO ID Extended: Select extended CRO frame for online programing
5) CCP Boot Station Address: Select CCP address for online programming station
6) CCP Boot CRO Data length: Set CCP CRO data length
8) UDS Boot CAN Channel: select UDS CAN channel for online programing
10) UDS Boot CRO ID Extended: Set extended CRO frame for UDS online programming
11) UDS Boot CRO Data Length: Set UDS CRO data length for online programming
This block is used for acquiring time step length for current task. (unit: second)
This block debounces and/or delay the rising edge from input.
Parameter:
1) Initial Condition is true: Initializing option. Check to set initial value to 1.
Input:
1) t: rising edge duration. (unit: second)
Output:
1) dout: signal after debounce.
This block debounces and/or delay the falling edge from input.
Parameter:
1) Initial Condition is true: Initialization option. Check to set initial value to 1.
Input:
1) t: falling edge duration. (unit: second)
Output:
1) dout: signal after debouncing.
PT1 Filter
Input:
1) IN: original input signal
Output:
1) Filtered signal
Hysteresis
Input:
1) R: Upper threshold
Output:
1) Output signal: Output signal 1 when the input signal X is larger than upper threshold R.
Output signal 0 or retaining the previous value when input signal X is smaller than L.
SR Flip Flop
!Q is the inverted Q.
When R=1 → Q=0
When R=0 and S=1 → Q=1
Parameter:
1) Variable Name: the name of the variable
Output:
1) Read value from the specific variable
Parameter:
1) XCP Enable: Check to enable the XCP, uncheck to disable the XCP
FlexRay Definition
This block is used for configuring FlexRay network. Startup frame and Sync Frame should
be placed at the beginning when defining the messages.
Parameter:
1) Select the m file: select the m file contains network parameters, node parameters, and
message definition. Please refer to the examples for how to construct a m file.
This block is used for getting the status of the FlexRay network.
Output:
1) St: status of the network
This block is mandatory when building a network. It is recommended to used high priority
1ms task schedule for this block.
Call this block to restore the default configuration. It is useful when encounter network
errors.
This block is used for reading messages from the network. Messages need to be
predefined in FlexRay Definition block.
Parameter:
1) FlexRay message name: the name of the message.
Output:
1) st: status flag, output 0 means message read successfully
This block is used for sending message on FlexRay. The messages need to be predefined
in the FlexRay Definition block.
Parameter:
1) FlexRay message name: the name of the message
Input:
1) data: the data in the message
Output:
1) st: status of writing message. Outputs 0 means the message has been written
successfully.
4.20 Ethernet
Ethernet Definition
Parameter:
1) IP address
2) Subnet mask
3) Default gateway
4) MAC address
Ethernet Handler
Ethernet upper-level protocol will only work when this block is called regularly.
Ethernet Init
Call this block after PHY chip is powered on to initialize Ethernet. Please note, this block
can only be called once after every power cycle.
Input:
1) Flg: input 1 to initialize Ethernet.
This module is used to define the TCP server. A server port currently only supports one
client connection. The new client connection will replace the previous connection.
Parameter:
1) Protocol control block name: Name of the block
2) Server port
This block is used to initialize the TCP server after the Ethernet is initialized. It is
recommended to run this block no more than once every power cycle.
Parameter:
1) Protocol control block name: Name of the control block.
Input:
1) Flg: Proceed initialization when flg is set to 1
Parameter:
1) Protocol control block name: name of the protocol control block
Use this block to connect to a server after Ethernet Init block is used.
Parameter:
1) Protocol control block name: name of the control block
Input:
1) Flg: set flg to 1 to start the connection.
TCP Close
Parameter:
1) Protocol control block name: name of the control block
Input:
1) Flg: set flg to 1 to close the connection.
TCP Abort
Parameter:
1) Protocol control block name: name of the control block
Input:
2) Flg: set flg to 1 to abort the connection.
TCP State
Parameter:
1) Protocol control block name: name of the control block
Output:
1) State: current state of the connection.
TCP Receive
Parameter:
1) Protocol control block name: name of the control block
Output:
1) f(): the function to run when data is received
TCP Transmit
Parameter:
1) Protocol control block name: name of the control block
Input:
1) Enable: set it to 1 to enable the transmit, set it to 0 disable the transmit
UDP Definition
Parameter:
1) Protocol control block name: the name of the protocol control block
UDP Init
This block is used for initiating the UDP ports. User should use this block after the
“Ethernet Init” block is called. It is recommended to call “UDP Init” block once every power
cycle.
Parameter:
1) Protocol control block name: the name of the protocol control block
Input:
1) Flg: input 1 to enable the initialization.
UDP Receive
Parameter:
1) Protocol control block name: the name of the protocol control block
Output:
1) f(): the trigger function to be run when any data received
UDP Transmit
Parameter:
1) Protocol control block name: the name of the protocol control block.
11) Transmit data width: the data width of the data input port
Input:
1) Enable: set to 1 to enable the transmission, set to 0 to disable the transmission
SPI Definition
Parameter:
1) Type: Master/Slave mode selection
Use this block to exchange data when the “SPI Definition” block is configured as master
node.
Parameter:
1) Channel: channel selection
9) Data Length(bytes): the length of the input port (TxData) and the output port (RxData).
Input:
1) Enable: set to 1 to enable the transmission, set to 0 to disable the transmission
Output:
1) RxData: the data to be received
Use this block to exchange data when the “SPI Definition” block is configured as slave node.
Parameter:
1) Channel: channel selection
2) Data Length(bytes): the length of the input port (TxData) and the output port (RxData).
Input:
1) Enable: set to 1 to enable the transmission, set to 0 to disable the transmission
Output:
1) RxData: the data to be received
The ‘Model’ block in Simulink library ‘Ports & Subsystems’ could be used to include a sub-
model in a parent model. The blocks included in the ‘Model’ block are regarded as
referenced models, and the model that includes the referenced models is named Parent
Model. The referenced model can be used as an independent model to run simulation
independently; it can also be used as the model reference and take part in the simulation
in the parent model.
For more information about the Model Reference, please refer to:
https://www.mathworks.com/help/simulink/model-reference.html
Add the Simulink block ‘Model’ to the current Simulink model, and double click, the user
will be able to add the referenced model in the popup window Block Parameters.
After the referenced model is successfully added, the inputs and outputs of the referenced
model will appear on both sides of the ‘Model’ block. The user can connect the inputs and
outputs on the ‘Model’ block to the parent model.
When building Simulink models with EcoCoder, the configurations of the referenced
model(s) and the parent model must be kept the same, otherwise there will be errors
during the code generation or simulation and the ongoing process will stop due to the
error. There are two methods to keep the same configuration for referenced model(s) and
parent model:
1. Use ‘Configuration Reference’
Or
Configuration Reference
In order to keep the same configuration for parent model and referenced model(s), the
user can use ‘Configuration Reference’ function. In Model Explorer, by clicking ‘Convert
Configuration Reference’, the configuration of the parent model will be converted to
configuration reference.
Then right click ‘Reference’, select ‘Propagates to Referenced Models’ in the menu to apply
the configuration in the referenced model(s).
After the conversion of the configuration file, please save the configuration file in the
Matlab Workspace, the default name is ‘configuration’.
Please remember to load the saved configuration file to Matlab Workspace before
opening the parent model.
In Model Explorer, the configuration file for different models could by copied by right
clicking the file. In this case, the user can also copy the configuration file of the parent
model to the referenced model(s) and activate the configuration file in the referenced
model by right clicking the configuration.
All blocks in the EcoCoder have been updated to be compatible with Model Reference.
But in order to keep the generated code with good normative and readability, users need
to pay special attention to some of the EcoCoder blocks. Specifically, all EcoCoder blocks
with blue edges could be used in both parent model and referenced model(s); while the
EcoCoder blocks with red edges will only be valid in the parent model (They can be used
in the referenced models to pass the simulation, but will not be generated in the C code)
ADC
All the blocks in ADC can be used and will be valid in both parent model and referenced
model(s).
Advanced Data Blocks
All the blocks in Advanced Data Blocks can be used in both parent model and referenced
model(s).
However, for the EEPROM Emulation Definition block, only the definition in parent model
is valid, and will be generated into C code. If this block is defined in the referenced
model(s), the definition will not be generated into C code.
All the blocks in Application Base blocks can be used and will be valid in both parent model
and referenced model(s).
Calibration & Measurement
In Calibration & Measurement, the Calibration Data Check can only be used in in the
parent model, for all other blocks in Calibration & Measurement, they can be used in both
parent model and referenced model(s). If these blocks are defined in the referenced
model(s), the definitions will not be generated into C code.
CAN
All the blocks in CAN can be used in both parent model and referenced model(s).
The CAN channel Definition block and CAN Wake-up Frame Definition block are valid and
will be generated into C code only when they are defined in the parent model.
CCP
In CCP, all blocks can only be used in the parent model and shall not be used in the
referenced model(s).
Diagnostic Blocks
All blocks in Diagnostic Block can be used and will be valid in both parent model and
referenced model(s).
Digital I/O
All the blocks in Digital I/O can be used in both parent model and referenced model(s).
However, the H-Bridge Definition block, IPWM interrupt Handler Definition block, PWM
Definition block and PWM IO Frequency Range Definition blocks are valid and will be
generated into C code only when they are defined in the parent model. If these blocks are
defined in the referenced model(s), they will not be generated into C code.
Non-Volatile Memory Blocks
In the Non-Volatile Memory Blocks, NVM Definition block can only be used in the parent
model and shall not be used in the referenced model(s).
And Fixed NVM Definition block is valid and will be generated into C code only when it is
defined in the parent model, if Fixed NVM Definition block is defined in the referenced
model(s), it will not be generated into C code (Unlike Non-Volatile Memory block, user can
still keep the Fixed NVM Definition block in the referenced model(s)). The parameters of
the Fixed NVM Definition in all models shall be kept the same.
All other blocks in Non-Volatile Memory blocks can be used in both parent model and
referenced model(s).
Programming Blocks
All blocks in the Programming Blocks can only be used in the parent model.
SCI
All the blocks in SCI can be used in both parent model and referenced model(s).
However, the SCI Definition block is valid and will be generated into C code only when they
are defined in the parent model. If this block is defined in the referenced model(s), it will
not be generated into C code.
System Management Blocks
All the blocks in System Management Blocks can be used in both parent model and
referenced model(s).
However, the ECU Master Chip Wake-up Definition block, Stack Overflow Detection
Definition block and Watchdog Definition block are valid and will be generated into C code
only when they are defined in the parent model. If these blocks are defined in the
referenced model(s), they will not be generated into C code.
Task Scheduler
All the blocks in Task Scheduler can be used and will be valid in both parent model and
referenced model(s).
5.1 Introduction
Controller Area Network (CAN) nowadays is very widely used on the vehicle control system.
Ecotron VCUs provide multiple CAN channels (3-5 channels, depending on the specific
VCU model) and enables the VCUs to communicate with multiple electronic control units
on the vehicle.
To use Ecotron VCUs, the user needs to convert DBC file into .m file and then use the .m
file to define and initialize the CAN communications. The process is intuitive, user-friendly,
and can give users more flexibility for CAN communication implementation.
User can convert DBC to .m file automatically using the software EcoCAN that can be
found in EcoCAL. If you want to know more about EcoCAL, please refer to the manual
EcoCAL manual for EV.
Process:
1. Open the DBC file to be converted in EcoCAN.
2. After DBC file being loaded, the following window will pop-up.
3. Click the indicated button and export the DBC file to m file, users can specify the
saving path.
Please select ‘Read CAN Message’ or ‘Send CAN Message’ if fixed-point tool has not
been installed in Matlab.
Select m file
This m file can help parse out signals in messages. Users need to save the .m file in the
folder where your model is.
Select Message
This step will let users pick the specific CAN messages that need to be parsed.
Task_Inherit:
If ‘Task_Inherit’ is selected, the block will be executed every time when the subsystem
that includes this block is executed.
Task_ini:
The block will only be executed during the initialization process when VCU is powered
on.
Task_MDef:
The sample time will be decided according to the interval value in the .m file that is
shown below. (This value comes from DBC file and is editable).
6.1 Introduction
When application software gets more complicated and larger, memory management will
become an important aspect of VCU software development.
Ecotron VCU includes two types of storage device, Flash and RAM.
Flash is the memory which stores basic software, application software, constant,
calibration and NVM variable data, the data in Flash will not be lost after powering off the
VCU. Contents in Flash would be copied to RAM during VCU power-up process. NVM
variable data is recommended to be saved to Flash before VCU power off. Calibration can
be implemented ‘on the fly’, and calibration variable data can be burned back to Flash
manually through EcoCAL, the calibration software developed by Ecotron.
RAM (Random Access Memory) directly works with CPU by storing software needed data
and code during VCU runtime. Different from Flash, the data in RAM would be lost when
VCU powers down.
Calibration/Measurement Variable
Please refer to section 4.10.1 to 4.10.4 for definition, initialization, reading and writing
calibration and measurement variables.
The only special part is writing of calibration variable. It is achieved through EcoCAL
‘Program’ or ‘Download’ function. EcoCAL is an advanced calibration tool developed by
Ecotron. ‘Download’ option can save calibration data to VCU RAM, while ‘Program’ option
can write calibration data to VCU flash. ‘Upload’ can help upload the existing calibration
data from VCU flash to PC.
Non-Volatile Variable
There are two types of non-volatile variables, NVM variables and Fixed NVM variables, for
different application purposes. Please refer to section 4.8 for definition, reading and
writing non-volatile variables.
Ecotron non-volatile memory theory is described in Appendix A.
3. Name the variable and set the properties through the window on the right
2. Set the properties through the window on the right. To define calibration variables,
“Calibration(Custom)” must be chosen in “Storage Class”.
2. Set the properties through the window on the right. To define measurement variables
“Measurement (Custom)” must be chosen in “Storage Class”.
2. Set the properties through the window on the right. To define NVM variables,
“MeasurementNvm (Custom)” must be chosen in “Storage Class”.
EcoFlash is a user-friendly GUI for programming VCU. Please refer to EcoFlash manual for
operation of the software. The below picture provides a quick glance of EcoFlash.
2. Choose MATLAB version, and select ‘Uninstall EcoCoder from selected MATLAB
For EcoCoder update, the user will need to uninstall older version EcoCoder from
Note: You have to close all open MATLAB applications before uninstalling.
1. Click ‘Start’ and then click ‘settings’, follow steps in picture below
Chapter 11 FAQs
11.1 Q1. The m file exported from DBC by ‘EcoCAN’ can’t be used
A1. The name of the m file must match to the C Language variable naming requirement.
generation error
1. Check if your MATLAB has Fixed-Point Tool license. If not, the use of fixed-point
updated EcoCoder
‘ECU_Setting’ module is divided into independent configuration blocks. Please add CAN,
If CAN library blocks used in the model are disabled, you need to firstly resolve all blocks
and save the model before installing new EcoCoder, otherwise the original model will be
file?
Yes. Please go through these steps, Configuration Parameters -> Code Generation ->
EcoCoder Debug Options -> Compiled Action. Then you can configure.
Compiled Action includes: No Prompt, OpenTarget, PopupBox.
No Prompt: There is no any prompt when it finishes generating file.
PopupBox: ‘Software has been compiled successfully!’ will pop up when it finishes generating files.
C code generation by Simulink will sometimes have the variable name not accepted
by compilers, for example as ‘AND’.
There is one simple way to solve this by reserving the variable Simulink is using. For
example, the variable ‘AND’ is not accepted by Infineon High-Tec Tri-core compiler, but
Simulink is generating code using ‘AND’ as one of the variable names since ‘AND’ is not
restricted in Simulink code generation. As being said, please be aware that the Simulink
generated code satisfies the coding rules for C code, but not necessarily satisfies the rules
of compiler: HighTec TriCore Tool Chain and S32DesignStudio. Follow the steps below to
reserve the ‘AND’ to prevent Simulink using it. Please note, the code is generated by
Matlab/Simulink, not by EcoCoder. The machine generated code might not be friendly to
read. Please follow the MAAB when designing your Simulink model. That way, you can
reduce the error in the generated code.
Non-volatile Variables
The NVM variables are stored in flash, which can maintain information even the VCU is
powered off (unlike RAM, which would lose data after the VCU power off).
NVM data values are read from flash and written into RAM when VCU is powered on. The
RAM variables can be read/written as many times as needed since RAM has high
Program/Erase cycle. When key off signal is detected, power off logic would trigger the
process of storing NVM variables from RAM to flash. An example power down block, which
includes this NVM variable storage logic, Power Management Example, is provided in
EcoCoder library.
Note: The power input to VCU BATT is required to be uninterrupted to make sure the
process of storing of NVM variables value is safe. If power is lost unexpectedly while
application is running, the value of the NVM variables on the next key-on will be the same
value as what had been saved into flash during the last controlled shutdown. If power is
lost unexpectedly during the controlled shutdown procedure (when the process of saving
NVM variables into flash is supposed to be happening), all NVM variables will revert to
their default values (defined in the application software).
The Fixed NVM variables will be kept the same even the VCU is programmed (unless it is
required to be changed by user configuration), so critical data such as odometer data will
not be lost even the VCU software update is performed. The fixed NVM variables are
stored in specific space of flash and arranged in the order defined block, which means
specific addresses in flash are reserved for specific variables.
If new variables need to be added to fixed NVM space, it is necessary to re-initialize by
calling definition block.
To include Fixed NVM in the control strategy, Fixed NVM Definition, Read Fixed NVM, and
Write Fixed NVM blocks are needed. For details about parameters in each block, please
refer to section 4.8. The subsystem above will increase the value of the Fixed NVM variable
by 1 every time this subsystem is executed. Other two blocks, Restore NVM Data and Store
All NVM Data, are also necessary to fulfill the function of Fixed NVM. They are included in
default power management block as shown below. Please include them in the control
strategy if default power management block is not used.
Table 1.
Status Value Supported MinGW version
0 Successful operation
1 Insufficient space, available active area block is less than set active block
2 Flash operation error
3 Block operation error
4 Block detection error
5 Insufficient space
6 Need to erase
7 Abnormal block status
8 Parameters error
9 Record not found
10 Record type does not match
11 Record deleted
12 Record replication succeeded
13 Writing a record
14 Executing a swap operation
15 Records need to be written to new activity area
16 Needs to be erased
Table 2
Status Code Description
0 Bus Normal
1 Parameter Error
2 Bus Busy
Code Generation
1. Improve the efficiency of code generation (ROM, RAM efficiency)
2. Ensure the robustness of generated code