Axis Pan+Tilt Servo issue?

Hello -

We’ve installed the Axis Pan and Tilt kit on one of our Axis cameras, but I’m having some issues controlling the servo’s. I’ve written the two servo’s into,, and (all wired to Joystick 3), but they refuse to respond.

Am I going about this in the absolute wrong way? - - -


Servo Set Angle expects an angle (in degrees). The joystick Get axis are from -1 to 1, which isn’t a very big range of angles.

I looked under the example code. Seems the servo’s have a 170 degree limit, whereas the joystick has a 360 degree range of motion. I guess that means a joystick is out as a controller. What else can I use to control the camera?

I could try putting Servo Set Angle with a numeric constant within a case structure and wiring it to a joystick button and seeing if that would work.

Update - Here’s what I threw together. I may edit the buttons once I get the joystick back in front of my face to see the button layout.

Currently, the code sets the servo’s to their home or middle angle. From there, I can mount the camera and have 85 degrees of motion on both pan and tilt.

Later on, I’ll add more case structures mapped to more/different buttons which move the camera to predefined angles. Good idea, or too much to do during teleop?

I added the output values for the joystick to my previous post, because I realized the documentation wasn’t clear at all.

You can use a joystick to control a servo, you just need to use a (simple) equation to scale the joystick value to the range the servo expects.

Oh, I see! I’ll try to get both methods working (joystick and case structures) and see which one our drivers prefer. Will post my results tomorrow.


While you won’t overload the cRIO doing that, it does take some time to program a whole bunch of cases.

True. I might just end up figuring out the equation and running from there.

Just to recap and correct the above comment:

The joysticks get function outputs a range of -1 to +1, floating point. So even though the joystick has a larger range of motion in degrees, it is scaled down by a factor of 127. It is then limited to within that range. (256 units)

Therefore you have to scale your joysticks between this range of 2 to a range of 170.

I’ve gotten it to work, thanks everyone for your help!