Creating a "delay" for a boolean value

Hey everyone, I am a programmer for team 3019 and have a quick question…

Here is the setup. Our kicker works like this. A cylinder pushes a kicker into its locked state, and a servo locks it into place. The cylinder then recedes. (this process is automatic)There is a limit switch to tell the program when it is in its locked state, which then tells it to activate the servo and pull in the cylinder. The problem is that as soon as the limit switch is activate, the cylinder recedes at the same time as the servo latches, and it does not latch fast enough.

So my question is, how can I create a delay for the cylinder, so the servo latches and after x amount of time the cylinder recedes?

The first thing I tried was creating a case structure right before solenoid fire. If the incoming boolean was false (the solenoid is going to retreat) I used a watchdog delay and feed (for the errors i used solenoid open to fire). This works, but it delays the entire robot, and I think logically it would constantly be delayed when the solenoid is not firing. Is there a better way to create this kind of delay?

the best way i have found to do this is in a flat sequence with two cases put a for loop the run amount for the loop is your delay then the second state returns to start over

The best solution for this would be to increment a value, and then check if is has reached a certain value. The idea behind it is that given a known period, you can approximate values by repeating that period a certain number of times, all while not having a program get hung up in a loop. You could achieve this by doing a simple if (value >= WhatIWant), do this, else value++ type thing. Or, you could do what I did and check the robot time, (A) because it automatically increments itself, and (B) because it is not dependent on processor time. I know this would be pretty straight forward in c++/java, and can only hope it is the same with labview. Hope this helps.

Could you elaborate on this with a screenshot or something? I think I know what you mean, and I will try it first.

I don’t know if this is the “best” way but I wrote these Boolean modifiers. The timing ones store a value and then compare it every loop. THese are fine to use in teleop, actually best to use there.


Boolean Programming (33.3 KB)

Boolean Programming (33.3 KB)

Thanks! Did I implement this properly? You can see am delaying the false value going into the solenoid set. I think this outputs a false value.And the delay is 2 seconds.

I always use them as SubVi-s. So unwrapping them I’m not sure I’ll have to look in a bit. You should be able to set up some momentary boolean and have it output a boolean that stays true or false for the millisecond value.

They are set to be “reentrant” so you can use them wherever you want and not have race conditions.

I was using one in periodic yesterday and it didn’t behave as expected, but then I passed it back into teleop with a global and it was fine.

Sometimes I’ll daisy-chain them together for doing multiple timings or sequential timing.

The latch switch ignores re-pressing so you can use the one-loop-latch as a trigger to the countdown vi if you need an exact timing length.

Ok. I guess since I don’t know what the boolean that is controling the case statement is doing, I don’t know what this will do.

This attached photo is typically how I wire it.

Try it out in a test blank VI with a while loop.

The boolean controlling the case structure is the incoming boolean for the solenoid. It’s set up that way because I only want a delay when the false value is coming in. I will try what you suggested. What I had before didn’t work though…Does it matter if its unwrapped or not?

Reading your description again, I think that the lower example that I showed would work for what you want:

When the incoming boolean goes true, it activates the “one-loop-latch” which is basically a modifier that makes the output true for only one loop. That will activate the countdown and make it true for just 2000 ms after the boolean input goes true.

If you wire it up as in the top example, the output will be held true for as long as the input is true plus 2000 ms before going false.

I hope this helps and not too late. We had another late night.

Sten will detect a rising edge of a boolean like your limit switch. You can change it to detect a falling edge.

The output Boolean will remain high for the amount of time that is passed in.
You can invert the output is needed. (11.6 KB) (11.6 KB)