Barotrauma

Barotrauma

50 ratings
Advanced Wiring for Batteries and Super Capacitors
By Cengaver_
This guide explains how to make batteries and super capacitors fully automated at an optimal efficiency. Give it a try and see it yourself.
   
Award
Favorite
Favorited
Unfavorite
Basics
So, your sub needs power to function properly. A device using power creates a ''load'' which is how much power it demands. This demand is met by power generated from Nuclear Reactor or supplied by Batteries. Both this load and power is being transferred between devices and energy sources via junction boxes. So, the power circuit is not stable. This makes it prone to errors. A big problem you will encounter is over-volting.

So, if power exceeds load by twice of it, it will cause your junction boxes to rapidly decay ,losing power eventually, and even catch fire causing more problems. This could be really common as most submarines devices demand lots of power so its easy to cause big power changes without knowing. This could be: Manoeuvring the sub too harshly, cutting power to oxygen generator, batteries or super-capacitors with high recharge rates.

To prevent these problems, you can set up a automatic reactor, this will both make your sub powerwise more stable and efficient. But thats not enough to make it fully stable so you need to use the batteries too. This guide shows you how to use the batteries also.
Advanced battery
assembly, try it yourself:
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=3006205526



So, whats going on here is:

-First your are finding the excess power by subtracting load from power
-Then you want match by adjusting battery recharge rate so it doesn't over-volt
>But there is a problem, whenever battery increases its recharge rate to match power, it also creates
load which then zeroes the excess power thus no longer matches the excess power, then it sees
excess power and repeats this cycle.
>For example: Power:2000 Load:1800 excess power:200 battery creates 200 load by adjusting
recharge rate, Power:2000 Load:1800+200 from battery, Battery tries to zero its recharge rate
thinking there are no longer excess power. This causes 200 excess power again then cycle
repeats.
-To avoid that, first you find the load battery creates via charge rate. Then you add this value to value ''excess power''. The calculation is like this:
>power-load=excess power
>power-load-load created by the battery=excess power=0
>This is what you want, to maintain this state, you add load created by the battery, so it maintains current conditions.
-Now the system will automatically match the excess power, but there is one problem: The batteries will not charge as long as there are radical changes in the power/load ratio, I wanted to make a system where batteries only charge if there are performance available from reactor, so recharging doesn't tanks subs performance.
-For this, I added a regEX that: If total battery charge is under %94, it will slowly increase recharge rate if there are power available
-After %94, it puts the batteries on hold mode from charge, to slowly lower charge rate then leave space for over-voltages
>What this does is, normally when charging battery, when it gets full, it will cause a sudden load
drop thus over-voltage, this lowers the charge rate slowly so the batteries avoid doing this.
>It puts the batteries in a mode that, they only charge if there are excess of power, preventing over-volt(Normally if batteries were %100, they wouldn't be able to do this)
With an example in this sub
You might need to make some adjustments depending on the sub, you can ask me if you have a question
Example sub:
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=3007675362
RegEX explanation
Expression: ^(9[4-9]|100)$
Output: -137
False Output: 137
Receives average battery% as signal
Send a value which is added to a value determining battery charge rate

Expression:
^ asserts the position at the start of the line
9 matches it literally
[4-9] matches a single character in the range between 4 and 9
| equivalent to boolean ''OR''
100 matches the characters 100 literally
$ asserts position at the end of a line

So if the average battery% is between 94-100, its sends the true output, if not then the false one.

False output makes batteries increase charging rate if possible

True output makes them lower charging rate then stop if not over-volted.
[/previewicon]
Step to Step

1- Take both battery charge_rate_out's and get the sum of both values by using an adder component.
(Note: you will need to repeat this step with multiple adder components if you have more than 2 batteries. For example if you were to have 4, you will need to use 3 adder components instead.)
2- Then multiply this value by the max charge rate/100 of a single battery(not total charge rate) via a multiply and a memory component. This will give you the ''load'' thats created by the batteries.
In this case max battery charge rate is 1000, which means the memory components value should be 10.


1- Subtract reactor load from reactor power, this will give you the ''excess power'' in your subs circuit via subtract component.
2- Then add this value to the previous value you found(from multiply component) via adder component.


Now you will need to the find your average battery charge%

1- Take both battery charge_% values and get the sum of them via adder component.
(Note: Again, you will need to repeat this step with multiple adder components if you have more than 2 batteries)
2- Divide this value by the amount of batteries you have via a divide and a memory component. This will give you the average battery charge%.


1- Now run that average charge% value you found(from divide component) into a regex component.
2- Regex expression should be: ^(9[4-9]|100)$
This actually works like a memory and a greater component combined. It will send a true output if the value its receiving passes 94.
3- Regex's output are: true: -137, false: 137, which is your total battery charge rate divided by 14.6 then rounded to nearest integer.
In this case the total charge rate is 2000, if you divide it by 14.6, it will be something around 137.
4- Then add this value to the previous values you found(from adder component) via adder component.


Now, the logic circuit is almost complete, just an final step
1- Multiply the both memory components values via multiply component.
2- Then divide the previous value you found from the adder component by this value via divide component.
3- Finally, take the output of the divide component and run it into set_charge_rate of all batteries, and its done.
Notes
Advantages of this system:

-Battery charging is fully automatic and doesn't put any pressure on your electrical circuit so it does not lower submarine performance. Batteries will drop their charge rate whenever your sub needs more power.
-The batteries will slowly stop charging when they hit %94, so they will leave some space for over-voltages(Batteries will only charge if there is an over-voltage current).

***

-If you get a max battery charge rate upgrade, you need to change memory components value which is designated for max battery charge rate/100.
-This system might not be enough to completely prevent over-voltages if your reactor is too strong compared to your batteries.

For super-capacitors:

I originally had a design for super-capacitors too but I realized that if you have a auto reactor and this system in place, your electrical circuit will be stable enough to set your super-capacitors whatever rate you want(as long as your super-capacitors are not super strong).
-I may add a design for them too.
32 Comments
antigua 20 Jan @ 8:56pm 
Where did the 14.6 come from?
Hrdy 13 Nov, 2024 @ 6:02pm 
Wait nvm I see your note
Hrdy 13 Nov, 2024 @ 5:57pm 
Wouldn’t tier upgrades and character abilities skew some of these values and break it, or does it just make it less efficient.
herbaciasz 27 Sep, 2024 @ 11:35am 
nope it didn't change anything. works exactly the same now with the memory comp
herbaciasz 27 Sep, 2024 @ 6:12am 
ah okay i get it. i will try and let you know if it works. thanks
TRONBOLON 27 Sep, 2024 @ 4:50am 
put it just before the set_charge_rate
TRONBOLON 27 Sep, 2024 @ 4:49am 
It prevents the triangle load spikes on reactor when using this contraption.
herbaciasz 27 Sep, 2024 @ 1:04am 
yea i didn't forget this. total battery charge rate (10000) / 14.6 is 648 which i have my regex set into. I don't quite understand what memory component you're talking about at the end? could you elaborate?
TRONBOLON 27 Sep, 2024 @ 12:32am 
@herbaciasz
Regex's output are your total battery charge rate divided by 14.6 then rounded to nearest integer.
You probably missed that one.
A memory component between circuit output and batteries charge rate should solve the triangles
herbaciasz 26 Sep, 2024 @ 4:56pm 
i made this in my sub and it seems to work, but with my very powerful reactor and engines (it is a big sub, i remade it for 10 batteries and changed values on memory components accordingly) theres one simple problem. The load power graph is shaped like triangles, its constantly trying to equal itself. the problem is that beacuse of this propably the batteries get charged to 100%, they dont stop at 94 and they cant take overvoltage no more. is there some way to stabilize this because when i turn off the engines, or when the batteries hit 100% charge they create overvoltage like 3-4 times the load and they just smoke all my jbs.