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

Library already available

Anything that doesn't fit our other forums goes here.
9 postsPage 1 of 1
9 postsPage 1 of 1

Library already available

Post by inaki » Mon Apr 04, 2005 10:57 pm

Post by inaki
Mon Apr 04, 2005 10:57 pm

My library for controlling your KHR-1 from your own programs is already available at:

http://robosavvy.com/Builders/inaki/krcbdl.zip

Please send your comments.
My library for controlling your KHR-1 from your own programs is already available at:

http://robosavvy.com/Builders/inaki/krcbdl.zip

Please send your comments.
inaki
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 233
Joined: Sun Mar 06, 2005 1:00 am
Location: EH

Post by limor » Fri Apr 08, 2005 3:23 pm

Post by limor
Fri Apr 08, 2005 3:23 pm

Thank you for this fantastic contribution!

At what speed can the RCB-1 serial interface work?
How do you change the speed?
Documentation says that max timeout is 30us, you may have had other experiences?
Can you add a per-port global variable, set at startup, that holds both the timeout and number of retries (or any other solution such as including a timeout and retry with every function call)?
Code: Select all
#include "krcbdll.h"
HANDLE com;
BYTE v[12];

// init com1, set com1 max wait to 30us
// and max of 4 retries
com = RCB_Start(1, 30, 4);

// get all servos positions for RCB1[0]
// wait up to 30us for a response, retry 4 times
if (!RCB_GetMotorPositions(com, 0, v))
    wxError ("problem with RCB-1..");


Thanks again!
Thank you for this fantastic contribution!

At what speed can the RCB-1 serial interface work?
How do you change the speed?
Documentation says that max timeout is 30us, you may have had other experiences?
Can you add a per-port global variable, set at startup, that holds both the timeout and number of retries (or any other solution such as including a timeout and retry with every function call)?
Code: Select all
#include "krcbdll.h"
HANDLE com;
BYTE v[12];

// init com1, set com1 max wait to 30us
// and max of 4 retries
com = RCB_Start(1, 30, 4);

// get all servos positions for RCB1[0]
// wait up to 30us for a response, retry 4 times
if (!RCB_GetMotorPositions(com, 0, v))
    wxError ("problem with RCB-1..");


Thanks again!
limor
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1845
Joined: Mon Oct 11, 2004 1:00 am
Location: London, UK

Post by inaki » Fri Apr 08, 2005 7:03 pm

Post by inaki
Fri Apr 08, 2005 7:03 pm

The RCB serial line works at 115kbps, so sending a reading command takes about 20us. Receiving data for 12 motors takes about 90us.

Apparently the speed of the serial line cannot be changed. There is a couple of commands undocumented so perhaps there is a way to do so.
Note that even HeartToHeart does not give a chance to configure the COM port speed.

The bad side of using 115kpbs is that some microcontrollers do not work at that speed.

The typical delay after sending a command is about 250us. This has been measured on the serial cable using an oscilloscope. The 30us stated by Kondo is wrong.

That makes about 750us to complete a command for reading all servos (from both RCB IDs) .

So theoretically is possible to get about 1300 readings of all servo positions per second in the best case, according to my tests, if no delay is used. Other commands may take more or less depending on the number of bytes transmited.

I am going to add support to configure the timeout. Retries can be configured too. Configuring these parameters per function seems too much. I think

Your idea of doing it at RCB_Start is okay.

So, our start function would become as follows:

RCB_Start( portNumber, flags, maxTimeout, maxRetries);
The RCB serial line works at 115kbps, so sending a reading command takes about 20us. Receiving data for 12 motors takes about 90us.

Apparently the speed of the serial line cannot be changed. There is a couple of commands undocumented so perhaps there is a way to do so.
Note that even HeartToHeart does not give a chance to configure the COM port speed.

The bad side of using 115kpbs is that some microcontrollers do not work at that speed.

The typical delay after sending a command is about 250us. This has been measured on the serial cable using an oscilloscope. The 30us stated by Kondo is wrong.

That makes about 750us to complete a command for reading all servos (from both RCB IDs) .

So theoretically is possible to get about 1300 readings of all servo positions per second in the best case, according to my tests, if no delay is used. Other commands may take more or less depending on the number of bytes transmited.

I am going to add support to configure the timeout. Retries can be configured too. Configuring these parameters per function seems too much. I think

Your idea of doing it at RCB_Start is okay.

So, our start function would become as follows:

RCB_Start( portNumber, flags, maxTimeout, maxRetries);
inaki
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 233
Joined: Sun Mar 06, 2005 1:00 am
Location: EH

Post by javi » Fri Apr 08, 2005 10:18 pm

Post by javi
Fri Apr 08, 2005 10:18 pm

Hello Iñaki,
I tried to use the library from VBS (using a wrapper for the dll), but I haven't found a way to get the address of a VBS variable (for the pointers in the function calls), so, would it be possible for you to create an ActiveX object version of the library?
Also, could you post the source code? I have a MC32C84 renesas evaluation board and would like to use it to make the robot autonomous (and it's easier to use code already written than to write my own :wink: )
Hello Iñaki,
I tried to use the library from VBS (using a wrapper for the dll), but I haven't found a way to get the address of a VBS variable (for the pointers in the function calls), so, would it be possible for you to create an ActiveX object version of the library?
Also, could you post the source code? I have a MC32C84 renesas evaluation board and would like to use it to make the robot autonomous (and it's easier to use code already written than to write my own :wink: )
javi
Robot Builder
Robot Builder
User avatar
Posts: 14
Joined: Tue Mar 29, 2005 1:00 am

Post by limor » Sun Apr 10, 2005 3:05 pm

Post by limor
Sun Apr 10, 2005 3:05 pm

inaki wrote:I am going to add support to configure the timeout. Retries can be configured too. Configuring these parameters per function seems too much. I think

Your idea of doing it at RCB_Start is okay.

So, our start function would become as follows:

RCB_Start( portNumber, flags, maxTimeout, maxRetries);


On second thought, maybe it's better to pass the two parameters via pointers (ie: by reference not by value) so that the user may be able to change their value later without having to call another RCB_* function.
(this may look unclean but it is C after all and maybe we'll wrap the stuff up in some fancy C++ later to protect users from themselves).

One scenario of chaning the retries/timeout during the course of a program is in case there are interferences and you want to throttle the connection before giving and error message.
inaki wrote:I am going to add support to configure the timeout. Retries can be configured too. Configuring these parameters per function seems too much. I think

Your idea of doing it at RCB_Start is okay.

So, our start function would become as follows:

RCB_Start( portNumber, flags, maxTimeout, maxRetries);


On second thought, maybe it's better to pass the two parameters via pointers (ie: by reference not by value) so that the user may be able to change their value later without having to call another RCB_* function.
(this may look unclean but it is C after all and maybe we'll wrap the stuff up in some fancy C++ later to protect users from themselves).

One scenario of chaning the retries/timeout during the course of a program is in case there are interferences and you want to throttle the connection before giving and error message.
limor
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1845
Joined: Mon Oct 11, 2004 1:00 am
Location: London, UK

Post by inaki » Sun Apr 10, 2005 6:21 pm

Post by inaki
Sun Apr 10, 2005 6:21 pm

I have provided two macros to change and read directly the timeout value from the actual variable used to calculate timeouts. This variable is accessed through the HANDLE returned when calling RCB_Start.

In my experiments with high resolution timers I have reached up to 270 readings per second. It seems that the RCB is unable to manage more 'long' commands per second. Or perhaps my library is unable to deliver more than that. I could not reach the theoretical limit of 1300. :(

I am stll working on it. I have added also some debug information that can be read from the client program to know how much time a command takes or how many retries take place.
I have provided two macros to change and read directly the timeout value from the actual variable used to calculate timeouts. This variable is accessed through the HANDLE returned when calling RCB_Start.

In my experiments with high resolution timers I have reached up to 270 readings per second. It seems that the RCB is unable to manage more 'long' commands per second. Or perhaps my library is unable to deliver more than that. I could not reach the theoretical limit of 1300. :(

I am stll working on it. I have added also some debug information that can be read from the client program to know how much time a command takes or how many retries take place.
inaki
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 233
Joined: Sun Mar 06, 2005 1:00 am
Location: EH

Post by inaki » Sat Apr 29, 2006 11:48 am

Post by inaki
Sat Apr 29, 2006 11:48 am

Hello. I am going to release a new version of this library with some improvements and, as I have many requests for this, this time the source code will be included !

Please if you have used this library and have found some problem with it please tell me before I release the new version.

Also this is the moment to request any special feature you think should be in the library.
Hello. I am going to release a new version of this library with some improvements and, as I have many requests for this, this time the source code will be included !

Please if you have used this library and have found some problem with it please tell me before I release the new version.

Also this is the moment to request any special feature you think should be in the library.
inaki
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 233
Joined: Sun Mar 06, 2005 1:00 am
Location: EH

Post by pandolio » Tue Jul 11, 2006 2:33 pm

Post by pandolio
Tue Jul 11, 2006 2:33 pm

Hi inaki,

Could you send me the source code for you first version of the api on C?

I could compile it on linux.

thanks.
Hi inaki,

Could you send me the source code for you first version of the api on C?

I could compile it on linux.

thanks.
pandolio
Newbie
Newbie
User avatar
Posts: 5
Joined: Wed Jul 05, 2006 1:00 am

Post by Borting » Thu Aug 10, 2006 3:41 am

Post by Borting
Thu Aug 10, 2006 3:41 am

Hi inaki,

Could you send me the source code for your PC -> RCB-1 communications API on C?

I need compile it on linux.

thanks a lot.
Hi inaki,

Could you send me the source code for your PC -> RCB-1 communications API on C?

I need compile it on linux.

thanks a lot.
Borting
Newbie
Newbie
User avatar
Posts: 1
Joined: Wed Aug 09, 2006 1:00 am


9 postsPage 1 of 1
9 postsPage 1 of 1