PDA

View Full Version : Open CM9.04 - Anyone had luck programming using the Arduno IDE?



KurtEck
12-15-2017, 05:32 PM
I was wondering if anyone has been using the current versions of Arduino (1.8.5) to program their OpenCM9.04 controllers.

I followed the instructions given in: https://github.com/ROBOTIS-GIT/OpenCM9.04/wiki/Arduino_Setup_Windows

And I have successfully built a program (example blink) for the board, but it errors out trying to write to the board. Note: I have successfully been able to use their private IDE to upload the board. Note: I have tried it on a couple of boards now.

I also installed the Arduino build on my UP board running Ubuntu following the similar instructions in:
https://github.com/ROBOTIS-GIT/OpenCM9.04/wiki/Arduino_Setup_Linux

With the same failure to upload. Wondering if it is expecting a different bootloader or?

Just wondering if I am missing something obvious. I tried it with an older B version I had, plus an C version I received today from Trossen and an A I also received today from Robotis.

Anyone tried this? Suggestions?

Thanks

KurtEck
12-15-2017, 07:02 PM
Quick update: Sort-of answer for myself.

Was able to get the Arduino to download, by using the firmware recovery method.

That is you unplug all power, and while holding in the little button, plug it into usb and then release. The green light stays on and then able to download the program...

KurtEck
12-18-2017, 08:02 AM
In case anyone is following.... On the above, worked on the new boards (at least the 2 out of 3 I have tried). It still does not work on my original board. Maybe it has a different firmware...

Will soon create new thread about making a version of the Phantom_Phoenix code base for the OpenCM board. I do have a working version of my AX12_Test program, that was converted to use the DynamixelSDK code. It currently defaults to working with servos on Serial3, but can switch to Serial1. I will probably make the version of the Phoenix code work with servos on either.

Probably more of a comment for other thread, but I soldered together one of the 904a boards with the normal AX servo headers and have it plugged into the 485 board... The servos don't work yet as no Servo power is brought back from 485 board to 904 board. Need to setup some form of jumper...

Next question/observation: The Arduino core files installed with the Arduino setup (from #1), do not install the actual core source files, they only install the header files... So I am assuming the build uses some form of pre-built archive in their builds. I found this out when some of my core hung (trying to initialize XBee).

while (Serial2.read() != -1) ;
Note: I believe this code works for the USB serial (change Serial2 to Serial)

When I looked in where Arduino was installed:
C:\Users\kurte\AppData\Local\Arduino15\packages\Op enCM904\hardware\OpenCM904\1.0.0\cores\arduino

There were only header files...

I looked up on github and I believe found the sources and releases at: https://github.com/ROBOTIS-GIT/OpenCM9.04

I believe their code is wrong:
The UARTClass.cpp code for read is:

int UARTClass::read( void )
{
rx_cnt++;
return drv_uart_read(_uart_num);
}

And the drv... code:

int drv_uart_read(uint8_t uart_num)
{
int ret = -1;
int index;

index = drv_uart_rx_buf_tail[uart_num];

ret = drv_uart_rx_buf[uart_num][index];

drv_uart_rx_buf_tail[uart_num] = (drv_uart_rx_buf_tail[uart_num] + 1) % DRV_UART_RX_BUF_LENGTH;

return ret;
}
No where does the code check for queue being empty...

I obviously can/will work around this by doing something like:

while (Serial2.available()) Serial2.read();
But thought I would post this, in case anyone else was interested where source files are, or runs into a hang like this.

Edit: Also found that this causes code like:

XBeeSerial.print(F("+++"));
XBeeSerial.flush();
XBeeSerial.setTimeout(20); // give a little extra time
if (XBeeSerial.readBytesUntil('\r', ab, 10) > 0) {
To fail as the read buffer type commands in stream.cpp called timedRead which

int Stream::timedRead()
{
int c;
_startMillis = millis();
do {
c = read();
if (c >= 0) return c;
} while(millis() - _startMillis < _timeout);
return -1; // -1 indicates timeout
}
When the queue is empty will always return something. Whatever happened to be leftover in the queue from the previous usage of that queue (or 0 if first time through)

KurtEck
01-05-2018, 03:11 PM
I thought I put in an update... But maybe not.

I put this problem up on their github project as an issue and they have since then resolved it. Should be in the next release whenever that is released. Or you can grab the updated stuff from the development branch.

So far the IDE is working. There are some minor issues that I run into including:
a) All of my openCM 9.04 boards show up as the same COM port (10) on my windows Machine.
b) The compiler does not always appear to give me the right line number for error messages
c) Serial Monitor window does not appear to want to reconnect to the serial port if I do an upload. I have to close it and reopen it...

Any way I now have a version of the Phoenix code working using the OpenCM9.04 with the installed libraries. I also have it setup to be able to use the XBee or the Robotis Remote control that connects using the Robotis BlueTooth module...

With the Robotis RC100 controller,


http://support.robotis.com/en/images/product/auxdevice/communication/rc-100a.png
the interaction currently is really primitive as the controller does not have any Axis like controls, but instead has 10 buttons. The Serial messages are really basic: 0xff 0x55 <low byte> <~low byte><high byte><~high byte>
And you only receive messages when the user presses something and it continues to send messages about 18 per second and finishes when the user releases the buttons...

Probably something I should detail on a different thread.