Stormworks: Build and Rescue

Stormworks: Build and Rescue

Tom Apr 4, 2020 @ 8:23am
Switch between diesel engine and eletric engine to rotate propeller
Hello everyone,

I know how to use hybrid engine system..where the propeller is rotated only by using eletric engine and the diesel engine only to power genarator when x amount of battery charge is low. BUT what I want to do is when my submarine surfaces it switches the eletric engine off and uses the diesel engine to power propellers. I have alot of trouble understanding how each logic module works some are very basic other not so quite..ive been killing myself to undwerstand how PIDS work..(only know that they act as Loops for checking variables..).

If anyone can give me a push in the right direction I would apprecciate it.

Cheers have a safe quaratine!
Last edited by Tom; Apr 4, 2020 @ 8:23am
< >
Showing 1-13 of 13 comments
Pointed Mammal29 Apr 4, 2020 @ 8:32am 
You want to link the electric to fuel pumps which link to the engines, that should work, good luck
Ra-Ra-Rasputin Apr 4, 2020 @ 10:12am 
The way electric motors lose power linearly with battery charge, "low" is around 80% battery charge at the current moment, and as there's no one-way electric relay, there's no way to keep a small battery topped up at the moment. Hybrid systems suffer as a result.

PID is difficult to understand even if i explain you exactly how it works. Basically it's all math. It compares 2 values, and outputs a decimal that's modified by 3 factors:
P = How far the current value is from desired value
I = Measures the delta of the current value in relation to P to adjust value positively or negatively according to time
D = Counteracts P based on vicinity of P to desired value. Can prevent P from reaching desired value.

At any rate, for a hybrid system all you need is a switchbox, a junction, equals and a less than.
- Switchbox disables clutch from main engines on full battery
- Junction diverts throttle control to electric motors, setting engine throttle to 0
- Equals sets a toggleable latch (such as SR latch) for the above
- Less than toggles the latch off when battery is below desired value

The latent torque in the system should be enough to kickstart the engines without hitting the engine starter.
Last edited by Ra-Ra-Rasputin; Apr 4, 2020 @ 10:13am
Tom Apr 7, 2020 @ 7:50am 
https://i.postimg.cc/NfLLL9yK/project.jpg

Hello Rasputin,

Im sorry to bother you again on the subject. Im having alot of trouble.. this is what i came up with and doe not work..ive might have understood your suggestion wrong.

Im also tryin to add a second condition on where ( IF my sub is Below 0Meters AND batteries are EQUAL to 100% the diesel engine should shut down, clutch disabled and throttle diverted to eletric engines) in a perfect world...haha
Last edited by Tom; Apr 7, 2020 @ 7:54am
Jorg Hammond Apr 7, 2020 @ 8:10am 
If you would upload the controller to the Workshop, it could help since it is not easy to read the numbers on the screenshot.

I'm still learning microcontroller programming too so I won't be of much help, but I think I noticed at least two things for starters:

- it looks like your depth condition will only be true if your submarine reaches 100 m;
- the controller lacks a throttle input to feed via a junction to either the diesel engine or the electric motors, in a similar fashion to what you have setup to cut off one or the others.
Jorg Hammond Apr 7, 2020 @ 8:59am 
I was saying nonsense about the junction, you only need one since "The path that the input doesn't take will output a value of 0."

So you can create a throttle control input on your microcontroller and link it to the junction input. The way you set it up, if your battery charge is 100% the junction is ON and will output your throttle control value from the top connection (and you'd want that to be your electric motor) and 0 from the bottom connection (so that would be your diesel engine). If your battery is below 50% charge, the junction is OFF and will output 0 from the top connection (cut the motor) and your throttle to the bottom connection (giving you control to the diesel).

But that means that if you are underwater and your battery charge falls under 50%, you will actually lose control of your ship, so to prevent that you'd have to link your depth detection logic to the engine switching logic to make sure that doesn't happen. It becomes a bit more complex and goes a bit out of my depth.
Ra-Ra-Rasputin Apr 7, 2020 @ 9:02am 
Let me mock the basic setup for you.
Tom Apr 7, 2020 @ 9:20am 
hahaha by theory I had this very well planned,...but seeing it logisticly is alot more complex than I thaught.
Ra-Ra-Rasputin Apr 7, 2020 @ 9:33am 
https://steamcommunity.com/sharedfiles/filedetails/?id=2052000485

Usually things are less complex than you think they are :)
The engine starting button is likely a requirement in a boat which is why i included it, but it's definitely not with wheels. Wheels can kickstart the engine just fine.
Last edited by Ra-Ra-Rasputin; Apr 7, 2020 @ 9:36am
Tom Apr 7, 2020 @ 9:44am 
This is amazing!! Might try to tweak it to add depth condition.. But thank you sooo much Rasputin!! Very different than what I was doing haha Live and Learn. Im going to study this to learn more about the logic and conditions you used cheers


Thank you also @Rashtek for giving advice. Cheers mate!
Last edited by Tom; Apr 7, 2020 @ 9:47am
Ra-Ra-Rasputin Apr 7, 2020 @ 9:57am 
You might want to separate the clutch on/off so you can allow a little bit of power to slip through the clutch as well even with electric drive, it all depends on how you set up the generator :)
Tom Apr 7, 2020 @ 10:08am 
but is it necessary for the gearboxes to be setup like that...would it make a diference if they were between the clutch and power source?..would make more sense..never saw a setup like this
Ra-Ra-Rasputin Apr 7, 2020 @ 10:14am 
They need to be behind the clutch because you don't want the electric motors to generate electricity, you want the electric motors to drive the load.

You don't necessarily need the same setup of gears, but it's just an example.
< >
Showing 1-13 of 13 comments
Per page: 1530 50

Date Posted: Apr 4, 2020 @ 8:23am
Posts: 13