How can I set a circuit to turn on immediately but delay turn off?

Discussion in 'General Discussion' started by iamnoobplzhelp, Jun 25, 2019.

  1. iamnoobplzhelp

    iamnoobplzhelp Lieutenant

    Joined:
    Apr 27, 2019
    Messages:
    18
    Likes Received:
    4
    So I am trying to set a retractable sentry gun to turn on immediately when the motion sensor detects something, but wait 30s after something leaves to turn back off.

    So far I have these circuits:
    Motion Sensor: MS1, a 10S delay on that switch, and then an inverter on the 10S Delay
    Finally, I have a Set/Rest Latch

    Using this, I have the 2nd part working, where it turns off after 30s (using 10s in example screenshot for faster testing)

    But, it also takes 10s to turn on, even though the "set" is the motion sensor signal.

    How do I get the light to turn on immediately but wait 10s after leaving the motion sensor area to turn off?
     

    Attached Files:

    #1
  2. Ravis

    Ravis Captain

    Joined:
    May 17, 2017
    Messages:
    143
    Likes Received:
    229
    Not a pro at this but...
    Set a signal to activate sentry and the delay signal to the turn it off. On a set reset signal you don't need the inverter.
     
    #2
  3. iamnoobplzhelp

    iamnoobplzhelp Lieutenant

    Joined:
    Apr 27, 2019
    Messages:
    18
    Likes Received:
    4
    Thanks for the suggestion. Unfortunately, lights, turrets, and other devices only have a single On/Off signal. There isn't one for ON and one for OFF. That's why I have the Set/Reset Latch.

    And, you do need the inverter on the delay. The delay will give a signal ON(1) after 10 seconds. The Reset portion of the latch needs an OFF(0) signal to get it to actually reset, hence the inverter.

    Without the inverter, it takes 10 seconds to turn on, but turns off immediately once you leave the motion sensor zone.
     
    #3
  4. Jacoviz

    Jacoviz Captain

    Joined:
    May 13, 2017
    Messages:
    138
    Likes Received:
    164
    Another thing that would need some semplification, the circuitry system is difficult to understand right now
     
    #4
  5. iamnoobplzhelp

    iamnoobplzhelp Lieutenant

    Joined:
    Apr 27, 2019
    Messages:
    18
    Likes Received:
    4
    I agree. There isn't any type of tutorial that explains how things work. There are user made ones, but an official, in game one would help a bunch.
     
    #5
    Jacoviz likes this.
  6. Vermillion

    Vermillion Rear Admiral

    Joined:
    Jul 15, 2018
    Messages:
    3,286
    Likes Received:
    8,956
    1. Sensor sends signal. Let's call it "Scan01"
    2. Add Delay Circuit for 30 seconds called "Sig001"
    3. Add Set/Reset Latch using "Scan01" and "Sig001" outputs "Sig002"
    4. Sentry Turret is set to follow "Sig002"
    With this, the sensor triggers the set/reset latch and enables the turret; the delay circuit activates 30 seconds later and turns off the turret.
    Inverter isn't necessary.
    An issue is that if someone stands inside the motion sensor's field for longer than the 30 second timer, the turret will remain active but close when they leave the sensor's range. A light barrier would work better for a short precise interval instead of a motion sensor, but a sensor is more accurate with a wider range and will keep the turret active as long as there's a target to shoot.
    If you want a light to activate immediately, have it activated by Scan01, unless you want it to activate for the same duration as the turret, in which case you'll want it to run on Sig002 like the turret.

    The real problem in your design is that you want the turret to close 30 seconds after the target has left, but the means of making a sensor activate the turret for as long as someone's standing in the field and turn off after another 30 second delay would require another delay timer and a different configuration.
     
    #6
    iamnoobplzhelp likes this.
  7. iamnoobplzhelp

    iamnoobplzhelp Lieutenant

    Joined:
    Apr 27, 2019
    Messages:
    18
    Likes Received:
    4
    This was exactly my setup, and it wasn't working. (Other than the inverter)

    And the problem isn't that the turret isn't closing 30s after the target as left. That part is working correctly. The problem is that it takes 30s for the light/turret to actually turn on, too, even though it's set to turn on with Scan01. Try it yourself. I've made it like 10 different times and I get exactly the same behavior. At this point, I think it's actually a bug.
     
    #7
  8. Vermillion

    Vermillion Rear Admiral

    Joined:
    Jul 15, 2018
    Messages:
    3,286
    Likes Received:
    8,956
    I did try it myself. I made the circuit before I posted it here. It worked fine for me.
    It's the inverter that's breaking yours. It's adding a step that's causing the latch circuit that activates the turret to set last.
     
    #8
    dpburke2 likes this.
  9. cp6891

    cp6891 Captain

    Joined:
    Mar 24, 2017
    Messages:
    5
    Likes Received:
    3
    I beleive I understand your problem. I've noticed it too. You set a motion sensor to turn on a light and when you enter the sensor field it takes 5 - 10 seconds for the light to actually come on. It seems the delay is more likely and longer the more devices are connected to the sensor. I don't know if this is a bug of some sort or something that just needs some polishing but it is frustrating. In your case, with the delay turrets seem to have anyway in targeting combined with the delay from the sensor it almost makes the turrt useless.
     
    #9
  10. Stamper

    Stamper Ensign

    Joined:
    Jan 5, 2022
    Messages:
    2
    Likes Received:
    0
    Hi, I know this is an old post, but I was searching for a solution to a similar task I wanted to perform and was having the same issue as the OP describes. In the end, I managed to understand the issue and found a solution.

    The issue is the Delay Trigger, once it is set high, it needs to be set low again for the delay to be reset.

    Here is my solution:
    I use a pulse to set the reset trigger high then low after 1 second
    HangerDoor is the Sensor
    HDLights is the Signal used to control a light (Could be a Turret of course)
    The delay is 5 seconds

    https://imgur.com/a/vut1Tv6

    hope this helps anyone else also looking for a delay off switch
     
    #10
  11. Krepper

    Krepper Ensign

    Joined:
    Feb 26, 2023
    Messages:
    2
    Likes Received:
    0
    Hello folks! Here's a little help with your digital logic problem. You can actually do this relatively easily with only 2 circuits, no need for an inverter or latch circuit. In boolean syntax what you can do is: Sensor OR Delay(Sensor) = output.

    In game "circuit" just take your sensor - could be a motion sensor, lever (switch), another circuit, any input - and put that into a delay circuit. Call it something like "DelayedSensor1".
    Then create a second circuit with an OR, and the inputs to that one are "Sensor1", "DelayedSensor1", output can be "OrControl". Assign the thing you want to control to "follow" "OrControl".

    That's it! How does it work?

    When the Sensor input turns on, the OR will get set (on) and will stay on as long as either Sensor1 or DelayedSensor1 are on. At the same time, the "DelayedSensor1" will stay off for x seconds delay and then switch on as well (but doesn't matter because Sensor1 is already on and already "shortcircuiting" the OR...) When Sensor1 turns off, the DelayedSensor1 will stay on for x seconds, keeping the OR output ON until the delay runs out. Once the delay runs out, it switches off... now BOTH Sensor1 and DelayedSensor1 are both off, so the output goes off. Easy Peasy!!
     
    #11
  12. The Android

    The Android Lieutenant

    Joined:
    Dec 29, 2022
    Messages:
    49
    Likes Received:
    23
    Sorry, this doesn't work but I see where you are going. The delay signal is set at the end of the signal, and unless you are in the trigger zone longer than the delay it won't stay on. Delays are also kind of a memory device as well they hold their state until the delay period is up.

    Let's keep this simple. Sensor -> light. Step in sensor, light comes on, leave sensor light stays on for 5 seconds.

    The issue with your OR gate solution is the first delay isn't covered. If you step in the sensor and step out, then the light will turn off because the first delay hasn't expired and DelaySensor is still 0. In 5 seconds the light will blink on for however long you were in the sensor (up to 5 seconds).

    I've not completely tested this, but it seems to work with some simple lights. You can recreate it by using 4 lights and a sensor.

    Sensor
    DelaySensor (set for 5 seconds)
    SRLatch
    S : Sensor
    R: DelaySensor
    Trigger = 4xOR :
    Sensor
    SRLatch
    DelaySensor
    (4th input should be set to 0, but there's a bug where that doesn't always work. Set it to Sensor as a work around)​

    That way, the light will be on if the Sensor is set, it's before the first delay, and while the delay is running. If the sensor is still on, it'll keep running. From my tests it seems to keep the light on for about an extra second, but it seems to be consistent. (so far)
     
    #12
  13. shortName

    shortName Lieutenant

    Joined:
    Oct 12, 2023
    Messages:
    106
    Likes Received:
    4
    The latch thingy is buggy. Apparently it's supposed to set an output signal to ON when an input signal is ON and to keep the output ON until it's reset by a second signal when the second signal changes (or when the second signal is ON, but that would leave the question what to do when both input and reset signal are ON).

    It would make sense if it were working. I haven't been able to figure out what it actually does.

    Another problem is that you can't decide in which order circuits happen, like do you want a signal inverted before or after X, a delay to begin before or after X, etc.. And an IF circuit is missing entirely :(

    The best advice is not to use circuits at all. Otherwise you quickly end up with too many unwanted effects. I guess the lesson is not to try to simulate hardware in software ...

    There's reasons why I keep saying that if the rockets that were sent to the moon had computers controlling them like they nowadays would have, they'd never have made it.
     
    #13
    Last edited: Oct 28, 2023
  14. The Android

    The Android Lieutenant

    Joined:
    Dec 29, 2022
    Messages:
    49
    Likes Received:
    23
    I approach Empyrion's logic as a state machine. There is no order they are either set or not all at the same time.

    From my experience the state of the latch with both the set and reset on is indeterminate. It's not a good answer, but it is what it is.

    So far my delay system has been working as intended. The delay is not accurate by any means (I've found that changing the delay value changes the actual cycle time in "non-linear" ways) but so far I've found it consistent.

    As for the rockets and computers, the latest moon mission(s) would say different. That being said, this game isn't NASA...
     
    #14
  15. shortName

    shortName Lieutenant

    Joined:
    Oct 12, 2023
    Messages:
    106
    Likes Received:
    4
    When you see it as a state machine, how would you know what state it assumes without knowing what the order in which its elements you configure, which determine which state it will assume depending on its inputs, is? I'd call it a black box instead, and I'd rather be able to decide which order I want. Not being able to do that is very confusing.

    You can't intentionally make a cake when you have only the ingredients, the tools and the required instructions but have no idea in which order the instructions need to be performed to bring the cake about. --- Did you ever bake or cook with kids? It's fun, and it's interesting to see what they don't know yet :)

    The only thing I accomplished with the latch thing is that two doors would continously open and close interchangeably, with wasn't at all what I wanted, and IIRC that can be achieved without the latch thing.


    As to the rockets, they haven't sent people to the moon lately, did they?

    NASA and whoever goes to space does accomplish amazing things, and what makes it so amazing is that they ultimately can not do tests and yet what they do mostly works. I guess you can only really understand and appreciate that when you put stuff together (like deploying a new server) or create something new (like a new piece of software) and see first hand how you can not get around thorougly testing what you have envisioned. It usually doesn't work right away. When going to space, you can't do that kind of testing, and what you created simply has to work; otherwise, people will die, and/or the failure is a very expensive one, and a lot of resources have been wasted.

    In a way, it's very similar to cooking and baking. It takes quite some experience to get it right.
     
    #15
  16. The Android

    The Android Lieutenant

    Joined:
    Dec 29, 2022
    Messages:
    49
    Likes Received:
    23
    Sorry for the late reply, but all I can say is check out Google...

    I'm not going to argue known computing science methods and theories. Read this and figure it out:

    https://en.wikipedia.org/wiki/Finite-state_machine

    It is what it is. I'm using the above on my CV to open and close my lower ramp on a ~3 second delay. Works every time, no issues.
     
    #16

Share This Page