using System;
using System.Collections.Generic;
using System.Text;
using RoBoIO_DotNet;//Include RoBoIO_DotNet.dll
namespace example_sv
{
class example_sv
{
static void Main(string[] args)
{
uint [] servo_position = new uint [32];
uint [] nofb_home_position = new uint [32];
nofb_home_position[0] = 1000;
servo_position[0] = 2000;
// if use RB-100, call RoBoIO.roboio_SetRBVer(RoBoIO.RB_100);
RoBoIO.roboio_SetRBVer(RoBoIO.RB_110);
// set pwm channel 0
if (RoBoIO.rcservo_SetServo(0, RoBoIO.RCSERVO_SERVO_DEFAULT_NOFB) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}
Console.Write("\nInitialize RC-servo lib...");
// initialize channel 0
if(RoBoIO.rcservo_Initialize(RoBoIO.RCSERVO_USECHANNEL0) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}
Console.Write("success\n\n");
// play servo
RoBoIO.rcservo_EnterPlayMode_NOFB(nofb_home_position);
// move to the specified position by 1000ms (1 second)
RoBoIO.rcservo_MoveTo(servo_position, 1000);
Console.Write("completed\n");
RoBoIO.rcservo_Close();
return;
}
}
}
RoBoIO.roboio_SetRBVer(RoBoIO.RB_110);
RoBoIO.roboio_SetRBVer(RoBoIO.RB_100);
roboard wrote:Hi, Spiked
there is a sample code for a non-feedback rc-servo.
the code uses the PWM channel 0 of RoBoard.
Please install the .NET Framework 2.0 before run it.
- Code: Select all
using System;
using System.Collections.Generic;
using System.Text;
using RoBoIO_DotNet;//Include RoBoIO_DotNet.dll
namespace example_sv
{
class example_sv
{
static void Main(string[] args)
{
uint [] servo_position = new uint [32];
uint [] nofb_home_position = new uint [32];
nofb_home_position[0] = 1000;
servo_position[0] = 2000;
// if use RB-100, call RoBoIO.roboio_SetRBVer(RoBoIO.RB_100);
RoBoIO.roboio_SetRBVer(RoBoIO.RB_110);
// set pwm channel 0
if (RoBoIO.rcservo_SetServo(0, RoBoIO.RCSERVO_SERVO_DEFAULT_NOFB) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}
Console.Write("\nInitialize RC-servo lib...");
// initialize channel 0
if(RoBoIO.rcservo_Initialize(RoBoIO.RCSERVO_USECHANNEL0) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}
Console.Write("success\n\n");
// play servo
RoBoIO.rcservo_EnterPlayMode_NOFB(nofb_home_position);
// move to the specified position by 1000ms (1 second)
RoBoIO.rcservo_MoveTo(servo_position, 1000);
Console.Write("completed\n");
RoBoIO.rcservo_Close();
return;
}
}
}
roboard wrote:
// set PWM channel 0
if (RoBoIO.rcservo_SetServo(0,RoBoIO.RCSERVO_SERVO_DEFAULT_NOFB) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}
roboard wrote:
// set PWM channel 15
if (RoBoIO.rcservo_SetServo(15,RoBoIO.RCSERVO_SERVO_DEFAULT_NOFB) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}
roboard wrote:
// initialize channel 0
if(RoBoIO.rcservo_Initialize(RoBoIO.RCSERVO_USECHANNEL0) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}
roboard wrote:
// initialize channel 15
if(RoBoIO.rcservo_Initialize(RoBoIO.RCSERVO_USECHANNEL15) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}
roboard wrote:If you want to use PWM channel 15,
please changeroboard wrote:
// set PWM channel 0
if (RoBoIO.rcservo_SetServo(0,RoBoIO.RCSERVO_SERVO_DEFAULT_NOFB) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}
toroboard wrote:
// set PWM channel 15
if (RoBoIO.rcservo_SetServo(15,RoBoIO.RCSERVO_SERVO_DEFAULT_NOFB) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}
and changeroboard wrote:
// initialize channel 0
if(RoBoIO.rcservo_Initialize(RoBoIO.RCSERVO_USECHANNEL0) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}
toroboard wrote:
// initialize channel 15
if(RoBoIO.rcservo_Initialize(RoBoIO.RCSERVO_USECHANNEL15) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}
roboard wrote:
- Code: Select all
// play servo
RoBoIO.rcservo_EnterPlayMode_NOFB(nofb_home_position);
roboard wrote:
- Code: Select all
// move to the specified position by 1000ms (1 second)
RoBoIO.rcservo_MoveTo(servo_position, 1000);
roboard wrote:At the beginning, the servo will back to nofb_home_position(here is 1000).roboard wrote:
- Code: Select all
// play servo
RoBoIO.rcservo_EnterPlayMode_NOFB(nofb_home_position);
And then the servo will move to servo_position(here is 2000) during one second.roboard wrote:
- Code: Select all
// move to the specified position by 1000ms (1 second)
RoBoIO.rcservo_MoveTo(servo_position, 1000);
You could try to change the values of nofb_home_position and servo_position.