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

Driving an RCB4

KHR-1, KHR-2HV, KHR-3HV, ICS servos, RCB controllers and other Kondo products
37 postsPage 2 of 31, 2, 3
37 postsPage 2 of 31, 2, 3

Post by amuthelet » Sun Oct 24, 2010 11:21 pm

Post by amuthelet
Sun Oct 24, 2010 11:21 pm

But I just discover kondo_send_ics_pos which seems to work fine for direct servo control I target, so probably don't need to call ics_pos ? Do I miss some important differences between the two ways ?
But I just discover kondo_send_ics_pos which seems to work fine for direct servo control I target, so probably don't need to call ics_pos ? Do I miss some important differences between the two ways ?
amuthelet
Savvy Roboteer
Savvy Roboteer
Posts: 27
Joined: Tue Jun 08, 2010 12:33 pm

Post by chrisvo » Mon Oct 25, 2010 3:53 am

Post by chrisvo
Mon Oct 25, 2010 3:53 am

ics.c is a separate library from rcb4.c. You can use them independently.

ics.c is designed for use when directly connected to servos using a half-duplex circuit like the ones pictured in the "pcb" folder in the repository.

rcb4.c is designed to be used when you are connecting to the RCB-4HV servo controller. The RCB-4 does have a way to pass ICS packets through (kondo_send_ics_pos() is an example).
ics.c is a separate library from rcb4.c. You can use them independently.

ics.c is designed for use when directly connected to servos using a half-duplex circuit like the ones pictured in the "pcb" folder in the repository.

rcb4.c is designed to be used when you are connecting to the RCB-4HV servo controller. The RCB-4 does have a way to pass ICS packets through (kondo_send_ics_pos() is an example).
chrisvo
Savvy Roboteer
Savvy Roboteer
Posts: 132
Joined: Mon Nov 02, 2009 10:24 pm

Driving a servo Bit Fields

Post by keukpa » Tue Oct 25, 2011 1:35 am

Post by keukpa
Tue Oct 25, 2011 1:35 am

Hi Chrisvo,

Thank you for the sterling effort you have put in with the KHR-3HV Software and conversions. I am struggling a little bit and wonder if you could give me some guidance.

I've compiled all your code under linux, and I can connect to the RCB4, and receive an ACK and there appears to be TX and RX packets (with data) but I can't get the servo to move.

For now I have the RCB4 and one servo (Green ID6) connected to SIO-8.

I'm trying to call your function 'kondo_send_ics_pos' but I do not understand how I select a servo to control. I'm unfamiliar with Bit Fields.

Any help (or small example file) you could provide, would be most appreciated.

Many thanks,

Keukpa
Hi Chrisvo,

Thank you for the sterling effort you have put in with the KHR-3HV Software and conversions. I am struggling a little bit and wonder if you could give me some guidance.

I've compiled all your code under linux, and I can connect to the RCB4, and receive an ACK and there appears to be TX and RX packets (with data) but I can't get the servo to move.

For now I have the RCB4 and one servo (Green ID6) connected to SIO-8.

I'm trying to call your function 'kondo_send_ics_pos' but I do not understand how I select a servo to control. I'm unfamiliar with Bit Fields.

Any help (or small example file) you could provide, would be most appreciated.

Many thanks,

Keukpa
keukpa
Robot Builder
Robot Builder
Posts: 15
Joined: Wed Feb 23, 2011 11:29 pm

Post by chrisvo » Tue Oct 25, 2011 2:09 am

Post by chrisvo
Tue Oct 25, 2011 2:09 am

The functions in libkondo4 are admittedly still a little low-level, I apologize.

The bit field is a way of specifying which servos are included to receive the command, and which are not included. You do this in a sequence of bits. Each bit position represents a servo. If the value of that bit is 0 it means the servo is not included to receive the command, if the value is 1, the servo is included.

For example, to move servo ID 6 to zero position, you do:

Code: Select all
int main()
{
  // initialize
  KondoInstance ki;
  kondo_init(&ki);

  // which servos?
  // ID number 6.
  // Note that servo numbering starts at 0.
  // 1 << 6 will give us the 7th bit set, or ID 6.
  unsigned char servos = { 0, 0, 0, 0, 1 << 6 };

  // which command?
  // zero-position is 7500.
  unsigned int command = 7500;

  // send the command.
  kondo_send_ics_pos(&ki, servos, command);

  // close
  kondo_close(&ki);
}
The functions in libkondo4 are admittedly still a little low-level, I apologize.

The bit field is a way of specifying which servos are included to receive the command, and which are not included. You do this in a sequence of bits. Each bit position represents a servo. If the value of that bit is 0 it means the servo is not included to receive the command, if the value is 1, the servo is included.

For example, to move servo ID 6 to zero position, you do:

Code: Select all
int main()
{
  // initialize
  KondoInstance ki;
  kondo_init(&ki);

  // which servos?
  // ID number 6.
  // Note that servo numbering starts at 0.
  // 1 << 6 will give us the 7th bit set, or ID 6.
  unsigned char servos = { 0, 0, 0, 0, 1 << 6 };

  // which command?
  // zero-position is 7500.
  unsigned int command = 7500;

  // send the command.
  kondo_send_ics_pos(&ki, servos, command);

  // close
  kondo_close(&ki);
}
chrisvo
Savvy Roboteer
Savvy Roboteer
Posts: 132
Joined: Mon Nov 02, 2009 10:24 pm

Post by chrisvo » Tue Oct 25, 2011 2:13 am

Post by chrisvo
Tue Oct 25, 2011 2:13 am

I have to find my code somewhere, but I wrote an update to libkondo4 a while back which has some slightly more abstract functions like "kondo_set_servo_pos" which you just give the ID number and position, you don't have to deal with the bit string.

I didn't commit it to the bitbucket because I haven't done adequate testing yet.
I have to find my code somewhere, but I wrote an update to libkondo4 a while back which has some slightly more abstract functions like "kondo_set_servo_pos" which you just give the ID number and position, you don't have to deal with the bit string.

I didn't commit it to the bitbucket because I haven't done adequate testing yet.
chrisvo
Savvy Roboteer
Savvy Roboteer
Posts: 132
Joined: Mon Nov 02, 2009 10:24 pm

Servo still not moving

Post by keukpa » Tue Oct 25, 2011 2:47 pm

Post by keukpa
Tue Oct 25, 2011 2:47 pm

Hi Chrisvo,

Thank you for your very quick response, sadly, this code still did not drive my servo (I had to edit unsigned char servos to -> unsigned char servos[], as it was complaining it wanted an array). When I run your ./run_motion example, and ./test_analoge I get appropriate outputs. e.g.

./run_motion 0

[keukpa@localhost utils]$ sudo ./run_motion 0
send 19 bytes: 13 0 2 0 0 0 1 0 fd 3 0 0 0 0 0 0 0 0 16
recv 4 bytes: 4 0 6 a
send 7 bytes: 7 c b8 b 0 0 d6
recv 4 bytes: 4 c 6 16
send 9 bytes: 9 0 2 0 0 0 3 0 e
recv 4 bytes: 4 0 6 a
send 10 bytes: a 0 20 0 0 0 0 0 2 2c
recv 5 bytes: 5 0 1 0 6
send 10 bytes: a 0 20 0 0 0 0 0 2 2c
recv 5 bytes: 5 0 1 0 6
send 10 bytes: a 0 20 0 0 0 0 0 2 2c

./test_anolge (when I touch AD1 the value changes)

Analog value of AD1: 125
Analog value of AD1: 0
Analog value of AD1: 0
Analog value of AD1: 11
Analog value of AD1: 0
Analog value of AD1: 109

However, I still can not access a servo and move it, or get its position, I've tried several servos, and I've tried the board and servos on HTH4 which works fine.

Please, any ideas, pointers, or help you could provide would be of great help!

Many thanks,

Keukpa
Hi Chrisvo,

Thank you for your very quick response, sadly, this code still did not drive my servo (I had to edit unsigned char servos to -> unsigned char servos[], as it was complaining it wanted an array). When I run your ./run_motion example, and ./test_analoge I get appropriate outputs. e.g.

./run_motion 0

[keukpa@localhost utils]$ sudo ./run_motion 0
send 19 bytes: 13 0 2 0 0 0 1 0 fd 3 0 0 0 0 0 0 0 0 16
recv 4 bytes: 4 0 6 a
send 7 bytes: 7 c b8 b 0 0 d6
recv 4 bytes: 4 c 6 16
send 9 bytes: 9 0 2 0 0 0 3 0 e
recv 4 bytes: 4 0 6 a
send 10 bytes: a 0 20 0 0 0 0 0 2 2c
recv 5 bytes: 5 0 1 0 6
send 10 bytes: a 0 20 0 0 0 0 0 2 2c
recv 5 bytes: 5 0 1 0 6
send 10 bytes: a 0 20 0 0 0 0 0 2 2c

./test_anolge (when I touch AD1 the value changes)

Analog value of AD1: 125
Analog value of AD1: 0
Analog value of AD1: 0
Analog value of AD1: 11
Analog value of AD1: 0
Analog value of AD1: 109

However, I still can not access a servo and move it, or get its position, I've tried several servos, and I've tried the board and servos on HTH4 which works fine.

Please, any ideas, pointers, or help you could provide would be of great help!

Many thanks,

Keukpa
keukpa
Robot Builder
Robot Builder
Posts: 15
Joined: Wed Feb 23, 2011 11:29 pm

Post by chrisvo » Tue Oct 25, 2011 3:06 pm

Post by chrisvo
Tue Oct 25, 2011 3:06 pm

Have you tested your servo communication within the Heart2Heart4 software? That is essential to test whether the controller is working at all.

If it works fine in Heart2Heart4, next thing you can try is sending the command to ALL servos by changing all the bits in the bit field to 1 like this:

unsigned char servos[] = { ~0, ~0, ~0, ~0, ~0};

Make sure also that the servo is NOT in FREE position by sending a HOLD command (32767). Servos stay freed until a hold issued to reactivate it.
Have you tested your servo communication within the Heart2Heart4 software? That is essential to test whether the controller is working at all.

If it works fine in Heart2Heart4, next thing you can try is sending the command to ALL servos by changing all the bits in the bit field to 1 like this:

unsigned char servos[] = { ~0, ~0, ~0, ~0, ~0};

Make sure also that the servo is NOT in FREE position by sending a HOLD command (32767). Servos stay freed until a hold issued to reactivate it.
chrisvo
Savvy Roboteer
Savvy Roboteer
Posts: 132
Joined: Mon Nov 02, 2009 10:24 pm

Post by keukpa » Tue Oct 25, 2011 3:37 pm

Post by keukpa
Tue Oct 25, 2011 3:37 pm

Hi, yes I have tried the board and servos with Heart2Heart4 and it all works fine.

Below is my code, however I still can not get the servo to move!

#include "rcb4.h"
#include <unistd>

KondoInstance ki;

int main(int argc, char *argv[])
{
// cmd line arguments ----------------------------

// open ------------------------------------------

kondo_init(&ki);

// servo set (ALL)
unsigned char servos[] = { ~0, ~0, ~0, ~0, ~0 };

printf("%d, %d\n", *argv[1], servos[0]);

unsigned int command = 32767;

//send the command
kondo_send_ics_pos(&ki, servos, command);

unsigned int command1 = 1000;
kondo_send_ics_pos(&ki, servos, command1);

// close -----------------------------------------
kondo_close(&ki);
}
Hi, yes I have tried the board and servos with Heart2Heart4 and it all works fine.

Below is my code, however I still can not get the servo to move!

#include "rcb4.h"
#include <unistd>

KondoInstance ki;

int main(int argc, char *argv[])
{
// cmd line arguments ----------------------------

// open ------------------------------------------

kondo_init(&ki);

// servo set (ALL)
unsigned char servos[] = { ~0, ~0, ~0, ~0, ~0 };

printf("%d, %d\n", *argv[1], servos[0]);

unsigned int command = 32767;

//send the command
kondo_send_ics_pos(&ki, servos, command);

unsigned int command1 = 1000;
kondo_send_ics_pos(&ki, servos, command1);

// close -----------------------------------------
kondo_close(&ki);
}
keukpa
Robot Builder
Robot Builder
Posts: 15
Joined: Wed Feb 23, 2011 11:29 pm

Post by chrisvo » Tue Oct 25, 2011 3:48 pm

Post by chrisvo
Tue Oct 25, 2011 3:48 pm

I'm not sure. That code works fine using my RCB4 and servos...
I'm not sure. That code works fine using my RCB4 and servos...
chrisvo
Savvy Roboteer
Savvy Roboteer
Posts: 132
Joined: Mon Nov 02, 2009 10:24 pm

Post by keukpa » Tue Oct 25, 2011 3:53 pm

Post by keukpa
Tue Oct 25, 2011 3:53 pm

hmmm that is strange!

Thank you for your help and suggestions.

Could it be my version of Linux or the linux ftdi / usb libs?

Cheers,

Keukpa
hmmm that is strange!

Thank you for your help and suggestions.

Could it be my version of Linux or the linux ftdi / usb libs?

Cheers,

Keukpa
keukpa
Robot Builder
Robot Builder
Posts: 15
Joined: Wed Feb 23, 2011 11:29 pm

Post by chrisvo » Tue Oct 25, 2011 4:01 pm

Post by chrisvo
Tue Oct 25, 2011 4:01 pm

libkondo4 will return error codes in its functions to indicate what's wrong. my example code in this thread skips checking for error codes, but you can take a look at the samples in the utils/ folder for how to check for errors and maybe that will tell you something. For example, if there was an error communicating over the FTDI then it would usually tell you specifically what in the FTDI library had a problem, and which kondo (libkondo4) function caused it.
libkondo4 will return error codes in its functions to indicate what's wrong. my example code in this thread skips checking for error codes, but you can take a look at the samples in the utils/ folder for how to check for errors and maybe that will tell you something. For example, if there was an error communicating over the FTDI then it would usually tell you specifically what in the FTDI library had a problem, and which kondo (libkondo4) function caused it.
chrisvo
Savvy Roboteer
Savvy Roboteer
Posts: 132
Joined: Mon Nov 02, 2009 10:24 pm

