Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

Beginners Help with CM-5 C programming

Bioloid robot kit from Korean company Robotis; CM5 controller block, AX12 servos..
13 postsPage 1 of 1
13 postsPage 1 of 1

Beginners Help with CM-5 C programming

Post by LunaCity » Thu May 01, 2008 11:05 pm

Post by LunaCity
Thu May 01, 2008 11:05 pm

Hi. I just got a Bioloid comprehensive kit, but the CD doesn't contain the "example.c" file that has been mentioned here.

Can someone provide me with a simple, basic "Hello World" type of C program for the CM-5 that can be compiled from a unix or linux command line.

Also instructions for getting it into the CM-5 if necessary. (Converting to .hex)

Alternatively, I would love to just use the CM-5 as a battery pack and just run stuff via the USB2Dynamixel connector if possible, since the CM-5 seems to be such a pain in the butt to program. If anyone knows how to do that, let me know.

I have C code that can communicate with the AX-12 directly, but it doesn't work if I send it to the CM-5, and it seems like a waste to have to ignore the CM-5 altogether and install my own power supply.
Hi. I just got a Bioloid comprehensive kit, but the CD doesn't contain the "example.c" file that has been mentioned here.

Can someone provide me with a simple, basic "Hello World" type of C program for the CM-5 that can be compiled from a unix or linux command line.

Also instructions for getting it into the CM-5 if necessary. (Converting to .hex)

Alternatively, I would love to just use the CM-5 as a battery pack and just run stuff via the USB2Dynamixel connector if possible, since the CM-5 seems to be such a pain in the butt to program. If anyone knows how to do that, let me know.

I have C code that can communicate with the AX-12 directly, but it doesn't work if I send it to the CM-5, and it seems like a waste to have to ignore the CM-5 altogether and install my own power supply.
LunaCity
Newbie
Newbie
Posts: 3
Joined: Thu May 01, 2008 10:58 pm

Post by StuartL » Fri May 02, 2008 7:16 am

Post by StuartL
Fri May 02, 2008 7:16 am

Firstly: If you understand the controller inside the CM-5 (i.e. the Atmel ATMega128) programming it is trivial. If you've come from a C background where the only thing you've ever programmed has been on a host OS (e.g. Windows, Linux) you're going to have to re-learn some of the key ideas.

Whereas C was originally intended to be a user-friendly assembler (so that you could write hardware-level code in a manner that didn't require remembering every instruction) in the modern world it's morphed into Yet Another Language With A Million Libraries.

Obviously in an embedded solution you a) don't have those libraries and b) don't want them. You have a grand total of 4k of RAM in the CM-5 and while that's absolutely plenty to do almost everything you could conceive of (short of vision systems) you need to be careful when writing software. For example, a careless 1000 element integer array will take literally half of your RAM.

Having said all that C is not hard to use on any of the AVR systems. It's well documented and the AVR GCC provided with WinAVR uses all the same constant names as the Atmel products and documentation so you can literally read the Atmel PDFs and write C.

So the next steps for you are:

1) Download and get a feel for the Atmel ATMega128 PDF documentation. Particularly pay attention to the registers in each section.

2) Download the latest CD from Robotis (you can Google, right?).

3) Read the example.c and the Bioloid guides upside and backwards and forwards and backwards again. You may notice *lots* of deliberate errors in the example.c.

4) Upload the example.c by compiling it with WinAVR as per the Robotis PDFs and using Robot Terminal to send the .hex file.

5) Post on here whenever you have any questions.
Firstly: If you understand the controller inside the CM-5 (i.e. the Atmel ATMega128) programming it is trivial. If you've come from a C background where the only thing you've ever programmed has been on a host OS (e.g. Windows, Linux) you're going to have to re-learn some of the key ideas.

Whereas C was originally intended to be a user-friendly assembler (so that you could write hardware-level code in a manner that didn't require remembering every instruction) in the modern world it's morphed into Yet Another Language With A Million Libraries.

Obviously in an embedded solution you a) don't have those libraries and b) don't want them. You have a grand total of 4k of RAM in the CM-5 and while that's absolutely plenty to do almost everything you could conceive of (short of vision systems) you need to be careful when writing software. For example, a careless 1000 element integer array will take literally half of your RAM.

Having said all that C is not hard to use on any of the AVR systems. It's well documented and the AVR GCC provided with WinAVR uses all the same constant names as the Atmel products and documentation so you can literally read the Atmel PDFs and write C.

So the next steps for you are:

1) Download and get a feel for the Atmel ATMega128 PDF documentation. Particularly pay attention to the registers in each section.

2) Download the latest CD from Robotis (you can Google, right?).

3) Read the example.c and the Bioloid guides upside and backwards and forwards and backwards again. You may notice *lots* of deliberate errors in the example.c.

4) Upload the example.c by compiling it with WinAVR as per the Robotis PDFs and using Robot Terminal to send the .hex file.

5) Post on here whenever you have any questions.
StuartL
Savvy Roboteer
Savvy Roboteer
Posts: 350
Joined: Mon Jun 04, 2007 3:46 pm
Location: Thatcham, Berkshire, UK

Post by LunaCity » Sun May 04, 2008 1:23 am

Post by LunaCity
Sun May 04, 2008 1:23 am

Thanks, that's pretty straightforward. I've done something similar with a PIC microcontroller before.

I think I'm going to bypass the CM-5 and use Gim Stix though, because of the memory constraints. What I'm trying to do involves some number crunching.
Thanks, that's pretty straightforward. I've done something similar with a PIC microcontroller before.

I think I'm going to bypass the CM-5 and use Gim Stix though, because of the memory constraints. What I'm trying to do involves some number crunching.
LunaCity
Newbie
Newbie
Posts: 3
Joined: Thu May 01, 2008 10:58 pm

Re: Beginners Help with CM-5 C programming

Post by siempre.aprendiendo » Sun May 04, 2008 10:00 am

Post by siempre.aprendiendo
Sun May 04, 2008 10:00 am

LunaCity wrote:Hi. I just got a Bioloid comprehensive kit, but the CD doesn't contain the "example.c" file that has been mentioned here.

Can someone provide me with a simple, basic "Hello World" type of C program for the CM-5 that can be compiled from a unix or linux command line.


The example and some resources about programming Bioloid:
example.zip
Robosavvy programming the bioloid

You can use avrdude for linux
LunaCity wrote:Hi. I just got a Bioloid comprehensive kit, but the CD doesn't contain the "example.c" file that has been mentioned here.

Can someone provide me with a simple, basic "Hello World" type of C program for the CM-5 that can be compiled from a unix or linux command line.


The example and some resources about programming Bioloid:
example.zip
Robosavvy programming the bioloid

You can use avrdude for linux
siempre.aprendiendo
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 559
Joined: Wed Aug 08, 2007 9:13 pm
Location: Barcelona

Post by LunaCity » Thu May 08, 2008 12:33 am

Post by LunaCity
Thu May 08, 2008 12:33 am

Followup question ...

I'm still thinking about possibly programming the CM-5, but would like to know if this is possible using MPLAB, which I have used before, so it's got a reasonable familiarity. The programmer has got a serial port, but it's female, suggesting it's for input from the computer, not output to the CM5.

I'm also suspecting maybe the CM-5 board interface might not be compaticle with the MPLAB ICD. I know there's a PIC microcontroller in there somehwere.

It would be great if I could just hook the CM-5 up to the MPLAB ICD and program away, so if someone knows how to do that, please let me know.
Followup question ...

I'm still thinking about possibly programming the CM-5, but would like to know if this is possible using MPLAB, which I have used before, so it's got a reasonable familiarity. The programmer has got a serial port, but it's female, suggesting it's for input from the computer, not output to the CM5.

