![]() |
? programming servos
we are having a heck of a time progrmming the servos for the camera.
We are trying to make the X-axis servo turn with the X-axis of the joystick and the Y-axis servo turn with the Y-axis of the joystick. We have no clue. we tried some code that tests the max and min angles but what happened is a watchdog error saying it was not fed. We are perplexed at this stuff. Does anyone have the capabilities to move the camera with servos. and would yo be willing to paste it for us to look at? |
Re: ? programming servos
If you're having problems with the watchdog, remember to feed it really often.
If your code cannot do this comfortably (see: Constant 'wait's), then do Code:
GetWatchdog().SetEnabled(false);Please note that disabling it this takes a large layer of safety away from your robot, so try to keep your Watchdog enabled as often as you can... Good luck getting Servos to work. :D |
Re: ? programming servos
First, you need to make sure you actually have your servos connected properly and that they actually work, before trying to do something more complex with them. Heres an example MyRobot.cpp that will help you do that (I've compiled this, but haven't tested it -- but it should work just fine).
Code:
#include "WPILib.h" |
Re: ? programming servos
I don't know why you are getting watchdog timer errors and can't tell without seeing your code. However, there are a few things about servos that you should be aware of. One, Make sure that there is a jumper on the digital sidecar associated with the PWM output that is driving your servo. That supplies power to the servo and it won't work without the jumper. The jumper goes right next to the PWM output. Two, the servo class takes a value between 0.0 and 1.0, not the -1.0 to 1.0 that you get from your joystick. You should add 1.0 to your joystick value and then divide by 2.
|
Re: ? programming servos
Ahh thanks for the sample code. The servo is fully functioning. the tips for adjusting the servo values helped too thanks. Just onbe step at a time for us.
If someone doesnt mind responding, how do we deal with analog inputs? We are trying to use a potentiometer. |
Re: ? programming servos
to declare one is fairly easy,
try: AnalogChannel *pot; pot=new AnalogChannel(<channel>); then to get the voltage from it: pot->GetVoltage(); check out the c++ help files, they explain a fair amount, not always in the best of detail but usually enough to use things |
| All times are GMT -5. The time now is 13:02. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi