0% found this document useful (0 votes)
228 views227 pages

EcoCoder Manual - 4.9.1

Uploaded by

h_878236333
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
228 views227 pages

EcoCoder Manual - 4.9.1

Uploaded by

h_878236333
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 227

EcoCoder Manual

EcoCoder Manual
V4.9.1

Copyright ECOTRON LLC


All Rights Reserved
EcoCoder Manual

Contact us:
Web: http://www.ecotron.ai
Email: [email protected]
[email protected]

Address: 13115 Barton Rd, STE H


Whittier, CA, 90605
United States

Tel: +1 562-758-3039
+1 562-713-1105

Copyright ECOTRON LLC www.ecotron.ai Page 2


EcoCoder Manual

Date Version Comments Editor

6/20/2019 4.8.2 Ted Wang

7/24/2019 4.8.3 NVM Demo David Wang

Model Reference
8/11/2019 4.8.4 Ted Wang
Section

05/11/2020 4.8.5 Contact info update Zack Li

07/10/2020 4.8.6 Screenshot update Yibo Wang

07/16/2020 4.8.7 NVM update Jake Li

07/30/2020 4.8.8 Add Task Monitor Jake Li

Add more Michael Hu, Peter


01/29/2021 4.8.9
EcoCoder blocks Zhu

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”

Copyright ECOTRON LLC www.ecotron.ai Page 3


EcoCoder Manual

Contents

CHAPTER 1 GENERAL INFORMATION ................................................................ 14

1.1 About EcoCoder........................................................................................................................ 14

1.2 System Requirements .............................................................................................................. 15

1.3 MATLAB Installation Requirements ...................................................................................... 15

1.4 Supported MATLAB Version ................................................................................................... 16

1.5 Developer’s Kit .......................................................................................................................... 16

CHAPTER 2 ECOCODER DEVELOPMENT ENVIRONMENT ............................. 18

2.1 Software Installation List......................................................................................................... 18

2.2 CodeWarrior Installation.......................................................................................................... 20

2.3 MinGW-GCC Compiler Installation ........................................................................................ 20

2.4 C++ Compiler Installation ........................................................................................................ 23


Installation of Compiler for MATLAB 32-Bit..........................................................................24
Compiler Selection for MATLAB 64-Bit .................................................................................25

2.5 EcoCoder Installation .............................................................................................................. 25

2.6 Link S32DS_Power_Win32 to EcoCoder .............................................................................. 29

2.7 Link HighTec TriCore Tool Chain to EcoCoder .................................................................... 32

2.8 Link CS+ to EcoCoder ............................................................................................................. 34

2.9 Activate EcoCoder .................................................................................................................... 34


Get Key File ..............................................................................................................................35
Activate EcoCoder by License (.dat) File .............................................................................37

CHAPTER 3 QUICK START ON APPLICATION SOFTWARE ............................ 39

Copyright ECOTRON LLC www.ecotron.ai Page 4


EcoCoder Manual

CHAPTER 4 ECOCODER LIBRARY....................................................................... 42

4.1 EcoCoder Target Definition ..................................................................................................... 42

4.2 ADC Analog Inputs ................................................................................................................... 44


Read ADC Value ......................................................................................................................44
Read Fixed-Point ADC Volt ....................................................................................................45
Read Float ADC Volt ...............................................................................................................47

4.3 CAN Communication................................................................................................................ 49


CAN Channel Definition ..........................................................................................................49
CAN Wake-up Frame Definition ............................................................................................51
Read Fixed-Point CAN Message ..........................................................................................52
Read CAN Message ................................................................................................................55
Send Fixed-Point CAN Message ...........................................................................................57
Send CAN Message ................................................................................................................59
Receive CAN Message ...........................................................................................................61
Transmit CAN Message ..........................................................................................................62
Send CAN Data........................................................................................................................63
CAN Receive Counter ........................................................................................................63
Set CAN Mode.....................................................................................................................64
Unpack CAN Data to Signals ............................................................................................66
Pack Signals to CAN Data .................................................................................................67
Read CAN Error State ........................................................................................................67
Receive CAN Raw with Trigger .........................................................................................68
Recover CAN Bus Off.........................................................................................................68
CAN MESSAGE2NormalType ..........................................................................................69
CAN NormalType2NormalType.........................................................................................70
Receive CANFD Raw With Trigger ..................................................................................71
Transmit CANFD Message ................................................................................................72
Disable CAN transceiver and Wake-up ...........................................................................72

4.4 Serial Communication Interface (SCI) Block ....................................................................... 73


SCI Definition............................................................................................................................73
Read SCI Data .........................................................................................................................74
Send SCI Data .........................................................................................................................74

Copyright ECOTRON LLC www.ecotron.ai Page 5


EcoCoder Manual

4.5 Digital I/O .................................................................................................................................... 75


Switch Input ..............................................................................................................................75
KeyOn Input ..............................................................................................................................76
Switch Output ...........................................................................................................................78
IPM Read ..................................................................................................................................79
PWM IO Frequency Range Definition...................................................................................79
IPWM Read ..............................................................................................................................80
IPWM Interrupt Handler Definition ........................................................................................80
IPWM Read with Interrupt Handler .......................................................................................81
PWM Definition ........................................................................................................................82
PWM Output ........................................................................................................................83
PPM Read ............................................................................................................................84
Switch Internal .....................................................................................................................84
WakeUp Input ......................................................................................................................85
H-bridge Definition ..............................................................................................................86
H-bridge Output ...................................................................................................................87
INA226 Definition ................................................................................................................88
Get INA226 Current ............................................................................................................89
Get INA226 Shunt Voltage ................................................................................................89
Quadrature Decoder Definition .........................................................................................90
Quadrature Decoder Input .................................................................................................90
Quadrature Decoder Set Counter .....................................................................................91
Get Switch Output Sense Current ....................................................................................92

4.6 LIN Communication .................................................................................................................. 92


LIN Channel Definition ............................................................................................................92
LIN Get Status ..........................................................................................................................93
LIN Receive Data .....................................................................................................................94
LIN Transmit Data ....................................................................................................................96

4.7 Task Scheduler .......................................................................................................................... 97


Task Trigger ..............................................................................................................................97
Task Monitor .............................................................................................................................98

4.8 Non-Volatile Memory Blocks................................................................................................... 99


Fixed NVM Definition...............................................................................................................99

Copyright ECOTRON LLC www.ecotron.ai Page 6


EcoCoder Manual

Read Fixed NVM................................................................................................................... 101


Write Fixed NVM ................................................................................................................... 102
NVM Definition ...................................................................................................................... 102
NVM Variable Definition ....................................................................................................... 103
Read NVM ............................................................................................................................. 104
Write NVM .............................................................................................................................. 105
Store All NVM Data ............................................................................................................... 107
Restore All NVM Data .......................................................................................................... 108
Get Fixed NVM Variable Address .................................................................................. 108

4.9 Diagnostic Blocks................................................................................................................... 109


Hardware Output DTC ......................................................................................................... 109
DTC Parser ............................................................................................................................ 111
Software Core Diagnostic .................................................................................................... 112
Clear H-bridge DTC .............................................................................................................. 112
Clear TLF35584 All DTC ...................................................................................................... 113
Get TLF35584 Summary DTC ............................................................................................ 113
Get TLF35584Specific DTC Total Number........................................................................ 114
Get TLF35584 Specific DTC ............................................................................................... 114

4.10 Calibration & Measurement .............................................................................................. 115


Calibration Definition ....................................................................................................... 115
Read Calibration .............................................................................................................. 116
Write Measurement ......................................................................................................... 117
Write and Read Measurement ....................................................................................... 118
Override Probe ................................................................................................................. 119
1-D Lookup Table ............................................................................................................. 121
2-D Lookup Table ............................................................................................................. 122
Calibration Data Check ................................................................................................... 123

4.11 System Management Blocks ............................................................................................ 124


Power Management Example ........................................................................................ 124
Shutdown Power .............................................................................................................. 126
Shutdown Power Hold ..................................................................................................... 127
Set ECU Mode.................................................................................................................. 127
ECU Master Chip Wake-Up Definition .......................................................................... 128

Copyright ECOTRON LLC www.ecotron.ai Page 7


EcoCoder Manual

Watchdog Definition ......................................................................................................... 129


Service Software Watchdog ........................................................................................... 130
Software Reset ................................................................................................................. 131
Software Reset Hold ........................................................................................................ 131
Read System Free Counter ............................................................................................ 132
Power Control Output ...................................................................................................... 132
Stack Overflow Detection Definition .............................................................................. 133
Detect Stack Overflow ..................................................................................................... 133
Read BootID ..................................................................................................................... 134
Hardware Reset ............................................................................................................... 134

4.12 CCP ....................................................................................................................................... 134


Fixed CCP Slave Definition ............................................................................................ 134
CCP/CAL Seed&Key Security Definition ...................................................................... 136
CCP DAQ Seed&Key Security Definition ..................................................................... 137
CCP PGM Seed&Key Security Definition ..................................................................... 137
CCP Generate Seed Demo ............................................................................................ 138
CCP Get Seed Trigger .................................................................................................... 138
CCP Set Seed .................................................................................................................. 139

4.13 Sensors Blocks .................................................................................................................. 139


Read Gyro Hex Value ...................................................................................................... 139
Read Gyro Phy Value ...................................................................................................... 140

4.14 Programming Blocks ......................................................................................................... 140


Online Programming Definition ...................................................................................... 140
Programming Seed&Key Definition ............................................................................... 143
Entry UDS Programming ................................................................................................ 145

4.15 Advanced Data Blocks ...................................................................................................... 145


Read OTP ......................................................................................................................... 145
Read OTP (Input port) ..................................................................................................... 146
Write OTP .......................................................................................................................... 147
Write OTP (Input port) ..................................................................................................... 149
Read Data by Address .................................................................................................... 150
Read Data by Address (Input port) ................................................................................ 151

Copyright ECOTRON LLC www.ecotron.ai Page 8


EcoCoder Manual

Read String Value ............................................................................................................ 152


Read EEPROM ................................................................................................................ 152
Write EEPROM................................................................................................................. 153
EEPROM Emulation Definition ...................................................................................... 154
Clear ALL EEPROM Emulation Record ........................................................................ 154
Clear One EEPROM Emulation Record ....................................................................... 155
Read EEPROM Emulation Record ................................................................................ 155
Write EEPROM Emulation Record ................................................................................ 156
Read Signals from EEPROM Emulation Record ........................................................ 157
Write Signals to EEPROM Emulation Record ............................................................. 158
EEPROM Emulation Area Need to Erase .................................................................... 158
Erase EEPROM Emulation Area ................................................................................... 159
Program First Run Flag ................................................................................................... 160
Write RAM Data by Address ........................................................................................... 160
Get General Variable Address........................................................................................ 161

4.16 Application Base Blocks ................................................................................................... 162


Rising Edge ....................................................................................................................... 162
Falling Edge ...................................................................................................................... 162
Online Programming by SoftReset ................................................................................ 162
Online Programing By HardReset ................................................................................. 164
dt – time step length ........................................................................................................ 165
Rising Edge Debounce ................................................................................................... 165
Falling Edge Debounce ................................................................................................... 166
PT1 Filter ........................................................................................................................... 166
Hysteresis.......................................................................................................................... 167
SR Flip Flop ...................................................................................................................... 167

4.17 Volatile Variable .................................................................................................................. 168


Read Const Volatile Variable .......................................................................................... 168

4.18 XCP Module ......................................................................................................................... 169


XCP Slave Definition ....................................................................................................... 169

4.19 FlexRay Module .................................................................................................................. 169


FlexRay Definition ............................................................................................................ 169

Copyright ECOTRON LLC www.ecotron.ai Page 9


EcoCoder Manual

FlexRay Get Current State ............................................................................................. 171


FlexRay Setup Network Control .................................................................................... 171
FlexRay Force to Halt ...................................................................................................... 172
FlexRay Restore to Default Configuration .................................................................... 172
Read FlexRay Message .................................................................................................. 173
Write FlexRay Message .................................................................................................. 173

4.20 Ethernet ............................................................................................................................... 174


Ethernet Definition ........................................................................................................... 174
Ethernet Handler .............................................................................................................. 175
Ethernet Init ....................................................................................................................... 175

4.21 TCP Protocol Blocks ......................................................................................................... 175


TCP Server Definition ...................................................................................................... 175
TCP Server Init ................................................................................................................. 176
TCP Client Definition ....................................................................................................... 177
TCP Client Connect ......................................................................................................... 177
TCP Close ......................................................................................................................... 178
TCP Abort .......................................................................................................................... 178
TCP State .......................................................................................................................... 179
TCP Receive ..................................................................................................................... 180
TCP Transmit .................................................................................................................... 180

4.22 UDP Blocks ......................................................................................................................... 181


UDP Definition .................................................................................................................. 181
UDP Init ............................................................................................................................. 182
UDP Receive .................................................................................................................... 182
UDP Transmit ................................................................................................................... 183

4.23 SPI Blocks ........................................................................................................................... 184


SPI Definition .................................................................................................................... 184
SPI Master Exchange Data ............................................................................................ 185
SPI Slave Exchange Data .............................................................................................. 186

4.24 Model Reference................................................................................................................. 187


Configurations for Parent Models and Referenced Models ....................................... 188
Configuration Reference ................................................................................................. 189

Copyright ECOTRON LLC www.ecotron.ai Page 10


EcoCoder Manual

Copy Parent Model Configuration File to Referenced Model .................................... 191


EcoCoder Blocks in Model Reference .......................................................................... 191

CHAPTER 5 CAN THEORY OF ECOTRON ......................................................... 194

5.1 Introduction ............................................................................................................................. 194

5.2 CAN Implementation .............................................................................................................. 194


Convert DBC to m File ......................................................................................................... 195
EcoCoder CAN Blocks ......................................................................................................... 197
Select m file ........................................................................................................................... 197
Select Message ..................................................................................................................... 198
Select Sample Time.............................................................................................................. 199

CHAPTER 6 MEMORY MANAGEMENT ............................................................... 201

6.1 Introduction ............................................................................................................................. 201

6.2 Storage device ........................................................................................................................ 201

6.3 Data Storage ............................................................................................................................ 201


Calibration/Measurement Variable ..................................................................................... 201
Non-Volatile Variable ............................................................................................................ 202

CHAPTER 7 CUSTOM VARIABLE TYPE ............................................................. 203

7.1 Customize Variable Types ..................................................................................................... 203

7.2 Add Variables to Workspace................................................................................................. 204

7.3 Customize Calibration Variables .......................................................................................... 206

7.4 Customize measurement Variables ..................................................................................... 207

7.5 Customize NVM Variables ..................................................................................................... 208

7.6 Save the Variables to M file ................................................................................................... 209

7.7 Load M file to Workspace ...................................................................................................... 210

Copyright ECOTRON LLC www.ecotron.ai Page 11


EcoCoder Manual

7.8 Model Example ........................................................................................................................ 211

CHAPTER 8 PROGRAMMING VCU WITH ECOFLASH .................................... 212

CHAPTER 9 MEASUREMENT AND CALIBRATION WITH ECOCAL .............. 213

CHAPTER 10 UNINSTALL ECOCODER .............................................................. 214

10.1 Uninstall EcoCoder from MATLAB .................................................................................. 214

10.2 Uninstall EcoCoder from Windows System .................................................................. 215

CHAPTER 11 FAQS ................................................................................................ 216

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.4 Q4. EcoCoder Loader Pop-up error ................................................................................ 217

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

APPENDIX A - NONVOLATILE VARIABLES ....................................................... 223

Non-volatile Variables .......................................................................................................................... 223

Fixed Non-volatile Variables ................................................................................................................. 223

Fixed NVM Demo ................................................................................................................................. 223

APPENDIX-B BATTERY INPUT ............................................................................. 226

Copyright ECOTRON LLC www.ecotron.ai Page 12


EcoCoder Manual

APPENDIX C-MAB(MATHWORKS ADVISORY BOARD) .................................. 227

Copyright ECOTRON LLC www.ecotron.ai Page 13


EcoCoder Manual

Chapter 1 General Information

1.1 About EcoCoder

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

Copyright ECOTRON LLC www.ecotron.ai Page 14


EcoCoder Manual

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.

1.2 System Requirements

OS Windows XP/Windows 7/Windows 10

CPU Intel CORE 2 Duo or higher

Memory 2 GB or higher

Hard drive 1 GB free hard disk space

1.3 MATLAB Installation Requirements

Mandatory Components:
• MATLAB
• Simulink
• MATLAB Coder
• Simulink Coder
• Embedded Coder
Highly recommended components to be installed:
• Stateflow
• Stateflow Coder

Copyright ECOTRON LLC www.ecotron.ai Page 15


EcoCoder Manual

1.4 Supported MATLAB Version

• MATLAB R2010b 32-bit/64-bit


• MATLAB R2011a 32-bit/64-bit
• MATLAB R2011b 32-bit/64-bit
• MATLAB R2012a 32-bit/64-bit
• MATLAB R2012b 32-bit/64-bit
• MATLAB R2013a 32-bit/64-bit
• MATLAB R2013b 32-bit/64-bit
• MATLAB R2014a 32-bit/64-bit
• MATLAB R2014b 32-bit/64-bit
• MATLAB R2015a 32-bit/64-bit
• MATLAB R2015b 32-bit/64-bit
• MATLAB R2016a 64-bit
• MATLAB R2016b 64-bit
• MATLAB R2017a 64-bit
• MATLAB R2017b 64-bit
• MATLAB R2018a 64-bit
• MATLAB R2018b 64-bit
• MATLAB R2019a 64-bit
• MATLAB R2019b 64-bit

Note: some of the MATLAB versions (old) may require extra configurations to make the
EcoCoder work. Contact us if you have compatibility issues.

1.5 Developer’s Kit

• 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

Copyright ECOTRON LLC www.ecotron.ai Page 16


EcoCoder Manual

or PeakCAN should be compatible with Ecotron products.

Copyright ECOTRON LLC www.ecotron.ai Page 17


EcoCoder Manual

Chapter 2 EcoCoder Development Environment

2.1 Software Installation List

Please install software tools in the following order:

1. Integrated development environment for generating executable files


Main Chip Integrated development environment

Infineon TC27x HighTec TriCore Tool Chain

NXP SPC57xx S32DS_Power_Win32_v2017.R1_b171019.exe

NXP SPC56xx CodeWarrior for MPC55xxMPC56xx v2.10.exe

Renesas RH850 CS+(CSPlus_CC_Package_V70000.EXE)

2. Compiler for generating DLL file (optional)


Compiler Integrated development environment
GCC compiler can generate DLL file, to set calibration,
Tdm64-gcc-4.9.2.exe measurement, and program flashing permission.
Support all MATLAB versions to generate DLL file.

3. EcoFlash Vxxxx Setup.exe

4. EcoCAL Vxxxx Setup.exe, or INCA

5. Ecotron USB-CAN adapter Driver, or other CAN adapter Driver, such as Kvaser

product

6. Stateflow Coder (optional)


Compiler Supported MATLAB version

C++ Compiler Support Stateflow of MATLAB 32/64-bit

Lcc-win32 Support Stateflow of MATLAB 32-bit


Support Stateflow of some MATLAB versions
Please see the corresponding relationship between
MinGW-GCC
the MATLAB version and the supported MinGW
version

Copyright ECOTRON LLC www.ecotron.ai Page 18


EcoCoder Manual

7. EcoCoder Setup.msi

Compilers and its Applications:


Compiler or integrated development
Application
environment utility
Compilation and link; HEX file generation for target
HighTec TriCore Tool Chain
EH2175A
Compilation and link; MOT file generation for NXP
S32DS_Power_Win32_v2017.R1_b171019.exe
MPC5744 based units.
Compilation and link; MOT file generation for target
CodeWarrior for MPC55xxMPC56xx v2.10.exe
EV2206B03, ET3206A

C++ Compiler Support Stateflow of 32-bit and 64-bit MATLAB

Lcc-win32 Support Stateflow of 32-bit MATLAB


1. Generate DLL file for calibration, measurement and
programming permission, support all versions of
MATLAB
WinGW-GCC
2. Support Stateflow of some MATLAB versions, you
can go to MATLAB official website to check whether it
supports specific MATLAB version
Compilation and link, MOT file generation for target
CS+(CSPlus_CC_Package_V70000.EXE)
GWRH850

The corresponding relationship between the MATLAB version and the supported MinGW

version:
MATLAB version Supported MinGW version

MATLAB2015a or below Not support

MATLAB2015b Support MinGW 4.9.2 (Distributor: TDM-GCC)

MATLAB 2016a Support MinGW 4.9.2 (Distributor: TDM-GCC)

MATLAB 2016b Support MinGW 4.9.2 (Distributor: TDM-GCC)

MATLAB 2017a Support MinGW 4.9.2 (Distributor: TDM-GCC)

MATLAB 2017b Support MinGW 5.3 (Distributor: TDM-GCC)

MATLAB 2018a Support MinGW 5.3 (Distributor: TDM-GCC)

Copyright ECOTRON LLC www.ecotron.ai Page 19


EcoCoder Manual

2.2 CodeWarrior Installation

The installation instruction is for CodeWarrior MPC55xxMPC56xx v2.10.exe, if you


installed other CodeWarrior version, please do the following after installation:
1. Run the “regserves.bat” file in the installation directory “Freescale\GW for MPC55xx
and MPC56xx 2.10\bin”. When the window appears, press any key to exit.

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.3 MinGW-GCC Compiler Installation

The MinGW-GCC compiler can be installed via TDM-GCC. TDM-GCC is a compiler


integration package for Windows that combines the latest version of the GCC toolset and
includes API of open source MinGW or MinGW-w64. The installation steps are as follows:
1. First check “Check for updated files on the TDM-GCC server”

Copyright ECOTRON LLC www.ecotron.ai Page 20


EcoCoder Manual

2. Choose MinGW-w64

3. Choose the installation directory

Copyright ECOTRON LLC www.ecotron.ai Page 21


EcoCoder Manual

4. Choose TDM-GCC Recommended, C/C++

Note: If the user uses MinGW-GCC as the Stateflow complier, proceed to the
next step.
5. Add environment variables

Copyright ECOTRON LLC www.ecotron.ai Page 22


EcoCoder Manual

6. Restart or open MATLAB.


7. Enter “mex -setup C++”

8. Choose MinGW64 Complier

2.4 C++ Compiler Installation

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.

Copyright ECOTRON LLC www.ecotron.ai Page 23


EcoCoder Manual

Installation of Compiler for MATLAB 32-Bit

1. Type ‘mex -setup’ at MATLAB Command Window.

2. Type ‘y’ at Command Window.

3. Type ‘1’ at Command Window.

4. Type ‘y’ at Command Window.

5. When the following information is displayed, the installation is successful.

Copyright ECOTRON LLC www.ecotron.ai Page 24


EcoCoder Manual

Compiler Selection for MATLAB 64-Bit

1. Go to the official website of MathWorks

https://www.mathworks.com/support/sysreq/previous_releases.html

2. Click ‘Details’ under ‘Supported Compilers’ of MATLAB version on customer PC.

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

configure compiler for MATLAB.

2.5 EcoCoder Installation

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.

Copyright ECOTRON LLC www.ecotron.ai Page 25


EcoCoder Manual

2. Choose installation path, click ‘Next’.

Note: it is recommended to install EcoCoder under the system drive.

3. Click ‘Next’.

Copyright ECOTRON LLC www.ecotron.ai Page 26


EcoCoder Manual

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

EcoCoder for all MATLAB versions on computer.

5. Click ‘Close’.

Copyright ECOTRON LLC www.ecotron.ai Page 27


EcoCoder Manual

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

successfully’ as shown in following red box. It indicates that EcoCoder is successfully

installed to MATLAB.

Copyright ECOTRON LLC www.ecotron.ai Page 28


EcoCoder Manual

2.6 Link S32DS_Power_Win32 to EcoCoder

Please refer to this video for setting up the S32DS IDE:

https://youtu.be/CiChf1_JZcw

Link for copy and paste:

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.

Copyright ECOTRON LLC www.ecotron.ai Page 29


EcoCoder Manual

1. Open EcoCoder, choose Tools > Select S32DS

2. Click Browse, choose makefile under e200_ew12, for example, the full path is:

Copyright ECOTRON LLC www.ecotron.ai Page 30


EcoCoder Manual

3. Right click on Computer, then click on properties

4. Choose Advanced system settings > Environment Variables

Copyright ECOTRON LLC www.ecotron.ai Page 31


EcoCoder Manual

5. 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_v201
7.R1\Cross_Tools\powerpc-eabivle-4_9\bin

2.7 Link HighTec TriCore Tool Chain to EcoCoder

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

