Home

Main Menu

Who's Online

We have 11 guests and 14 members online
  • Thex1138
  • Enderwiggins
  • RKM83
  • RobotServicesGroup
  • Bullit
  • Ausrobo
  • matrix2db
  • robogeek3
  • helishaun
  • UncleBob
  • JonHylands
  • Tyberius
  • SK
  • veltrop

Login Form






Lost Password?
No account yet? Register
Welcome ( Log in )
English translation of PC -> RCB1 protocol

 
Post new topic   Reply to topic    RoboSavvy Forum Forum Index -> KHR-1, KHR-2HV, KHR3-HV & Kondo
View previous topic :: View next topic  
Author Message
limor
Savvy Roboteer
Savvy Roboteer


Joined: 11 Oct 2004
Posts: 1203
Location: London, UK

PostPosted: Sun Mar 06, 2005 11:25 am    Post subject: English translation of PC -> RCB1 protocol Reply with quote

Exclamation Finally you can write your own software for controlling KHR-1 Exclamation

This protocol is the same one used by HeartToHeat.

The document, originally in Japanese, was translated by Dan Albert of the South Jersey Robotics Group (SJRobotics.org).

http://www.robosavvy.com/Support/images/RCB1stdraft.doc
Back to top
View user's profile Send private message   MSN Messenger
Meltdown
Savvy Roboteer
Savvy Roboteer


Joined: 26 Nov 2004
Posts: 125
Location: Holland

PostPosted: Sun Mar 06, 2005 5:50 pm    Post subject: Reply with quote

So this can be used for lets say Visual Basic?
Back to top
View user's profile Send private message  
limor
Savvy Roboteer
Savvy Roboteer


Joined: 11 Oct 2004
Posts: 1203
Location: London, UK

PostPosted: Sun Mar 06, 2005 9:36 pm    Post subject: Reply with quote

Meltdown wrote:
So this can be used for lets say Visual Basic?


Yes. The protocol describes the messages sent and received by the PC over the serial port. Dan Albert sent me a program that he wrote. He has connected a Serial-to-WiFi board to his KHR-1. More info will be uploaded to the forum over the next couple of days.
Back to top
View user's profile Send private message   MSN Messenger
limor
Savvy Roboteer
Savvy Roboteer


Joined: 11 Oct 2004
Posts: 1203
Location: London, UK

PostPosted: Tue Mar 08, 2005 7:38 pm    Post subject: Reply with quote

I asked Dan Albert the following:

    how’s the wifi-serial connection working out ?
    which one did you use ?
    Any software you’d like to share ?


Dan asked me to post his reply on the forum.


Here are some source code project files :


I have the ATOP ABLELink GW21SW-MAXI.

It seems to work very well. I have written an embedded C++ app for my Axim that can send some basic commands to the KHR-1. I can put it into sleep mode, wake it up, and have it play 1 of the 40 stored motions.
The GW21SW-MAXI draws a bit to much current. At 450 mAmps that will drain the original pack fairly rapidly.
I've switched to using 1200mAh NiMH packs I got from www.onlybatteries.com They are much better than
the 600mAh Nicad pack that came with the KHR-1.
The other nice thing about the WiFi solution is that the serial port is high speed and bidirectional. It is my understanding,
although not yet tested or proven, that the 2400 baud remote port is only input.

I have included my VB program that I use to monitor the serial line between the PC and the bot. I had to build up a special serial cable.

Code:

 PC                                          Robot
                   MonTX
                       |         
TX --------------------------------------------RX
RX -------------------------------------------TX
                       |
                    MonRX


The Monitor lines go to com1 and com2 of a separate PC that runs the VB program.
You could use one PC if it had three serial ports.
Don't forget to tie the signal grounds together too.
There is a resistor in the PC connector of the original cable that needs to be there.
I forget which pin it is on, I think it was one of the handshaking lines.

