<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
<link rel="self" type="application/atom+xml" href="http://forum.robosavvy.com/feed.php?f=1&amp;t=765" />

<title>RoboSavvy Forum</title>
<subtitle>Robosavvy Forum: The largest online community of Humanoid Robot Builders</subtitle>
<link href="http://forum.robosavvy.com/index.php" />
<updated>2006-12-11T09:08:04+01:00</updated>

<author><name><![CDATA[RoboSavvy Forum]]></name></author>
<id>http://forum.robosavvy.com/feed.php?f=1&amp;t=765</id>
<entry>
<author><name><![CDATA[ryann2k1]]></name></author>
<updated>2006-12-11T09:08:04+01:00</updated>
<published>2006-12-11T09:08:04+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=5152#p5152</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=5152#p5152"/>
<title type="html"><![CDATA[Programmable robot]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=5152#p5152"><![CDATA[
Hi all,<br />Are there any library source for C++?<br /><br /><blockquote><div><cite>Bullit wrote:</cite><br />Here are some links for avr programming.<br /><a href="http://hubbard.engr.scu.edu/embedded/avr/avrlib/docs/html/main.html" class="postlink">Procyon AVRlib</a><br /><a href="http://www.avrfreaks.net/" class="postlink">ARVfreaks</a><br /><a href="http://www.pdturner.info/index.html" class="postlink">Peter turner's very useful web site and links</a><br />I have not programmed the bioloid in C but I have programmed the CM-2 for the cycloid II in C and its very easy.  The tools are all free and there are many libraries available just not one specific for the bioloid.  If you check the tribotix site you will find an example.c program that includes some basic communications functions for communicating with the dynamixels. At <a href="http://www.tribotix.info/Downloads/Downloads.htm" class="postlink">Tribotix</a>, look under CM-2.  I'm sure this is compatable with the CM-5 as they are almost identical.<br />I hope this helps.<br /></div></blockquote><p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=384">ryann2k1</a> — Mon Dec 11, 2006 9:08 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[limor]]></name></author>
<updated>2006-11-12T15:45:47+01:00</updated>
<published>2006-11-12T15:45:47+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4684#p4684</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4684#p4684"/>
<title type="html"><![CDATA[Programmable robot]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4684#p4684"><![CDATA[
Hi Bullit,<br /><br />the R/Txpacket routines are only superficially different.<br />I just tried to rewrite and comment B.S.Kim's (Robotis) code but dared not modify the protocol or the register sequencing.<br /><br />I created a new sourceforge project: robosavvy.sourceforge.net<br />and the plan is to upload and maintain various code excerpts posted regularly on this forum using sourceforge's CVS or maybe better SVN(?).<br />The licensing on this sourceforge project is LGPL which means open-source code that may be freely used in commercial projects (unlike GPL).<br /><br />If you or anyone else have a sourceforge user name, i'll gladly add you to the project group so you can maintain your source code revisions ro compiled applications through their great system and share it with everyone.<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=2">limor</a> — Sun Nov 12, 2006 3:45 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Bullit]]></name></author>
<updated>2006-11-12T14:54:15+01:00</updated>
<published>2006-11-12T14:54:15+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4683#p4683</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4683#p4683"/>
<title type="html"><![CDATA[Programmable robot]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4683#p4683"><![CDATA[
These are a few basic subroutines in my library for the CM-2 which may be useful.  Note the TXPacket and RxPacket are a little different then limor's above.<br /><br /><dl class="codebox"><dt>Code: </dt><dd><code>void setLED&#40;byte servoID,byte onOff01&#41;<br />&#123;<br />  byte bTxPacketLength,bRxPacketLength;<br />  <br />  if &#40;onOff01 &gt; 1&#41; onOff01 = 1;<br />  gbpParameter&#91;0&#93; = P_LED; //Address of LED<br />  gbpParameter&#91;1&#93; = onOff01;// 0 = Off, 1 = On<br />  bTxPacketLength = TxPacket&#40;servoID,INST_WRITE,2&#41;;<br />&#125;<br /><br />void setTorque&#40;byte servoID,uint16_t torque&#41;<br />&#123;<br />  byte th,tl,bTxPacketLength,bRxPacketLength;<br /><br />  th = torque &gt;&gt; 8;<br />  tl = torque &amp; 0xff;<br /><br />  gbpParameter&#91;0&#93; = P_TORQUE_LIMIT_L;<br />  gbpParameter&#91;1&#93; = tl;<br />  gbpParameter&#91;2&#93; = th;<br />  bTxPacketLength = TxPacket&#40;servoID,INST_WRITE,3&#41;;<br />   // now enable toque limit<br />  TorqueEnable&#40;servoID,1&#41;;<br />  return;<br />&#125;<br /><br />void TorqueEnable&#40;byte servoID,byte onoff01&#41;<br />&#123;<br />  byte bTxPacketLength,bRxPacketLength;<br /><br />  gbpParameter&#91;0&#93; = P_TORQUE_ENABLE; <br />  gbpParameter&#91;1&#93; = onoff01; // OnOff<br />  bTxPacketLength = TxPacket&#40;servoID,INST_WRITE,2&#41;;<br />  return;<br />&#125;<br /><br />void setSpeed&#40;byte servoID,uint16_t speed&#41;<br />&#123;<br />  byte th,tl,bTxPacketLength,bRxPacketLength;<br /><br />  th = speed &gt;&gt; 8;<br />  tl = speed &amp; 0xff;<br /><br />  gbpParameter&#91;0&#93; = P_GOAL_SPEED_L;<br />  gbpParameter&#91;1&#93; = tl;<br />  gbpParameter&#91;2&#93; = th;<br />  bTxPacketLength = TxPacket&#40;servoID,INST_WRITE,3&#41;;<br />  return;<br />&#125;<br /><br />void MoveTo&#40;byte servoID,uint16_t pos,uint16_t speed,byte wait&#41;<br />&#123;<br /><br />  byte ph,pl,sh,sl,bTxPacketLength,bRxPacketLength;<br />  uint16_t curpos;<br />  uint16_t count;<br />  <br />  ph = pos &gt;&gt; 8;<br />  pl = pos &amp; 0xff;<br />  sh = speed &gt;&gt; 8;<br />  sl = speed &amp; 0xff;<br />  <br />  gbpParameter&#91;0&#93; = P_GOAL_POSITION_L; //Address of Firmware Version<br />  gbpParameter&#91;1&#93; = pl; //Writing Data P_GOAL_POSITION_L<br />  gbpParameter&#91;2&#93; = ph; //Writing Data P_GOAL_POSITION_H<br />  gbpParameter&#91;3&#93; = sl; //Writing Data P_GOAL_SPEED_L<br />  gbpParameter&#91;4&#93; = sh; //Writing Data P_GOAL_SPEED_H<br />  bTxPacketLength = TxPacket&#40;servoID,INST_WRITE,5&#41;;<br /><br />  if&#40;wait == 0&#41; return;<br />  count = 0;<br />  while&#40;1&#41;<br />  &#123;<br />   curpos = GetMotorPosition&#40;servoID&#41;;<br />  if&#40;curpos != 0xffff&#41;<br />    &#123;<br />    count++;<br />   if&#40;curpos == pos || curpos == pos -1 || curpos == pos + 1&#41; <br />     &#123;<br />     TxDString&#40;&quot;\r\n Move complete at = &quot;&#41;;TxD32Dec&#40;&#40;long&#41;curpos&#41;;<br />     TxDString&#40;&quot;\r\n measurements = &quot;&#41;;TxD32Dec&#40;&#40;long&#41;count&#41;;<br />     return;<br />     &#125;<br />   &#125;<br />  &#125;<br />&#125;<br /><br />uint16_t GetMotorPosition&#40;byte servoID&#41;<br />&#123;<br />  byte bTxPacketLength,bRxPacketLength;<br />  uint16_t curpos;<br /><br />  gbpParameter&#91;0&#93; = P_PRESENT_POSITION_L; <br />  gbpParameter&#91;1&#93; = 2; //Read Length<br />  bTxPacketLength = TxPacket&#40;servoID,INST_READ,2&#41;;<br />  bRxPacketLength = RxPacket&#40;DEFAULT_RETURN_PACKET_SIZE+gbpParameter&#91;1&#93;&#41;;<br /><br />  if&#40;bRxPacketLength == DEFAULT_RETURN_PACKET_SIZE+gbpParameter&#91;1&#93;&#41;<br />   &#123;<br />    curpos = &#40;gbpRxBuffer&#91;6&#93;&lt;&lt;8&#41; + gbpRxBuffer&#91;5&#93;;<br />   return curpos;<br />   &#125;<br />  return 0xffff;<br />&#125;<br /><br />uint16_t GetMotorLoad&#40;byte servoID&#41;<br />&#123;<br />  byte bTxPacketLength,bRxPacketLength;<br />  uint16_t curVal;<br /><br />  gbpParameter&#91;0&#93; = P_PRESENT_LOAD_L; <br />  gbpParameter&#91;1&#93; = 2; //Read Length<br />  bTxPacketLength = TxPacket&#40;servoID,INST_READ,2&#41;;<br />  bRxPacketLength = RxPacket&#40;DEFAULT_RETURN_PACKET_SIZE+gbpParameter&#91;1&#93;&#41;;<br /><br />  if&#40;bRxPacketLength == DEFAULT_RETURN_PACKET_SIZE+gbpParameter&#91;1&#93;&#41;<br />   &#123;<br />    curVal = &#40;gbpRxBuffer&#91;6&#93;&lt;&lt;8&#41; + gbpRxBuffer&#91;5&#93;;<br />   return curVal;<br />   &#125;<br />  return 0xffff;<br />&#125;<br /><br />uint16_t GetMotorTorque&#40;byte servoID&#41;<br />&#123;<br />  byte bTxPacketLength,bRxPacketLength;<br />  uint16_t curVal;<br /><br />  gbpParameter&#91;0&#93; = P_TORQUE_LIMIT_L; <br />  gbpParameter&#91;1&#93; = 2; //Read Length<br />  bTxPacketLength = TxPacket&#40;servoID,INST_READ,2&#41;;<br />  bRxPacketLength = RxPacket&#40;DEFAULT_RETURN_PACKET_SIZE+gbpParameter&#91;1&#93;&#41;;<br /> <br />  if&#40;bRxPacketLength == DEFAULT_RETURN_PACKET_SIZE+gbpParameter&#91;1&#93;&#41;<br />   &#123;<br />    curVal = &#40;gbpRxBuffer&#91;6&#93;&lt;&lt;8&#41; + gbpRxBuffer&#91;5&#93;;<br />   return curVal;<br />   &#125;<br />  return 0xffff;<br />&#125;<br /><br />/*<br />TxPacket&#40;&#41; send data to RS485.<br />TxPacket&#40;&#41; needs 3 parameter; ID of Dynamixel, Instruction byte, Length of parameters.<br />TxPacket&#40;&#41; return length of Return packet from Dynamixel.<br />*/<br />byte TxPacket&#40;byte bID, byte bInstruction, byte bParameterLength&#41; <br />&#123;<br />    byte bCount,bCheckSum,bPacketLength;<br /><br />    gbpTxBuffer&#91;0&#93; = 0xff;<br />    gbpTxBuffer&#91;1&#93; = 0xff;<br />    gbpTxBuffer&#91;2&#93; = bID;<br />    gbpTxBuffer&#91;3&#93; = bParameterLength+2; //Length&#40;Paramter,Instruction,Checksum&#41;<br />    gbpTxBuffer&#91;4&#93; = bInstruction;<br />    for&#40;bCount = 0; bCount &lt; bParameterLength; bCount++&#41;<br />    &#123;<br />        gbpTxBuffer&#91;bCount+5&#93; = gbpParameter&#91;bCount&#93;;<br />    &#125;<br />    bCheckSum = 0;<br />    bPacketLength = bParameterLength+4+2;<br />    for&#40;bCount = 2; bCount &lt; bPacketLength-1; bCount++&#41; //except 0xff,checksum<br />    &#123;<br />        bCheckSum += gbpTxBuffer&#91;bCount&#93;;<br />    &#125;<br />    gbpTxBuffer&#91;bCount&#93; = ~bCheckSum; //Writing Checksum with Bit Inversion<br /><br />    RS485_TXD;<br />    for&#40;bCount = 0; bCount &lt; bPacketLength; bCount++&#41;<br />    &#123;<br />        sbi&#40;UCSR0A,6&#41;;//SET_TXD0_FINISH;<br />        TxD80&#40;gbpTxBuffer&#91;bCount&#93;&#41;;<br />    &#125;<br />    while&#40;!CHECK_TXD0_FINISH&#41;; //Wait until TXD Shift register empty<br />    RS485_RXD;<br />    return&#40;bPacketLength&#41;;<br />&#125;<br /><br />/*<br />RxPacket&#40;&#41; read data from buffer.<br />RxPacket&#40;&#41; need a Parameter; Total length of Return Packet.<br />RxPacket&#40;&#41; return Length of Return Packet.<br />*/<br /><br />byte RxPacket&#40;byte bRxPacketLength&#41;<br />&#123;<br />#define RX_TIMEOUT_COUNT2   3000L  <br />#define RX_TIMEOUT_COUNT1  &#40;RX_TIMEOUT_COUNT2*10L&#41;  <br />  unsigned long ulCounter;<br />  byte bCount, bLength, bChecksum;<br />  byte bTimeout;<br /><br />  bTimeout = 0;<br />  for&#40;bCount = 0; bCount &lt; bRxPacketLength; bCount++&#41;<br />  &#123;<br />    ulCounter = 0;<br />    while&#40;gbRxBufferReadPointer == gbRxBufferWritePointer&#41;<br />    &#123;<br />      if&#40;ulCounter++ &gt; RX_TIMEOUT_COUNT1&#41;<br />      &#123;<br />        bTimeout = 1;<br />        break;<br />      &#125;<br />    &#125;<br />    if&#40;bTimeout&#41; break;<br />    gbpRxBuffer&#91;bCount&#93; = gbpRxInterruptBuffer&#91;gbRxBufferReadPointer++&#93;;<br />  &#125;<br />  bLength = bCount;<br />  bChecksum = 0;<br />  <br />  if&#40;gbpTxBuffer&#91;2&#93; != BROADCASTING_ID&#41;<br />  &#123;<br />    if&#40;bTimeout &amp;&amp; bRxPacketLength != 255&#41; <br />    &#123;<br />      if&#40;bVerbose == 1&#41; <br />       &#123;<br />      TxDString&#40;&quot;\r\n &#91;Error:RxD Timeout&#93;&quot;&#41;;<br />        &#125;      <br />     CLEAR_BUFFER;<br />    &#125;<br />    <br />    if&#40;bLength &gt; 3&#41; //checking is available.<br />    &#123;<br />      if&#40;gbpRxBuffer&#91;0&#93; != 0xff || gbpRxBuffer&#91;1&#93; != 0xff &#41; <br />      &#123;<br />        if&#40;bVerbose == 1&#41; <br />         &#123;<br />         TxDString&#40;&quot;\r\n &#91;Error:Wrong Header&#93;&quot;&#41;;<br />         &#125;<br />      CLEAR_BUFFER;<br />        return 0;<br />      &#125;<br />      if&#40;gbpRxBuffer&#91;2&#93; != gbpTxBuffer&#91;2&#93; &#41;<br />      &#123;<br />        if&#40;bVerbose == 1&#41; <br />         &#123;<br />         TxDString&#40;&quot;\r\n &#91;Error:TxID != RxID&#93;&quot;&#41;;<br />         &#125;<br />      CLEAR_BUFFER;<br />        return 0;<br />      &#125;  <br />      if&#40;gbpRxBuffer&#91;3&#93; != bLength-4&#41; <br />      &#123;<br />        if&#40;bVerbose == 1&#41; <br />         &#123;<br />         TxDString&#40;&quot;\r\n &#91;Error:Wrong Length&#93;&quot;&#41;;<br />         &#125;<br />        CLEAR_BUFFER;<br />        return 0;<br />      &#125;  <br />      for&#40;bCount = 2; bCount &lt; bLength; bCount++&#41; bChecksum += gbpRxBuffer&#91;bCount&#93;;<br />      if&#40;bChecksum != 0xff&#41; <br />      &#123;<br />        if&#40;bVerbose == 1&#41; <br />         &#123;<br />         TxDString&#40;&quot;\r\n &#91;Error:Wrong CheckSum&#93;&quot;&#41;;<br />         &#125;<br />        CLEAR_BUFFER;<br />        return 0;<br />      &#125;<br />    &#125;<br />  &#125;<br />  return bLength;<br />&#125;<br /><br /><br /></code></dd></dl><br />again, I use these for the CM-2 but they should be identical.<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=173">Bullit</a> — Sun Nov 12, 2006 2:54 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[limor]]></name></author>
<updated>2006-11-12T13:59:50+01:00</updated>
<published>2006-11-12T13:59:50+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4682#p4682</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4682#p4682"/>
<title type="html"><![CDATA[Programmable robot]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4682#p4682"><![CDATA[
Hello freeforall and welcome to the forum!<br /><br />I've uploaded some code for the Bioloid.<br />It is a rewrite of the example.c that comes with the kit.<br /><br /><!-- m --><a class="postlink" href="http://robosavvy.com/Builders/limor/Bioloid_example.zip">http://robosavvy.com/Builders/limor/Bioloid_example.zip</a><!-- m --><br /><br />The pnproj file is a Programmers Notepad Project file. WinAVR (gcc for Atmel) comes with PN as the default IDE. It uses gnu make to compile the project. The makefile only needs a couple of lines modified to fit your project files.<br /><br />This code is not yet fully functional but it demonstrates how Atmega128 is programmed and how the Robotis servo protocol works.<br /><br />It should be compatible eventually with both the CM5 and with the Bioloid sensor board by Pepperm (search the Bioloid forum).<br /><br /><br />For example, here is a routines that initialize the RS485 serial interface <br /><br /><dl class="codebox"><dt>Code: </dt><dd><code><br />/*<br /> * InitSerialRS485 - set the i/o pins to talk to servos<br /> * Interrupt - if 1 then input will be interrupt driven<br /> *             gInterruptBuffer&#91;gInterruptBufferPointer++&#93; will continously take new read values<br /> * Baudrate - used in conjunction with prescaler...<br /> */<br />void InitSerialRS485&#40;byte Baudrate, byte Interrupt&#41;<br />&#123;<br /><br />    UBRR0H = 0;<br />   UBRR0L = Baudrate; <br />    UCSR0A = 0x02; // U2X: Double the USART transmission speed<br />   UCSR0B = 0x18; // Receiver and Transmitter enable<br />    if&#40;Interrupt&#41; sbi&#40;UCSR0B,7&#41;; // RxD interrupt enable<br />    UCSR0C = 0x06; // 8 bit data, no parity<br />   UDR0 = 0xFF; // this will be broadcast &#40;may be required by servos?&#41;<br />    SET_TXRS485_FINISH; // Note. set 1, then 0 is read<br />&#125;<br /><br /></code></dd></dl><br /><br />As you may notice, it is indeed C but 99% of the logic of what this code does is in the Atmega128 documentation. There is no object-oriented design patterns. This is back to basics, like writing a device driver. No operating system no JIT or garbage-collection or simulated threads or any other hidden agenda. <br /><br />Here's another example, this time it is the actual implementation of the Robotis protocol<br /><br /><dl class="codebox"><dt>Code: </dt><dd><code><br />volatile byte Buffer&#91;256&#93;; // in interrupt UART read mode, gBuffer&#91;gBufferPointer++&#93; will continously take new read values<br />volatile byte BufferPointer=0;<br /><br /><br />/*<br /> * SIGNAL&#40;&#41;  Rx Interrupt - write data to buffer &#40;used with CM5's RS485&#41;<br /> * When a byte &#40;8bit + parity + stop&#41; has been read by the Atmega, it issues an interrupt <br /> * RxBufferPointer goes back to 0 after 255, RxPacket doesn't need it to reset it to 0<br /> *<br /> * The reason for using an interrupt driven Rx is because the CM5 has 2 serials.<br /> * you can't poll two Rx because the other one may need attention during poll.<br /> */<br />SIGNAL &#40;SIG_UART0_RECV&#41;<br />&#123;<br />   Buffer&#91;BufferPointer++&#93; = RXRS485_DATA;<br />&#125;<br /><br /><br /><br /><br />/*<br /> * TxRS485&#40;&#41; write byte to Robotis bus <br /> */<br />static void TxRS485&#40;byte Data&#41;<br />&#123;<br />   while&#40;!CHECK_TXRS485_READY&#41;;<br />   TXRS485_DATA = Data;<br />&#125;<br />/*<br /> * RxRS485&#40;&#41; read byte from Robotis bus &#40;CM5 is normally interrupt Rx so doesnt use this routine&#41;<br /> */<br />static byte RxRS485&#40;void&#41;<br />&#123;<br />   while&#40;!CHECK_RXRS485_READY&#41;;<br />   return&#40;RXRS485_DATA&#41;;<br />&#125;<br /><br /><br /><br /><br /><br />/*<br />TxRS485Packet&#40;&#41; send Robotis package to RS485.<br />Similar format packet is sent by master and by slave &#40;5th byte differs&#41;<br />ID - My ID<br />Instruction - Master: PING, READ etc. Slave: Error bitmask<br />ParameterLength - number of parameters sent in Buffer<br />Parameter - will be coppied to Buffer&#91;5&#93;..Buffer&#91;5+ParameterLength-1&#93; <br />*/<br />void TxRS485Packet&#40;byte ID, byte Instruction, byte ParameterLength, byte *Parameter&#41; <br />&#123;<br />    byte i, CheckSum, PacketLength;<br /><br />    Buffer&#91;0&#93; = 0xff;<br />    Buffer&#91;1&#93; = 0xff;<br />    Buffer&#91;2&#93; = ID;<br />    Buffer&#91;3&#93; = ParameterLength+2; //Length&#40;Paramter,Instruction,Checksum&#41;<br />    Buffer&#91;4&#93; = Instruction;<br />   for &#40;i=0; i&lt; ParameterLength;i++&#41;<br />      Buffer&#91;5+i&#93; = Parameter&#91;i&#93;;<br /><br />    CheckSum = 0;<br />    PacketLength = ParameterLength+4+2;<br />    for&#40;i = 2; i &lt; PacketLength-1; i++&#41; //except 0xff,checksum<br />    &#123;<br />        CheckSum += Buffer&#91;i&#93;;<br />    &#125;<br />    Buffer&#91;i&#93; = ~CheckSum; //Writing Checksum with Bit Inversion<br /><br />    SET_RS485_TXD;<br />    for&#40;i = 0; i &lt; PacketLength; i++&#41;<br />    &#123;<br />        SET_TXRS485_FINISH; // ? this only clears bit6. triggers interrupt if interrupt flag is set<br />        TxRS485&#40;Buffer&#91;i&#93;&#41;;<br />    &#125;<br />    while&#40;!CHECK_TXRS485_FINISH&#41;; // Wait until &#40;bit6&#41; TXD Shift register empty<br />    SET_RS485_RXD;<br />   <br />   BufferPointer=0; // Response packet instantanous. Interrupt Rx relies on buffer being filled from 0<br />&#125;<br /><br />/*<br /> * RxRS485Packet&#40;&#41; receive Robotis instruction packet through RS485.<br /> * This is is the non-interrupt version of the read-packet designed for a sensor board.<br /> * The full protocol implementation of the protocol is needed only by Robotis servos<br /> * returns the packet pointer if the packet is intended for me otherwise null<br />*/<br />byte *RxRS485Packet&#40;byte ID&#41; <br />&#123;<br />    byte i;<br />   <br />   <br />    Buffer&#91;0&#93; = RxRS485&#40;&#41;; // 0xff;<br />    Buffer&#91;1&#93; = RxRS485&#40;&#41;; // 0xff;<br />    Buffer&#91;2&#93; = RxRS485&#40;&#41;; // ID;<br />    Buffer&#91;3&#93; = RxRS485&#40;&#41;; // ParameterLength+2; // Length&#40;Paramter,Instruction,Checksum&#41;<br />    Buffer&#91;4&#93; = RxRS485&#40;&#41;; // Instruction;<br />   for &#40;i=0; i&lt;Buffer&#91;3&#93;-2; i++&#41;<br />      Buffer&#91;5+i&#93; = RxRS485&#40;&#41;; // Parameters..<br />   Buffer&#91;5+i&#93; = RxRS485&#40;&#41;; // Checksum;<br />   <br />   // not performing any error checking. assumning that robotis cables are ok.<br />   <br />   return &#40;Buffer&#91;2&#93; == ID&#41;? Buffer: &#40;byte *&#41;0;<br /><br />&#125;<br /><br />/*<br /> * RxRS485PacketIntr&#40;&#41; receive Robotis &#40;response&#41; packet through RS485.<br /> * This is is the interrupt-driven version of the read-packet designed for CM5<br /> * Just waits for the buffer to fill up by the interrupt routine<br /> *<br /> * The reason for using an interrupt driven Rx is because the CM5 has 2 serials.<br /> * you can't poll two Rx because the other one may need attention during poll.<br />*/<br /><br />byte *RxRS485PacketIntr&#40;&#41; <br />&#123;<br />   byte i;<br />   long r=0;<br />   <br />   while &#40;BufferPointer &lt; 4&#41; if &#40;r++ &gt; 100000&#41; return 0;<br />   while &#40;BufferPointer &lt; 4+Buffer&#91;3&#93;&#41; if &#40;r++ &gt; 200000&#41; return 0;<br /><br />   return Buffer;<br /><br />&#125;<br /><br /></code></dd></dl><br /><br /><br />Finally here is the actual main() program. Hopefully when this library will be complete, you wont have to care about the details of the above implementation of the protocol and initialization, and focus only on getting servo position and other sensor data packets and sending back servo position and torque packets and you AI algorithms.<br /><br /><dl class="codebox"><dt>Code: </dt><dd><code><br />#include &lt;inttypes.h&gt;<br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;avr/sleep.h&gt;<br /><br />#include &quot;robotis.h&quot;<br /><br /><br /><br />int main &#40;void&#41;<br />&#123;<br />   unsigned short popo=300;<br />   byte i;<br />   byte *packet;<br />   byte buf&#91;256&#93;;<br />   <br />   InitPorts&#40;&#41;;<br /><br />   InitSerialRS485&#40;BAUD_1000000, 1&#41;; // Rx is interrupt driven<br />   InitSerialPC&#40;BAUD_57600, 0&#41;; // Rx is not interrupt driven<br /><br />   sei&#40;&#41;; // enable interrupts<br />   <br />   while &#40;1&#41; &#123;<br />   <br />      TxPCString&#40;&quot;Press Enter -&gt;&quot;&#41;;<br />      RxPC&#40;&#41;; // wait for PC keypress<br /><br />   popo += 30;<br />   buf&#91;0&#93; = P_GOAL_POSITION_L;<br />   buf&#91;1&#93; = 0; // Data P_GOAL_POSITION_L<br />   buf&#91;2&#93; = 2; // Data P_GOAL_POSITION_H<br />   buf&#91;3&#93; = 0x00; // Data P_GOAL_SPEED_L<br />   buf&#91;4&#93; = 0x01; // Data P_GOAL_SPEED_H<br />   TxRS485Packet&#40;6,INST_WRITE,5, buf&#41;;<br />   if &#40;packet = RxRS485PacketIntr&#40;&#41;&#41;   TxPCString&#40;&quot;Bingo!\r\n&quot;&#41;;<br />   <br />   <br />      for &#40;i=0; i &lt;20; i++&#41; &#123;<br />         TxPCString&#40;&quot;Testing &#91;&quot;&#41;;<br />         TxPC32Dec&#40;i&#41;;<br />         TxPCString&#40;&quot;&#93; &quot;&#41;;<br />         TxRS485Packet&#40;i, INST_PING, 0, 0&#41;;<br />         if &#40;packet = RxRS485PacketIntr&#40;&#41;&#41; &#123;<br />            TxPCString&#40;&quot;Bingo!&quot;&#41;;<br />         &#125;<br />         TxPCString&#40;&quot;\r\n&quot;&#41;;<br />      &#125;<br />   &#125;<br />&#125;<br /></code></dd></dl><p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=2">limor</a> — Sun Nov 12, 2006 1:59 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Bullit]]></name></author>
<updated>2006-11-12T13:45:51+01:00</updated>
<published>2006-11-12T13:45:51+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4681#p4681</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4681#p4681"/>
<title type="html"><![CDATA[Programmable robot]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4681#p4681"><![CDATA[
Here are some links for avr programming.<br /><a href="http://hubbard.engr.scu.edu/embedded/avr/avrlib/docs/html/main.html" class="postlink">Procyon AVRlib</a><br /><a href="http://www.avrfreaks.net/" class="postlink">ARVfreaks</a><br /><a href="http://www.pdturner.info/index.html" class="postlink">Peter turner's very useful web site and links</a><br />I have not programmed the bioloid in C but I have programmed the CM-2 for the cycloid II in C and its very easy.  The tools are all free and there are many libraries available just not one specific for the bioloid.  If you check the tribotix site you will find an example.c program that includes some basic communications functions for communicating with the dynamixels. At <a href="http://www.tribotix.info/Downloads/Downloads.htm" class="postlink">Tribotix</a>, look under CM-2.  I'm sure this is compatable with the CM-5 as they are almost identical.<br />I hope this helps.<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=173">Bullit</a> — Sun Nov 12, 2006 1:45 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[inaki]]></name></author>
<updated>2006-11-12T13:26:31+01:00</updated>
<published>2006-11-12T13:26:31+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4680#p4680</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4680#p4680"/>
<title type="html"><![CDATA[Programmable robot]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4680#p4680"><![CDATA[
There are no libraries to program the Bioloid in C. The only thing that Bioloid has published is a simple source code to perform some basic tasks, mostly communications. <br /><br />Reading and writing from/to servos is easy with your own program. The only thing you will miss is that you lose all standard CM5 abilities when you program your CM5 in C. Note that CM5 has an internal set of software registers, already made functions, and a BCP interpreter. You lose all that when you put your own C program into CM5. The reason is you replace the original program with your own. A small part remains which allows you to upload a new program or restore the original Bioloid code.<br /><br />Other than that you can program the Bioloid in the language of your choice in your PC using remote control, that is, using the serial interface from your PC to send commands and receive data. This interface is used for example by Robot Terminal, a program that comes with Bioloid kit.<br /><br />You can even prepare a BCP program that allows remote control using Zigbee wireless from your PC (or even Bluetooth if you perform the hack provided by Pev).<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=8">inaki</a> — Sun Nov 12, 2006 1:26 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[freeforall]]></name></author>
<updated>2006-11-12T09:57:16+01:00</updated>
<published>2006-11-12T09:57:16+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4679#p4679</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4679#p4679"/>
<title type="html"><![CDATA[Programmable robot]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4679#p4679"><![CDATA[
thank you for your answer. <br /><br />but do you know any tutorials which can help me to program the Bioloid in C?<br /><br />actually I know how to program in C language in general but I don't know how programming a robot's microcontroller. There is certainly some C libraries which permit to program it. Isn't it?<br /><br />thank you.<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=377">freeforall</a> — Sun Nov 12, 2006 9:57 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[hivemind]]></name></author>
<updated>2006-11-12T02:29:51+01:00</updated>
<published>2006-11-12T02:29:51+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4674#p4674</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4674#p4674"/>
<title type="html"><![CDATA[Programmable robot]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4674#p4674"><![CDATA[
Hello,<br /><br />Yes, I believe the Bioloid is the best robot (that I have seen) as far as programming goes.  It also happens to have the best servos (at least for a reasonable cost) and a great design.  Robotis did nice work putting it together.  But that is just opinion.  <br /><br />I think that if I wouldnt have gotten an RN then it would have been a Bioloid of me.<br /><br />Gotta love robots <img src="http://forum.robosavvy.com/images/smilies/icon_smile.gif" alt=":)" title="Smile" /> <br /><br />-Hive<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=221">hivemind</a> — Sun Nov 12, 2006 2:29 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[freeforall]]></name></author>
<updated>2006-11-12T02:16:38+01:00</updated>
<published>2006-11-12T02:16:38+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4673#p4673</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4673#p4673"/>
<title type="html"><![CDATA[Programmable robot]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=765&amp;p=4673#p4673"><![CDATA[
Hello everybody,<br /><br />Could you help me to choose a robot which permits programming in java or in C language ( I prefer java).<br /><br />I did some research on the internet: the best robot I found is the bioloid. what do you think of this robot as far as programming in C is concerned? if you have any other suggestions I will be pleased to know them.<br /><br />Moreover do you know any tutorials about programming the bioloid in C ?<br /><br />Thank you for your help.<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=377">freeforall</a> — Sun Nov 12, 2006 2:16 am</p><hr />
]]></content>
</entry>
</feed>