S32K388 with MC33771B SPI BMS: MBDT, code generation, and AI deployment

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K388 with MC33771B SPI BMS: MBDT, code generation, and AI deployment

615 Views
SonHyunTaek
Contributor I

Hello NXP Community,

I am developing an integrated BMS using S32K388-Q289 and FRDM-MC33771B-SPI-EVB via SPI communication, targeting a real lithium-ion battery pack. While researching, I noticed that there are relatively few BMS-specific example projects and reference implementations available for the S32K3 series, so it has been challenging to confirm the recommended workflow and supported toolchain for this type of application.

My goal is to implement the full embedded BMS stack on the MCU, including:

Cell voltage / temperature monitoring (via BCC)

Cell balancing control

SOC / SOH estimation algorithms (including deep learning-based approaches)

Real-time operation on the MCU

Model-Based Design workflow if possible (otherwise an S32DS C project)

I plan to use MATLAB/Simulink Model-Based Design Toolbox (MBDT) first, and if full support is not available for my setup, I will proceed with S32 Design Studio (S32DS).

I would appreciate guidance on the questions below:

1) MBDT support and training materials for S32K3 BMS applications
Is there any official documentation, user guide, training course, or application note for using MBDT with the S32K3 series specifically for BMS-related development (e.g., SPI-based BCC communication, sampling/processing, protection logic, and real-time monitoring)?

2) Integrating MBDT models with Deep Learning models and code generation
If I develop the BMS logic in Simulink (MBDT) and add a SOC/SOH model built using Deep Learning Toolbox:

- Can these be combined into a single integrated Simulink model?

- If yes, can the integrated model be automatically generated into C code (or other supported embedded code) using Embedded Coder for deployment on S32K388?

3) Real-time inference feasibility on S32K388
If code generation in (2) is feasible:

- Can the deployed model perform real-time inference (SOC/SOH estimation) using live battery data (voltage/current/temperature) on the MCU?

- Are there recommended constraints or best practices (e.g., fixed-point vs floating-point, supported layer types, model size limits, inference timing considerations) for S32K388?

4) Safety constraints / protection logic in MBDT
For safety, I need to implement protection logic such as:

- Over-voltage / under-voltage thresholds

- Over-temperature / under-temperature thresholds

- Fault handling and safe-state behavior

Is it possible to implement these limits and protection logic directly in MBDT/Simulink and include them in the generated embedded code?
If there are any reference examples (BMS or safety logic) for S32K targets, please share.

5) S32K388 compatibility with FRDM-MC33771B-SPI-EVB and alternatives
Is S32K388-Q289 officially supported/recommended to work with MC33771B via SPI for BMS applications?
If this combination is not recommended, could you suggest an officially supported BCC + reference platform (SPI or TPL) for S32K3-based BMS development?

6) On-device training (online learning) vs inference-only workflow
From an embedded AI perspective:

- Is on-device training (online learning using real-time battery data) supported or recommended on S32K3 MCUs?

- Or is the recommended approach offline training on PC + inference-only on the MCU?

If offline training is recommended, are there any official references describing a recommended workflow?

7) Performance / memory guidance for AI inference on S32K388
Are there any benchmarks or guidelines for running AI inference on S32K3 (especially S32K388) regarding:

- Flash/RAM usage expectations

- Typical inference latency ranges

- Optimization approaches (fixed-point, quantization, lightweight architectures)

Preferred alternative workflow if MBDT + DL integration is not recommended
If full integration and auto code generation are not recommended/supported, what is the preferred workflow to deploy an AI model on S32K3? For example:

- Converting the model to lightweight C inference code manually

- Using CMSIS-NN-like approaches (if applicable)

- Using any NXP middleware / recommended libraries / examples (e.g., eIQ)

Thank you for your support. Any documentation links, training references, SDK examples, or best-practice recommendations would be very helpful.

Best regards,

 

0 Kudos
Reply
1 Reply

339 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @SonHyunTaek,


Thank you for posting your detailed questions regarding your project on our community forum. Please note that the answers below are provided from the MBDT software perspective; from a hardware standpoint, there might be better approaches in terms of component combinations. It would also help to know the target voltage for your BMS and whether pack current sensing is required. Since you plan to use a single AFE connected via SPI, I assume you are targeting a maximum 48V BMS system.

Regarding the combination of devices you proposed: at the hardware level, the S32K3 is fully compatible with the MC33771B. However, from the software perspective, things are more complex. The MBDT for S32K3 is built to generate code on top of the NXP Real-Time Drivers (RTD) at the MCAL layer, while the MBDT for BMS generates code on top of the BMS SDK, which is also compatible with RTD. The BMS SDK includes an external configuration tool for pins, clocks, and peripherals, accessible from Simulink, along with ready-to-run examples.
Please note:

- MBDT for BMS 1.2.0 works only with MBDT for S32K3 1.4.0, which does not support the S32K388.
- The BMS SDK is compatible only with RTD 3.0.0, used by MBDT for S32K3 1.4.0. At that time, the S32K388 was not available.
- MBDT for BMS and MBDT for S32K3 support only newer AFE parts such as MC33774, MC33775, MC33664, MC33665, and MC33772C, typically used in hardware designs with Battery Junction Box functionality.

These limitations come from the software packages (RTD and BMS SDK). The MC33771B you intend to use includes a C SDK driver, which you must integrate manually into MBDT using custom code, as there are no ready-to-run compatible C drivers for connecting S32K3 and MC33771B. In other words, the Embedded SW: Battery Cell Controller Software Driver for MC33771B/MC33772B  requires manual C coding and integration into MBDT. An article describing how to do this (based on MBDT for S32K1) can be found here.


I will address your questions below and propose some solutions at the end.

1. MBDT Support and Training
The best resources we offer are available on the MBDT Community page.  On the right-hand side, you will find the Beginner's Guide for Model-Based Design Toolbox, which explains how to perform basic tasks with MBDT for S32K3. Additionally, there are BMS Webinars that provide insights into Battery Management Systems.
Here is a link to our latest webinar on BMS, created in collaboration with MathWorks:
Streamlining Battery Systems Development for NXP S32 Devices.

2. Integrating Deep Learning Models
In previous collaborations with MathWorks, we successfully deployed a Deep Learning-based State of Charge (SOC) estimation algorithm directly from Simulink and tested it in PIL mode. Yes, Embedded Coder can generate the neural network directly from the Simulink model, and together with MBDT, it can be deployed on the S32K3.
Here is a link to the related webinar:
Deploying a Deep Learning-Based SOC Estimation Algorithm to NXP S32K3 Microcontrollers

3. Real-Time Inference Feasibility on S32K388
Yes, real-time inference is feasible. In previous work, we used cell voltage, current, and temperature as inputs. These values can be measured by the AFE at runtime and provided to the neural network. As a best practice, intensive testing in PIL mode can help evaluate performance. You can also experiment with optimization techniques to identify the best configuration.

4. Safety Constraints
The logic for your safety requirements can be implemented in Simulink, and the corresponding code can be automatically generated. MathWorks provides an example we have used and deployed on S32K3:
Design and Test Lithium-Ion Battery Management Algorithms 

5. S32K388 Compatibility with FRDM-MC33771B-SPI-EVB and Alternatives
To test your neural network application directly from Simulink, use MBDT for S32K3 the latest version. This allows you to verify deployment feasibility and perform benchmarking tests on all the available MCU at this time.
From a hardware perspective, you have several options:

a. Continue with the proposed solution (S32K358 + MC33771C)
Start with MC33771C instead of MC33771B, as it is newer, supports SPI, and includes current measurement. You can integrate the MC33771C driver directly in Simulink using custom code and use MBDT for BMS 1.8.0.

b. Use MBDT for BMS in Simulink with supported MCUs
For example, S32K358 with MC33774/MC33775 for cell monitoring and MC33772C for current measurement (all over SPI). This setup works with MBDT for BMS and MBDT for S32K3 1.4.0. However, first test that the neural network runs on S32K358.

c. Use any S32K3 with AFE parts or the newest BMA7318
Note: There is no direct support for deploying code from Simulink using MBDT for BMS in this case. You can still generate application logic and neural network C code in Simulink, then manually integrate with the AFE using S32 Design Studio.


6. On-Device Training vs Inference-Only Workflow
This depends on your application requirements. Our previous approach was inference-only: train the network in MATLAB, then deploy it on the MCU. Recommended resources:
Battery State Estimation Using Deep Learning Followed by the webinar mentioned in point 2 above.