The program displays the TXed and RXed data in Hex in two separate windows.
The program is not yet complete. There is a form for changing the port speed and com numbers but I haven't
had time to finish it. It also has a tendency to get some errors as the text window gets too full.
There is a clear window button that helps that problem.
Also, I could have made it format the responses a bit better in the receive data window.

You will need VB6 to compile and run it.
If you don't have it I can compile a runtime for you.

dan


Last edited by limor on Thu Dec 14, 2006 1:27 am; edited 3 times in total
Back to top
View user's profile Send private message   MSN Messenger
limor
Savvy Roboteer
Savvy Roboteer


Joined: 11 Oct 2004
Posts: 1203
Location: London, UK

PostPosted: Mon Mar 14, 2005 7:28 pm    Post subject: Reply with quote

check out what Dan uploaded :



Last edited by limor on Tue Sep 26, 2006 10:25 am; edited 2 times in total
Back to top
View user's profile Send private message   MSN Messenger
DanAlbert
Savvy Roboteer
Savvy Roboteer


Joined: 04 Feb 2005
Posts: 70

PostPosted: Wed Mar 16, 2005 7:55 pm    Post subject: Visual Basic Monitor program Reply with quote

Some added info:

My original cable split the lines into two additional cables. One for TX and one for RX. It occurs to me that you should need only one cable with both signals. The program would need to be changed to use only COMM1. It currently uses COMM1 and COMM2. I will do this in the future after the RoboGames in SF.
Also, the resister inside the cable that comes with KHR-1 is used to pull down the TX line from the robot to DTR. Therefor DTR must be a low voltage. I found this out because the 802.11 device I was using had DTR always high. IE. commands were getting thru but responses were not coming back.

dan
Back to top
View user's profile Send private message  
Guest






PostPosted: Sun Aug 07, 2005 1:53 am    Post subject: Reply with quote



has anyone disected RoboSapien's receiver board and plugged it into KHR-1 as shown in this site?

http://www.alberts-equation.net/Robotics.shtml
Back to top
DanAlbert
Savvy Roboteer
Savvy Roboteer


Joined: 04 Feb 2005
Posts: 70

PostPosted: Wed Aug 17, 2005 1:59 pm    Post subject: Reply with quote

Sorry,
This RoboSapien Hack is custom programmed for the RoboSapien.
It is also built to plug into the RoboSapien's control board.
In addition the pic12F675 chip doesn't come with a UART to connect to the KHR-1.(However a good assembly programmer could make it do RS232)

However, you could build an I/R receiver and controller board to control the KHR-1 with the RoboSapien remote.
If I wanted to do this I might use a more powerful Pic that has a UART interface built in and then it is just a matter of preprogramming the RoboSapien moves into the KHR-1. (SMOP) Simple Matter of Prpramming)

Of course the KHR-1 is not as stable as the RS so some extra moves like "stand up" are in order. An IMU or at least a gyro would help too.

Anyway, it was a cool idea and I may add an I/R interface to the custom Robo-1 I am now constructing.

Dan Albert
Albert's Equation Inc.
Back to top
View user's profile Send private message  
Guest






PostPosted: Tue Sep 06, 2005 1:35 am    Post subject: VB Sample missing file? Reply with quote

I downloaded all the files and tried opening the visual basic program posted above, but I get an error message when opening the project that the file w32comms.bas could not be found. Crying or Very sad Can this file be made available? Doesn't work without whatever is in that module. Thanks
Back to top
DanAlbert
Savvy Roboteer
Savvy Roboteer


Joined: 04 Feb 2005
Posts: 70

PostPosted: Wed Sep 14, 2005 1:46 am    Post subject: Reply with quote

Sorry about the missing file.
I have uploaded it.
If you have any questions about the program, don't hesitate to contact me directly.

dan@sjrobotics.org
Back to top
View user's profile Send private message  
Pygmy
Newbie
Newbie


Joined: 14 Aug 2006
Posts: 1

PostPosted: Mon Aug 14, 2006 10:11 am    Post subject: Reply with quote

