Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

Roboard Simple Example of Digital IO

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.
3 postsPage 1 of 1
3 postsPage 1 of 1

Roboard Simple Example of Digital IO

Post by RoWayne » Wed Aug 04, 2010 2:27 am

Post by RoWayne
Wed Aug 04, 2010 2:27 am

I have the Roboard, loaded the OS, have MS development studio and a pretty good programmer. However, all the examples I find for the Roboard are to control a complex organization of Servos (Play, replay, etc).

Does anyone have the simplest main() loop code example minimum which can designate a pin for digital input and a pin for digital output? From that I should be able to program till the late hours of the night.

The available downloads (that I have found) from the Roboard site all deal with PWM/Servos.

I have done a lot of programming in various languages and using various processors (embedded or other) but seem to have a hard time finding the examples to get going on this new project of mine.
I have the Roboard, loaded the OS, have MS development studio and a pretty good programmer. However, all the examples I find for the Roboard are to control a complex organization of Servos (Play, replay, etc).

Does anyone have the simplest main() loop code example minimum which can designate a pin for digital input and a pin for digital output? From that I should be able to program till the late hours of the night.

The available downloads (that I have found) from the Roboard site all deal with PWM/Servos.

I have done a lot of programming in various languages and using various processors (embedded or other) but seem to have a hard time finding the examples to get going on this new project of mine.
RoWayne
Newbie
Newbie
Posts: 6
Joined: Wed Dec 09, 2009 3:52 pm

Re: Roboard Simple Example of Digital IO

Post by roboard » Wed Aug 04, 2010 4:42 am

Post by roboard
Wed Aug 04, 2010 4:42 am

Code: Select all
#include <stdio.h>
#include <roboard.h>

int main() {
    int val;

    roboio_SetRBVer(RB_100);  // set the RoBoard version
    // roboio_SetRBVer(RB_110);  // use this instead if your RoBoard is RB-110

    // use all PWM channels as GPIO channels
    if (rcservo_Initialize(RCSERVO_USENOCHANNEL) == false)
    {
        printf("ERR: rcservo_Initialize() fails (%s)!\n", roboio_GetErrMsg());
        return -1;
    }

    printf("out logic 1 on PWM channel 0 (pin: S1)\n");
    rcservo_Outp(0, 1);
    getchar();

    printf("out logic 0 on PWM channel 0 (pin: S1)\n");
    rcservo_Outp(0, 0);
    getchar();

    printf("read digital input from PWM channel 1 (pin: S2)\n");
    val = rcservo_Inp(1);
    printf("the value of digital input is %d\n", val);
    getchar();

    rcservo_Close();
    return 0;
}


:)
Code: Select all
#include <stdio.h>
#include <roboard.h>

int main() {
    int val;

    roboio_SetRBVer(RB_100);  // set the RoBoard version
    // roboio_SetRBVer(RB_110);  // use this instead if your RoBoard is RB-110

    // use all PWM channels as GPIO channels
    if (rcservo_Initialize(RCSERVO_USENOCHANNEL) == false)
    {
        printf("ERR: rcservo_Initialize() fails (%s)!\n", roboio_GetErrMsg());
        return -1;
    }

    printf("out logic 1 on PWM channel 0 (pin: S1)\n");
    rcservo_Outp(0, 1);
    getchar();

    printf("out logic 0 on PWM channel 0 (pin: S1)\n");
    rcservo_Outp(0, 0);
    getchar();

    printf("read digital input from PWM channel 1 (pin: S2)\n");
    val = rcservo_Inp(1);
    printf("the value of digital input is %d\n", val);
    getchar();

    rcservo_Close();
    return 0;
}


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

Post by RoWayne » Tue Aug 10, 2010 1:03 am

Post by RoWayne
Tue Aug 10, 2010 1:03 am

Thanks very much! That was exactly the example I was looking for. Now I just have to build the roboio.lib for MSDEV 6.0! It seems to be fighting me with the various DEFS needed. right now it has initialize errors.
Thanks very much! That was exactly the example I was looking for. Now I just have to build the roboio.lib for MSDEV 6.0! It seems to be fighting me with the various DEFS needed. right now it has initialize errors.
RoWayne
Newbie
Newbie
Posts: 6
Joined: Wed Dec 09, 2009 3:52 pm


3 postsPage 1 of 1
3 postsPage 1 of 1