I have an issue with my flywheel motor, number 6 randomly disconnecting from the brain and the flywheel not working correctly.
I would like to have some sort of rumble and alert on the controller to let me know if a motor has disconnected, and which one has disconnected, just by showing a number or something. On the controller. I just figured out rumble, and I know how to type something on the controller, the hard part is getting the brain to tell you that the motor is disconnected.
Keep in mind that I am using block code, and I donât really care how long the code is to get it to work.
A way to not need to make this, (as Iâm pretty sure it is not possible), is to just switch the port or wire of the motor so that a disconnect doesnât happen.
Hope this helps, will be happy to help with anything else!
- Henry 344E
I know you can definitely do that, In fact port 1 on the brain was dead, so my drivetrain is actually motors 2,3,4, and 9. This is because I ran out of holes on the top of the brain, and the bottom of the brain is very out of the way and low to the ground, so Itâs not exactly an option for plugging things into. I kinda just want a way to tell when it disconnects so I know not to use they flywheels during a match so i donât damage them.
No,
Ports 2,3,4,9 are drivetrain
Port 8 is the intake
Port 6 and 7 are the flywheels
Port 5 is the indexer
Port 1 and 10 are both dead
The one on the side is the radio (21?)
The installed() motor class member function will tell you if a motor is installed on a particular port. example of use.
while(1) {
for(int port=PORT1;port<PORT22;port++) {
vex::motor m(port);
if( m.installed() ) {
// do something with a detected motor
}
else {
// no motor on this port
}
}
this_thread::sleep_for(100);
}
How do you make a toggle? LIke, press the button once to start a motor spinning, and press the same button again to stop. I havenât figured out how to do that.
Can I put an If statement around the whole thing saying that x was pressed, due to competition code and the fact that it has to be in one long list of code?
It does not need to be in a single long list of code, that would be difficult to navigate at least for me. You can multithread (use multiple âwhen driver controlâ hat blocks), and the code shown by Hudsonville_Robotics would work fine in a competition bot, as long as you donât press the trigger during autonomous. I am not sure if the field control automatically disables the controller during auton period, but if you would like to avoid an accidental autonomous-control activation, you could code the bot to disable the controller until driver control starts. However, the code you showed would work fine, just wouldnât be the main choice for lots of people Iâve met.
It doesnât have to be in one long list of code. The advantage of events is that they separate the responsibilities of the code. The competition template knows how to handle events too.
If you donât want to use events, then you need to add a latching variable. Events fire one time for each button press. If you are using an in-line if statement, the code fires once for every loop. This means that your code would repeat on - off - on - off when you held the button down. The latch adds an extra layer that locks the state after it has changed one time.
Thatâs interesting. Iâm really not a coder, we had a coder last year but he went to another team, and I was willing to try it. I was told by the rest of my team that hat blocks wouldnât work in driver control at all. Iâll seperate the code and try it in the future