I am rewriting the code for an old 2010 robot in 2011 style code.
the kicker is cocked by a pnuematic. when the kicker is kicked, the 3 double solenoids flip directions and springs kick the kicker.
I have figured out how to set it so it so it kicks when the kick button is held. I also have it so if it is kicked with button x, it kicks low, button y kicks medium, and button z kicks high using how many solenoids are activated (to control flow)
I am trying to make the solenoid go forward for 500ms and then retract (reverse) when a button is tapped (not held). i was told by the team’s lead programmer to use a flat sequence structure.
I thought that i read that flat sequences were not allowed in teleop.vi. Also, i am not sure if a flat sequence is the right way to go.
any thoughts on what approach I should use?
I am considering using one button to kick and 3 others to set kick power. as it is now, I could rewrite it so holding such power button while kicking would set power (no button held defaults to full power). not what i want. I would like to make it so hitting (not holding) the proper power button sets the power until another power button is hit. I am not sure how to do that.
I am a bit of a noob on this…
A flat sequence is okay, but it goes in Periodic Tasks, not Teleop.
Teleop needs to remain streamlined, quick and simple, to keep up the 50Hz loop rate.
I wouldn’t recommend putting much more than the basic drive train in there, unless it’s direct joystick control of something.
Periodic Tasks is made for timed, sensor triggered, and sequenced events.
Tasks within it are also shared with both Autonomous and Teleop, although I imagine Auto isn’t of much concern to you with an old robot.
no sensors to speak of other than the pressure sensor for the compressor.
so the button presses must be in periodic? i though that anything buttons only had to be in teleop?
The driver inputs, buttons and joysticks alike, can be checked anywhere you need to know what they are.
Periodic Tasks need to be within one of the infinite While loops there, so it keeps checking for a value change and your sequence can be repeated when it’s needed.
I added a new while loop to the periodic tasks.
attached is the image of what is in the loop.
does it look right?
if so, then what about the 3 switch power toggle thing? if my controller (usb converted xbox) had a 3 way switch, then i’d use that. i don’t, so what do i do? I think there might be a shift register involved… but I am not 100% sure.
You’re going to need to throttle that loop. Without a wait like what’s in the other periodic task loops, it’ll run full bore and eat up all the CPU time it can. 50 ms is probably a good value.
Otherwise, it looks okay, except that I can’t tell what’s in the other cases of the power selection. The contents should be obvious, but there’s always the chance that something got miswired by mistake.
well, the problem is that in the loop is a flat sequence, with 2 frames. the first is timed for either 500, 625, or 750 ms (depends on kicking power), and the second is always 500ms
i thought that by itself would server as timing enough…
the power button has me confused… if this were digital electronics, all i would do is wire a nor gate to each reset of the flip-flop… but this isn’t that
I think i fixed it.
I found in the function block menu flip-flops. i used those to set the 3 button system. being an electronics guy, i knew how to wire them to do what i wanted.
I also moved the button/flip-flop section to the teleop.vi and clustered the kick boolean and the enum kick power to the periodic tasks.vi . i did it this way to make a future dashboard and/or autonomous project more modular.
i attached the teleop and periodic halves of the kick code. (well, screenshots)
edit- (not in pictures) i changed the cluster wire to a global variable. that way I can add it to my custom dashboard (I did, thanks to a tut. video), and if i want to do an autonomous demo, I can use the kicker without creating a conflict.