<< return to Pixycam.com

Pixy2 Pan/Tilt How to Limit Servo's range of movement

Hello,

I have a robotic project which uses the Pixy2, mounted to a robot’s head, to look at an object. The robot’s head design only allows it to tilt a small amount before it collides with the chassis of the robot’s torso. So, I am attempting to limit how far the Pix2 will move the tilt servos when tracking an object.

I ran rcs_getPos in PixyMon console and the maximum range of movement the head’s design will allow is 640 - 370. 640 is looking up and 370 is looking down.

So I attempted to use the rcs_setLimits command to adjust this range but it didn’t seem to have any effect. I also adjusted the S1 lower and upper limit in the Servo tab under configure and this too had no effect.

I am not connected to Arduino, I am just using the Pixy2 board.

What setting do I need to change to limit the tilt servo’s range of movement?

Thank you for your help :?

Hello,
The servo limits are adjustments. It might be that you need a courser adjustment. I’d just limit the positions you send to rcs_setPos.

Edward

I too am experiencing this issue, and as a newbie…I dont know where to find documentation for the rcs_setPos command

what is the syntax?
what is the name for what I think should be called pixy command reference?

ty

Hello,
There are several internal commands used by our developers (including rcs_setPos), but they aren’t very useful except for debugging.

If you wish to set the servo limits, the “servo tab” has several parameters you can adjust:

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixymon_index#servo-tab

Edward

I have adjusted the servo parameters in pixy, clicked update, and also have tried this for dozens of different settings,
also have tried this with running on the PC and with an arduino nano.
my servos are digital, from amazon and are metal gears
cant seem to limit the servo travel.
in desperation I have tried constrain command, as shown below

constrain(tiltOffset,1,300);// limit servo travel for your mechanical application and it did not work so next time try if then statement

but dont know what to do next…ideas?

What servos are you using? Can you please send a link?

didnt see this request yesterday, here is the link to my servos

Hello,
These servos are big and powerful and require more power than Pixy can provide. Are you powering them with a separate power supply?

Edward

Yes, I have 8 18650 lithium cells wired as( 2 series 4 parallel) for a pack voltage of about 6.8 volts.

there is a common ground from the pixy and the signal wires only to the servos. I used the supplied i2c
ribbon cable to my Nano.

Hello,
The servo limits on the servo tab may not provide enough limit. Are you able to get the servos to move with your setup?

BTW, your robot looks awesome!!

Edward

yes I have servo movement, although the pan is jerky…I anticipate settings in the PID
will help
here is a revised photo! with uncanny eyes
yes, I still struggle with tilt servo limit
for now the servo pushrod is replaced with a spring

Whoa, that looks great!

…is that a Prius or other electric vehicle battery??

I own AutoBeYours…we specialize in Prius repairs… so…YES those are toyota niMh cells.
(you have a good eye).

it greets our customers and has an Alexa in it also.

anybody got a fix for servo limit? I have set the limits in the pixy software many times, with a variety of upper and lower limits.
I still have excessive travel

Hello,
Regarding the servo limits, it sounds like you need limits outside of what’s provided. Have you tried limiting the values that you send to the servos?

Edward

I would like to, but im not sure how… this is what Im fiddling with:

// calculate translate and rotate errors
panOffset -= panLoop.m_command - PIXY_RCS_CENTER_POS;// this should reverse the pan servo
// panOffset += panLoop.m_command - PIXY_RCS_CENTER_POS;// this was the original line see? negative instead of positive
tiltOffset += tiltLoop.m_command - PIXY_RCS_CENTER_POS - PIXY_RCS_CENTER_POS/2 + PIXY_RCS_CENTER_POS/8;

 constrain(tiltOffset,1,300);// limit servo travel for your mechanical application  and it did not work so next time try if then statement

am I correct that I need to somehow limit the tiltoffset here? like say for example if offset is greater than 100 then tilt offset ==100 ( forgive my syntax )

Hello,
Yes, the servo values range between 0 and 1000. You can just restrict that to 100 and 900 (for example).

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api

Edward