Trying to make a circuit event based on a changing rail signal

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
DisRuptive1
Burner Inserter
Burner Inserter
Posts: 6
Joined: Mon Mar 20, 2017 5:35 am
Contact:

Trying to make a circuit event based on a changing rail signal

Post by DisRuptive1 »

I have one rail signal that I want to keep red most of the time. However, when another rail signal goes from green to red (another train returning to its station), I want the original rail signal to turn green for a given number of seconds (5 or more, long enough for the train to leave the station). I can't figure out how to do it though.

I'm not looking for alternatives to my problem but rather how I can solve it with circuits.

UPDATE: I think I solved my problem:

Last edited by DisRuptive1 on Sat Oct 10, 2020 1:54 am, edited 3 times in total.

Premu
Fast Inserter
Fast Inserter
Posts: 100
Joined: Wed Nov 13, 2019 4:40 pm
Contact:

Re: Trying to make a circuit event based on a changing rail signal

Post by Premu »

You need to combine a clock with a reset condition. Here's a short mockup which you could adapt:



The second signal closes if the timer C is over 150 (which happens after 5s) or if the first signal is green.
The timer tries to count up, but is reset to 0 if the first signal is not red. If the first signal turns red, there is a five second window in which the second signal turns green.

MassiveDynamic
Filter Inserter
Filter Inserter
Posts: 260
Joined: Sun Sep 16, 2018 10:44 pm
Contact:

Re: Trying to make a circuit event based on a changing rail signal

Post by MassiveDynamic »

DisRuptive1 wrote:
Sat Oct 03, 2020 7:26 pm
I have one rail signal that I want to keep red most of the time. However, when another rail signal goes from green to red (another train returning to its station), I want the original rail signal to turn green for a given number of seconds (5 or more, long enough for the train to leave the station). I can't figure out how to do it though.
This is an interesting problem. Can you explain what and why exactly you are doing here? With screenshots?
I would like to try to solve this but I can’t think of a reason to do this, which is making it difficult to reproduce.

User avatar
Nosferatu
Fast Inserter
Fast Inserter
Posts: 228
Joined: Fri Jan 20, 2017 4:48 pm
Contact:

Re: Trying to make a circuit event based on a changing rail signal

Post by Nosferatu »

I would not do that with a clock.
You could read a second signal that is placed after the controlled one to check if the train has passed

DisRuptive1
Burner Inserter
Burner Inserter
Posts: 6
Joined: Mon Mar 20, 2017 5:35 am
Contact:

Re: Trying to make a circuit event based on a changing rail signal

Post by DisRuptive1 »

MassiveDynamic wrote:
Sun Oct 04, 2020 12:31 am
This is an interesting problem. Can you explain what and why exactly you are doing here? With screenshots?
I would like to try to solve this but I can’t think of a reason to do this, which is making it difficult to reproduce.
I can explain what I'm trying to do but I got a lot of flak about it on Reddit when I tried to ask for help there. Just be aware that I don't want to remake my problem and solve it with a more simpler method, but instead solve the problem I have (with circuits) in the hopes that I might learn something in the process.

I have two refueling trains on different parts of the map that each carry a different type of fuel; one carries Coke (a modded fuel slightly better than coal) and the other has solid fuel. Both of their starting points can be connected by circuits if necessary.

At each of the drop off stations for my various substances (currently coal, oil, copper, and iron), I also have a refueling station set up for the refueling train. Both refueling trains have every refueling station in their station list. Each refueling station is turned off when the adjacent drop off station has enough fuel to refuel any trains that come through. When the drop off stations run low, the refueling station turns on which summons the refueling train which then refuels the drop off station, and when the fuel is high enough, the refueling station turns off. The refueling train then goes back to its starting location to top up on fuel.

I want to prioritize one train over another even though the same event will set them both in motion. I'm trying to keep the Coke train in its station until the Solid Fuel train returns because I want the more efficient fuel to go out over the less efficient fuel. The one way I could track this is through the chain signal behind the Solid Fuel train. When the Solid Fuel train leaves the station, it will go from red to green. When it returns, it will go from green to red. At this point, the Coke train would be given an opportunity to leave the station and it would have a reason to do so if the Solid Fuel train couldn't quite refuel the station that summoned it.

Theikkru
Filter Inserter
Filter Inserter
Posts: 354
Joined: Wed Mar 27, 2019 2:18 pm
Contact:

Re: Trying to make a circuit event based on a changing rail signal

Post by Theikkru »

This depends on what you're actually trying to accomplish here. If you want a way to send the coke train out when the solid fuel train returns, the most appropriate solution is to tell the coke train to leave its home stop on a circuit condition, and use an edge-finder circuit to send a pulse to that stop whenever the solid fuel train returns to its station.
If you really just want to learn how to set up a timed signal on a trigger, see save below. I've set up a simple circuit that demonstrates how an edge-finder circuit, a positive signal filter, and a sticky clock can send out a signal for a specific length of game time whenever a state change (e.g. rail signal change) occurs.
If you want to learn more about different useful circuits, see the combinator tutorial on the wiki.
Attachments
clockdem.zip
(2.08 MiB) Downloaded 63 times

MassiveDynamic
Filter Inserter
Filter Inserter
Posts: 260
Joined: Sun Sep 16, 2018 10:44 pm
Contact:

Re: Trying to make a circuit event based on a changing rail signal

Post by MassiveDynamic »

Would it make sense to check the cargo level of the solid fuel train when it is in the station, and if it is low or empty then open the latch on the coke train?

User avatar
Nosferatu
Fast Inserter
Fast Inserter
Posts: 228
Joined: Fri Jan 20, 2017 4:48 pm
Contact:

Re: Trying to make a circuit event based on a changing rail signal

Post by Nosferatu »

I think a clock is not needed.
Just wire the signal at the entrance of your solid fuel station to the coal station.
Set the coal station to send signal to train and set the train to leave on circuit condition yellow = 1

DisRuptive1
Burner Inserter
Burner Inserter
Posts: 6
Joined: Mon Mar 20, 2017 5:35 am
Contact:

Re: Trying to make a circuit event based on a changing rail signal

Post by DisRuptive1 »

MassiveDynamic wrote:
Thu Oct 08, 2020 1:14 pm
Would it make sense to check the cargo level of the solid fuel train when it is in the station, and if it is low or empty then open the latch on the coke train?
Yes, I saw this problem when I realized the whole point of my setup was for in case the Solid Fuel train became low on cargo. I didn't want to send it out and have it waste fuel during a time when my fuel was lowest so I set up a second signal to release the coal train in these specific circumstances.
Nosferatu wrote:
Thu Oct 08, 2020 8:08 pm
I think a clock is not needed.
I ended up using a clock. I restricted the coal train to its station and then used a self-resetting timer to give it a small window to leave its station once the solid fuel train returned. In testing, you really only need to give it half a second to leave if the signal is directly next to the station.
Set the coal station to send signal to train and set the train to leave on circuit condition yellow = 1
There was another issue I ran into which happens when the solid fuel train doesn't leave its station because it doesn't have enough fuel (I don't want trains to go if they don't have enough cargo). If it doesn't leave the station, it doesn't trigger the rail signal at the station's entrance. So I had to figure out a way to release the coal train if the solid fuel train was stuck in its station without enough cargo.

---

I've solved the problem and put the blue print in the OP in case anyone else wants to use it.

Image
Image

Post Reply

Return to “Gameplay Help”