Dear Dan
May ask you that where you upload the mising file?
Back to top
View user's profile Send private message  
DanAlbert
Savvy Roboteer
Savvy Roboteer


Joined: 04 Feb 2005
Posts: 70

PostPosted: Mon Aug 14, 2006 1:35 pm    Post subject: Reply with quote

try under KHR-1 documentation.

There is a big "W" link that will download a word file.

It is the first draft and I may have a second draft lying around somewhere.

Let me know if it was helpful.

Dan
Back to top
View user's profile Send private message  
animetown9
Robot Builder
Robot Builder


Joined: 13 Sep 2006
Posts: 18

PostPosted: Sat Sep 23, 2006 9:54 pm    Post subject: Reply with quote

Hi all.

I try to download the above file and load into VB6
However, when I load it in...

it says...
file not fould "w32comms.bas"

Did I do something wrong.

Thanks in advance.
Back to top
View user's profile Send private message  
DanAlbert
Savvy Roboteer
Savvy Roboteer


Joined: 04 Feb 2005
Posts: 70

PostPosted: Tue Sep 26, 2006 1:29 am    Post subject: Reply with quote

Copy and paste the code below and save it as w32comms.bas

Attribute VB_Name = "W32Comms"
Option Explicit
Global RXByteBuffer() As Byte
Global TXByteBuffer() As Byte
Global RXByteTemp() As Byte
Global TXByteTemp() As Byte
Global intNextRX As Integer
Global intNextTX As Integer
Global intRXptr As Integer
Global intTXptr As Integer
Global variantRXBuffer As Variant
Global variantTXBuffer As Variant
Global variantOutData As Variant
Global ChkSum As Byte
Global Cmd As Byte
Global bytePortVal As Byte
Global intRXforCnt As Integer
Global intTXforCnt As Integer
Global CommPort As Integer
Global CurrentServo As Integer
' COMM stuff from WIN32API.TXT

' Serial provider type.
Const SP_SERIALCOMM = &H1&

' Provider SubTypes
Const PST_UNSPECIFIED = &H0&
Const PST_RS232 = &H1&
Const PST_PARALLELPORT = &H2&
Const PST_RS422 = &H3&
Const PST_RS423 = &H4&
Const PST_RS449 = &H5&
Const PST_FAX = &H21&
Const PST_SCANNER = &H22&
Const PST_NETWORK_BRIDGE = &H100&
Const PST_LAT = &H101&
Const PST_TCPIP_TELNET = &H102&
Const PST_X25 = &H103&

' Provider capabilities flags.
Const PCF_DTRDSR = &H1&
Const PCF_RTSCTS = &H2&
Const PCF_RLSD = &H4&
Const PCF_PARITY_CHECK = &H8&
Const PCF_XONXOFF = &H10&
Const PCF_SETXCHAR = &H20&
Const PCF_TOTALTIMEOUTS = &H40&
Const PCF_INTTIMEOUTS = &H80&
Const PCF_SPECIALCHARS = &H100&
Const PCF_16BITMODE = &H200&

' Comm provider settable parameters.
Const SP_PARITY = &H1&
Const SP_BAUD = &H2&
Const SP_DATABITS = &H4&
Const SP_STOPBITS = &H8&
Const SP_HANDSHAKING = &H10&
Const SP_PARITY_CHECK = &H20&
Const SP_RLSD = &H40&

' Settable baud rates in the provider.
Const BAUD_075 = &H1&
Const BAUD_110 = &H2&
Const BAUD_134_5 = &H4&
Const BAUD_150 = &H8&
Const BAUD_300 = &H10&
Const BAUD_600 = &H20&
Const BAUD_1200 = &H40&
Const BAUD_1800 = &H80&
Const BAUD_2400 = &H100&
Const BAUD_4800 = &H200&
Const BAUD_7200 = &H400&
Const BAUD_9600 = &H800&
Const BAUD_14400 = &H1000&
Const BAUD_19200 = &H2000&
Const BAUD_38400 = &H4000&
Const BAUD_56K = &H8000&
Const BAUD_128K = &H10000
Const BAUD_115200 = &H20000
Const BAUD_57600 = &H40000
Const BAUD_USER = &H10000000

