Plecs Plant code generator

battery_charger_protype.plecs (451.8 KB) I am not getting the code generator to work for this model due to the lithium ion battery that I am trying to use to implement a battery charging and discharging. Is there a way that I can make a similar circuit to where I can get the code generator to work for a plecs rt box so I can output the model?

Even when I tried to use the R model, the simulation stops around 4 seconds and doesn’t continue to run forward. Due to the stiffness

battery_charger_protype R BATTERY.plecs (444.8 KB)

Hi brandontm85, have you tried changing the solver to “RADAU” or setting it to “auto”? I was able to run the “battery_charger_protype R BATTERY.plecs“ model when I changed the solver type.

battery_charger_protype.plecs (451.8 KB) I am not getting the code generator to work for this model … where I can get the code generator to work for a plecs rt box so I can output the model?”

The battery model you are using variable components that are not supported currently for code generation. Have you looked at the “On-Board Charger” demo model in the TI Target Support Package? There is a battery model that might be more suitable for code generation for you to use in your project?

Hey Munadir, yes, I have, and it stops around the 4-second mark of the simulation even if I change the time span

No I have not I can;t find the standalone for it all i see is a pdf online for the may you send me the standalone

hi brandon85 - basically the culprit is an element in the battery model you are using. It seems that at around ~4s, the battery is frequently going from charging to discharging and this causes the voltage calculated in the “Polarizing Resistance” block to constantly change and causes the simulation to appear to stop. However, if you zoom in you’ll notice that the simulation is still running but it’s just very slow.

I set the option “Enable/Disable Polarizing Resistance” to Disable and this removes the constantly changing voltage due to the frequent change in charging vs discharging that the simulation is experiencing. See if that helps resolve your issue.

As for the “On-board Charger” demo model. I see that you already have the TI TSP installed and it’s part of the demo models that ship with the TSP. Here is a screen shot of where it can be located:

Let me know if you are able to find it.

I would want to keep that battery system instead of the other charger model however when I change the enable the battery does show it is discharging towards my system via the soc. Also I am trying to see why my system is not producing in power for current going into the battery