directory in EcoCoder Loader.

Open EcoCoder Loader, click Tools, then click “Select HighTec”.

Copyright ECOTRON LLC www.ecotron.ai Page 32


EcoCoder Manual

Then in the pop-up window, click “Browse”, locate the “make.exe” in the HIGHTEC

installation path, in “bin” folder under the folder ‘toolchains’.

For example, the full path can be: “C:\HIGHTEC\toolchains\tricore\v4.9.1.0-infineon-

1.1\bin\make.exe”

Copyright ECOTRON LLC www.ecotron.ai Page 33


EcoCoder Manual

2.8 Link CS+ to EcoCoder

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.

2.9 Activate EcoCoder

There are two ways to activate EcoCoder and other Ecotron software.

Note: Please close MATLAB for the activation process.

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.

Copyright ECOTRON LLC www.ecotron.ai Page 34


EcoCoder Manual

Get Key File

1. Double-click “EcoCoder Loader” on the desktop.

2. Select Tools → Get EcoCoder Key.

3. Click ‘Export’.

Copyright ECOTRON LLC www.ecotron.ai Page 35


EcoCoder Manual

4. Save the key file.

5. Please send the key file to [email protected] for license file.

Copyright ECOTRON LLC www.ecotron.ai Page 36


EcoCoder Manual

Activate EcoCoder by License (.dat) File

1. Double-click ‘EcoCoder Loader’ at the Desktop.

2. Select Tools->Activate EcoCoder.

3. Click ‘Browse’.

Copyright ECOTRON LLC www.ecotron.ai Page 37


EcoCoder Manual

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.

7. If following message shows up in MATLAB command window, EcoCoder should be ready


to use.

Copyright ECOTRON LLC www.ecotron.ai Page 38


EcoCoder Manual

Chapter 3 Quick Start on Application Software

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)

for you, to fill in your existing model.

1. Change path to desired folder other than MATLAB installation directory.

2. Type the command ‘EcoCoder_Prj (‘DemoTest')’ in Command Window.

3. A model ‘DemoTest.mdl’, and a ‘.m’ file as shown in the following figure will be

generated. In Simulink, by using shortcut key ‘Ctrl + B’ or click ‘Build Model’

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

‘configurable’, EcoCoder will only generate ‘.a2l’ and ‘mot’/’hex’. )

Copyright ECOTRON LLC www.ecotron.ai Page 39


EcoCoder Manual

Copyright ECOTRON LLC www.ecotron.ai Page 40


EcoCoder Manual

If the ‘CodeWarrior’ window pops up, do not manually intervene, it will automatically

compile and close when the process is finished.

As shown in below picture, you can find the generated ‘.mot’, ‘.cal’, and ‘.a2l’ files.

Copyright ECOTRON LLC www.ecotron.ai Page 41


EcoCoder Manual

Chapter 4 EcoCoder Library

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.

4.1 EcoCoder Target Definition

Folder: EcoCoder Blocks


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 42


EcoCoder Manual

Under the ‘General Parameters’ tab, this block defines the specific model of Ecotron VCU

that you are using.

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:

Parameter Field Value Comments/Description

Target Drop-down list Pick target VCU

Enable all required Check box If enabled:

execution modules to be All subsystems that are not

scheduled assigned to tasking triggers

would be assigned to L1ms

Copyright ECOTRON LLC www.ecotron.ai Page 43


EcoCoder Manual

trigger*

Advanced Parameters Memory addresses (RAM, Contact our tech support

ROM) for adjustments

* Please refer to Task Scheduler for knowledge of 'Tasking'.

4.2 ADC Analog Inputs

Read ADC Value

Folder: EcoCoder Blocks/ADC


Description:

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

Copyright ECOTRON LLC www.ecotron.ai Page 44


EcoCoder Manual

to datasheet of the specific VCU.

See examples below:

Channel ADC Predefined RAW ADC Raw ADC (binary)


Resolution (bits)

1 10 500 000111110100

2 12 500 00000111110100

Block Parameters:

Parameter Field Value Comments/Description

Analog input channel 0 – n (determined by Pick specific analog input


hardware resource of channel
specific VCU)

Read Fixed-Point ADC Volt

Folder: EcoCoder Blocks/ADC


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 45


EcoCoder Manual

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.

(*) For fixed point toolbox advantages, refer to


https://www.mathworks.com/help/simulink/fixed-point.html

Copyright ECOTRON LLC www.ecotron.ai Page 46


EcoCoder Manual

(*) Every channel has its unique configuration defined in firmware, please refer to
datasheet of VCU and select correct setting for the channel

Read Float ADC Volt

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:

Copyright ECOTRON LLC www.ecotron.ai Page 47


EcoCoder Manual

Volt: Physical value of input voltage of specified channel.

Copyright ECOTRON LLC www.ecotron.ai Page 48


EcoCoder Manual

4.3 CAN Communication

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

preliminary knowledge of implementing CAN on Ecotron VCU.

CAN Channel Definition

This block is used to initialize the CAN bus configurations. Including CAN channel enable,
CAN ID filtering, baud rate settings.

Copyright ECOTRON LLC www.ecotron.ai Page 49


EcoCoder Manual

Parameter:
1) CAN Channel: CAN channel selection

2) CAN Enable: enabling the CAN channel

3) CAN ID Filter Enable: When filtering is enabled, the CAN bus is only receiving CAN
messages with a specific ID.

4) CAN Extended: enable to receive extended frame only.

a. Note: if the CAN ID Filter is not enabled, both extended and regular frame will
be received.

5) CAN ID Mask (uint32 Hex): Set CAN ID mask

b. Note: used CAN ID Filter (uint32 Hex) with this option

6) CAN Filter (uint32 Hex): Filters ID. It is a 16-bit variable; user needs to use this with CAN
ID Filter (uint32 Hex)

7) CAN Baud Rate (kbps): CAN baud rate configuration

8) CAN TxBuffer Size: send buffer for CAN transmission, minimum value is 2

9) CAN RXBuffer Size: receive buffer for CAN transmission

10) CAN FD Enable: enables CAN FD

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%

14) CAN FD TxBuffer Size: CAN FD transmit buffer; minimum value is 2

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

Copyright ECOTRON LLC www.ecotron.ai Page 50


EcoCoder Manual

c. The CAN Node is receiving:


i. b1111
ii. b1101
2. Example 2
a. MASK(4-bit): b1001
b. FILTER(4-bit): b1111
c. The CAN Node is receiving:
i. b1111
ii. b1101
iii. b1011
iv. b1001

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.

CAN Wake-up Frame Definition

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.

Read Fixed-Point CAN Message

Folder: EcoCoder Blocks/CAN


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 52


EcoCoder Manual

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

(from .dbc file to .m file) is explained in Chapter 5.

Block Parameters

Parameter Field Value Comments/Description

The CAN channel has to be


Select CAN Channel Drop-down list
defined before applied.

Copyright ECOTRON LLC www.ecotron.ai Page 53


EcoCoder Manual

If checked: please enter the


Select M File Check box name of m file in the blank
space under check box.

Specify CAN message to be


Select Message Drop-down list received and processed by
the block.

If checked: the block will


Show Message Available provide a signal flag to help
Check box
Port tell the availability of this
CAN message.

Message counter, if
checked: every time the
Show Message Count Port Check box
message is received, the
counter increments by 1.

If checked: the names of the


Show Signal Name Check box
signals will be displayed.

If checked: signals parsed


out from the block will be
cast as measurement
Define Signal Check box
variables. ‘Show Signal
Name’ must be checked
before checking this item.

Specify prefix to parsed out


Signal prefix Alpha-numeric text signal names, remember to
use single quote.

If checked: the data type of


the signal is inherited from
Output Data Type: Inherit Check box input data type.
If not checked: the signal
type is automatically

Copyright ECOTRON LLC www.ecotron.ai Page 54


EcoCoder Manual

defined using fixed point


tool.

Sample time Drop-down list Please refer to section 5.2.5

Read CAN Message

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.

Copyright ECOTRON LLC www.ecotron.ai Page 55


EcoCoder Manual

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

b. Disconnected: messages sent from the output port

c. DisconnectedOnlyData: the block is only used as a data converter

2) Select CAN Channel: CAN channel selection

3) Select M file: select the m file from DBC converting tool. Click OK then double click the
block to select specific message.

4) Select Message: select specific message

5) Show Message Available Port: check to show the message availability port, output 1
when read a valid message.

6) Show Message Count Port: check to show message counter.

7) Show Signal Names: Enable to show the signal name

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.

9) Signal prefix: show signal prefix on the signal name

10) Sample time: Simulation sample time

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

2) Remote: this flag is set to 1 when sending a remote frame

3) Extended: this flag is set to 0 when sending an extended frame

4) ID: CAN message ID

5) Length: data length

6) Data: data in the message

7) Function Packaging:

Copyright ECOTRON LLC www.ecotron.ai Page 56


EcoCoder Manual

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.

Send Fixed-Point CAN Message

Folder: EcoCoder Blocks/CAN


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 57


EcoCoder Manual

Parameter Field Value Comments/Description

Select CAN Channel State Drop-down list Connected: Message will be


- Connected sent out from the CAN
- Disconnected channel selected under
‘Select CAN Channel’
Disconnected: User will
have to assign the output
port manually.

Select CAN Channel Drop-down list CAN channel selection

Select M File Check box If checked: please enter the


name of m file in the blank
space under check box.

Select Message Drop-down list Specify CAN message to be


sent and processed by the
block.

Input Data Type: Inherit Check box If checked: the data type of
the signal is inherited from

Copyright ECOTRON LLC www.ecotron.ai Page 58


EcoCoder Manual

input data type.


If not checked: the signal
type is automatically
defined using fixed point
tool.

Sample time Drop-down list Please refer to section


5.2.5

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

Send CAN Message

This block is used for sending CAN messages. It takes the .m file converted from .dbc file
and send CAN messages accordingly.

Copyright ECOTRON LLC www.ecotron.ai Page 59


EcoCoder Manual

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

b. Disconnected: messages sent from the output port

c. DisconnectedOnlyData: the block is only used as a data converter

2) Select CAN Channel: CAN channel selection

3) Select M file: select the m file from DBC converting tool. Click OK then double click the
block to select specific message.

4) Select Message: select specific message

5) Sample time: select simulation sample time

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.

Copyright ECOTRON LLC www.ecotron.ai Page 60


EcoCoder Manual

Output:
2) When channel state is at “Disconnected”:

a. Remote: this flag is set to 1 when sending a remote frame

b. Extended: this flag is set to 1 when sending an extended frame

c. ID: CAN message ID

d. Length: data length

e. Data: data in the message

Receive CAN Message

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

Copyright ECOTRON LLC www.ecotron.ai Page 61


EcoCoder Manual

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.

Transmit CAN Message

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.

Copyright ECOTRON LLC www.ecotron.ai Page 62


EcoCoder Manual

Send CAN 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.

CAN Receive Counter

Folder: EcoCoder Blocks/CAN


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 63


EcoCoder Manual

This module can be used to count the number of frames received by specified CAN

channel.

Block Parameters

Parameter Field Value Comments/Description

Specify the channel to be


CAN channel Drop-down list
monitored

Block Output:

cnt: If the selected channel receives one frame, cnt value increments by 1.

Set CAN Mode

Folder: EcoCoder Blocks/CAN


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 64


EcoCoder Manual

This module can be used to switch CAN operating mode between ‘listen only’ and

‘normal’.

Block Parameters

Parameter Field Value Comments/Description

Trigger type Drop-down list Trigger type selection

Specify CAN channel to be


CAN Channel Drop-down list
controlled

Specify the CAN mode to


CAN Mode Drop-down list
be triggered by the block

Block Input:
Trigger signal: the signal input to trigger the execution of this block.

Copyright ECOTRON LLC www.ecotron.ai Page 65


EcoCoder Manual

Unpack CAN Data to Signals

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.

Copyright ECOTRON LLC www.ecotron.ai Page 66


EcoCoder Manual

Pack Signals to 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.

Read CAN Error State

Copyright ECOTRON LLC www.ecotron.ai Page 67


EcoCoder Manual

This block diagnoses errors happen in CAN channels.

Block Parameters:
1) CAN Channel: Channel selection

Receive CAN Raw with Trigger

Block Parameter:

1) CAN Channel: channel selection

Block Output:

1) f(): trigger event

2) Remote: set to 1 to use remote frame, set to 0 to use data frame