' Settable Data Bits
Const DATABITS_5 = &H1&
Const DATABITS_6 = &H2&
Const DATABITS_7 = &H4&
Const DATABITS_8 = &H8&
Const DATABITS_16 = &H10&
Const DATABITS_16X = &H20&

' Settable Stop and Parity bits.
Const STOPBITS_10 = &H1&
Const STOPBITS_15 = &H2&
Const STOPBITS_20 = &H4&
Const PARITY_NONE = &H100&
Const PARITY_ODD = &H200&
Const PARITY_EVEN = &H400&
Const PARITY_MARK = &H800&
Const PARITY_SPACE = &H1000&

Type COMMPROP
wPacketLength As Integer
wPacketVersion As Integer
dwServiceMask As Long
dwReserved1 As Long
dwMaxTxQueue As Long
dwMaxRxQueue As Long
dwMaxBaud As Long
dwProvSubType As Long
dwProvCapabilities As Long
dwSettableParams As Long
dwSettableBaud As Long
wSettableData As Integer
wSettableStopParity As Integer
dwCurrentTxQueue As Long
dwCurrentRxQueue As Long
dwProvSpec1 As Long
dwProvSpec2 As Long
wcProvChar(1) As Integer
End Type

'Type COMSTAT
' fCtsHold As Long
' fDsrHold As Long
' fRlsdHold As Long
' fXoffHold As Long
' fXoffSent As Long
' fEof As Long
' fTxim As Long
' fReserved As Long
' cbInQue As Long
' cbOutQue As Long
'End Type

Type COMSTAT
fBitFields As Long 'See Comment in Win32API.Txt
cbInQue As Long
cbOutQue As Long
End Type
' The eight actual COMSTAT bit-sized data fields within the four bytes of fBitFields can be manipulated by bitwise logical And/Or operations.
' FieldName Bit # Description
' --------- ----- ---------------------------
' fCtsHold 1 Tx waiting for CTS signal
' fDsrHold 2 Tx waiting for DSR signal
' fRlsdHold 3 Tx waiting for RLSD signal
' fXoffHold 4 Tx waiting, XOFF char rec'd
' fXoffSent 5 Tx waiting, XOFF char sent
' fEof 6 EOF character sent
' fTxim 7 character waiting for Tx
' fReserved 8 reserved (25 bits)

' DTR Control Flow Values.
Const DTR_CONTROL_DISABLE = &H0
Const DTR_CONTROL_ENABLE = &H1
Const DTR_CONTROL_HANDSHAKE = &H2

' RTS Control Flow Values
Const RTS_CONTROL_DISABLE = &H0
Const RTS_CONTROL_ENABLE = &H1
Const RTS_CONTROL_HANDSHAKE = &H2
Const RTS_CONTROL_TOGGLE = &H3

'Type DCB
' DCBlength As Long
' BaudRate As Long
' fBinary As Long
' fParity As Long
' fOutxCtsFlow As Long
' fOutxDsrFlow As Long
' fDtrControl As Long
' fDsrSensitivity As Long
' fTXContinueOnXoff As Long
' fOutX As Long
' fInX As Long
' fErrorChar As Long
' fNull As Long
' fRtsControl As Long
' fAbortOnError As Long
' fDummy2 As Long
' wReserved As Integer
' XonLim As Integer
' XoffLim As Integer
' ByteSize As Byte
' Parity As Byte
' StopBits As Byte
' XonChar As Byte
' XoffChar As Byte
' ErrorChar As Byte
' EofChar As Byte
' EvtChar As Byte
'End Type

