euroastar350
Resource contributor
- Messages
- 861
- Country

Howdy,
I'm looking at doing a custom battery with charging, discharging, temperatures, voltage and amps and I've come up with a code using AI (got some successful code using this method). While I got a correct battery voltage, the electrical total amps is too high and the battery temperature seems very excessive using the following code. I'm sure it's full of errors (the cost of using AI). So my question is how to get a proper battery simulation? I'm recreating the battery logic for my AS350 Squirrel project. Battery is 24 volts, generator voltage should float around 28 volts and total generator amperage is 150. I don't have a GPU/APU coded yet, that'll be the next step. Any pointers is greatly appreciated.
I'm looking at doing a custom battery with charging, discharging, temperatures, voltage and amps and I've come up with a code using AI (got some successful code using this method). While I got a correct battery voltage, the electrical total amps is too high and the battery temperature seems very excessive using the following code. I'm sure it's full of errors (the cost of using AI). So my question is how to get a proper battery simulation? I'm recreating the battery logic for my AS350 Squirrel project. Battery is 24 volts, generator voltage should float around 28 volts and total generator amperage is 150. I don't have a GPU/APU coded yet, that'll be the next step. Any pointers is greatly appreciated.
Code:
<Element>
<Select>
<Value>
(L:switch_generator, bool) if{ (L:Eng2N2Percent,enum) 0.01 * 150 * (>L:AS350_Gen_Output, amps) } els{ 0 (>L:AS350_Gen_Output, amps) }
(L:gpu,bool) if{ 0 (>L:AS350_Battery_Amps, amps) }
els{
(L:AS350_Gen_Output, amps) (A:ELECTRICAL TOTAL LOAD AMPS, amps) - (>L:AS350_Battery_Amps, amps)
}
</Value>
</Select>
</Element>
<Element>
<Select>
<Value>
(L:AS350_Battery_SOC, percent) (L:AS350_Battery_Amps, amps) 0.0001 * + 100 min 0 max (>L:AS350_Battery_SOC, percent)
(L:AS350_FirstRun, bool) ! if{ 95 (>L:AS350_Battery_SOC, percent) 1 (>L:AS350_FirstRun, bool) }
</Value>
</Select>
</Element>
<Element>
<Select>
<Value>
24 (L:AS350_Battery_SOC, percent) 100 / 2 * + (>L:AS350_Base_Volts)
(L:switch_generator, bool) if{ (L:AS350_Base_Volts) 2.5 + } els{ (L:AS350_Base_Volts) } (>L:AS350_Current_Volts)
(L:AS350_Current_Volts) (A:ELECTRICAL TOTAL LOAD AMPS, amps) 0.02 * - (>L:AS350_Battery_Voltage_Disp, Volts)
</Value>
</Select>
</Element>
<Element>
<Select>
<Value>
(L:AS350_Battery_Amps, amps) abs 2 pow 0.00005 * (>L:AS350_Heat_Generated)
(L:AS350_Battery_Temp, Celsius) (A:AMBIENT TEMPERATURE, Celsius) - 0.001 * (>L:AS350_Cooling_Loss)
(L:AS350_Battery_Temp, Celsius) (L:AS350_Heat_Generated) + (L:AS350_Cooling_Loss) - (>L:AS350_Battery_Temp, Celsius)
(A:AMBIENT TEMPERATURE, Celsius) (>L:AS350_Battery_Temp, Celsius)
</Value>
</Select>
</Element>