With this small script the Servo degrees can be set by matlab.

 
% Define Serial Port for communication with the Kondo Robot
s=serial('COM1','Baud',115200,'DataBits',8,'StopBits',1,'Parity','none');
 
% Set RCB-1 Servo Position From Robot
cmd=hex2dec('FD');
% ID 0 means Channel 1:12
% ID 1 means Channel 13:24
ID=hex2dec('00');
% Servo Speed
Speed=hex2dec('07');
% Degrees in Hexadecimal representation
ch(1)=hex2dec('00');
ch(2)=hex2dec('07');
ch(3)=hex2dec('5A');
ch(4)=hex2dec('E1');
ch(5)=hex2dec('E1');
ch(6)=hex2dec('5A');
ch(7)=hex2dec('B4');
ch(8)=hex2dec('AD');
ch(9)=hex2dec('50');
ch(10)=hex2dec('E1');
ch(11)=hex2dec('E1');
ch(12)=hex2dec('E1');
 
% Calculate Checksum
TX_checksum=bitand(cmd+ID+Speed+sum(ch),hex2dec('7F'));
 
% Open Serial port and Send Data to the Kondo Robot
fopen(s);
fwrite(s, [cmd,ID,Speed,ch(1:end),TX_checksum], 'uint8');  
fclose(s);

4 Responses to “Matlab Controll”

  1. interpici says:

    Hello!

    I would like control a Kondo khr 2 hv robot by Matlab. I tried this code, but the robot didn’t move. I logged control in H2H and Matlab with PortMon, and I saw many difference. I tried change the code, I watched the rcb-1 command reference, and the robot didn’t move.

    Do you can help me?

    Thanks for help!

  2. Christoph says:

    Hi

    The command reference was writte for the KHR1, iam not shure if it is the same for the KHR2.

    You will have to reverse engeneer the whole serial communication.
    Begin with the Serial parameters like baud rate and so on. (you can see it in portmon too)
    These parameters need to be the same as for the H2H program.

    Then do some movement in the H2H and capture it with portmon.
    Now change the movement again and close H2H
    Start your matlab program with this capured command and the KHR2 should do the same movement as with the H2H program before.

    Just use
    fwrite(s, ‘command_read_from_portmon’, ‘uint8′);

  3. interpici says:

    I tried it, didn’t move… :(

  4. Christoph says:

    iam just asking to be shure
    The commands read from portmon are in Hexadecimal format am i right?
    the you need to use the command like this:
    fwrite(s,hex2dec(‘command_read_from_portmon’), ‘uint8′);

    due to the fact that i dont have a KHR2 available here i cant make investigations on my own.

    And As far is I remember i found somewhere on the net that the KHR2 is using 0xFF for calculating the
    checksum and not 0x7F

    It would be nice if you could write a blog entry about your research
    Maybe i could help if i had more information.

Leave a Reply