I'm also suspecting maybe the CM-5 board interface might not be compaticle with the MPLAB ICD. I know there's a PIC microcontroller in there somehwere.

It would be great if I could just hook the CM-5 up to the MPLAB ICD and program away, so if someone knows how to do that, please let me know.
LunaCity
Newbie
Newbie
Posts: 3
Joined: Thu May 01, 2008 10:58 pm

Post by JonHylands » Thu May 08, 2008 2:41 am

Post by JonHylands
Thu May 08, 2008 2:41 am

The CM-5 has an AVR ATmega128 in it, not a PIC, so MPLAB is out of the question. For something similar, look at AVRStudio...

- Jon
The CM-5 has an AVR ATmega128 in it, not a PIC, so MPLAB is out of the question. For something similar, look at AVRStudio...

- Jon
JonHylands
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 512
Joined: Thu Nov 09, 2006 1:00 am
Location: Ontario, Canada

Post by tom_chang79 » Thu May 08, 2008 7:00 am

Post by tom_chang79
Thu May 08, 2008 7:00 am

Can the SDK provided by Atmega be used for the CM-5? The SDK I found from Atmel's site is AVR Studio 4:

http://www.atmel.com/dyn/products/tools ... ol_id=2725

???

Or do people prefer using GNU's C Compiler?
Can the SDK provided by Atmega be used for the CM-5? The SDK I found from Atmel's site is AVR Studio 4:

http://www.atmel.com/dyn/products/tools ... ol_id=2725

???

Or do people prefer using GNU's C Compiler?
tom_chang79
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 116
Joined: Sat Jan 12, 2008 2:31 am
Location: California

Post by StuartL » Thu May 08, 2008 1:49 pm

Post by StuartL
Thu May 08, 2008 1:49 pm

Both of them are fine. I personally use avr-gcc with great success but would have no fears over using AVR Studio.
Both of them are fine. I personally use avr-gcc with great success but would have no fears over using AVR Studio.
StuartL
Savvy Roboteer
Savvy Roboteer
Posts: 350
Joined: Mon Jun 04, 2007 3:46 pm
Location: Thatcham, Berkshire, UK

Post by JonHylands » Thu May 08, 2008 1:52 pm

Post by JonHylands
Thu May 08, 2008 1:52 pm

Personally, I use GCC for all my ATmega work. I don't work with the CM-5, but I work with a few other custom ATmega168 boards I have made.

I use the programmer with AVRStudio to set the fuses, and do the initial programming on most of my boards, just because it has good diagnostics included.

- Jon
Personally, I use GCC for all my ATmega work. I don't work with the CM-5, but I work with a few other custom ATmega168 boards I have made.

I use the programmer with AVRStudio to set the fuses, and do the initial programming on most of my boards, just because it has good diagnostics included.

- Jon
JonHylands
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 512
Joined: Thu Nov 09, 2006 1:00 am
Location: Ontario, Canada

Post by le fatumbi » Mon May 19, 2008 7:10 am

Post by le fatumbi
Mon May 19, 2008 7:10 am

Hello,

I used also successfuly gnu's avr-gcc built on msys to program my cm5 this week-end.

example.c works fine, as an example, and I get inspired from it to build my own gateway between my PC and DaisyBus, and it begins to run well.


Is there any complementary ressources on how I/O ports are used ?

For coms, it's easy to find and understand, but I'd need a little more definitions : ie button, leds, battery charging, and also on what is let free to use in cm-5.
Robotis seems not so cooperatif with these informations on their FAQ ?


I have another little problem, in the same idea:

Now, I'm trying also to program cm5 using ADA langage, with avr-ada.
The version of the compiler I'm using is the snapshot built on 2002 and is not so mature, but the code generated seems not so bad at a first (and third...) glance.

However the result is appalling... even after having reduced my code at minimum, with no interruption and only uart1 initialized, I can not see why mcu resets every time. I'm not able to send more than two characters.

At minimum, I'd need a tool able to debugg/simulate (with nothing like jtag-ice or so...).

Even AVR-studio does not seem to be able to simulate directly a MCU from hex or elf file, and seems to need a C source or I missed something ?

Any experience from somebody in this way ?
Hello,

I used also successfuly gnu's avr-gcc built on msys to program my cm5 this week-end.

example.c works fine, as an example, and I get inspired from it to build my own gateway between my PC and DaisyBus, and it begins to run well.


Is there any complementary ressources on how I/O ports are used ?

For coms, it's easy to find and understand, but I'd need a little more definitions : ie button, leds, battery charging, and also on what is let free to use in cm-5.
Robotis seems not so cooperatif with these informations on their FAQ ?


I have another little problem, in the same idea:

Now, I'm trying also to program cm5 using ADA langage, with avr-ada.
The version of the compiler I'm using is the snapshot built on 2002 and is not so mature, but the code generated seems not so bad at a first (and third...) glance.

However the result is appalling... even after having reduced my code at minimum, with no interruption and only uart1 initialized, I can not see why mcu resets every time. I'm not able to send more than two characters.

At minimum, I'd need a tool able to debugg/simulate (with nothing like jtag-ice or so...).

Even AVR-studio does not seem to be able to simulate directly a MCU from hex or elf file, and seems to need a C source or I missed something ?

Any experience from somebody in this way ?
le fatumbi
Robot Builder
Robot Builder
User avatar
Posts: 15
Joined: Sun May 04, 2008 9:07 am
Location: france

Post by StuartL » Mon May 19, 2008 4:41 pm

Post by StuartL
Mon May 19, 2008 4:41 pm

Mark Pepper has documented an (almost complete) schematic:
http://robosavvy.com/Builders/pepperm/C ... c%20V1.JPG

Jon Hylands has contributed a lot of info here: http://www.bioloid.info/tiki/tiki-index.php

Between those two you should be able to figure out most of the I/O for the CM-5.
Mark Pepper has documented an (almost complete) schematic:
http://robosavvy.com/Builders/pepperm/C ... c%20V1.JPG

Jon Hylands has contributed a lot of info here: http://www.bioloid.info/tiki/tiki-index.php

Between those two you should be able to figure out most of the I/O for the CM-5.
StuartL
Savvy Roboteer
Savvy Roboteer
Posts: 350
Joined: Mon Jun 04, 2007 3:46 pm
Location: Thatcham, Berkshire, UK

Post by siempre.aprendiendo » Mon May 19, 2008 7:37 pm

Post by siempre.aprendiendo
Mon May 19, 2008 7:37 pm

Don't forget robosavvy's wiki!
Don't forget robosavvy's wiki!
siempre.aprendiendo
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 559
Joined: Wed Aug 08, 2007 9:13 pm
Location: Barcelona

Post by le fatumbi » Wed May 21, 2008 7:08 pm

Post by le fatumbi
Wed May 21, 2008 7:08 pm

Thanks a lot for that :-)

Especially for the drawing.

That helped me to make something working (copy Buttons to Dels) with Ada compiler and I found (i think) my bugg.

For simulation (with a nice display of registers and ports): I didn't noticed any option to load a .hex file in the simulator, but it seems that I just need an empty project and configure it to compile and run with my makefile, in avr-studio.

That should work, with maybe some litlle adjustments in makefile... I'll try this week-end.
Thanks a lot for that :-)

Especially for the drawing.

That helped me to make something working (copy Buttons to Dels) with Ada compiler and I found (i think) my bugg.

For simulation (with a nice display of registers and ports): I didn't noticed any option to load a .hex file in the simulator, but it seems that I just need an empty project and configure it to compile and run with my makefile, in avr-studio.

That should work, with maybe some litlle adjustments in makefile... I'll try this week-end.
le fatumbi
Robot Builder
Robot Builder
User avatar
Posts: 15
Joined: Sun May 04, 2008 9:07 am
Location: france


13 postsPage 1 of 1
13 postsPage 1 of 1