3) Extended: set to 1 to use extended frame, set to 0 to use standard frame

4) ID: message ID

5) Length: data length

6) Data: data in the message

Recover CAN Bus Off

This block recovers CAN Bus off errors.

Copyright ECOTRON LLC www.ecotron.ai Page 68


EcoCoder Manual

Block Parameters:

1) CAN Channel

Block Input

1) Trigger signal: Bus off recovered if the signal returns 1.

CAN MESSAGE2NormalType

Along with Transmit CAN Message block, this block can pack and send message

with Simulink Embedded Coder by execute the following steps: Embedded

Coder->Embedded Targets->CAN Pack. CAN Pack block is recommended to use in

MATLAB R2018b (or higher version) since the CAN Pack works more efficiently in the

later versions.

Block Input:

1) msg:Simulink default CAN_MESSAGE type.

Block Output:

Copyright ECOTRON LLC www.ecotron.ai Page 69


EcoCoder Manual

1) remote:Remote frame:1 Data frame: 0

2) extended:Extended frame:1 Standard frame: 0

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

following steps: Embedded Coder->Embedded Targets-> CAN Unpack. CAN UnPack

block is recommended to use in MATLAB R2018b (or higher version) since the CAN

Pack works more efficiently in the later versions.

Block Input:

1) remote:Remote frame:1 Data frame: 0。

2) extended:Extended frame:1 Standard frame: 0

3) id:

4) length

Copyright ECOTRON LLC www.ecotron.ai Page 70


EcoCoder Manual

5) data

Block Output:

1) msg:Simulink default CAN_MESSAGE type.

Receive CANFD Raw With Trigger

This block receives CANFD with Trigger

Block Parameter:

1) CAN Channel

2) Data Output Port Width

Block Output:

1) f(): trigger event

2) Extended:Extended frame:1 Standard frame: 0

3) ID: message ID

4) FastBitRate: Changeable rate, Changeable: 1, Unchangeable: 0

5) Length: the length of the date

6) DLC:Data Length Code.

7) ESI:Error state, Passive Error:1, Active Error: 0

8) Data:Data Output Port Width function can be used to set up the port width.

Copyright ECOTRON LLC www.ecotron.ai Page 71


EcoCoder Manual

Transmit CANFD Message

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:

1) Extended:Extended frame:1 Standard frame: 0

2) ID

3) FastBitRate:Changeable rate, Changeable: 1, Unchangeable: 0

4) Data: Data Output Port Width function can be used to set up the port width.

Disable CAN transceiver and Wake-up

This block can turn off CAN Wake-up in when powered off

Copyright ECOTRON LLC www.ecotron.ai Page 72


EcoCoder Manual

Block Parameter:

1) Select Trigger Type

2) CAN Channel

4.4 Serial Communication Interface (SCI) Block

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

6. SCI Parity Mode: Parity check mode setup.

Read SCI Data

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.

Send SCI Data

This block will send SCI data to assigned channel.

Block Parameter:
SCI_Channel: SCI channel selection.

Copyright ECOTRON LLC www.ecotron.ai Page 74


EcoCoder Manual

Block Input:
Data: The 8-bit data to be sent out.

4.5 Digital I/O

These blocks are used for measuring digital input/output. Including Switch Input, Switch

Output, PWM input and PWM output.

Switch Input

Folder: EcoCoder Blocks/Digital I/O


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 75


EcoCoder Manual

This block reads the physical voltage level of digital input channels and output Boolean

variable to application layer.

Block Parameters:

Parameter Field Value Comments/Description

Digital input channel


Switch input channel Drop-down list
selection

KeyOn Input

Folder: EcoCoder Blocks/Digital I/O


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 76


EcoCoder Manual

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

Parameter Field Value Comments/Description

Switch input channel Drop-down list Only one channel selectable for KeyOn

The voltage factor for KeyOn voltage

Key AD2Volt Factor Numeric detection (only valid when KeyOn is

read from AI)

If the input voltage is lower than this


Key Off Threshold Volt Numeric
value, output is ‘0’.

Copyright ECOTRON LLC www.ecotron.ai Page 77


EcoCoder Manual

The hysteresis value between upper

and lower threshold. If the interpreted

KeyOn Hysteresis Volt Numeric voltage is larger than the sum of ‘Key

Off Threshold Volt’ value and this

value, output is ‘1’.

Switch Output

Folder: EcoCoder Blocks/Digital I/O


Description:

Block Parameters

Parameter Field Value Comments/Description

Select switch channels to


Switch output channel Drop-down list
be controlled

Input Numeric (bool) 0 or 1, switch control value

Copyright ECOTRON LLC www.ecotron.ai Page 78


EcoCoder Manual

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.

PWM IO Frequency Range Definition

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.

Copyright ECOTRON LLC www.ecotron.ai Page 79


EcoCoder Manual

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%

IPWM Interrupt Handler Definition

This module is used to initialize the configuration of the switch input channel using
interrupt mode to measure frequency and duty cycle.

Copyright ECOTRON LLC www.ecotron.ai Page 80


EcoCoder Manual

Block Parameter:

1) IPWM Channel
2) IPWM Enable
3) Trigger Type: Including rising edge and falling edge.

IPWM Read with Interrupt Handler

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:

1) f(): functional call

2) tEff: Specifies the effective level time of the channel signal, in (us).

3) tPer: Specify the period 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

refers to low 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

PWM IO Frequency Range Definition setting.

4) OPWM Duty: The channel initialization duty cycle, where 0-10000 corresponds

Copyright ECOTRON LLC www.ecotron.ai Page 82


EcoCoder Manual

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

Folder: EcoCoder Blocks/Digital I/O


Description:

This block configures PWM outputs.

Block Parameters:

Parameter Field Value Comments/Description

OPWM channel Drop-down list Specify the PWM output channel

Theoretical range is 1-2000000 Hz.

Recommended range for perfect

freq (input) Numeric square wave output is 15 – 2000 Hz.

For the input value unit, refer to PWM

IO Frequency Range Definition.

Copyright ECOTRON LLC www.ecotron.ai Page 83


EcoCoder Manual

Control the duty cycle of the selected

duty (input) Numeric channel output, value 0-10000

corresponds to 0-100%.

PPM Read

This module is used to read PPM signal.

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

the system is powered on.

Copyright ECOTRON LLC www.ecotron.ai Page 84


EcoCoder Manual

Block Parameter:

1) Switch internal channel

Note: Calling the shutdown module will clear this bit to 0.

WakeUp Input

Folder: EcoCoder Blocks/Digital I/O


Description:

This block can read wake-up signal status.

Block Parameters

Parameter Field Value Comments/Description

Switch input channel Drop-down list Wakeup source selection

Copyright ECOTRON LLC www.ecotron.ai Page 85


EcoCoder Manual

Output Numeric (Boolean) ‘1’ is active

H-bridge Definition

Folder: EcoCoder Blocks/Digital I/O


Description:

This block is used for setting up the VCU H-bridge(s).

Block Parameters

Parameter Field Value Comments/Description

H-bridge Channel Drop-down list Select H-bridge channel

H-bridge Enable Check box If checked: Enable H-bridge

If checked: The current direction is

from A->B.

H-bridge Current Direction If not checked: the current direction is


Check box
A->B B->A.

(A and B are the two outputs of H-

bridge, see the VCU data sheet for

Copyright ECOTRON LLC www.ecotron.ai Page 86


EcoCoder Manual

more information)

The theoretical range is 1-2000000 Hz.

Recommended range for perfect

square wave output is 15 – 2000 Hz.


H-bridge Initial Frequency Numeric (Hz)
Input value unit is configurable in the

PWM IO Frequency Range Definition

block.

H-bridge Initial Duty Cycle Numeric 0-10000 corresponds to 0-100%.

H-bridge Output

Folder: EcoCoder Blocks/Digital I/O


Description:

This block controls H-bridge output.

Block Parameters

Parameter Field Value Comments/Description

H-bridge Channel Drop-down list Select H-bridge channel

en (input) Numeric (bool) ‘1’ to enable H-bridge

‘1’: current flows from A to B;


curA2B (input) Numeric (bool)
‘0’: currents flow from B to A.

Copyright ECOTRON LLC www.ecotron.ai Page 87


EcoCoder Manual

The theoretical range is 1-2000000

Hz. Recommended range for perfect

square wave output is 15 – 2000 Hz.


frq (input) Numeric
Input value unit is configurable in the

PWM IO Frequency Range Definition

block.

duty (input) Numeric 0-10000 corresponds to 0-100%.

INA226 Definition

Block Parameter:

1) OPWM Channel

2) Monitor enable: Enable monitoring IN226

3) Number of averages

4) Conversion time:Bus and shunt voltage conversion time.

Copyright ECOTRON LLC www.ecotron.ai Page 88


EcoCoder Manual

Get INA226 Current

Block Parameter:

1) OPWM Channel

Block Output:

1) mA:Read the INA226 current, in mA.

Get INA226 Shunt Voltage

Block Parameter:

1) OPWM Channel

Block Output:

1) mV:Read the INA226 shunt voltage value,in mV.

Copyright ECOTRON LLC www.ecotron.ai Page 89


EcoCoder Manual

Quadrature Decoder Definition

Block Parameter

1) Select Quadrature Decoder Channel

2) Decoder Input1

3) Decoder Input2

Quadrature Decoder Input

Block Parameter

1) Select Quadrature Decoder Channel

Block Output:

1) frq:Frequency in Hz

Copyright ECOTRON LLC www.ecotron.ai Page 90


EcoCoder Manual

2) cnt:For a square wave counter, if the phase state stPhase is 1, it will increase

by 1, and if it is -1, it will decrease by 1.

3) stPhase:Phase status, 1 means channel 1 leads channel 2 by 90°, -1 means

channel 1 lags channel 2 by 90°

Quadrature Decoder Set Counter

This module can be used to set the initial value of quadrature decoding square wave count

value, generally used to clear the count.

Block Parameter:

1) Select Quadrature Decoder Channel

Block Output:

1) cnt:Initial square wave count.

Copyright ECOTRON LLC www.ecotron.ai Page 91


EcoCoder Manual

Get Switch Output Sense Current

Block Parameter

1) Switch output channel

Block Output:

2) mA:Channel detection current value, the unit is mA.

4.6 LIN Communication

LIN Channel Definition

Folder: EcoCoder Blocks/LIN


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 92


EcoCoder Manual

This block provides configuration interface for LIN parameters.

Block Parameters

Parameter Field Value Comments/Description

LIN Channel Drop-down list Please refer to datasheet to


select supported LIN
channel.

LIN Mode Drop-down list Select Lin mode. (Master or


Slave)

LIN Baud Rate (bps): Numeric Input LIN baud rate.

LIN Get Status

Folder: EcoCoder Blocks/LIN


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 93


EcoCoder Manual

This module is used to get the status of LIN channel.

Block Parameters

Parameter Field Value Comments/Description

LIN Channel Drop-down list Please refer to datasheet to


select supported LIN
channel.

Block Output:
1. St: (status)

Value Description

0 Normal

1 Error

6 Busy

LIN Receive Data

Folder: EcoCoder Blocks/LIN


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 94


EcoCoder Manual

This module is used to receive data from the LIN bus.

Block Parameters

Parameter Field Value Comments/Description

LIN Channel Drop-down list Please refer to datasheet to


select supported LIN
channel.

ID Numeric Data address to receive

Data Length Numeric Data length

Direction Drop-down list Select according to LIN


mode

Classic Checksum Drop-down list Checksum category

Sample Time Drop-down list Task sample time

Block Outputs:
1) Available: output of 1 means data is valid, otherwise invalid.
2) Date: receiving data

Copyright ECOTRON LLC www.ecotron.ai Page 95


EcoCoder Manual

LIN Transmit Data

Folder: EcoCoder Blocks/LIN


Description:

This module is used to send data to the LIN bus.

Block Parameters

Parameter Field Value Comments/Description

LIN Channel Drop-down list Please refer to datasheet to


select supported LIN
channel.

ID Numeric Data address to receive

Data Length Numeric Data length

Direction Drop-down list Select according to LIN

Copyright ECOTRON LLC www.ecotron.ai Page 96


EcoCoder Manual

mode

Classic Checksum Drop-down list Checksum category

Sample Time Drop-down list Task sample time

Block Input:
1) Date: sending data

4.7 Task Scheduler

Task Trigger

Folder: EcoCoder Blocks/Task Scheduler


Description:

This block is for task scheduling and prioritization.

Definition / initialization blocks need to be executed when the VCU power on, for

variables initialization/parameter definitions.

All other blocks/subsystems should be triggered by this block, for task prioritization and

scheduling.

Copyright ECOTRON LLC www.ecotron.ai Page 97


EcoCoder Manual

Block Parameters

Parameter Field Value Comments/Description

Task type and execution


Set Task Time Drop-down list
period selection*

* H represents high priority. Tasks will be implemented by interruption. L represents low

priority. Tasks will be implemented by software timer function call.

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

link for more information: https://www.mathworks.com/help/simulink/examples/block-

priority.html

* For CAN bus applications, they are recommended to be set up in 10ms tasks.

Task Monitor

Folder: EcoCoder Blocks/Task Scheduler


Description:

This module is used to monitor task scheduling time.

Block Parameters

Parameter Field Value Comments/Description

Copyright ECOTRON LLC www.ecotron.ai Page 98


EcoCoder Manual

Set Task Time Drop-down list Task type selection

NXP5606: 150,000

NXP5744: 5,000

RTC Frequency (KHz) Numeric TC275: 100,000

TC297: 200,000

TC397: 100,000
Block Output:

1. ms: The actual execution cycle of the task.

2. %: Load factor of chosen task type.

4.8 Non-Volatile Memory Blocks

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.

Fixed NVM Definition

Folder: EcoCoder Blocks/Non-volatile Memory Blocks


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 99


EcoCoder Manual

This module is used to define and initialize fixed NVM variables.

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

Parameter Field Value Comments/Description

Select the .m file defining


Select the m file .m file
NVM variables.

*The m file can be defined as the picture below:

Parameters in the .m file:

Copyright ECOTRON LLC www.ecotron.ai Page 100


EcoCoder Manual

1) Order: order of the Fixed NVM variables


2) Name: variable name
3) Type: data type of the variable
4) Size: length of the array variable
5) Init: The ‘init’ in the .m file is the flag for NVM variable initialization.
init = 1: The NVM variable value will be set to initial value defined in parameter
‘Value’ after .mot file being flashed into VCU.
init = 0: The NVM variable value will be loaded from the VCU flash (value stored
last time) after .mot file being flashed into VCU.
6) Value: initial value of the variable
If the VCU that you are operating is a brand new VCU and will be flashed for the very first
time, no matter what the ‘init’ value is, the NVM variables will be initialized from .mot file.
Note: The .m file needs to be added under MATLAB path.

Read Fixed NVM

Folder: EcoCoder Blocks/Non-volatile Memory Blocks


Description:

This module is used for reading fixed NVM variables.

Block Parameters

Parameter Field Value Comments/Description

Copyright ECOTRON LLC www.ecotron.ai Page 101


EcoCoder Manual

Specify the variable name


Fixed NVM Variable Variable name
to be read

Block Output:
The value of corresponding variables.

Write Fixed NVM

Folder: EcoCoder Blocks/Non-volatile Memory Blocks


Description:

This module is used for writing fixed NVM variables.

Block Parameters:

Parameter Field Value Comments/Description

Specify the variable to be


Fixed NVM Variable Variable name
written.

NVM Definition

Folder: EcoCoder Blocks/Non-volatile Memory Blocks


Description:
Copyright ECOTRON LLC www.ecotron.ai Page 102
EcoCoder Manual

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:

Parameter Field Value Comments/Description

Load previous saved values in flash:

The corresponding NVM variable value

would be initialized from the NVM

Load NVM value in the memory area, instead of .mot file.


Drop-down list
following way Restore from factory default values

in .mot:

The corresponding NVM variable value

would be initialized from .mot file.

NVM Variable Definition

Folder: EcoCoder Blocks/Non-volatile Memory Blocks


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 103


EcoCoder Manual

This block is used to define regular NVM variables.

Block Parameters:

Parameter Field Value Comments/Description

Variable Name Alpha-numeric text Variable name

Initial value of the to-be


Initial Value Numeric
defined variable

Variable Type Drop-down list Select variable data type

Dimension Numeric Variable dimension

Unit Alpha-numeric text User-defined variable unit

User-defined variable
Description Alpha-numeric text
description

Read NVM

Folder: EcoCoder Blocks/Non-volatile Memory Blocks

Copyright ECOTRON LLC www.ecotron.ai Page 104


EcoCoder Manual

Description:

This module is used for reading regular NVM variables.

Block Parameters:

Parameter Field Value Comments/Description

Variable_name Alpha-numeric text Specify variable name

Variable_type Drop-down list Variable data type

Block Output:
The NVM variable value

Write NVM

Folder: EcoCoder Blocks/Non-volatile Memory Blocks


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 105


EcoCoder Manual

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:

Parameter Field Value Comments/Description

Variable Name Alpha-numeric text NVM variable name

If checked:

Define and write NVM variable


Enable Variable Definition Check box
If not checked:

Only write NVM

NVM variable initial value (for


Initial Value Numeric
NVM variable definition)

Variable Type Drop-down list NVM variable type

Dimension Numeric Dimension of NVM variable

Copyright ECOTRON LLC www.ecotron.ai Page 106


EcoCoder Manual

Unit Alpha-numeric text User-defined variable unit

Description Alpha-numeric text Memo

Store All NVM Data

Folder: EcoCoder Blocks/Non-volatile Memory Blocks


Description:

When this module is triggered, all NVM variable data will be written from RAM to flash,

so that the NVM data will be stored in the VCU.

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:

Parameter Field Value Comments/Description

Select Trigger Type Drop-down list Select trigger type

Copyright ECOTRON LLC www.ecotron.ai Page 107


EcoCoder Manual

Restore All NVM Data

Folder: EcoCoder Blocks/Non-volatile Memory Blocks


Description:

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:

Parameter Field Value Comments/Description

Select Trigger Type Drop-down list Select trigger type

Get Fixed NVM Variable Address

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.

Copyright ECOTRON LLC www.ecotron.ai Page 108


EcoCoder Manual

Parameter:
1) Variable Name: the name of the variable.

2) Address Offset: the offset of the address

Output:
1) addr: the address of the variable

4.9 Diagnostic Blocks

Diagnostic blocks are designed to realize VCU diagnostic functions.

Hardware Output DTC

Folder: EcoCoder Blocks/Diagnostic Blocks


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 109


EcoCoder Manual

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:

Parameter Field Value Comments/Description

DTC_Channel Drop-down list Select hardware channel

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 Position Error Type

Bit 0 Short to power supply

Bit 1 Short to ground

Bit 2 Open Circuit

Bit 3 Overheating

Copyright ECOTRON LLC www.ecotron.ai Page 110


EcoCoder Manual

Bit 4 Power supply error

Bit 5 Short circuit at the load

Bit 6 Overload

Bit 7 Others

DTC Parser

Folder: EcoCoder Blocks/Diagnostic Blocks


Description:

This block can help parse out specific fault of DTC.

Block Parameters:

Parameter Field Value Comments/Description

Index of bit Drop-down list Select the fault to be analyzed

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.

Copyright ECOTRON LLC www.ecotron.ai Page 111


EcoCoder Manual

Software Core Diagnostic

Folder: EcoCoder Blocks/Diagnostic Blocks


Description:

This block provides memory/chip fault check.

Block Parameters:

Parameter Field Value Comments/Description

Select the memory or chip


DTC_Channel Drop-down list
to be diagnosed.

Output:
1) DTC: Output 1 represents error detected, output 0 represents error not detected

Clear H-bridge DTC

Folder: EcoCoder Blocks/Diagnostic Blocks


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 112


EcoCoder Manual

This block can clear the H-bridge channel faults, the trigger type to trigger this block is
rising edge.

Block Parameters:

Parameter Field Value Comments/Description

H-bridge Channel Drop-down list Select the channel of H-bridge

Clear TLF35584 All DTC

This block is used for clearing all DTC code on TLF35584.

Input:
1) Triger signal: set to 1 to clear all DTC

Get TLF35584 Summary DTC

This block is used for reading the DTC summary from TLF35584.

Copyright ECOTRON LLC www.ecotron.ai Page 113


EcoCoder Manual

Output:
1) DTC: DTC summary from TLF35584.

Note:
1) For more information about specific error codes, please refer to TLF35584 manual.

Get TLF35584Specific DTC Total Number

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.

Get TLF35584 Specific DTC

Parameter:

Copyright ECOTRON LLC www.ecotron.ai Page 114


EcoCoder Manual

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.

2) The output from this block is uint32 type.

3) For more information about specific error codes, please refer to TLF35584 manual.

4.10 Calibration & Measurement

Calibration Definition

Folder: EcoCoder Blocks/Calibration & Measurement


Description:

This block can help define and initialize calibration variable.

Block Parameters:

Copyright ECOTRON LLC www.ecotron.ai Page 115


EcoCoder Manual

Parameter Field Value Comments/Description

variable_name Alpha-numeric text Calibration variable name

variable_value Numeric Calibration variable initial value

variable_type Drop-down list Calibration variable data type

variable_min Numeric Calibration variable lower limit

variable_max Numeric Calibration variable upper limit

Unit Alpha-numeric text User-defined calibration variable unit

Description Alpha-numeric text Memo

Read Calibration

Folder: EcoCoder Blocks/Calibration & Measurement


Description:

This block defines and reads calibration variables.


Block Parameters:

Parameter Field Value Comments/Description

variable_name Alpha-numeric text Calibration variable name

Copyright ECOTRON LLC www.ecotron.ai Page 116


EcoCoder Manual

variable_value Numeric Calibration variable initial value

variable_type Drop-down list Calibration variable data type

variable_min Numeric Calibration variable lower limit

variable_max Numeric Calibration variable upper limit

Unit Alpha-numeric text User-defined calibration variable unit

Description Alpha-numeric text Memo

Block Output:
Calibration variable value.

Write Measurement

Folder: EcoCoder Blocks/Calibration & Measurement


Description

This block can help define measurement variables.

Block Parameters:

Copyright ECOTRON LLC www.ecotron.ai Page 117


EcoCoder Manual

Parameter Field Value Comments/Description

variable_name Alpha-numeric text Measurement variable name

variable_type Drop-down list Variable data type

Dimensions Numeric The dimension of measurement

variable

Unit Alpha-numeric text User-defined measurement variable

unit

Description Alpha-numeric text Memo

Block Input:
To-be-measured variable.

Write and Read Measurement

Folder: EcoCoder Blocks/Calibration & Measurement


Description:

This block is an inline block, it helps read measurement variables.


Copyright ECOTRON LLC www.ecotron.ai Page 118
EcoCoder Manual

Parameter Field Value Comments/Description

variable_name Alpha-numeric text Measurement variable name

variable_type Drop-down list Variable data type

Dimensions Numeric The dimension of measurement

variable

Unit Alpha-numeric text User-defined measurement variable

unit

Description Alpha-numeric text Memo

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

This block is used for overriding signal values for calibration.

Copyright ECOTRON LLC www.ecotron.ai Page 119


EcoCoder Manual

In calibration software, ‘Variable_nameOvrCal_val’ is calibration variable,


‘Variable_nameOvrMsr’ is the measurement variable, ‘Variable_nameOvrEn_val’ is the
control signal – when control signal is ‘1’, the calibration variable will override the original
signal that passes through the block, and the block output will be the calibration variable
value. When the control signal is ‘0’, this block will not override the passing-through signal,
the measurement variable will have the same value as block input and block output would
be the same as the block input.

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)

Copyright ECOTRON LLC www.ecotron.ai Page 120


EcoCoder Manual

1-D Lookup Table

Folder: EcoCoder Blocks/Calibration & Measurement


Description:

This block defines 1-D look-up table. 1-D look-up table supports online calibration.

Block Parameters

Parameter Field Value Comments/Description

Name Alpha-numeric text Variable name

Breakpoint type Drop-down list Variable type

Breakpoint data Numeric (Matrix) Breakpoint data

Table type Drop-down list Table variable type

Table data Numeric (Matrix) Table data

Copyright ECOTRON LLC www.ecotron.ai Page 121


EcoCoder Manual

2-D Lookup Table

Folder: EcoCoder Blocks/Calibration & Measurement


Description:

This block defines 2-D look-up table, 2-D look-up table supports online calibration.

Block Parameters:

Parameter Field Value Comments/Description

Name Alpha-numeric text 2-D look-up table name

Breakpoints 1 type Drop-down list Breakpoints 1 variable data type

Breakpoints 1
Numeric (Matrix) Breakpoints 1 variable data
data(Row)

