Log in

View Full Version : Camera Troubles


cmurdoch
06-02-2006, 10:25
I'd like to say there's a problem with the camera itself causing our problems. Unfortunately, the camera was working fine until I attempted to adapt the tracking and search code to manipulate the pwm output for our rotating turret instead of the pan servo. I tried my best to leave the tilt tracking code intact. When we tested, however, the panning code worked as anticipated, while the tilt code didn't work at all (well... it tried to work, but failed miserably resulting in a subtle twitching motion). It seems as though the camera is trying to change the tilt servo value and remain in home position simultaneously. I'd appreciate any ideas anyone might have to solve my problem. Thanks

Jared Russell
06-02-2006, 11:14
If you post the part of your code that isn't working, we'll be better able to help.

Kevin Watson
06-02-2006, 11:22
I'd like to say there's a problem with the camera itself causing our problems. Unfortunately, the camera was working fine until I attempted to adapt the tracking and search code to manipulate the pwm output for our rotating turret instead of the pan servo. I tried my best to leave the tilt tracking code intact. When we tested, however, the panning code worked as anticipated, while the tilt code didn't work at all (well... it tried to work, but failed miserably resulting in a subtle twitching motion). It seems as though the camera is trying to change the tilt servo value and remain in home position simultaneously. I'd appreciate any ideas anyone might have to solve my problem. ThanksThere are a few FAQ entries discussing spastic cameras.

-Kevin

cmurdoch
06-02-2006, 16:24
Here's my updated camera search code. So, if anyone has any insights I'd appreciate it.

//turn the turret to the right for a specified
//number of loops if direction is equal to 1
if (direction == 1)
{
pwm12 = 255;
loop_number++;
//when it reaches the end of the time,
//change tilt value, change direction
//and reset loop counter
if (loop_number > 50)
{
if(temp_tilt_servo >= (int)Tracking_Config_Data.Tilt_Max_PWM)
{
temp_tilt_servo = (int)Tracking_Config_Data.Tilt_Min_PWM;
}
else
{
// step the tilt servo to its next destination
temp_tilt_servo += (int)Tracking_Config_Data.Tilt_Search_Step_Size;

// make sure its new position isn't beyond
// the maximum value set in tracking.h
if(temp_tilt_servo >= (int)Tracking_Config_Data.Tilt_Max_PWM)
{
temp_tilt_servo = (int)Tracking_Config_Data.Tilt_Max_PWM;
}
}
direction = 0;
loop_number = 0;
}
}
//turn the turret to the left for a specified
//number of loops if direction is equal to 0
else if (direction == 0)
{
pwm12 = 0;
loop_number++;
//when it reaches the end of the time,
//change tilt value, change direction
//and reset loop counter
if (loop_number > 50)
{
if(temp_tilt_servo >= (int)Tracking_Config_Data.Tilt_Max_PWM)
{
temp_tilt_servo = (int)Tracking_Config_Data.Tilt_Min_PWM;
}
else
{
// step the tilt servo to its next destination
temp_tilt_servo += (int)Tracking_Config_Data.Tilt_Search_Step_Size;

// make sure its new position isn't beyond
// the maximum value set in tracking.h
if(temp_tilt_servo >= (int)Tracking_Config_Data.Tilt_Max_PWM)
{
temp_tilt_servo = (int)Tracking_Config_Data.Tilt_Max_PWM;
}
}
direction = 1;
loop_number = 0;
}
}
//if direction isn't left or right
//there is a code error and the
//motor is set to neutral
// else
// pwm12 = 127;
}

// update the pan and tilt servo PWM value
//PAN_SERVO = (unsigned char)temp_pan_servo;
TILT_SERVO = (unsigned char)temp_tilt_servo;
}
}
}
}

scitobor 617
06-02-2006, 17:45
Nothing in your code jumps out at me but I just don't like the fact that you type cast temp_tilt_servo as an int when you change the servo position then change it back to a unsigned char when finally setting the actual tilt variable. I would suggest however, that you use some sort of sensor to find the actual position of the pan device, at the very least you should use a limit switch or keep track of how many times you have turned left, or right, to be sure you do not break something.

cmurdoch
08-02-2006, 10:25
ok what tells the camera to go to home position or stay in home position. Is that on the camera itself and if so is there a portion of the code that overrides that? Basically, I'm wondering what could be causing the camera to try to stay in home position even when it's receiving new tilt servo values. I really don't know where to start.

sparkydp
08-02-2006, 23:57
we had problems with the servo pwm cable being attached to the wrong input on the RC, if it is hooked up to the wrong PWM, it tries to stay on neutral, triple check to make sure PAN and TILT are hooked up to the pwm's stated in tracking.h


ok what tells the camera to go to home position or stay in home position. Is that on the camera itself and if so is there a portion of the code that overrides that? Basically, I'm wondering what could be causing the camera to try to stay in home position even when it's receiving new tilt servo values. I really don't know where to start.

cmurdoch
11-02-2006, 11:24
I've just discovered something. I was testing the tracking code again and found that when we ran it without the driving code, it worked fine, but when we ran it in the combined code we had problems with the tilt servo. :confused: So, my problem isn't in tracking.c; it must be somewhere else but I don't know where. Any idea what the problem could be?

Bharat Nain
11-02-2006, 11:29
Do a search for all the pwm's, inputs and outputs the camera uses and see if any other code interferes.

cmurdoch
11-02-2006, 11:34
yup that was the problem. In the drive code, the drive motors are on pwms 1 and 2 and the camera also uses those outputs in the camera code. When I combined them I forgot to change the outputs for the drive motors. Man is my face red :o ... oh well at least it works now. Thank you everyone for your help.