How to store and read last data from non-volatile memory?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to store and read last data from non-volatile memory?

27 Views
Contributor III

Hello everyone,

 

This is Ozan and I am using S32K144, mbdt v4.2 and Matlab 2020a. I try to modify the BMS example in the toolbox. The example model provides several information such as cell voltages, pack voltage, cell temperature and pack current. 

I want to built a model which acts as simple Coulomb counter. The main goal is sum the pack current over period of time sample, subtract this summed value from remaining capacity and divide this over total capacity and store this data as packSOC (after multiplying with 100 for %). The model details and ss are provided below.

After calculating the packSOC I want to store this value in non-volatile memory in case the board is powered off. And I want to read this value and start SOC calculation from this stored lastSOC value. 

I observe non-sense and constantly floating values from Freemaster when I upload this model. I think the problem is related with initialization. 

I stuck with this problem quite a while and any help will be appreciated. Thanks in advance. 

The model ss:

oeren5_5-1599034585750.pngoeren5_6-1599034608863.png

oeren5_7-1599034639517.png

 

 

 

0 Kudos
1 Reply

22 Views
NXP Employee
NXP Employee

Hello @oeren5 ,

 

Well, from the screenshot you have attached, it looks like you are reading the data stored every time when the model executes the step function. 

I think you should only read once, at the beginning of the program, the value stored for the CC_SOC. To do that, I would declare a flag variable with an IF statement to be executed only once at the beginning of the step function.

mariuslucianand_0-1600088031231.png

After each new computation of the CC_SOC, you can store the new value in flash just like you already do.

Hope this helps,

Marius

 

0 Kudos