Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Finding servo location? (http://www.chiefdelphi.com/forums/showthread.php?t=44671)

ForgottenSalad 23-02-2006 21:30

Finding servo location?
 
Just as a quick question, seeing as I never got to test my code, would getting the location of the servo be as simple as
Code:

printf("Servo Location is... %d\r", pwm01)
or would I have to do something more to find where it is betweeen 0 and 255...?

bush 23-02-2006 21:38

Re: Finding servo location?
 
that works

Joe Ross 23-02-2006 22:10

Re: Finding servo location?
 
Code:

printf("Servo Location is... %d\r", (int)pwm01)

JJG13 24-02-2006 16:21

Re: Finding servo location?
 
Quote:

Originally Posted by ForgottenSalad
Just as a quick question, seeing as I never got to test my code, would getting the location of the servo be as simple as
Code:

printf("Servo Location is... %d\r", pwm01)
or would I have to do something more to find where it is betweeen 0 and 255...?

First of all what are you trying to do? If you are setting a value to pwm01 and then printing it out later, this should work. However, you can't physically read the current position of the servo motor. Neither the hardware or software support this.

rodgadashruba 26-02-2006 19:18

Re: Finding servo location?
 
Quote:

Originally Posted by JJG13
However, you can't physically read the current position of the servo motor. Neither the hardware or software support this.

wait so there is no way to tell where the camera, like to read what position the tilt servo is at?

bush 26-02-2006 19:20

Re: Finding servo location?
 
You can. Just read the value of the PWM - in Kevin's code, the position is in the variable TILT_SERVO and PAN_SERVO

Tom Bottiglieri 26-02-2006 19:21

Re: Finding servo location?
 
If you are using the onboard motor control (PWM) to move the camera servos, you can put that printf right after the line that modifies that outputs value (make sure it is before the PutData !!)

If you are using the servo controller on the camera, you will have to ask the camera for what the current servo value is.

rodgadashruba 26-02-2006 19:47

Re: Finding servo location?
 
Quote:

Originally Posted by bush
You can. Just read the value of the PWM - in Kevin's code, the position is in the variable TILT_SERVO and PAN_SERVO

well i tried that in user routines, in the default code funtion. the code compiles just fine but when i add int he comman

int testTest = PAN_SERVO ;
or
static int testTest = PAN_SERVO;

i get syntax errors
is there a way to access these varible outside of tracking.c?

Bharat Nain 26-02-2006 20:05

Re: Finding servo location?
 
Quote:

Originally Posted by rodgadashruba
well i tried that in user routines, in the default code funtion. the code compiles just fine but when i add int he comman

int testTest = PAN_SERVO ;
or
static int testTest = PAN_SERVO;

i get syntax errors
is there a way to access these varible outside of tracking.c?

Paste the whole file where you put this line of code.

rodgadashruba 26-02-2006 20:24

Re: Finding servo location?
 
1 Attachment(s)
alright its attached
its down where it is commented out for the aim up code

ForgottenSalad 26-02-2006 20:44

Re: Finding servo location?
 
Quote:

Originally Posted by rodgadashruba
alright its attached
its down where it is commented out for the aim up code

Don't you have to declare the variable andrew OUTSIDE the routine?

That might be it, then again, I could be wrong.

(code trimmed out to point out lines in question)

Code:

void Default_Routine(void)
{
int shooter;
// aim up code... WOOT
// ok so find the value of pwm1 to line up the robot.. should be easy enough
static int Andrew = PAN_SERVO;


rodgadashruba 26-02-2006 20:48

Re: Finding servo location?
 
I thought that was it but shooter is declared..
i will try it out tho

rodgadashruba 26-02-2006 20:55

Re: Finding servo location?
 
wow alright.. so turns out i fail at remembering basic C...
had to declare Andrew at the top of default routines..

Matt Krass 26-02-2006 21:31

Re: Finding servo location?
 
Keep in mind this tells you where the servo is being commanded to go, not where it is, in most case they're synonomous, but if you're caught on something, or doing a lot of tracking this value could introduce lag which creates oscillations, making it worse, feedback loops, a constantly increasing error, all kinds of bad stuff. Just remember thats where it's trying to be and 98% of the time it should be there.

ForgottenSalad 26-02-2006 21:45

Re: Finding servo location?
 
Just out of curiosity, is there a better way, then?


All times are GMT -5. The time now is 03:13.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi