by PedroR » Wed Mar 14, 2012 1:50 pm
by PedroR
Wed Mar 14, 2012 1:50 pm
Hi all
Following up to our initial discussions on this thread
http://robosavvy.com/forum/viewtopic.php?t=7811, we have put together an English document detailing how to
Control Motion Playing through the RCB4 Serial port/serial Protocol.
Our work is actually based on libkondo (by chrivo) and understanding what it does.
Our approach was to document and hard code the Byte sequences necessary for Stopping a motion, Playing a specific Motion number and Querying the motion Status.
While this is a bit of a brute force approach it has worked well for us and reliably for us.
Sequence for Playing a Motion:
To play a Motion there are 4 steps:
- Code: Select all
Step 1: Send a Command to Stop Current Program and Save Current Status to RAM. It's the same sequence of Bytes all the time regardless of the motion number.
Step 2: Send the "Run Motion" Command. This command varies depending on the Motion number.
Step 3: Send Command to restore Current Status. It's the same sequence of Bytes all the time regardless of the motion number.
Step 4 (OPTIONAL): Wait for the Motion to Complete. You can do it polling the controller every 50ms to obtain Execution Status.
""Polling"" the controller for Execution Status is OPTIONAL.
The detailed sequence of Bytes for each Operation
as well as Response codes can be found on the
Protocol Document we've created.
The part we've documented already offers good flexibility: you can start a motion, stop a motion and a
very handy one which is Query Motion status to determine if a Motion is running or not.
Also note that by following the sequence of steps above, it means that if you send another sequence to Play Motion while you're still executing a motion, the Robot will stop the current motion and will initiate the new motion.
Signal Levels and Sending commands Serial without using the Kondo USB Adapter HS:The Serial Commands are sent to RCB4 through the where the Kondo USb Adapter ICS connects when you want to use HTH.
You should set the Jumper position and connect the cable just as if you were going to use H2H.
It
is possible to send commands to RCB4 without using the Kondo USB Adapter HS (ie using your own MCU of a Bluetooth or Zigbee module but please keep reading as there are some odd requirements for talking to the RCB4).
RCB4 uses a Full Duplex bus and the pinout is explained in the picture bellow.
KHR 3HV- RCB4 Controller Pinout by
RoboSavvy, on Flickr
In this scenario, you will probably
need to a Logic Level converter because RCB4 uses 5V Inverted Logic.We've built a simple one ourselves to convert from 3.3V TTL to 5V TTL inverted logic which we will hopefully post over the next weeks.
Inverted Logic Essentially means that a 1 is represented by +5V and and idle is represented by a low voltage. This is the opposite of TTL where idle is +3.3V (or +5V) and a "1" is low 0 V.
( It was not completely clear for us if it uses CMOS or TTL logic as the Oscilloscope showed us something but Googling and user reports suggested otherwise but we used TTL levels and it worked fine. )
Also, as a side note, it seems the pinout for the PIO ports is incorrect in the manual. The outer pin is always GND (the manual mentions it's PIO on the outer pin). We _believe_ the pinout shown for PIO is correct in terms of where is Vdd and PIO but we haven't tested it thoroughly.
In terms of communication, another "gotcha" and odd feature of
RCB4 is that it uses EVEN parity (instead of the more common "No parity").
Apart from that, you can set
Baud Rate of RCB4 to different speed levels (ranging from 1.25 Mbps to 115 200bps) with setting: 8 data bits, 1 stop bit, EVEN parity.
Sample Python test ScriptWe have also created a simple
Python script that you can use to test your code.
To run it you will need install Python and to install the PySerial library.
- Code: Select all
Usage:
python_playmotion.py "COM_PORT" MOTION_NUMBER [TIMEOUT]
COM_PORT should be specified in the form of "COMx" for Windows and "/dev/ttySx"
or equivalent for Linux
This Python code should run on Windows, Linux and Mac.
Finding out more information and more commands:
If you'd like to find out more and really understand the complete structure of the packets (header, command and checksum), you may refer to
libkondo and also to the Japanese documentation release by Kondo here
http://kondo-robot.com/sys/archives/2477 (thanks to EngineerD for pointing this out)
Downloads:
The full PDF can be found here:
http://robosavvy.com/RoboSavvyPages/Sup ... otions.pdf
Python test Script:
http://robosavvy.com/RoboSavvyPages/Sup ... ymotion.py
Regards
Pedro.
Hi all
Following up to our initial discussions on this thread
http://robosavvy.com/forum/viewtopic.php?t=7811, we have put together an English document detailing how to
Control Motion Playing through the RCB4 Serial port/serial Protocol.
Our work is actually based on libkondo (by chrivo) and understanding what it does.
Our approach was to document and hard code the Byte sequences necessary for Stopping a motion, Playing a specific Motion number and Querying the motion Status.
While this is a bit of a brute force approach it has worked well for us and reliably for us.
Sequence for Playing a Motion:
To play a Motion there are 4 steps:
- Code: Select all
Step 1: Send a Command to Stop Current Program and Save Current Status to RAM. It's the same sequence of Bytes all the time regardless of the motion number.
Step 2: Send the "Run Motion" Command. This command varies depending on the Motion number.
Step 3: Send Command to restore Current Status. It's the same sequence of Bytes all the time regardless of the motion number.
Step 4 (OPTIONAL): Wait for the Motion to Complete. You can do it polling the controller every 50ms to obtain Execution Status.
""Polling"" the controller for Execution Status is OPTIONAL.
The detailed sequence of Bytes for each Operation
as well as Response codes can be found on the
Protocol Document we've created.
The part we've documented already offers good flexibility: you can start a motion, stop a motion and a
very handy one which is Query Motion status to determine if a Motion is running or not.
Also note that by following the sequence of steps above, it means that if you send another sequence to Play Motion while you're still executing a motion, the Robot will stop the current motion and will initiate the new motion.
Signal Levels and Sending commands Serial without using the Kondo USB Adapter HS:The Serial Commands are sent to RCB4 through the where the Kondo USb Adapter ICS connects when you want to use HTH.
You should set the Jumper position and connect the cable just as if you were going to use H2H.
It
is possible to send commands to RCB4 without using the Kondo USB Adapter HS (ie using your own MCU of a Bluetooth or Zigbee module but please keep reading as there are some odd requirements for talking to the RCB4).
RCB4 uses a Full Duplex bus and the pinout is explained in the picture bellow.
KHR 3HV- RCB4 Controller Pinout by
RoboSavvy, on Flickr
In this scenario, you will probably
need to a Logic Level converter because RCB4 uses 5V Inverted Logic.We've built a simple one ourselves to convert from 3.3V TTL to 5V TTL inverted logic which we will hopefully post over the next weeks.
Inverted Logic Essentially means that a 1 is represented by +5V and and idle is represented by a low voltage. This is the opposite of TTL where idle is +3.3V (or +5V) and a "1" is low 0 V.
( It was not completely clear for us if it uses CMOS or TTL logic as the Oscilloscope showed us something but Googling and user reports suggested otherwise but we used TTL levels and it worked fine. )
Also, as a side note, it seems the pinout for the PIO ports is incorrect in the manual. The outer pin is always GND (the manual mentions it's PIO on the outer pin). We _believe_ the pinout shown for PIO is correct in terms of where is Vdd and PIO but we haven't tested it thoroughly.
In terms of communication, another "gotcha" and odd feature of
RCB4 is that it uses EVEN parity (instead of the more common "No parity").
Apart from that, you can set
Baud Rate of RCB4 to different speed levels (ranging from 1.25 Mbps to 115 200bps) with setting: 8 data bits, 1 stop bit, EVEN parity.
Sample Python test ScriptWe have also created a simple
Python script that you can use to test your code.
To run it you will need install Python and to install the PySerial library.
- Code: Select all
Usage:
python_playmotion.py "COM_PORT" MOTION_NUMBER [TIMEOUT]
COM_PORT should be specified in the form of "COMx" for Windows and "/dev/ttySx"
or equivalent for Linux
This Python code should run on Windows, Linux and Mac.
Finding out more information and more commands:
If you'd like to find out more and really understand the complete structure of the packets (header, command and checksum), you may refer to
libkondo and also to the Japanese documentation release by Kondo here
http://kondo-robot.com/sys/archives/2477 (thanks to EngineerD for pointing this out)
Downloads:
The full PDF can be found here:
http://robosavvy.com/RoboSavvyPages/Sup ... otions.pdf
Python test Script:
http://robosavvy.com/RoboSavvyPages/Sup ... ymotion.py
Regards
Pedro.