by roboard » Tue Sep 07, 2010 3:56 pm
by roboard
Tue Sep 07, 2010 3:56 pm
dragonax wrote:I tried the following with no luck
...
Hi, please try the following code again:
- Code: Select all
if (rcservo_SetServo(2, RCSERVO_SERVO_DEFAULT_NOFB))
{
if (rcservo_Initialize(RCSERVO_USECHANNEL2))
{
unsigned long motion[32];
motion[2] =1500;
rcservo_EnterPlayMode_NOFB(motion);
motion[2] =1800;
rcservo_MoveTo(motion, 1000L); //move servo in channel 2 from position 1500 (us) to 1800 (us) in 1sec
rcservo_Close();
}
}
In rcservo_EnterPlayMode_NOFB(motion), the "motion" must be the home (initial) position of servo; and in rcservo_MoveTo(motion, 1000L), the "motion" is the destination (target) position.
When calling rcservo_MoveTo(), servo will move from the last position to the specified destination position. For example, if you want servo to move from home, motion1, motion2, ..., to motion 10, then you can write
- Code: Select all
unsigned long home[32];
unsigned long motion1[32];
unsigned long motion2[32];
...
unsigned long motion10[32];
...
... //set value for home, motion1, ..., motion10
...
rcservo_EnterPlayMode_NOFB(home);
rcservo_MoveTo(motion1, 200L); //move from home to motion1 in 200ms
rcservo_MoveTo(motion2, 200L); //move from motion1 to motion2 in 200ms
rcservo_MoveTo(motion3, 200L); //move from motion2 to motion3 in 200ms
...
rcservo_MoveTo(motion10, 200L); //move from motion9 to motion10 in 200ms

dragonax wrote:I tried the following with no luck
...
Hi, please try the following code again:
- Code: Select all
if (rcservo_SetServo(2, RCSERVO_SERVO_DEFAULT_NOFB))
{
if (rcservo_Initialize(RCSERVO_USECHANNEL2))
{
unsigned long motion[32];
motion[2] =1500;
rcservo_EnterPlayMode_NOFB(motion);
motion[2] =1800;
rcservo_MoveTo(motion, 1000L); //move servo in channel 2 from position 1500 (us) to 1800 (us) in 1sec
rcservo_Close();
}
}
In rcservo_EnterPlayMode_NOFB(motion), the "motion" must be the home (initial) position of servo; and in rcservo_MoveTo(motion, 1000L), the "motion" is the destination (target) position.
When calling rcservo_MoveTo(), servo will move from the last position to the specified destination position. For example, if you want servo to move from home, motion1, motion2, ..., to motion 10, then you can write
- Code: Select all
unsigned long home[32];
unsigned long motion1[32];
unsigned long motion2[32];
...
unsigned long motion10[32];
...
... //set value for home, motion1, ..., motion10
...
rcservo_EnterPlayMode_NOFB(home);
rcservo_MoveTo(motion1, 200L); //move from home to motion1 in 200ms
rcservo_MoveTo(motion2, 200L); //move from motion1 to motion2 in 200ms
rcservo_MoveTo(motion3, 200L); //move from motion2 to motion3 in 200ms
...
rcservo_MoveTo(motion10, 200L); //move from motion9 to motion10 in 200ms