Breakpoints 2 type Drop-down list Breakpoints 2 variable data type

Breakpoints 2
Numeric (Matrix) Breakpoints 2 variable data
data(Column)

Table type Drop-down list Select table variable data type

Table data Numeric (Matrix) Initialize table data

Copyright ECOTRON LLC www.ecotron.ai Page 122


EcoCoder Manual

Calibration Data Check

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.

Copyright ECOTRON LLC www.ecotron.ai Page 123


EcoCoder Manual

4.11 System Management Blocks

Power Management Example

Folder: EcoCoder Blocks/System Management Blocks


Description:

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.

Copyright ECOTRON LLC www.ecotron.ai Page 124


EcoCoder Manual

Block Parameters

Parameter Field Value Comments/Description

If checked, the key switch signal


Key Signal from Input Check box
can be read from VCU input.

Power Off Delay(S) Numeric Power off delay time

If set to 0, VCU will not be reset if

key switch turns back on before

VCU power-off delay period ends.


Key Cycle Reset Enable Numeric (Boolean)
If set to 1, VCU will be reset if key

switch turns back on before VCU

power-off delay ends.

The duration (time threshold) after

the key-off moment (KeyOn signal


Key Cycle Off Duration(S) Numeric
absent) to the time when VCU

starts power-off process.

VCU starts power-up process if

Key Cycle On Duration(S) Numeric KeyOn signal is detected for more

than this time threshold.

The factor to be multiplied that

Key AD2Volt Factor Numeric convert AD to voltage, see section

4.2.1 for details.

If the input KeyOn voltage is less

Key Off Threshold Volt(V) Numeric than this value, KeyOn signal is

interpreted as ‘0’.

Key On Hysteresis Volt(V) Numeric If the KeyOn input voltage is larger

Copyright ECOTRON LLC www.ecotron.ai Page 125


EcoCoder Manual

than the sum of ‘Key Off Threshold

Volt’ and this hysteresis value,

KeyOn signal is ‘1’.

If this setting is ‘1’, VCU would keep

Power Off Fail Enable trying to power off at certain


Numeric (Boolean)
Reset frequency when power-down

process fails.

Enable NVM Store and If Checked: Enable NVM control


Check box
Restore option.

Set The Waiting Time(ms) Numeric Power-off delay time

Shutdown Power

Folder: EcoCoder Blocks/System Management Blocks


Description:

This block can be called to start VCU power-off process.

Copyright ECOTRON LLC www.ecotron.ai Page 126


EcoCoder Manual

Block Parameters

Parameter Field Value Comments/Description

Block trigger signal type


Select Trigger Type Drop-down list
selection.

Set the time of power-off


Set The Waiting Time(ms) Numeric
delay waiting time.

Shutdown Power Hold

This block is used to power off the controller.

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.

Set ECU Mode

Folder: EcoCoder Blocks/System Management Blocks


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 127


EcoCoder Manual

This module can set the working mode of ECU.

Block Parameters

Parameter Field Value Comments/Description

Block trigger signal type


Trigger Type Drop-down list
selection.

Select ECU Mode Drop-down list Work mode selection

ECU Master Chip Wake-Up Definition

Folder: EcoCoder Blocks/System Management Blocks


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 128


EcoCoder Manual

The block specifies the CAN channel that wakes up the VCU.

Block Parameters

Parameter Field Value Comments/Description

Wake-up CAN channel


Trigger Type Drop-down list
selection

If checked: the specified

Wakeup Enable Check box CAN channel can wake up

VCU.

Watchdog Definition

Folder: EcoCoder Blocks/System Management Blocks


Description:

Settings for software watchdog and hardware watchdog.

Block Parameters

Copyright ECOTRON LLC www.ecotron.ai Page 129


EcoCoder Manual

Parameter Field Value Comments/Description

If checked: Software watchdog is


Software Watchdog Enable Check box
enabled.

The ‘feeding dog’ operation is


Software Watchdog Wait
Numeric executed at Task_L1ms, software will
Time(ms)
reset when timeout.

If checked: Hardware watchdog

Hardware Watchdog enabled.


Check box
Enable (If this icon is greyed out, the specified VCU has

no hardware watchdog built in)

Service Software Watchdog

Folder: EcoCoder Blocks/System Management Blocks


Description:
Software watchdog is used for resetting VCU software if the watchdog internal counter
times out.
To enable this block, simply drag this block into your application software and schedule it
as a low priority task using task scheduler. Every time this block being triggered by task
scheduler will be taken as ‘feed dog’. As a result, the scheduling period should be less than
software watchdog timeout threshold.

Copyright ECOTRON LLC www.ecotron.ai Page 130


EcoCoder Manual

Software Reset

Folder: EcoCoder Blocks/System Management Blocks


Description:

This block is used for triggering VCU software reset. If this block is called, the VCU software

will be reset immediately.

Block Parameters

Parameter Field Value Comments/Description

Block trigger signal type


Select Trigger Type Drop-down list
selection.

Software Reset Hold

This block is used for software reset.

Input:
1) Trigger Signal: send reset signal if the trigger signal is 1

Copyright ECOTRON LLC www.ecotron.ai Page 131


EcoCoder Manual

Read System Free Counter

Folder: EcoCoder Blocks/System Management Blocks


Description:

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.

Power Control Output

Folder: EcoCoder Blocks/System Management Blocks


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 132


EcoCoder Manual

Block Parameters

Parameter Field Value Comments/Description

Power Control Channel Drop-down list Power channel selection.

1: turning on power for

corresponding channel.
input Boolean
0: turning off power for

corresponding channel.

Stack Overflow Detection Definition

This block initializes the stack overflow detection.

Parameter:
1) Stack Overflow Detection Enable: Check to enable the stack overflow detection.

Detect Stack Overflow

This block is used for detecting stack overflow.

1) flg: Output 1 indicates stack overflow detected. Output 0 indicates stack overflow is not

Copyright ECOTRON LLC www.ecotron.ai Page 133


EcoCoder Manual

detected.

Read BootID

This block is used for reading the hardware serial number.

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

This block set includes CCP related implementations.

Fixed CCP Slave Definition

Folder: EcoCoder Blocks/CCP


Copyright ECOTRON LLC www.ecotron.ai Page 134
EcoCoder Manual

Description:

This block is used for setting up CCP related slave station definitions

Block Parameters

Parameter Field Value Comments/Description

Simple:

Under this option, the only

configurable parameter in this block is

CAN channel. After building, users will

get A2L, CAL and Mot (or Hex) file. To


CCP Type Drop-down list
use EcoCAL, both A2L and CAL files

need to be loaded.

Configurable:

Under this option, after building, users

will get A2L and Mot (or Hex) file. To

Copyright ECOTRON LLC www.ecotron.ai Page 135


EcoCoder Manual

use EcoCAL, A2L and Mot (or Hex) files

are needed.

CCP Enable Check box CCP enable

CAN Channel Drop-down list Specify CAN channel for CCP

Station Address(Intel) Numeric CCP Station Address

Command Receive Specify Command Receive Object


Numeric
Object(CRO) ID (CRO) ID (Master->Slave)

Data Transmit Object(DTO) Data Transmit Object (DTO) ID (Slave


Numeric
ID -> Master)

Data Acquisition (DAQ) ID Numeric CCP DAQ ID

Data Acquisition (DAQ) PID Numeric The first PID in the DAQ list.

Data Acquisition (DAQ)


Numeric DAQ list length
Length

Data Acquisition (DAQ)


Numeric CCP DAQ period
Period(ms)

CCP/CAL Seed&Key Security Definition

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".

Copyright ECOTRON LLC www.ecotron.ai Page 136


EcoCoder Manual

CCP DAQ Seed&Key Security Definition

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".

CCP PGM Seed&Key Security Definition

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".

Copyright ECOTRON LLC www.ecotron.ai Page 137


EcoCoder Manual

CCP Generate Seed Demo

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.

CCP Get Seed Trigger

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.

Copyright ECOTRON LLC www.ecotron.ai Page 138


EcoCoder Manual

CCP Set Seed

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.

4.13 Sensors Blocks

Read Gyro Hex Value

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.

Copyright ECOTRON LLC www.ecotron.ai Page 139


EcoCoder Manual

Read Gyro Phy Value

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.

4.14 Programming Blocks

Online Programming Definition

Folder: EcoCoder Blocks/CCP


Description:

Copyright ECOTRON LLC www.ecotron.ai Page 140


EcoCoder Manual

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:

Parameter Field Value Comments/Description

Online programming CAN channel


Select CAN Channel Drop-down list
selection.

If checked: programming will


Enable KeyCycle Program Check box require key cycle to start
programming.

If checked: VCU programming will


Enable Online Program Check box
not require a key cycle.

This value cannot be changed for


Station Address (Intel) Greyed out
now.

Copyright ECOTRON LLC www.ecotron.ai Page 141


EcoCoder Manual

Specify Command Receive Object


Command Receive Object (CRO) ID (Master->Slave)
Alpha-numeric text
(CRO) ID (11-bit) It is recommended to remain as
default.

Data Transmit Object (DTO) ID


Data Transmit Object (Slave -> Master)
Alpha-numeric text
(DTO) ID (11-bit) It is recommended to remain as
default.

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.

Copyright ECOTRON LLC www.ecotron.ai Page 142


EcoCoder Manual

Programming Seed&Key Definition

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.

Copyright ECOTRON LLC www.ecotron.ai Page 143


EcoCoder Manual

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.

Copyright ECOTRON LLC www.ecotron.ai Page 144


EcoCoder Manual

Entry UDS Programming

Enter the UDS programming mode by this block, which enables controller to update
the program through the UDS protocol.

Parameter Field Value Comments/Description

Select trigger type Drop-down list Trigger type selection.

4.15 Advanced Data Blocks

OTP One-Time Programmable memory

Read OTP

Copyright ECOTRON LLC www.ecotron.ai Page 145


EcoCoder Manual

Block Parameters:

Parameter Field Value Comments/Description

Start Position Offset (Byte) Numeric Start address offset value

Data length (the number of


Data Length (Byte) Numeric
bytes the data takes)

Block Outputs:
data: The data read from OTP area.
st: Data reading status, 0 stands for data reading successfully.

Read OTP (Input port)

Copyright ECOTRON LLC www.ecotron.ai Page 146


EcoCoder Manual

Block Parameters:

Parameter Field Value Comments/Description

The number of bytes that


Data Length (Byte) Numeric
the data takes in OTP area.

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

Copyright ECOTRON LLC www.ecotron.ai Page 147


EcoCoder Manual

Block Parameters:

Parameter Field Value Comments/Description

Start address offset, the


Start Position Offset (8Bytes) Numeric
unit is 8 bytes.

Select Trigger Type Drop-down list Trigger type selection.

The length of the data to be


Data Length (Byte) Numeric
written.

The data to be written in


Data (Block input)
OTP area.

Data write status, 0 stands


for writing successful; Non-
st (Block output) boolean
0 value stands for writing
unsuccessful.

Copyright ECOTRON LLC www.ecotron.ai Page 148


EcoCoder Manual

Write OTP (Input port)

Block Parameters:

Parameter Field Value Comments/Description

Block Input: OTP writing start address


Numeric
Start Position Offset (8Bytes) offset, the unit is 8 bytes.

Select Trigger Type Drop-down list Block trigger type selection.

Data Length (Byte) Numeric The data length in byte.

Block Input: Data input

Copyright ECOTRON LLC www.ecotron.ai Page 149


EcoCoder Manual

data

Data write status, 0 stands


Block Output: for writing successful; Non-
boolean
st 0 value stands for writing
unsuccessful.

Read Data by Address

This block enables users to have access to memory by address.

Block Parameters

Parameter Field Value Comments/Description

Start address Numeric Start address

Copyright ECOTRON LLC www.ecotron.ai Page 150


EcoCoder Manual

Data Length (Byte) Numeric Data length

Block Output:
Data output
Data

Read Data by Address (Input port)

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

Parameter Field Value Comments/Description

Start address(input) Numeric Start address

Data Length(Byte) Numeric Data read length

Block Output:
Data output
data

Copyright ECOTRON LLC www.ecotron.ai Page 151


EcoCoder Manual

Read String Value

This block can translate strings to corresponding ASCII numeric arrays.

Block Parameters

Parameter Field Value Comments/Description

String Input String The string to be parsed

Block Output: The numeric arrays of the


Numeric
Data string ASCII.

Read EEPROM

