loading
 
Servo movement deadband
Robert Dunn from China  [6 posts]
6 years
I have a question, I'm not sure how to go about this.

This is the code in the vb script program:

' first check that something moving is in view
if GetVariable("COG_BOX_SIZE") > 10 then

  ' get the current screen width so we can calibrate movement
  width = GetVariable("IMAGE_WIDTH")

' get the current screen height so we can calibrate movement
  height = GetVariable("IMAGE_HEIGHT")

  ' get the current center of movement
  'x = GetVariable("COG_X")
   x = GetVariable("IMAGE_WIDTH") - GetVariable("COG_X") ' Reverse servo movement...

' get the current center of movement
  y = GetVariable("COG_Y")
'y = GetVariable("IMAGE_HEIGHT") - GetVariable("COG_Y") ' Reverse servo movement.

  ' scale the image space into the servo space
  x = CInt(((x/width)*2000))+500
  
  ' scale the image space into the servo space
  y = CInt(((y/height)*2000))+500

  ' set the variable for use in the servo controller
  SetVariable "Pan", x

' set the variable for use in the servo controller
  SetVariable "Tilt", y

end if

This seems to work rather well.   The question lies in the actual servo commanded movement.  As It gets to the commanded movement positions for both Pan and Tilt, it seems to overshoot a bit and then go back the other direction. it then overshoots that direction and then moves back the other direction. ( Hunting )

So, can this vb script program be changed to incorporate a dead zone?
By dead zone, I'm meaning that when it gets very close to it commanded position is stops just shy of it, thus eliminating the overshoot.

Thanks,

Robert
Robert Dunn from China  [6 posts] 6 years
I have attached the robo file just in case.
program.robo
Anonymous 6 years
Robert,

Yes, you can incorporate a deadzone right in the middle of the target by checking for near values and then setting the result to center. For example this could be inserted into the code just before the SetVarible commands.

deadZoneSize = 10

if x < (1250 + deadZoneSize) and x > (1250 - deadZoneSize) then
  x = 1250
end if

if y < (1250 + deadZoneSize) and y > (1250 - deadZoneSize) then
  y = 1250
end if

which has the effect of setting x to neutral (center) value if it is close to that value. You will have to play with the actual deadZoneSize to see what works best for you.

STeven.
Robert Dunn from China  [6 posts] 6 years
OK, I see what you are saying.   But in that code it looks like it would only be good for that position.  

My target will always be changing ( currently a red  ball ) and this doe not pose a problem, as it tracks it just fine.  But at the intended stop position ( It will always be changing ) it will hunt.  What variable contains the actual intended set position for the servo?

if x < (1250 + deadZoneSize) and x > (1250 - deadZoneSize) then
  x = 1250
end if

I'm not sure How X can be less than and greater than1250 at the same time.

So I'm guessing here that I could use a for next loop to increment x's position until it falls into the dead band, if it is less than.  and use another loop to decrease x's posistion if it was greater than.

But I would need to know what the intended position to be is set at to make that work.

I did set Pan as the x value so I'm guessing that pan will be holding the servo's current position but not the intended position.

I have attached a shot of the Chart containing the x value while hunting.

Robert

 
Robert from China  [6 posts] 6 years
OK I did some checking into this a bit more.  Using the original code from above, It is always hunting after it tracks it target to a stopped position.

During this test I removed the camera from the servo's that it was mounted to. With the camera now on the desk, I repeated the red ball tracking test.

This time it was very stable, no hunting of the servos at all.

So it would seem that the camera being mounted to the servo's for pan and tilt seems to be causing the problem.

This is very light weight camera, so I do not think it's from the weight.

I did turn down the servo's rate to 100 but even though it was moving pretty slow, that did not help the hunting when the camera is mounted to the servos.

any suggestions?

Robert
Anonymous 6 years
Robert,

X is the variable that contains the location to track. Since that should always be in the center of the image the deadband will always be the same.

You should re-read the equation. X is not being compared directly to 1250 but to 1250 MINUS and then PLUS the deadband zone amount.

The problem you have is one of momentum. While the camera does not weight that much it will cause a slight oscillation. You will either need to mount the camera closer to the pan/tilt's center OR you will need stronger servos to counter the additional weight OR just work with the slower speed.

It is also possible that we don't understand your setup. How could the camera track the ball correctly without it mounted on any servos? Ideally with the servos on the camera should attempt to move the ball to the center of its screen ... are you seeing something different?

STeven.

Robert from China  [6 posts] 6 years
The Camera not being mounted to the servo does still tell the servos to move when the red object passes the camera. it's just that the servo' will move to the extreme end position towards the sides of the camera. I was just interested in the fact if I did not let the camera move, could the object stay in the center of the camera and the servo's not hunt.  which seems to hold true.

So f I hold the red object in the center view of the camera, the servo's do not hunt. and as I move the abject across the camera view the servos try to track it.
Just like it should do.

It is when the camera is mounted to the servo that the problems start.  It does try to move the red object to the center of the screen.  It's when it gets there that it hunts/oscillates. Actually I think it is hunting at all times if you look at the chart.

I did make 2 quick avi videos of the tests so you may get a good indication of what is going on, but I can't seem to get the file size under 300k.
Robert from China  [6 posts] 6 years
I'm Going to order some 12 Vdc High torque servos and see if the probem persists.

I did turn the servo rates down to 10 and it is still hunting.  one thing I did notice was that the y distance was never in the center of the screen. Z would make it there, but y never did.

The line from the cog center to center screen was always about a 1/2 inch off.
I tried to reduce the y scaling +500 value a bit, at +200 it would hold center screen.

I'm guessing I may have some cheesy servos.  These are Futaba S3003 mounted in a pan and tilt assembly.

Do you have any recommendations as to what servos would be a good choice?

Thanks,

Robert
Anonymous 6 years
Robert,

Yea, changing servos might be a good check to do. In terms of which servos ... that seems to keep changing and we don't typically use 12V ones. HiTech seem to be quite popular.

Another possibility is your servo controller. Its possible that the board may be bad and causing incorrect signals to be sent. If you have another one handy you can use it to check if the servos or the servo controller is bad.

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index