Hello, our team recently built a new robot, and is having a hard time coding the choo choo mechanism for our catapult.
We press the button, and the choo choo motor spins until button is released.
However, it’s hard to get a ball in the choo choo, because when we release the button at the point we want the catapult to stay at, the choo choo rewinds back up.
How can I stop the choo choo from rewinding? I want it to be like when I press the button, the choo choo stays in place until it goes further enough to snap back up.
Our code is currently programmed to just spin the choo choo/catapult motor when pressing a button, and then to stop when released.
what do you mean by stop when its done? if im thinking correctly you want it to stop right before it snaps up? if so, you might need to code it to spin a certain distance and adjust your tension. what type of tension are you using?
Yes you are right, we want it to be programmed right before it snaps back up.
On our previous robot (hero bot) our catapult would shoot up and go automatically down, we want the same for the new robot.
We use choo choo fling too, you can measure the lowest point of your fling when it is being armed, install a bumper switch at that location to detect the bump pressing event.
Program logic:
Setup a global variable to keep track of the fling status, like fling_status (1 = armed, 0 = not armed).
Map a button to spin motor (about 0.8 turn, that is if a full turn will turn the choo a full cycle) to pull down the arm, in a forever loop, use if block to detect when the bumper switch is pressing and fling_status = 0, if yes - immediately stop spinning. Update fling_status to 1. Add a sleep time 0.3s to prevent multiple triggers and jam the fling.
Map another button to spin 0.2 turn again to fire the fling. You may need to tune it to 0.3-0.5 turn to fire the fling. The bumper switch will make sure you don’t overturn and misfire. Update fling_status to 0.