response not valid

Post by keukpa » Tue Oct 25, 2011 4:15 pm

Post by keukpa
Tue Oct 25, 2011 4:15 pm

Hi Chrisvo,

I've put back in error checking and now get the following output:

[keukpa@localhost utils]$ sudo ./zero_pos 2
50, 255
send 89 bytes: 59 10 ff ff ff ff ff 1 ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f 15
recv 4 bytes: 4 10 6 1a
ERROR: kondo_send_ics_pos: Response was not valid


Any ideas?

Many thanks,

Keukpa
Hi Chrisvo,

I've put back in error checking and now get the following output:

[keukpa@localhost utils]$ sudo ./zero_pos 2
50, 255
send 89 bytes: 59 10 ff ff ff ff ff 1 ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f ff 7f 15
recv 4 bytes: 4 10 6 1a
ERROR: kondo_send_ics_pos: Response was not valid


Any ideas?

Many thanks,

Keukpa
keukpa
Robot Builder
Robot Builder
Posts: 15
Joined: Wed Feb 23, 2011 11:29 pm

Post by chrisvo » Tue Oct 25, 2011 4:42 pm

Post by chrisvo
Tue Oct 25, 2011 4:42 pm

wow, can you send me your code? I have never seen something like that.
wow, can you send me your code? I have never seen something like that.
chrisvo
Savvy Roboteer
Savvy Roboteer
Posts: 132
Joined: Mon Nov 02, 2009 10:24 pm

Post by keukpa » Tue Oct 25, 2011 4:53 pm

Post by keukpa
Tue Oct 25, 2011 4:53 pm

thank you, here is my program. This is residing in the /util directory and I use make to build it.

#include "rcb4.h"
#include <unistd>

KondoInstance ki;

int main(int argc, char *argv[])
{
// cmd line arguments ----------------------------

if (argc < 2) {
fprintf(stderr, "Usage: zero_pos position\n");
exit(1);
}

// open ------------------------------------------

int ret = kondo_init(&ki);
if (ret < 0) {
printf("%s", ki.error);
exit(-1);
}
ki.debug = 1;

// servo set (ALL)
unsigned char servos[] = { ~0, ~0, ~0, ~0, ~0 };

unsigned int command = 32767;

//send the command
ret = kondo_send_ics_pos(&ki, servos, command);
if (ret < 0) {
printf("%s", ki.error);
exit(-1);
}

unsigned int command1 = atoi(argv[1]);
ret = kondo_send_ics_pos(&ki, servos, command1);
if (ret < 0) {
printf("%s", ki.error);
exit(-1);
}

// close -----------------------------------------
ret = kondo_close(&ki);
if (ret < 0) {
printf("%s", ki.error);
exit(-1);
}
return 0;
}
thank you, here is my program. This is residing in the /util directory and I use make to build it.

#include "rcb4.h"
#include <unistd>

KondoInstance ki;

int main(int argc, char *argv[])
{
// cmd line arguments ----------------------------

if (argc < 2) {
fprintf(stderr, "Usage: zero_pos position\n");
exit(1);
}

// open ------------------------------------------

int ret = kondo_init(&ki);
if (ret < 0) {
printf("%s", ki.error);
exit(-1);
}
ki.debug = 1;

// servo set (ALL)
unsigned char servos[] = { ~0, ~0, ~0, ~0, ~0 };

unsigned int command = 32767;

//send the command
ret = kondo_send_ics_pos(&ki, servos, command);
if (ret < 0) {
printf("%s", ki.error);
exit(-1);
}

unsigned int command1 = atoi(argv[1]);
ret = kondo_send_ics_pos(&ki, servos, command1);
if (ret < 0) {
printf("%s", ki.error);
exit(-1);
}

// close -----------------------------------------
ret = kondo_close(&ki);
if (ret < 0) {
printf("%s", ki.error);
exit(-1);
}
return 0;
}
keukpa
Robot Builder
Robot Builder
Posts: 15
Joined: Wed Feb 23, 2011 11:29 pm

Post by keukpa » Tue Oct 25, 2011 9:45 pm

Post by keukpa
Tue Oct 25, 2011 9:45 pm

You wouldn't happen to have a pre-compiled binary for Linux I could try would you? If that works I can then at least rule out system problems! :)
You wouldn't happen to have a pre-compiled binary for Linux I could try would you? If that works I can then at least rule out system problems! :)
keukpa
Robot Builder
Robot Builder
Posts: 15
Joined: Wed Feb 23, 2011 11:29 pm

PreviousNext
37 postsPage 2 of 31, 2, 3
37 postsPage 2 of 31, 2, 3