Our team is figuring out compressor code and the hardware was all set up at the correct ports etc. The main issue is that, upon turning on and enabling the robot, the compressor starts and the valve turns on. So then, naturally, we press the button 11 or 12 to pull out or pull in the hatch. But this basically crashes the roborio and turns off the compressor. We have no idea what is going on, and we’re mostly sure that this is a hardware error. We just want to know if this code works since this is our first year using a pneumatics system.
This is for the ball shooter by the way!
Would really appreciate any help. Program down below:
ALSO please note that we have no programming mentors this year, so we are trying to figure this out as best as we can but are struggling technical terms and general usage, etc. But thank you.
There are no error messages but instead the roborio just shuts off for a few seconds and the teleop is disabled. So we manually have to enable it again and the compressor starts up. But after pressing a button, such as 11 or 12, the hatch doesn’t move and the roborio shuts off?
Does the roboRIO actually reboot (status light on the roboRIO will go yellow for a moment), or does the Driver Station Communications light stay lit and the Robot Code light goes red, before coming back to green after a few moments ( a user code crash and restart)?
It sounds like you’ve programmed a crash button.
Usually that’s because the device being referenced in the routine is not within the scope.
P.S.
Is there any particular reason you’re starting multiple compressors?
Normally, no compressor code is necessary at all.
I’d comment out every compressor statement you have in there.
Yes, it rebooted. The reboots took around 2-5~seconds to happen and we had to completely re-enable the robot to restart everything.
We are basing our code off of some source code found online, and we have 3 pneumatics to control the hatch panel. As for the multiple compressors, what do you exactly mean by that? The code was formatted that way, so we kept the compressors that way.
Also, if we comment out every compressor statement, then how would the compressors start to begin with? And how do we control pressure overload?
Sorry about all of these questions but we really would like to figure pneumatics out to some extent by Wednesday.
roboRIO reboots take 30 seconds, so what you are seeing is a user code crash and restart.
When the user code crashes, the Driver Station automatically switches into Disable mode.
The compressor calls are not required, because any creation of a solenoid includes starting the compressor deeper within the call.
The pressure overload is handled automatically by the PCM. It doesn’t want to depend on user code operating properly for safety.
Ah, I see. Thank you. But since we have 3 solenoids, does that mean 3 compressors are being started? Also, then how would we ever turn the compressors off, for example for overheating issues or pressure overloads?
Also, the weird thing is that there was no crash error message or warning message
And alright, good to know the pressure overload is not much of an issue
if you call a solenoid command the PCM will automatically turn on an off the compressor to maintain pressure while the robot is enabled, as for presure overload, that is a purely mechanical system, no code is involved, if the pneumatics over-pressurize, then the safety relief should auto bleed or blow off, depending on the type you have, any excess pressure
The library checks to see that a compressor object already exists and doesn’t create additional ones.
You can create a single instance of a compressor if you want to stop it from running, but you don’t directly control when it does run. That parts automatic.
So if I remove the compressor, should the code work find when called by the joysticks?
Sadly, we put away to robot to end the day of testing 30 minutes ago, but hopefully we’ll be able to test soon. Just wanted to know if the code itself seems fine. We really have no experienced programmers to check it for us
Sorry but could you please elaborate on that? We’re a bit confused as to how to solve that. We’re mostly just instantiating the object and that we’re not really used to other solutions. So far, it seems to have successfully created a solenoid object Robot.java and we can call methods for it.
Ah, in that case you should not create a new Joystick in your Solenoid class. There are a couple ways you could access the joystick from your Solenoid class however I would pass the joystick object to the Solenoid object in the constructor.
Ah, I see, that would make sense. So use it as a parameter?
Also, would it be better to have all of these methods in a Solenoid.java class or would it be better to have everything in the robot.java file as its own big method? If that makes sense, this was one of the ideas we had
You could check your joystick buttons in Robot.java, and then call functions in the Solenoid object, that way you don’t have all your code in a big mess in one place, and also won’t have to worry about passing the joystick around.