7. Performance and Memory Guidance for AI Inference on S32K388
Performance depends on your application. If the neural network is already trained, test the generated code in PIL mode on the S32K3 family, profile execution, and decide if S32K388 meets your needs. For reference, the SOC algorithm mentioned earlier was successfully tested on S32K344 and S32K358.

In summary, you can use Embedded Coder to generate code from your neural network and test performance in PIL mode. After validation, import the generated code into S32 Design Studio and deploy it on S32K388 as required.

Hope this helps,

Marius

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2270562%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K388%20with%20MC33771B%20SPI%20BMS%3A%20MBDT%2C%20code%20generation%2C%20and%20AI%20deployment%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2270562%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20NXP%20Community%2C%3C%2FP%3E%3CP%3EI%20am%20developing%20an%20integrated%20BMS%20using%20S32K388-Q289%20and%20FRDM-MC33771B-SPI-EVB%20via%20SPI%20communication%2C%20targeting%20a%20real%20lithium-ion%20battery%20pack.%20While%20researching%2C%20I%20noticed%20that%20there%20are%20relatively%20few%20BMS-specific%20example%20projects%20and%20reference%20implementations%20available%20for%20the%20S32K3%20series%2C%20so%20it%20has%20been%20challenging%20to%20confirm%20the%20recommended%20workflow%20and%20supported%20toolchain%20for%20this%20type%20of%20application.%3C%2FP%3E%3CP%3EMy%20goal%20is%20to%20implement%20the%20full%20embedded%20BMS%20stack%20on%20the%20MCU%2C%20including%3A%3C%2FP%3E%3CP%3ECell%20voltage%20%2F%20temperature%20monitoring%20(via%20BCC)%3C%2FP%3E%3CP%3ECell%20balancing%20control%3C%2FP%3E%3CP%3ESOC%20%2F%20SOH%20estimation%20algorithms%20(including%20deep%20learning-based%20approaches)%3C%2FP%3E%3CP%3EReal-time%20operation%20on%20the%20MCU%3C%2FP%3E%3CP%3EModel-Based%20Design%20workflow%20if%20possible%20(otherwise%20an%20S32DS%20C%20project)%3C%2FP%3E%3CP%3EI%20plan%20to%20use%20MATLAB%2FSimulink%20Model-Based%20Design%20Toolbox%20(MBDT)%20first%2C%20and%20if%20full%20support%20is%20not%20available%20for%20my%20setup%2C%20I%20will%20proceed%20with%20S32%20Design%20Studio%20(S32DS).%3C%2FP%3E%3CP%3EI%20would%20appreciate%20guidance%20on%20the%20questions%20below%3A%3C%2FP%3E%3CP%3E1)%20MBDT%20support%20and%20training%20materials%20for%20S32K3%20BMS%20applications%3CBR%20%2F%3EIs%20there%20any%20official%20documentation%2C%20user%20guide%2C%20training%20course%2C%20or%20application%20note%20for%20using%20MBDT%20with%20the%20S32K3%20series%20specifically%20for%20BMS-related%20development%20(e.g.%2C%20SPI-based%20BCC%20communication%2C%20sampling%2Fprocessing%2C%20protection%20logic%2C%20and%20real-time%20monitoring)%3F%3C%2FP%3E%3CP%3E2)%20Integrating%20MBDT%20models%20with%20Deep%20Learning%20models%20and%20code%20generation%3CBR%20%2F%3EIf%20I%20develop%20the%20BMS%20logic%20in%20Simulink%20(MBDT)%20and%20add%20a%20SOC%2FSOH%20model%20built%20using%20Deep%20Learning%20Toolbox%3A%3C%2FP%3E%3CP%3E-%20Can%20these%20be%20combined%20into%20a%20single%20integrated%20Simulink%20model%3F%3C%2FP%3E%3CP%3E-%20If%20yes%2C%20can%20the%20integrated%20model%20be%20automatically%20generated%20into%20C%20code%20(or%20other%20supported%20embedded%20code)%20using%20Embedded%20Coder%20for%20deployment%20on%20S32K388%3F%3C%2FP%3E%3CP%3E3)%20Real-time%20inference%20feasibility%20on%20S32K388%3CBR%20%2F%3EIf%20code%20generation%20in%20(2)%20is%20feasible%3A%3C%2FP%3E%3CP%3E-%20Can%20the%20deployed%20model%20perform%20real-time%20inference%20(SOC%2FSOH%20estimation)%20using%20live%20battery%20data%20(voltage%2Fcurrent%2Ftemperature)%20on%20the%20MCU%3F%3C%2FP%3E%3CP%3E-%20Are%20there%20recommended%20constraints%20or%20best%20practices%20(e.g.%2C%20fixed-point%20vs%20floating-point%2C%20supported%20layer%20types%2C%20model%20size%20limits%2C%20inference%20timing%20considerations)%20for%20S32K388%3F%3C%2FP%3E%3CP%3E4)%20Safety%20constraints%20%2F%20protection%20logic%20in%20MBDT%3CBR%20%2F%3EFor%20safety%2C%20I%20need%20to%20implement%20protection%20logic%20such%20as%3A%3C%2FP%3E%3CP%3E-%20Over-voltage%20%2F%20under-voltage%20thresholds%3C%2FP%3E%3CP%3E-%20Over-temperature%20%2F%20under-temperature%20thresholds%3C%2FP%3E%3CP%3E-%20Fault%20handling%20and%20safe-state%20behavior%3C%2FP%3E%3CP%3EIs%20it%20possible%20to%20implement%20these%20limits%20and%20protection%20logic%20directly%20in%20MBDT%2FSimulink%20and%20include%20them%20in%20the%20generated%20embedded%20code%3F%3CBR%20%2F%3EIf%20there%20are%20any%20reference%20examples%20(BMS%20or%20safety%20logic)%20for%20S32K%20targets%2C%20please%20share.%3C%2FP%3E%3CP%3E5)%20S32K388%20compatibility%20with%20FRDM-MC33771B-SPI-EVB%20and%20alternatives%3CBR%20%2F%3EIs%20S32K388-Q289%20officially%20supported%2Frecommended%20to%20work%20with%20MC33771B%20via%20SPI%20for%20BMS%20applications%3F%3CBR%20%2F%3EIf%20this%20combination%20is%20not%20recommended%2C%20could%20you%20suggest%20an%20officially%20supported%20BCC%20%2B%20reference%20platform%20(SPI%20or%20TPL)%20for%20S32K3-based%20BMS%20development%3F%3C%2FP%3E%3CP%3E6)%20On-device%20training%20(online%20learning)%20vs%20inference-only%20workflow%3CBR%20%2F%3EFrom%20an%20embedded%20AI%20perspective%3A%3C%2FP%3E%3CP%3E-%20Is%20on-device%20training%20(online%20learning%20using%20real-time%20battery%20data)%20supported%20or%20recommended%20on%20S32K3%20MCUs%3F%3C%2FP%3E%3CP%3E-%20Or%20is%20the%20recommended%20approach%20offline%20training%20on%20PC%20%2B%20inference-only%20on%20the%20MCU%3F%3C%2FP%3E%3CP%3EIf%20offline%20training%20is%20recommended%2C%20are%20there%20any%20official%20references%20describing%20a%20recommended%20workflow%3F%3C%2FP%3E%3CP%3E7)%20Performance%20%2F%20memory%20guidance%20for%20AI%20inference%20on%20S32K388%3CBR%20%2F%3EAre%20there%20any%20benchmarks%20or%20guidelines%20for%20running%20AI%20inference%20on%20S32K3%20(especially%20S32K388)%20regarding%3A%3C%2FP%3E%3CP%3E-%20Flash%2FRAM%20usage%20expectations%3C%2FP%3E%3CP%3E-%20Typical%20inference%20latency%20ranges%3C%2FP%3E%3CP%3E-%20Optimization%20approaches%20(fixed-point%2C%20quantization%2C%20lightweight%20architectures)%3C%2FP%3E%3CP%3E%3CLI-EMOJI%20id%3D%22lia_smiling-face-with-sunglasses%22%20title%3D%22%3Asmiling_face_with_sunglasses%3A%22%3E%3C%2FLI-EMOJI%3E%20Preferred%20alternative%20workflow%20if%20MBDT%20%2B%20DL%20integration%20is%20not%20recommended%3CBR%20%2F%3EIf%20full%20integration%20and%20auto%20code%20generation%20are%20not%20recommended%2Fsupported%2C%20what%20is%20the%20preferred%20workflow%20to%20deploy%20an%20AI%20model%20on%20S32K3%3F%20For%20example%3A%3C%2FP%3E%3CP%3E-%20Converting%20the%20model%20to%20lightweight%20C%20inference%20code%20manually%3C%2FP%3E%3CP%3E-%20Using%20CMSIS-NN-like%20approaches%20(if%20applicable)%3C%2FP%3E%3CP%3E-%20Using%20any%20NXP%20middleware%20%2F%20recommended%20libraries%20%2F%20examples%20(e.g.%2C%20eIQ)%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20support.%20Any%20documentation%20links%2C%20training%20references%2C%20SDK%20examples%2C%20or%20best-practice%20recommendations%20would%20be%20very%20helpful.%3C%2FP%3E%3CP%3EBest%20regards%2C%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2291024%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K388%20with%20MC33771B%20SPI%20BMS%3A%20MBDT%2C%20code%20generation%2C%20and%20AI%20deployment%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2291024%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F250679%22%20target%3D%22_blank%22%3E%40SonHyunTaek%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EThank%20you%20for%20posting%20your%20detailed%20questions%20regarding%20your%20project%20on%20our%20community%20forum.%20Please%20note%20that%20the%20answers%20below%20are%20provided%20from%20the%20MBDT%20software%20perspective%3B%20from%20a%20hardware%20standpoint%2C%20there%20might%20be%20better%20approaches%20in%20terms%20of%20component%20combinations.%20It%20would%20also%20help%20to%20know%20the%20target%20voltage%20for%20your%20BMS%20and%20whether%20pack%20current%20sensing%20is%20required.%20Since%20you%20plan%20to%20use%20a%20single%20AFE%20connected%20via%20SPI%2C%20I%20assume%20you%20are%20targeting%20a%20maximum%2048V%20BMS%20system.%3C%2FP%3E%0A%3CP%3ERegarding%20the%20combination%20of%20devices%20you%20proposed%3A%20at%20the%20hardware%20level%2C%20the%20S32K3%20is%20fully%20compatible%20with%20the%20MC33771B.%20However%2C%20from%20the%20software%20perspective%2C%20things%20are%20more%20complex.%20The%20MBDT%20for%20S32K3%20is%20built%20to%20generate%20code%20on%20top%20of%20the%20NXP%20Real-Time%20Drivers%20(RTD)%20at%20the%20MCAL%20layer%2C%20while%20the%20MBDT%20for%20BMS%20generates%20code%20on%20top%20of%20the%20BMS%20SDK%2C%20which%20is%20also%20compatible%20with%20RTD.%20The%20BMS%20SDK%20includes%20an%20external%20configuration%20tool%20for%20pins%2C%20clocks%2C%20and%20peripherals%2C%20accessible%20from%20Simulink%2C%20along%20with%20ready-to-run%20examples.%3CBR%20%2F%3EPlease%20note%3A%3C%2FP%3E%0A%3CP%3E-%20MBDT%20for%20BMS%201.2.0%20works%20only%20with%20MBDT%20for%20S32K3%201.4.0%2C%20which%20does%20not%20support%20the%20S32K388.%3CBR%20%2F%3E-%20The%20BMS%20SDK%20is%20compatible%20only%20with%20RTD%203.0.0%2C%20used%20by%20MBDT%20for%20S32K3%201.4.0.%20At%20that%20time%2C%20the%20S32K388%20was%20not%20available.%3CBR%20%2F%3E-%20MBDT%20for%20BMS%20and%20MBDT%20for%20S32K3%20support%20only%20newer%20AFE%20parts%20such%20as%20MC33774%2C%20MC33775%2C%20MC33664%2C%20MC33665%2C%20and%20MC33772C%2C%20typically%20used%20in%20hardware%20designs%20with%20Battery%20Junction%20Box%20functionality.%3C%2FP%3E%0A%3CP%3EThese%20limitations%20come%20from%20the%20software%20packages%20(RTD%20and%20BMS%20SDK).%20The%20MC33771B%20you%20intend%20to%20use%20includes%20a%20C%20SDK%20driver%2C%20which%20you%20must%20integrate%20manually%20into%20MBDT%20using%20custom%20code%2C%20as%20there%20are%20no%20ready-to-run%20compatible%20C%20drivers%20for%20connecting%20S32K3%20and%20MC33771B.%20In%20other%20words%2C%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdesign%2Fdesign-center%2Fsoftware%2Fanalog-expert-software-and-tools%2Fsdk-analog-expert-drivers%2Fembedded-sw-battery-cell-controller-software-driver-for-mc33771b-mc33772b%3AEMBEDDED-SW-BCC%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EEmbedded%20SW%3A%20Battery%20Cell%20Controller%20Software%20Driver%20for%20MC33771B%2FMC33772B%3C%2FA%3E%20%26nbsp%3Brequires%20manual%20C%20coding%20and%20integration%20into%20MBDT.%20An%20article%20describing%20how%20to%20do%20this%20(based%20on%20MBDT%20for%20S32K1)%20can%20be%20found%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FNXP-Model-Based-Design-Tools%2FHow-to-use-your-own-C-code-in-our-Toolbox-Battery-Management%2Fta-p%2F1119004%22%20target%3D%22_self%22%3Ehere.%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EI%20will%20address%20your%20questions%20below%20and%20propose%20some%20solutions%20at%20the%20end.%3C%2FP%3E%0A%3CP%3E1.%20MBDT%20Support%20and%20Training%3CBR%20%2F%3EThe%20best%20resources%20we%20offer%20are%20available%20on%20the%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FModel-Based-Design-Toolbox-MBDT%2Fbd-p%2Fmbdt%22%20target%3D%22_self%22%3EMBDT%20Community%3C%2FA%3E%20page.%26nbsp%3B%20On%20the%20right-hand%20side%2C%20you%20will%20find%20the%20Beginner's%20Guide%20for%20Model-Based%20Design%20Toolbox%2C%20which%20explains%20how%20to%20perform%20basic%20tasks%20with%20MBDT%20for%20S32K3.%20Additionally%2C%20there%20are%20BMS%20Webinars%20that%20provide%20insights%20into%20Battery%20Management%20Systems.%3CBR%20%2F%3EHere%20is%20a%20link%20to%20our%20latest%20webinar%20on%20BMS%2C%20created%20in%20collaboration%20with%20MathWorks%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.mathworks.com%2Fvideos%2Fstreamlining-battery-systems-dev-for-nxp-s32-devices-1751294505102.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EStreamlining%20Battery%20Systems%20Development%20for%20NXP%20S32%20Devices.%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E2.%20Integrating%20Deep%20Learning%20Models%3CBR%20%2F%3EIn%20previous%20collaborations%20with%20MathWorks%2C%20we%20successfully%20deployed%20a%20Deep%20Learning-based%20State%20of%20Charge%20(SOC)%20estimation%20algorithm%20directly%20from%20Simulink%20and%20tested%20it%20in%20PIL%20mode.%20Yes%2C%20Embedded%20Coder%20can%20generate%20the%20neural%20network%20directly%20from%20the%20Simulink%20model%2C%20and%20together%20with%20MBDT%2C%20it%20can%20be%20deployed%20on%20the%20S32K3.%3CBR%20%2F%3EHere%20is%20a%20link%20to%20the%20related%20webinar%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.mathworks.com%2Fvideos%2Fdeploying-a-deep-learning-based-state-of-charge-soc-estimation-algorithm-to-nxp-s32k3-microcontrollers-1638200087678.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EDeploying%20a%20Deep%20Learning-Based%20SOC%20Estimation%20Algorithm%20to%20NXP%20S32K3%20Microcontrollers%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E3.%20Real-Time%20Inference%20Feasibility%20on%20S32K388%3CBR%20%2F%3EYes%2C%20real-time%20inference%20is%20feasible.%20In%20previous%20work%2C%20we%20used%20cell%20voltage%2C%20current%2C%20and%20temperature%20as%20inputs.%20These%20values%20can%20be%20measured%20by%20the%20AFE%20at%20runtime%20and%20provided%20to%20the%20neural%20network.%20As%20a%20best%20practice%2C%20intensive%20testing%20in%20PIL%20mode%20can%20help%20evaluate%20performance.%20You%20can%20also%20experiment%20with%20optimization%20techniques%20to%20identify%20the%20best%20configuration.%3C%2FP%3E%0A%3CP%3E4.%20Safety%20Constraints%3CBR%20%2F%3EThe%20logic%20for%20your%20safety%20requirements%20can%20be%20implemented%20in%20Simulink%2C%20and%20the%20corresponding%20code%20can%20be%20automatically%20generated.%20MathWorks%20provides%20an%20example%20we%20have%20used%20and%20deployed%20on%20S32K3%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Ffileexchange%2F72865-design-and-test-lithium-ion-battery-management-algorithms%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EDesign%20and%20Test%20Lithium-Ion%20Battery%20Management%20Algorithms%26nbsp%3B%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E5.%20S32K388%20Compatibility%20with%20FRDM-MC33771B-SPI-EVB%20and%20Alternatives%3CBR%20%2F%3ETo%20test%20your%20neural%20network%20application%20directly%20from%20Simulink%2C%20use%20MBDT%20for%20S32K3%20the%20latest%20version.%20This%20allows%20you%20to%20verify%20deployment%20feasibility%20and%20perform%20benchmarking%20tests%20on%20all%20the%20available%20MCU%20at%20this%20time.%3CBR%20%2F%3EFrom%20a%20hardware%20perspective%2C%20you%20have%20several%20options%3A%3C%2FP%3E%0A%3CP%3Ea.%20Continue%20with%20the%20proposed%20solution%20(S32K358%20%2B%20MC33771C)%3CBR%20%2F%3EStart%20with%20MC33771C%20instead%20of%20MC33771B%2C%20as%20it%20is%20newer%2C%20supports%20SPI%2C%20and%20includes%20current%20measurement.%20You%20can%20integrate%20the%20MC33771C%20driver%20directly%20in%20Simulink%20using%20custom%20code%20and%20use%20MBDT%20for%20BMS%201.8.0.%3C%2FP%3E%0A%3CP%3Eb.%20Use%20MBDT%20for%20BMS%20in%20Simulink%20with%20supported%20MCUs%3CBR%20%2F%3EFor%20example%2C%20S32K358%20with%20MC33774%2FMC33775%20for%20cell%20monitoring%20and%20MC33772C%20for%20current%20measurement%20(all%20over%20SPI).%20This%20setup%20works%20with%20MBDT%20for%20BMS%20and%20MBDT%20for%20S32K3%201.4.0.%20However%2C%20first%20test%20that%20the%20neural%20network%20runs%20on%20S32K358.%3C%2FP%3E%0A%3CP%3Ec.%20Use%20any%20S32K3%20with%20AFE%20parts%20or%20the%20newest%20BMA7318%3CBR%20%2F%3ENote%3A%20There%20is%20no%20direct%20support%20for%20deploying%20code%20from%20Simulink%20using%20MBDT%20for%20BMS%20in%20this%20case.%20You%20can%20still%20generate%20application%20logic%20and%20neural%20network%20C%20code%20in%20Simulink%2C%20then%20manually%20integrate%20with%20the%20AFE%20using%20S32%20Design%20Studio.%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E6.%20On-Device%20Training%20vs%20Inference-Only%20Workflow%3CBR%20%2F%3EThis%20depends%20on%20your%20application%20requirements.%20Our%20previous%20approach%20was%20inference-only%3A%20train%20the%20network%20in%20MATLAB%2C%20then%20deploy%20it%20on%20the%20MCU.%20Recommended%20resources%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.mathworks.com%2Fvideos%2Fbattery-state-estimation-using-deep-learning-1608051899333.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EBattery%20State%20Estimation%20Using%20Deep%20Learning%3C%2FA%3E%26nbsp%3BFollowed%20by%20the%20webinar%20mentioned%20in%20point%202%20above.%3C%2FP%3E%0A%3CP%3E7.%20Performance%20and%20Memory%20Guidance%20for%20AI%20Inference%20on%20S32K388%3CBR%20%2F%3EPerformance%20depends%20on%20your%20application.%20If%20the%20neural%20network%20is%20already%20trained%2C%20test%20the%20generated%20code%20in%20PIL%20mode%20on%20the%20S32K3%20family%2C%20profile%20execution%2C%20and%20decide%20if%20S32K388%20meets%20your%20needs.%20For%20reference%2C%20the%20SOC%20algorithm%20mentioned%20earlier%20was%20successfully%20tested%20on%20S32K344%20and%20S32K358.%3C%2FP%3E%0A%3CP%3EIn%20summary%2C%20you%20can%20use%20Embedded%20Coder%20to%20generate%20code%20from%20your%20neural%20network%20and%20test%20performance%20in%20PIL%20mode.%20After%20validation%2C%20import%20the%20generated%20code%20into%20S32%20Design%20Studio%20and%20deploy%20it%20on%20S32K388%20as%20required.%3C%2FP%3E%0A%3CP%3EHope%20this%20helps%2C%3C%2FP%3E%0A%3CP%3EMarius%3C%2FP%3E%3C%2FLINGO-BODY%3E