![]() |
Motors/solenoids won't work; Can't print to console
I don't know what to do. I'm out of ideas. I go to a small, rural high school, that doesn't offer any programming classes, so I've taught myself some coding over the past few months. My code looks fine, and I can't find any mistakes in it, but for whatever reason, nothing on the robot (other than driving) will work. None of the solenoids extend, none of the window motors turn...nothing. I've nested a few print statements throughout my code, but they aren't printing to the console when the robot is running. Can someone take a look at my code, and tell me if there are any glaring mistakes? I know it's a lot to ask, but I don't have any other options at this point. Thank you all so much in advance. (By the way, our robot has a pneumatic-powered arm, sort of like a tractor backhoe or excavator. The arm rotates on a window motor. It also shoots by pushing the ball with a solenoid into 2 spinning motors.)
Code:
#include "WPILib.h" |
Re: Motors/solenoids won't work; Can't print to console
I'm more used to looking at Java than C++, so maybe I'm just missing it, but I don't see where either stick or stick2 are constructed. I would expect this code to throw null pointer exceptions all over the place.
|
Re: Motors/solenoids won't work; Can't print to console
They're constructed under the Robot class definition, right?
Code:
class Robot: public IterativeRobot |
Re: Motors/solenoids won't work; Can't print to console
Any messages or in the console log? Maybe a "timeout expired"? I don't see any calls to enable or disable motor safety.
Check the mapping of the joystick in the driver's station and make sure it works by monitoring it in the driver's station diagnostics. I would put some prints in some obvious places that always called to make sure your code is getting compiled and deployed successfully, for example, print out the value of joystick2Y before comparing it. You could also print "Hey I'm alive!" in TeleopInit() |
Re: Motors/solenoids won't work; Can't print to console
Yeah, we get the timeout expired one occasionally. And I've nested a few more print statements. What do you mean by enable/disable motor safety?
|
Re: Motors/solenoids won't work; Can't print to console
I don't see anything obviously wrong with the code. How's your wiring?
Seriously, where do you have the motors wired to? I assume they're Spike relay modules, but which connectors? What are the Spikes' LED indicators doing? How do you have the wires run between the Spike and roboRIO? Similarly with the pneumatic solenoids, what are they connected to? Assuming it's a PCM, what are its LEDs showing you? |
Re: Motors/solenoids won't work; Can't print to console
I got the solenoids working. The motors are wired into the spike relays, and the spikes are wired into the power distribution board and the Relay ports on the roboRIO. We're pretty sure that our spikes are broken somehow. I wrote this block that should just turn on the motors and leave them spinning as long as TeleOp is enabled. I've tried a few variations of this, and the motors still won't turn on. Logic dictates that if the relays were working, they'd be continuously running, right?
Code:
void TeleopPeriodic() |
Re: Motors/solenoids won't work; Can't print to console
Quote:
|
Re: Motors/solenoids won't work; Can't print to console
Quote:
You also aren't telling us what the Spike's LED is doing. What color is it when you apply power? What color is it when you enable the robot? What color is it when you're trying to run the motor? Quote:
Do you see the "A motor should be on" message printing 50 times a second? |
Re: Motors/solenoids won't work; Can't print to console
We checked our wiring with the diagrams, and it all matches. The LED on the relays is either off, or orange. Are there any guides or pictures online for wiring a spike relay?
|
Re: Motors/solenoids won't work; Can't print to console
Quote:
If the LED goes straight from orange to black, this means that both sides of the relay are switching at the same time (or that you're losing power). It appears you are using kForward not kOn, so I'll move on to hardware. The first thing I can think of is that the red and white wires on your "PWM" data cable are shorted to each other, or that there is a similar short in your RIO or Spike. If the cable tests OK, look in the connector wells for swarf (metal shavings) or other conductive material. Edit: If you get through all of those, put a meter or the output of the data cable and see what you get. When the motor is supposed to be going forward, you should get 0V on red and 5V on white (using the black data wire as a reference). It looks like you are having both go to 5V at the same time. |
Re: Motors/solenoids won't work; Can't print to console
Quote:
If you don't know how to wire a Spike, how can you say that it matches? You might not be understanding the right way to do it. Please answer the questions and let us help you. Tell us exactly where and what each of the seven connections on the Spike (GND, 12V, M+, M-, white, red, and black) is wired to. Be more specific and detailed than you think you need to, including everything that you think you're doing right, because you might be wrong about what right means. Quote:
Also show us the rest of your code, so we can verify that you're defining and initializing the relay objects properly. |
| All times are GMT -5. The time now is 10:24 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi