![]() |
Problems running servos
Hi everyone,
I am a coach on Team 3373 out of Warrenton, VA. Recently, our programming team was writing some code for a generic servo (I didn't think it was necessary to label the part number) in order to make sure we know how to write the code. Displaying only the relevant portions, we defined a joystick (in Module 1) and a servo instance. Then we initialized the servo instance. We physically connected it to Module 2, Port/Channel 9. Afterwards, we noted because the joystick GetRawAxis function assumes values from [-1,1] and the Servo Set function assumes values from [0,1] we did a little algebra on the Servo Set argument. Lastly, I printed to the driver station the value of the Servo Set argument and I saw it change as I moved the Xbox joystick. HOWEVER, the servo itself does not move. We do have other code written (not displayed) which moves a motor and gets camera feed etc. which all work fine. But for whatever reason we cannot get the Servo to work. There are a limited number of functions for the Servo class so between trying different things and looking on Google, we just need a fresh pair of eyes. Can anyone make any suggestions? The code compiles when we run it. We obtained the skeleton of it from the Simple Robot Template in Windriver. Many thanks, Brian #####BEGIN CODE ##### #include “WPILib.h” class RobotDemo : public SimpleRobot { Joystick Xbox; Servo Elevation; public: RobotDemo() Xbox(1), Elevation(2,9) { /* GetWatchdog().SetEnabled(false); */ } void Autonomous() { /* commented out code */ } void OperatorControl() { while (IsOperatorControl()) { Elevation.Set((Xbox.GetRawAxis(5)+1)/2); } } }; START_ROBOT_CLASS(RobotDemo); #####END CODE ##### |
Re: Problems running servos
I'm not fluent in that language at all, but the first thing I would check is to see if you have a jumper on the pins next to the servo output. Without that jumper, the servo will not get power to move at all.
|
Re: Problems running servos
Quote:
Codewise: Try hardcoding a value and verify that it is (or isn't) hardware. If the hardcoded value works and the code doesn't. Good luck! |
Re: Problems running servos
One possible problem is that your servo is unusual and doesn't operate on the conventional signal range. We've encountered this problem before with Parallax servos. As a reference (I'm not sure about the actual DS output), since Hitec servos are the brand that FIRST recommends,
Quote:
|
Re: Problems running servos
Did you remember to connect the 6V jumper for Servo power on the Digital Sidecar?
|
Re: Problems running servos
Hi everyone,
Thank you so much for your inputs (no pun intended ;) One thought I did have was to make sure the port we are using has a recorded 6 V difference on the DSC which it does. I also did hardcode a value in for the servo and no response. The DSC is also getting power since we have other hardware hooked into it and it is functioning properly with the correct C++ code. I never thought about the servo not operating in the conventional signal range so that is something to look at. I am new to FRC so I am still learning where things go etc., but I do know some programming so I feel reasonably confident that the code is correct, especially since the analogous code for the motors work fine. For feverittm: If the 6V jumper were not present, what would happen? In other words, would there still be a voltage difference across the leads? Thanks everyone for your quick replies. |
Re: Problems running servos
The jumper is what applies the 5 Volt power to the hot pin on the pwm / servo outputs. Without it, the servos get no power.
|
Re: Problems running servos
In your code, change the digital module to 1, instead of 2.
|
Re: Problems running servos
What Joe said. Module numbers =/= Slot numbers, it's a semantics change this year that chokes people up who haven't followed everything. Once that changes, it should work fine.
|
Re: Problems running servos
Changing the module to 1 did work!! Thank you so much for the help!!
|
| All times are GMT -5. The time now is 05:28. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi