rb-110 example code

Based on DMP's Vortex processor / SoC this board is a full computer capable of running a standard Windows and Linux installation on the backpack of your robot.
20 postsPage 1 of 21, 2
20 postsPage 1 of 21, 2

rb-110 example code

Post by Spiked3 » Wed Jan 26, 2011 4:56 am

Post by Spiked3
Wed Jan 26, 2011 4:56 am

so, does anyone have some rb-110 c# code that can move a servo? I've spent a couple of weeks on it and nothing. The only discussion I've read said 'i gave up and wrote my own'.
I'm not trying to do anything fancy - move a servo left then right, but i'd have to say the lack of example code and api documentation leaves a lot of guesswork.
so, does anyone have some rb-110 c# code that can move a servo? I've spent a couple of weeks on it and nothing. The only discussion I've read said 'i gave up and wrote my own'.
I'm not trying to do anything fancy - move a servo left then right, but i'd have to say the lack of example code and api documentation leaves a lot of guesswork.
Spiked3 offline
Savvy Roboteer
Savvy Roboteer
Posts: 41
Joined: Sun Feb 22, 2009 8:31 pm

Post by roboard » Thu Jan 27, 2011 7:02 am

Post by roboard
Thu Jan 27, 2011 7:02 am

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;
        }
    }
}
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 offline
Savvy Roboteer
Savvy Roboteer
Posts: 302
Joined: Fri Jul 03, 2009 4:44 am

Post by Spiked3 » Thu Jan 27, 2011 2:47 pm

Post by Spiked3
Thu Jan 27, 2011 2:47 pm

consistent "I/O library fails to initializeThe program"
consistent "I/O library fails to initializeThe program"
Spiked3 offline
Savvy Roboteer
Savvy Roboteer
Posts: 41
Joined: Sun Feb 22, 2009 8:31 pm

Post by roboard » Thu Jan 27, 2011 4:05 pm

Post by roboard
Thu Jan 27, 2011 4:05 pm

Spiked3 wrote:consistent "I/O library fails to initializeThe program"


Please ensure that winio.dll and winio.sys are put in the same directory with your application.

:)
Spiked3 wrote:consistent "I/O library fails to initializeThe program"


Please ensure that winio.dll and winio.sys are put in the same directory with your application.

:)
roboard offline
Savvy Roboteer
Savvy Roboteer
Posts: 302
Joined: Fri Jul 03, 2009 4:44 am

Post by Spiked3 » Thu Jan 27, 2011 4:48 pm

Post by Spiked3
Thu Jan 27, 2011 4:48 pm

that is not the error that would occur if they were not.
that is not the error that would occur if they were not.
Spiked3 offline
Savvy Roboteer
Savvy Roboteer
Posts: 41
Joined: Sun Feb 22, 2009 8:31 pm

Post by roboard » Fri Jan 28, 2011 4:00 am

Post by roboard
Fri Jan 28, 2011 4:00 am

Spiked3 wrote:that is not the error that would occur if they were not.


Please also ensure that you login WinXP with the Administrator account.

:)
Spiked3 wrote:that is not the error that would occur if they were not.


Please also ensure that you login WinXP with the Administrator account.

:)
roboard offline
Savvy Roboteer
Savvy Roboteer
Posts: 302
Joined: Fri Jul 03, 2009 4:44 am

Post by PaulL » Fri Jan 28, 2011 12:54 pm

Post by PaulL
Fri Jan 28, 2011 12:54 pm

PaulL offline
Savvy Roboteer
Savvy Roboteer
Posts: 423
Joined: Sat Sep 15, 2007 12:52 am

Post by Spiked3 » Fri Jan 28, 2011 6:24 pm

Post by Spiked3
Fri Jan 28, 2011 6:24 pm

i'll have to admit, I dont understand how anyone could get that error message if the files are not there. I moved them out of the directory and got an expected dll not found error from .net long before any robio error could occur.

the logon I am using is a full administrator account. I also note significant differences between the two samples of code.

I am just not able to fight through this at the moment so im going back to lego's (in java) for a while, at least they move.

http://spiked3.blogspot.com/
i'll have to admit, I dont understand how anyone could get that error message if the files are not there. I moved them out of the directory and got an expected dll not found error from .net long before any robio error could occur.

the logon I am using is a full administrator account. I also note significant differences between the two samples of code.

I am just not able to fight through this at the moment so im going back to lego's (in java) for a while, at least they move.

http://spiked3.blogspot.com/
Last edited by Spiked3 on Mon Jan 31, 2011 9:07 pm, edited 2 times in total.
Spiked3 offline
Savvy Roboteer
Savvy Roboteer
Posts: 41
Joined: Sun Feb 22, 2009 8:31 pm

Post by roboard » Mon Jan 31, 2011 2:07 pm

Post by roboard
Mon Jan 31, 2011 2:07 pm

Hi,

under WinXP, RoBoIO fails to initialize the "I/O library" only if it fails to initialize WinIO or it finds a wrong version of RoBoard.

If you get the "I/O library fails to ..." message, please ensure that

1. you login WinXP with Administrator, and

2. you don't run your RoBoIO application (with WinIO) on a network disk, and

3. you put winio.sys in a correct path (e.g. the directory of your RoBoIO application).

If you have correctly set up WinIO and RoBoIO application, then please also ensure that you set the version of RoBoard correctly. As mentioned in the sample code, if your RoBoard is RB-100, please change the line (in the sample code):

Code: Select all
RoBoIO.roboio_SetRBVer(RoBoIO.RB_110);


into

Code: Select all
RoBoIO.roboio_SetRBVer(RoBoIO.RB_100);


:)
Hi,

under WinXP, RoBoIO fails to initialize the "I/O library" only if it fails to initialize WinIO or it finds a wrong version of RoBoard.

If you get the "I/O library fails to ..." message, please ensure that

1. you login WinXP with Administrator, and

2. you don't run your RoBoIO application (with WinIO) on a network disk, and

3. you put winio.sys in a correct path (e.g. the directory of your RoBoIO application).

If you have correctly set up WinIO and RoBoIO application, then please also ensure that you set the version of RoBoard correctly. As mentioned in the sample code, if your RoBoard is RB-100, please change the line (in the sample code):

Code: Select all
RoBoIO.roboio_SetRBVer(RoBoIO.RB_110);


into

Code: Select all
RoBoIO.roboio_SetRBVer(RoBoIO.RB_100);


:)
roboard offline
Savvy Roboteer
Savvy Roboteer
Posts: 302
Joined: Fri Jul 03, 2009 4:44 am

Post by Spiked3 » Mon Jan 31, 2011 2:51 pm

Post by Spiked3
Mon Jan 31, 2011 2:51 pm

its probably #2. the thing is so slow I was running the compile and link elsewhere.
I'm on to the Legos for now, I may come back to it later.

Spiked3 - http://spiked3.blogspot.com/
its probably #2. the thing is so slow I was running the compile and link elsewhere.
I'm on to the Legos for now, I may come back to it later.

Spiked3 - http://spiked3.blogspot.com/
Spiked3 offline
Savvy Roboteer
Savvy Roboteer
Posts: 41
Joined: Sun Feb 22, 2009 8:31 pm

Post by hellu » Mon Feb 14, 2011 12:15 am

Post by hellu
Mon Feb 14, 2011 12:15 am

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;
        }
    }
}


I`ve tested the code above with the channel 15 of my board but the only problem is when i change the servo position arry with another value the servo moves the same, like nothing changed. I`m using a TowerPro non feedback servo. Am i missing something, i`ve tested out with PWM functions for the servo and the result is the same. Isn`t there a more explicit guide for servos in C#?

Best regards,Vlad
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;
        }
    }
}


I`ve tested the code above with the channel 15 of my board but the only problem is when i change the servo position arry with another value the servo moves the same, like nothing changed. I`m using a TowerPro non feedback servo. Am i missing something, i`ve tested out with PWM functions for the servo and the result is the same. Isn`t there a more explicit guide for servos in C#?

Best regards,Vlad
hellu offline
Robot Builder
Robot Builder
Posts: 18
Joined: Thu Jan 06, 2011 5:34 pm

Post by roboard » Mon Feb 14, 2011 1:53 am

Post by roboard
Mon Feb 14, 2011 1:53 am

If you want to use PWM channel 15,

please change

roboard wrote:
// set PWM channel 0
if (RoBoIO.rcservo_SetServo(0,RoBoIO.RCSERVO_SERVO_DEFAULT_NOFB) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}


to

roboard wrote:
// set PWM channel 15
if (RoBoIO.rcservo_SetServo(15,RoBoIO.RCSERVO_SERVO_DEFAULT_NOFB) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}




and change


roboard wrote:
// initialize channel 0
if(RoBoIO.rcservo_Initialize(RoBoIO.RCSERVO_USECHANNEL0) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}


to

roboard wrote:
// initialize channel 15
if(RoBoIO.rcservo_Initialize(RoBoIO.RCSERVO_USECHANNEL15) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}
If you want to use PWM channel 15,

please change

roboard wrote:
// set PWM channel 0
if (RoBoIO.rcservo_SetServo(0,RoBoIO.RCSERVO_SERVO_DEFAULT_NOFB) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}


to

roboard wrote:
// set PWM channel 15
if (RoBoIO.rcservo_SetServo(15,RoBoIO.RCSERVO_SERVO_DEFAULT_NOFB) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}




and change


roboard wrote:
// initialize channel 0
if(RoBoIO.rcservo_Initialize(RoBoIO.RCSERVO_USECHANNEL0) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}


to

roboard wrote:
// initialize channel 15
if(RoBoIO.rcservo_Initialize(RoBoIO.RCSERVO_USECHANNEL15) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}
roboard offline
Savvy Roboteer
Savvy Roboteer
Posts: 302
Joined: Fri Jul 03, 2009 4:44 am

Post by hellu » Mon Feb 14, 2011 6:13 am

Post by hellu
Mon Feb 14, 2011 6:13 am

roboard wrote:If you want to use PWM channel 15,

please change

roboard wrote:
// set PWM channel 0
if (RoBoIO.rcservo_SetServo(0,RoBoIO.RCSERVO_SERVO_DEFAULT_NOFB) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}


to

roboard wrote:
// set PWM channel 15
if (RoBoIO.rcservo_SetServo(15,RoBoIO.RCSERVO_SERVO_DEFAULT_NOFB) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}




and change


roboard wrote:
// initialize channel 0
if(RoBoIO.rcservo_Initialize(RoBoIO.RCSERVO_USECHANNEL0) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}


to

roboard wrote:
// initialize channel 15
if(RoBoIO.rcservo_Initialize(RoBoIO.RCSERVO_USECHANNEL15) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}


I`ve don already this stuff. Another questions, the servo only moves in one direction. If i put in the servo_position arry the values 1000,2000,1500 the servo moves only in one direction, isn`t is supposed to move backwards when it reaches 1500?
roboard wrote:If you want to use PWM channel 15,

please change

roboard wrote:
// set PWM channel 0
if (RoBoIO.rcservo_SetServo(0,RoBoIO.RCSERVO_SERVO_DEFAULT_NOFB) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}


to

roboard wrote:
// set PWM channel 15
if (RoBoIO.rcservo_SetServo(15,RoBoIO.RCSERVO_SERVO_DEFAULT_NOFB) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}




and change


roboard wrote:
// initialize channel 0
if(RoBoIO.rcservo_Initialize(RoBoIO.RCSERVO_USECHANNEL0) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}


to

roboard wrote:
// initialize channel 15
if(RoBoIO.rcservo_Initialize(RoBoIO.RCSERVO_USECHANNEL15) == false)
{
Console.Write(RoBoIO.roboio_GetErrMsg());
return;
}


I`ve don already this stuff. Another questions, the servo only moves in one direction. If i put in the servo_position arry the values 1000,2000,1500 the servo moves only in one direction, isn`t is supposed to move backwards when it reaches 1500?
hellu offline
Robot Builder
Robot Builder
Posts: 18
Joined: Thu Jan 06, 2011 5:34 pm

Post by roboard » Mon Feb 14, 2011 8:24 am

Post by roboard
Mon Feb 14, 2011 8:24 am

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. :)
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. :)
roboard offline
Savvy Roboteer
Savvy Roboteer
Posts: 302
Joined: Fri Jul 03, 2009 4:44 am

Post by hellu » Mon Feb 14, 2011 7:33 pm

Post by hellu
Mon Feb 14, 2011 7:33 pm

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. :)


Done that the first time with channel 15 and no change. Is there something with my servo? Should i try a new one?
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. :)


Done that the first time with channel 15 and no change. Is there something with my servo? Should i try a new one?
hellu offline
Robot Builder
Robot Builder
Posts: 18
Joined: Thu Jan 06, 2011 5:34 pm

Next
Next
20 postsPage 1 of 21, 2
20 postsPage 1 of 21, 2