Type dcb
DCBlength As Long
BaudRate As Long
fBitFields As Long 'See Comments in Win32API.Txt
wReserved As Integer
XonLim As Integer
XoffLim As Integer
ByteSize As Byte
Parity As Byte
StopBits As Byte
XonChar As Byte
XoffChar As Byte
ErrorChar As Byte
EofChar As Byte
EvtChar As Byte
wReserved1 As Integer 'Reserved; Do Not Use
End Type
' The fourteen actual DCB bit-sized data fields within the four bytes of fBitFields can be manipulated by bitwise logical And/Or operations.
' FieldName Bit # Description
' ----------------- ----- ------------------------------
' fBinary 1 binary mode, no EOF check
' fParity 2 enable parity checking
' fOutxCtsFlow 3 CTS output flow control
' fOutxDsrFlow 4 DSR output flow control
' fDtrControl 5 DTR flow control type (2 bits)
' fDsrSensitivity 7 DSR sensitivity
' fTXContinueOnXoff 8 XOFF continues Tx
' fOutX 9 XON/XOFF out flow control
' fInX 10 XON/XOFF in flow control
' fErrorChar 11 enable error replacement
' fNull 12 enable null stripping
' fRtsControl 13 RTS flow control (2 bits)
' fAbortOnError 15 abort reads/writes on error
' fDummy2 16 reserved

Type COMMTIMEOUTS
ReadIntervalTimeout As Long
ReadTotalTimeoutMultiplier As Long
ReadTotalTimeoutConstant As Long
WriteTotalTimeoutMultiplier As Long
WriteTotalTimeoutConstant As Long
End Type


' COMM declarations
Declare Function SetCommState Lib "kernel32" (ByVal hCommDev As Long, lpDCB As dcb) As Long
Declare Function SetCommTimeouts Lib "kernel32" (ByVal hFile As Long, lpCommTimeouts As COMMTIMEOUTS) As Long
Declare Function GetCommState Lib "kernel32" (ByVal nCid As Long, lpDCB As dcb) As Long
Declare Function GetCommTimeouts Lib "kernel32" (ByVal hFile As Long, lpCommTimeouts As COMMTIMEOUTS) As Long
Declare Function PurgeComm Lib "kernel32" (ByVal hFile As Long, ByVal dwFlags As Long) As Long
Declare Function BuildCommDCB Lib "kernel32" Alias "BuildCommDCBA" (ByVal lpDef As String, lpDCB As dcb) As Long
Declare Function BuildCommDCBAndTimeouts Lib "kernel32" Alias "BuildCommDCBAndTimeoutsA" (ByVal lpDef As String, lpDCB As dcb, lpCommTimeouts As COMMTIMEOUTS) As Long
Declare Function TransmitCommChar Lib "kernel32" (ByVal nCid As Long, ByVal cChar As Byte) As Long
Declare Function SetCommBreak Lib "kernel32" (ByVal nCid As Long) As Long
Declare Function SetCommMask Lib "kernel32" (ByVal hFile As Long, ByVal dwEvtMask As Long) As Long
Declare Function ClearCommBreak Lib "kernel32" (ByVal nCid As Long) As Long
Declare Function ClearCommError Lib "kernel32" (ByVal hFile As Long, lpErrors As Long, lpStat As COMSTAT) As Long
Declare Function SetupComm Lib "kernel32" (ByVal hFile As Long, ByVal dwInQueue As Long, ByVal dwOutQueue As Long) As Long
Declare Function EscapeCommFunction Lib "kernel32" (ByVal nCid As Long, ByVal nFunc As Long) As Long
Declare Function GetCommMask Lib "kernel32" (ByVal hFile As Long, lpEvtMask As Long) As Long
Declare Function GetCommProperties Lib "kernel32" (ByVal hFile As Long, lpCommProp As COMMPROP) As Long
Declare Function GetCommModemStatus Lib "kernel32" (ByVal hFile As Long, lpModemStat As Long) As Long
'Declare Function WaitCommEvent Lib "kernel32" (ByVal hFile As Long, lpEvtMask As Long, lpOverlapped As OVERLAPPED) As Long