This block reads data from EEPROM.

Parameter:
1) Data length: the length of the data to be read

Copyright ECOTRON LLC www.ecotron.ai Page 152


EcoCoder Manual

Input:
1) addr: the address of the data to be read

Output:
1) data: data read from EEPROM

2) st: Output status. Output 0 when data read successfully

Write EEPROM

This block is used for writing data to the EEPROM.

Parameter:
1) Select Trigger Type: trigger type selection

2) Data length: the length of the data to be written

Input:
1) addr: the address to be written on

2) Data: the data to be written

Output:
1) St: output status. Output 0 when data read successfully

Copyright ECOTRON LLC www.ecotron.ai Page 153


EcoCoder Manual

EEPROM Emulation Definition

Parameter Field Value Comments/Description

Enable logging of information, non-self-


Enable Record Cache Check box
recording.

Record Cache Size (Record) Numeric The number of the cached record message.

Clear ALL EEPROM Emulation Record

Parameter Field Value Comments/Description

Select Trigger Type Drop-down list Trigger type selection

Block Output:
Numeric Output state, refer to Appendix Table 1.
st

Copyright ECOTRON LLC www.ecotron.ai Page 154


EcoCoder Manual

Clear One EEPROM Emulation Record

Parameter Field Value Comments/Description

Select Trigger Type Drop-down list Start address

Block Input:
Record id
id

Block Output: Output state, refer to


Numeric
st Appendix Table 1

Read EEPROM Emulation Record

Parameter Field Value Comments/Description

Data Length (Byte) Numeric Data length in byte

Block Input:
1. id 1. The id of records to be read
2. type

Copyright ECOTRON LLC www.ecotron.ai Page 155


EcoCoder Manual

2. The type of records to be


read, which inherits the data
type of the previous block

Block Output: 1. Read Data

1. data 2. Output state, refer to

2. st Appendix Table 1

Write EEPROM Emulation Record

Parameter Field Value Comments/Description

Select Trigger Type Drop-down Trigger type selection

Data Length Numeric Data length

Block Input: 1. Id of records to be written

1. id 2. Type of records to be

2. type written

3. data 3. Data written

Block Output: Output state, refer to Appendix


Numeric
st Table 1

Copyright ECOTRON LLC www.ecotron.ai Page 156


EcoCoder Manual

Read Signals from EEPROM Emulation Record

Parameter Field Value Comments/Description

Add M file to MATLAB path, specify the


M file name, then click “OK” and
Select M file Check box “APPLY”, finally double-click the module
again to select the Message.

Select Type Drop-down list Record type selection

if enabled: the name of the signal will be


Show Signal Names Check box
displayed on the output signal line.

User-defined variable prefix on the


Signal Prefix
signal line.

Block Input:
The record ID to be read and parsed
Record ID

Output state, refer Appendix Table 1


Block Output: Note: The value of the signal after
st parsing record is the actual physical
value

Copyright ECOTRON LLC www.ecotron.ai Page 157


EcoCoder Manual

Write Signals to EEPROM Emulation Record

Parameter Field Value Comments/Description

Add M file to MATLAB path, (users can


change the default M file name) then
Select M file Check box click “OK” and “APPLY”, finally double-
click the module again to select the
Message.

Select Type Drop-down list Record type selection


1. Write record enable control, it is
Block Input:
recommended to control by edge
1. Enable triggering signal.
2. Record ID 2. The record ID to be written

Block Output:
Output state, refer Appendix Table 1
st

EEPROM Emulation Area Need to Erase

This block is used for determining whether if the EEPROM emulation area need to be
erased.

Copyright ECOTRON LLC www.ecotron.ai Page 158


EcoCoder Manual

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.

Erase EEPROM Emulation Area

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

Copyright ECOTRON LLC www.ecotron.ai Page 159


EcoCoder Manual

Program First Run Flag

Parameter Field Value Comments/Description

Outputs the flag value, 1 stands for the


first run of the program. The flag
Block Output:
Boolean becomes 0 when the Store ALL NVM
Flg
Data module is used and triggered
successfully.

Write RAM Data by Address

This block writes data to RAW based on the given address.

Parameter:
1) Data Length (Byte): Data length in byte

Copyright ECOTRON LLC www.ecotron.ai Page 160


EcoCoder Manual

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

5) addr: start address

Output:
1) data

Get General Variable Address

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

2) Address offset: the offset of the address

Output:
1) addr: the address of variable

Copyright ECOTRON LLC www.ecotron.ai Page 161


EcoCoder Manual

4.16 Application Base Blocks

Rising Edge

This block is used for detecting rising edges.

Parameter:
1) Initial Condition is true: initialization option, check the box to initialize the value as 1.

Falling Edge

This block is used for detecting falling edges.

Parameter:
1) Initial Condition is true: initialization option, check the box to initialize the value as 1.

Online Programming by SoftReset

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

3) CCP Boot CRO ID: Set CRO ID 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

7) UDS Boot Online Programming: Check to enable UDS online programming

8) UDS Boot CAN Channel: select UDS CAN channel for online programing

9) UDS Boot CRO ID: Set UDS ID for online programming

10) UDS Boot CRO ID Extended: Set extended CRO frame for UDS online programming

Copyright ECOTRON LLC www.ecotron.ai Page 163


EcoCoder Manual

11) UDS Boot CRO Data Length: Set UDS CRO data length for online programming

Online Programing By HardReset

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

3) CCP Boot CRO ID: Set CRO ID 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

7) UDS Boot Online Programming: Check to enable UDS online programming

8) UDS Boot CAN Channel: select UDS CAN channel for online programing

9) UDS Boot CRO ID: Set UDS ID for online programming

Copyright ECOTRON LLC www.ecotron.ai Page 164


EcoCoder Manual

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

dt – time step length

This block is used for acquiring time step length for current task. (unit: second)

Rising Edge Debounce

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)

2) din: original input

Output:
1) dout: signal after debounce.

Copyright ECOTRON LLC www.ecotron.ai Page 165


EcoCoder Manual

Falling Edge 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)

2) din: original input

Output:
1) dout: signal after debouncing.

PT1 Filter

This block is used for filtering signals.

Input:
1) IN: original input signal

Copyright ECOTRON LLC www.ecotron.ai Page 166


EcoCoder Manual

12) TC: Low-pass filter factor (unit: second)

13) I: Enabling initialization. Set output value as IV

14) IV: Initialization value

Output:
1) Filtered signal

Hysteresis

This block converts analog signal to digital signal.

Input:
1) R: Upper threshold

15) X: Input signal

16) L: Lower 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

Copyright ECOTRON LLC www.ecotron.ai Page 167


EcoCoder Manual

When R=0 and S=0 → Q=Previous value

4.17 Volatile Variable

Read Const Volatile Variable

This block is used for reading constant volatile variable.

Parameter:
1) Variable Name: the name of the variable

2) Variable DataType: the type of the data

3) Variable Size: the length of the variable

4) First Element Value: the value of the first element

Copyright ECOTRON LLC www.ecotron.ai Page 168


EcoCoder Manual

5) Difference Between Elements: the difference between each element

Output:
1) Read value from the specific variable

4.18 XCP Module

XCP Slave Definition

This block is used for initializing XCP module.

Parameter:
1) XCP Enable: Check to enable the XCP, uncheck to disable the XCP

2) CAN Channel: CAN channel selection

3) Master ID: address of the master node

4) Slave ID: address of the slave node

4.19 FlexRay Module

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.

Copyright ECOTRON LLC www.ecotron.ai Page 169


EcoCoder Manual

Parameter:
1) Select the m file: select the m file contains network parameters, node parameters, and

Copyright ECOTRON LLC www.ecotron.ai Page 170


EcoCoder Manual

message definition. Please refer to the examples for how to construct a m file.

FlexRay Get Current State

This block is used for getting the status of the FlexRay network.

Output:
1) St: status of the network

FlexRay Setup Network Control

This block is mandatory when building a network. It is recommended to used high priority
1ms task schedule for this block.

Copyright ECOTRON LLC www.ecotron.ai Page 171


EcoCoder Manual

FlexRay Force to Halt

This block is used for force halt the FlexRay communication.

FlexRay Restore to Default Configuration

Call this block to restore the default configuration. It is useful when encounter network
errors.

Copyright ECOTRON LLC www.ecotron.ai Page 172


EcoCoder Manual

Read FlexRay Message

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

5) data: data from the message

Write FlexRay Message

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

Copyright ECOTRON LLC www.ecotron.ai Page 173


EcoCoder Manual

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

This block is used for configuring the Ethernet.

Parameter:
1) IP address

2) Subnet mask

3) Default gateway

4) MAC address

Copyright ECOTRON LLC www.ecotron.ai Page 174


EcoCoder Manual

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.

4.21 TCP Protocol Blocks

TCP Server Definition

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.

Copyright ECOTRON LLC www.ecotron.ai Page 175


EcoCoder Manual

Parameter:
1) Protocol control block name: Name of the block

2) Server port

TCP Server Init

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

Copyright ECOTRON LLC www.ecotron.ai Page 176


EcoCoder Manual

TCP Client Definition

This block is used to define a TCP client.

Parameter:
1) Protocol control block name: name of the protocol control block

2) Client local port

3) Remote server IP address

4) Remote server port

TCP Client Connect

Use this block to connect to a server after Ethernet Init block is used.

Copyright ECOTRON LLC www.ecotron.ai Page 177


EcoCoder Manual

Parameter:
1) Protocol control block name: name of the control block

Input:
1) Flg: set flg to 1 to start the connection.

TCP Close

This block closes the current connection.

Parameter:
1) Protocol control block name: name of the control block

Input:
1) Flg: set flg to 1 to close the connection.

TCP Abort

This block aborts the current connection.

Copyright ECOTRON LLC www.ecotron.ai Page 178


EcoCoder Manual

Parameter:
1) Protocol control block name: name of the control block

Input:
2) Flg: set flg to 1 to abort the connection.

TCP State

Use this block to request the state of the current connection.

Parameter:
1) Protocol control block name: name of the control block

Output:
1) State: current state of the connection.

Copyright ECOTRON LLC www.ecotron.ai Page 179


EcoCoder Manual

TCP Receive

This block is used for receiving TCP data.

Parameter:
1) Protocol control block name: name of the control block

2) Receive data width: the width of the Data port

Output:
1) f(): the function to run when data is received

2) IP: IP address of the sender

3) Length: actual received data length

4) Data: received data

TCP Transmit

This block is used for transmitting TCP data.

Copyright ECOTRON LLC www.ecotron.ai Page 180


EcoCoder Manual

Parameter:
1) Protocol control block name: name of the control block

2) Transmit data width: the width of the Data

Input:
1) Enable: set it to 1 to enable the transmit, set it to 0 disable the transmit

2) Length: the length of the data to be transmit

3) Data: the Data to be transmitted

4.22 UDP Blocks

UDP Definition

This block is used for defining UDP ports.

Copyright ECOTRON LLC www.ecotron.ai Page 181


EcoCoder Manual

Parameter:
1) Protocol control block name: the name of the protocol control block

5) Local Port: local port configuration

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

This block is used for receiving UDP data.

Parameter:

Copyright ECOTRON LLC www.ecotron.ai Page 182


EcoCoder Manual

1) Protocol control block name: the name of the protocol control block

6) Receive data width: the data width of the output port

Output:
1) f(): the trigger function to be run when any data received

7) Port: sender’s data port

8) IP: IP address of the sender

9) Length: the actual length of the received data

10) Data: received data

UDP Transmit

This block is used for transmitting UDP data.

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

12) Port: the data port of the receiver

13) IP: the target IP

14) Length: the length of the data to be transmitted

15) Data: the data to be transmitted

Copyright ECOTRON LLC www.ecotron.ai Page 183


EcoCoder Manual

4.23 SPI Blocks

SPI Definition

Use this block to configure the SPI driver.

Parameter:
1) Type: Master/Slave mode selection

2) Channel: channel selection

3) Baud Rate (bps): baud rate setting

4) Clock Polarity: clock polarity selection

5) Shift Clock: Clock shift setting

6) Data Heading: Endianness

7) Data Width: the width of the data

8) Parity Mode: odd/even parity mode

Copyright ECOTRON LLC www.ecotron.ai Page 184


EcoCoder Manual

SPI Master Exchange Data

Use this block to exchange data when the “SPI Definition” block is configured as master
node.

Parameter:
1) Channel: channel selection

2) Baud Rate (bps): baud rate setting