Public Sub sendData()
For intTXforCnt = 0 To intNextTX - 1
TXByteBuffer(intTXptr) = TXByteTemp(intTXforCnt)
intTXptr = intTXptr + 1
Next intTXforCnt

End Sub

' Set baud rate using Win32 API.
' The PortOpen property should be set to True before calling.
' May raise the following errors:
' comPortNotOpen the PortOpen property has not been set to True
' comDCBError failed to read current state of the port
' comSetCommStateFailed failed to set new baud rate
Sub SetBaudRate(Com As MSComm, baud As Long)
Dim ComDcb As dcb
Dim ret As Long

' Check port is open
If Not Com.PortOpen Then
Err.Raise comPortNotOpen, Com.Name, _
"Operation valid only when the port is open"
Exit Sub
End If

' Get existing Comm state
ret = GetCommState(Com.CommID, ComDcb)
If ret = 0 Then
Err.Raise comDCBError, Com.Name, _
"Could not read current state of the port"
Exit Sub
End If

' Modify state with new baud rate
ComDcb.BaudRate = baud
' Set the new Comm state
ret = SetCommState(Com.CommID, ComDcb)
If ret = 0 Then
Err.Raise comSetCommStateFailed, Com.Name, _
"Could not set port to specified baud rate" + Str(baud)
Exit Sub
End If
End Sub

' Get baud rate using Win32 API
' The PortOpen property should be set to True before calling.
' May raise the following errors:
' comPortNotOpen the PortOpen property has not been set to True
' comDCBError failed to read current state of the port
Function GetBaudRate(Com As MSComm) As Long
Dim ComDcb As dcb
Dim ret As Long

GetBaudRate = 0

' Check port is open
If Not Com.PortOpen Then
Err.Raise comPortNotOpen, Com.Name, _
"Operation valid only when the port is open"
Exit Function
End If

' Get Comm state
ret = GetCommState(Com.CommID, ComDcb)
If ret = 0 Then
Err.Raise comDCBError, Com.Name, _
"Could not read current state of the port"
Exit Function
End If
' Extract baud rate
GetBaudRate = ComDcb.BaudRate
End Function
Back to top
View user's profile Send private message  
Display posts from previous:   
Post new topic   Reply to topic    RoboSavvy Forum Forum Index -> KHR-1, KHR-2HV, KHR3-HV & Kondo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Robonova Humanoid Bioloid Comprehensive Kit Robobuilder 5710K Humanoid Robobuilder 5720T Humanoid MechRC ShadowStalker KHR 1 HV and KHR 2 HV Humanoids KHR 3HV Humanoid Kit
Robonova-I
Intro | Forum | Buy
Bioloid
Intro | Forum | Buy
Robobuilder 5710K
Intro | Forum | Buy
Robobuilder 5720T
Intro | Forum | Buy
MechRC
Intro | Forum | Buy
KHR 1HV & 2HV
1HV 2HV | Forum | Buy
KHR 3HV
Intro | Forum | Buy
POBbot Wheeled Platforms (POB) POPbot Arduino Wheeled Robot Microcamp Atmega8 Activity / Introductory Kit Robobox 3 Educational Robot Kit Robotis OLLO - Starter Robotics Kits Sparkfun Products Roboard X86 Embedded Robot Board
Edu Robots
Intro | Buy
Arduino Robot
Intro | Buy
Cheap Robot
Intro | Buy
Wheeled Robot
Intro | Buy
Kids Robots
Intro | Buy
Sparkfun Electronics
Buy
x86 Robot Board
Intro | Forum | Buy



Powered by phpBB ©

In Our Store

 

Robobuilder Hip Pivot Full Kit (incl. 2xwCK 1111 Full Mtl Gears)
£83.50   £98.11 inc. VAT
 

GoogleSearch

Google
robosavvy.com
Web


© 2010 RoboSavvy
All rights reserved. Privacy Policy.