3) Clock Polarity: clock polarity selection

4) Shift Clock: Clock shift setting

5) Data Heading: Endianness

6) Data Width: the width of the data

7) Parity Mode: odd/even parity mode

8) CS Channel: CS Channel selection

9) Data Length(bytes): the length of the input port (TxData) and the output port (RxData).

Copyright ECOTRON LLC www.ecotron.ai Page 185


EcoCoder Manual

10) Wait Time: the time to wait

Input:
1) Enable: set to 1 to enable the transmission, set to 0 to disable the transmission

16) TxData: the data to be transmitted

Output:
1) RxData: the data to be received

SPI Slave Exchange Data

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).

3) Wait Time: the time to wait

Input:
1) Enable: set to 1 to enable the transmission, set to 0 to disable the transmission

2) TxData: the data to be transmitted

Output:
1) RxData: the data to be received

Copyright ECOTRON LLC www.ecotron.ai Page 186


EcoCoder Manual

4.24 Model Reference

Model reference in Matlab Simulink:

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.

Copyright ECOTRON LLC www.ecotron.ai Page 187


EcoCoder Manual

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.

Configurations for Parent Models and Referenced Models

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

Copyright ECOTRON LLC www.ecotron.ai Page 188


EcoCoder Manual

2. Copy the configuration of the parent model to the referenced model(s)

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).

Copyright ECOTRON LLC www.ecotron.ai Page 189


EcoCoder Manual

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.

Copyright ECOTRON LLC www.ecotron.ai Page 190


EcoCoder Manual

For more information about Configuration Reference, please refer to:


https://www.mathworks.com/help/simulink/ug/more-about-configuration-
references.html?#responsive_offcanvas

Copy Parent Model Configuration File to Referenced 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.

EcoCoder Blocks in Model Reference

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.

Application Base Blocks

Copyright ECOTRON LLC www.ecotron.ai Page 191


EcoCoder Manual

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.

Copyright ECOTRON LLC www.ecotron.ai Page 192


EcoCoder Manual

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).

Copyright ECOTRON LLC www.ecotron.ai Page 193


EcoCoder Manual

Chapter 5 CAN Theory of Ecotron

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.

5.2 CAN Implementation

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.

Copyright ECOTRON LLC www.ecotron.ai Page 194


EcoCoder Manual

Convert DBC to m File

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.

Copyright ECOTRON LLC www.ecotron.ai Page 195


EcoCoder Manual

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.

Copyright ECOTRON LLC www.ecotron.ai Page 196


EcoCoder Manual

EcoCoder CAN Blocks

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.

Copyright ECOTRON LLC www.ecotron.ai Page 197


EcoCoder Manual

Select Message

This step will let users pick the specific CAN messages that need to be parsed.

Copyright ECOTRON LLC www.ecotron.ai Page 198


EcoCoder Manual

Select Sample Time

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).

Copyright ECOTRON LLC www.ecotron.ai Page 199


EcoCoder Manual

Interval (-t,-1) (0,0.005) [0.005,0.01) [0.01,0.02) [0.02,0.05)


Sample
Task_Inherit Task_H1ms Task_H5ms Task_H10ms Task_L20ms
Time
Interval [0.05,0.1) [0.1,0.2) [0.2,0.5) [0.5,1) [1,10)
Sample
Task_L50ms Task_L100ms Task_L200ms Task_L500ms Task_L1000ms
Time

Copyright ECOTRON LLC www.ecotron.ai Page 200


EcoCoder Manual

Chapter 6 Memory Management

6.1 Introduction

When application software gets more complicated and larger, memory management will
become an important aspect of VCU software development.

6.2 Storage device

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.

6.3 Data Storage

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.

Copyright ECOTRON LLC www.ecotron.ai Page 201


EcoCoder Manual

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.

Copyright ECOTRON LLC www.ecotron.ai Page 202


EcoCoder Manual

Chapter 7 Custom Variable Type

There are two ways to define monitoring/calibration/NVM variables. One is to custom


variable type, and the other is to use the definition block in the EcoCoder library.
The method in this chapter eliminates the need for software engineers to load multiple
monitor/calibration/NVM variable blocks during simulation by simply defining the
variables in "Base Workspace" and save them as m files.
EcoObj is a custom data storage definition package. It is an extension of the simulated
signal object and the simulation parameter object. Define custom data objects and classes
by using the ASAP2 standard. It generates the product code and the ASAP2 file (or a2l file).
You can use EcoObj or MATLAB's "Model Explorer" to define types and variables in M files,
the following sections describe the graphical definition method.

7.1 Customize Variable Types

1. Open “Model Explorer”

2. Base Workspace > Add > Simulink Numeric Type

Copyright ECOTRON LLC www.ecotron.ai Page 203


EcoCoder Manual

3. Name the variable and set the properties through the window on the right

7.2 Add Variables to Workspace

Add "EcoObj.Signal" or "EcoObj.Parameter" to "Base Workspace" via "Model Explorer" as


shown below.
1. Open “Model Explorer”

2. Base Workspace > Add > Add Custom…

Copyright ECOTRON LLC www.ecotron.ai Page 204


EcoCoder Manual

3. Click “Add Custom”, choose “EcoObj.Signal” or “EcoObj.Parameter”.

Copyright ECOTRON LLC www.ecotron.ai Page 205


EcoCoder Manual

7.3 Customize Calibration Variables

1. Choose “EcoObj.Parameter”, name the variable then click “OK”.

2. Set the properties through the window on the right. To define calibration variables,
“Calibration(Custom)” must be chosen in “Storage Class”.

Copyright ECOTRON LLC www.ecotron.ai Page 206


EcoCoder Manual

7.4 Customize measurement Variables

1. Choose “EcoObj.Signal”, name the variable then click “OK”.

2. Set the properties through the window on the right. To define measurement variables
“Measurement (Custom)” must be chosen in “Storage Class”.

Copyright ECOTRON LLC www.ecotron.ai Page 207


EcoCoder Manual

7.5 Customize NVM Variables

1. Choose “EcoObj.Signal”, name the variable then click “OK”.

2. Set the properties through the window on the right. To define NVM variables,
“MeasurementNvm (Custom)” must be chosen in “Storage Class”.

Copyright ECOTRON LLC www.ecotron.ai Page 208


EcoCoder Manual

7.6 Save the Variables to M file

1. Base Workspace > Export…

2. Click “Export…”, as shown below, save the file to “Demo_data.m”.

Copyright ECOTRON LLC www.ecotron.ai Page 209


EcoCoder Manual

7.7 Load M file to Workspace

Drag “Demo_data.m” file to the “Command Window”.

Copyright ECOTRON LLC www.ecotron.ai Page 210


EcoCoder Manual

7.8 Model Example

Copyright ECOTRON LLC www.ecotron.ai Page 211


EcoCoder Manual

Chapter 8 Programming VCU with EcoFlash

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.

Copyright ECOTRON LLC www.ecotron.ai Page 212


EcoCoder Manual

Chapter 9 Measurement and Calibration with EcoCAL

EcoCAL is dedicated for data measurement, calibration, logging and analysis.


It is a professional calibration tool developed by Ecotron. EcoCAL is based on CCP/XCP
protocols and uses the CAN bus for communication between master-slave stations. It
provides great convenience for VCU in-vehicle testing and prototype development.

Copyright ECOTRON LLC www.ecotron.ai Page 213


EcoCoder Manual

Chapter 10 Uninstall EcoCoder

10.1 Uninstall EcoCoder from MATLAB

Note: You have to close all MATLAB applications before uninstalling.

1. Double-click ‘EcoCoder Loader’.

2. Choose MATLAB version, and select ‘Uninstall EcoCoder from selected MATLAB

version’, then click ‘OK’.

Copyright ECOTRON LLC www.ecotron.ai Page 214


EcoCoder Manual

10.2 Uninstall EcoCoder from Windows System

For EcoCoder update, the user will need to uninstall older version EcoCoder from

Window before installing new version EcoCoder.

Note: You have to close all open MATLAB applications before uninstalling.

1. Click ‘Start’ and then click ‘settings’, follow steps in picture below

Copyright ECOTRON LLC www.ecotron.ai Page 215


EcoCoder Manual

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.

And it can’t be the name of the existing model or m file.

11.2 Q2. Model created by ‘EcoCoder_Prj’, emulation or code

generation error

1. Check if your MATLAB has Fixed-Point Tool license. If not, the use of fixed-point

blocks will trigger errors.

2. Make sure all support files are added to path.

3. Check whether necessary MATLAB components are installed.

11.3 Q3. ‘CAN’ module is blank after being configured

Please check whether the CAN definition .m file is added to Path.

Copyright ECOTRON LLC www.ecotron.ai Page 216


EcoCoder Manual

11.4 Q4. EcoCoder Loader Pop-up error

You may have to register the ‘comdlg32.ocx’ to windows.

11.5 Q5. How to update application model to be compatible with

updated EcoCoder

a) EcoCoder Target Definition

The model must include the EcoCoder Target Definition

b) Model configuration module

‘ECU_Setting’ module is divided into independent configuration blocks. Please add CAN,

OPWM, CCP and other configuration blocks if needed.

Copyright ECOTRON LLC www.ecotron.ai Page 217


EcoCoder Manual

c) Resolve some disabled modules

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

stuck when using new EcoCoder.

1) Right-click on the disable block, and select Library link->Resolve Link

2) Restore all disable linked blocks.

Copyright ECOTRON LLC www.ecotron.ai Page 218


EcoCoder Manual

11.6 Q6. Is there a way to get rid of popping up folder of generated

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.

OpenTarget: It will open folder which has generated files.

PopupBox: ‘Software has been compiled successfully!’ will pop up when it finishes generating files.

Copyright ECOTRON LLC www.ecotron.ai Page 219


EcoCoder Manual

11.7 Q7. Is there a way to access project file in C code?

Yes, go same steps as Q6 then configure box of ‘Project Files Options’.


Project Files Options includes Reserved, Removed.
Reserved: ‘XX_CWprj’ will be reserved when it finishes generating file, so user can access C code
from ‘XX_CWprj ’ file.

Removed: ‘XX_CWprj’ will be removed when it finishes generating files.

Copyright ECOTRON LLC www.ecotron.ai Page 220


EcoCoder Manual

11.8 Q8. C code generation by Simulink is not accepted by compilers.

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.

Copyright ECOTRON LLC www.ecotron.ai Page 221


EcoCoder Manual

Copyright ECOTRON LLC www.ecotron.ai Page 222


EcoCoder Manual

Appendix A - Nonvolatile Variables


This is a description of assigning variable values to non-volatile memory and fixed non-
volatile memory locations, how to change such values and notice for operation.

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).

Fixed Non-volatile Variables

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.

Fixed NVM Demo

Copyright ECOTRON LLC www.ecotron.ai Page 223


EcoCoder Manual

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.

Copyright ECOTRON LLC www.ecotron.ai Page 224


EcoCoder Manual

Copyright ECOTRON LLC www.ecotron.ai Page 225


EcoCoder Manual

Appendix-B Battery Input


As mentioned previously, power supply has to be maintained at least for a short period
after key-off, in order for the VCU to execute the shutdown process.
The shutdown process implemented by block ‘Power Management Example’ includes
stopping the application and saving NVM variables that have been temporarily stored in
RAM to flash, during the power-off delay, after key-off. This is the recommended way to
save nonvolatile variables to flash. If the frequency of calling ‘Store All NVM Data’ block is
too high, errors might occur.

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

Copyright ECOTRON LLC www.ecotron.ai Page 226


EcoCoder Manual

17 Read length does not match

Table 2
Status Code Description
0 Bus Normal
1 Parameter Error
2 Bus Busy

Appendix C-MAB(MathWorks Advisory Board)


For your information, below is from MathWorks’ guideline for model construction.
MathWorks Advisory Board (MAB) guidelines stipulate important basic rules for modeling
in Simulink and Stateflow. The overall purpose of these modeling guidelines is to allow for
a simple, common understanding by modelers and consumers of control system models.
The main objectives of these guidelines are:
Readability
1. Improve graphical understandability
2. Improve readability of functional analysis
3. Prevent connection mistakes
4. Comments, etc.

Simulation and verification


1. Mechanism to enable simulation
2. Testability

Code Generation
1. Improve the efficiency of code generation (ROM, RAM efficiency)
2. Ensure the robustness of generated code

If more information is needed, please refer to the link here.

Copyright ECOTRON LLC www.ecotron.ai Page 227

You might also like