Edit on GitHub

Introduction

It makes the users possible to develop their own firmware. The characteristics are as follows:

NOTE : If you want to use Embedded C, you need the knowledge of software and hardware. If you are a beginner, we recommend you use Embedded C after learing the software and the hardware.

NOTE : If you use Embedded C, you cannot use RoboPlus since the controller’s firmware is changed. If you want to use RoboPlus again, you must restore the firmware using RoboPlus.

CM-510, CM-700

File Structure

Getting Started

Install WinAVR

WinAVR is necessary for AVR programming.
WinAVR can be downloaded from the following website, and it is free-of-charge.
http://winavr.sourceforge.net/

The installation process is as below.

  1. Select a language.

  2. The initial window is as below.

  3. The window below is about the license agreement. You must agree to continue the installation.

  4. Select a folder for the installation, and then click “Next” button.

  5. Select programs and environment options. If there are no specific reasons, it is recommended to install all in the list.

  6. Start WinAVR installation.

  7. WinAVR installation is completed.

Install Atmel Studio

Atmel Studio provides users various Macro, Library, and comprehensive environment for easy programming.
Atmel Studio can be downloaded from the website below, and it is free-of-charge.
http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2725

The installation procedure is as follows.

  1. The initial window is as below.

  2. The window below is about license agreement. You must agree to continue the installation.

  3. Select a folder for the installation, and then click “Next” button.

  4. Click “Next” to continue the installation.

  5. Start Atmel Studio installation.

  6. Atmel Studio installation is completed.

Environment Setting

If you want to use Embedded C, you must select the basic environment of the installed program.

  1. Click on Debug - Options and Settings.

  2. With the left mouse click select Toolchain. Selcts Atmel AVR 8-bit (C language). Click on Add Flavour.

  3. Click on […] and select version’s 20100110 bin folder.
    Ex) c:\WinAVR-20100110\bin

  4. Select Win AVR then click on the OK button.

  5. Click on File > Open > Project/Solution.

  6. Select the example file then open it.

  7. Click to select the c file located to the right of Solution Explorer. Click on Project -> Properties.
    If Solution Explorer cannot be seen then select Solution Explorer from View.

  8. From the left hand menu click on Toolchain. Click on Directories. Click on the green + to add item.

  9. This will select the Include.
    Ex) c:\embedded_c(cm700_v1.01)\include

  10. Its possible to verify in the include folder has been added.

  11. On Solution Explorer, from the right, click on the project file and click on Add Library.

  12. Click on Browse Libraries. Click on [Browse] on the lower right side.

  13. To select the library select and open the lib folder.

  14. To add the 3 libraries select all and lick on [open] from the lower right.

  15. its possible to verify that all 3 libraries have been added.

  16. To compile click on Build -> Rebuild Solution and check for Build succeeded on the output window Build Succeeded.

Restore RoboPlus

The result made by Embedded C is a controller firmware (hex file). If you install it, you cannot use RoboPlus since the existing controller firmware is erased. If you want to use RoboPlus again, you must install the original controller firmware built-in from the factory. You can install the original controller firmware easily using RoboPlus Manager.

For more information, please refer to Firmware Restoration of RoboPlus Manager.

Programming

Hardware Port Map

The following hardware port map shows the hardware main pin functions of the controller.
Each port or internal functions can be controlled easily with macro function provided by Atmel Studio.

CM-510

Port Name Function
PORTF1 ~ PORTF6 ADC
PORTD0 Start Button
PORTD1 ~ PORTD2 Tx, Rx
PORTA2 ~ PORTA7 External Output ( 5 Pin Port)
PORTC0 ~ PORTC6 Controller LED ( Status, Power )
PORTB5 Buzzer Control Port
PORTE4 ~ PORTE6 Direction Button (U, D, L, R)
PORTD4 ~ PORTD6 Communication Control Port

The external port pin composition of CM-510 is as below. You can check port 1 ~ port 6 by the scale marks on the external port. For more information, please refer to CM-510.

  1. OUT : 5V Output Available
  2. VCC (5V)
  3. ADC : Analogue signals of sensors made by users can be read.
  4. GND
  5. NC : Not used

CM-700

Port Name Function
PORTF1 ~ PORTF6 ADC
PORTD0 Start Button
PORTD2 ~ PORTD3 Tx, Rx
PORTA2 ~ PORTA7 External Output ( 5 Pin Port)
PORTC0 ~ PORTC6 Controller LED ( Status, Power )

The external port pin composition of CM-700 is as below. You can check port 1 ~ port 6 by the letters written on the bottom of Sub-board.
For more information, please refer to CM-700.

  1. OUT : 5V Output Available
  2. VCC (5V)
  3. ADC : Analogue signals of sensors made by users can be read.
  4. GND
  5. NC : Not used

Basic Programming

It explains how to make simple Embedded C examples on Atmel Studio.

Creating Project

The procedure of creating project is as below.

  1. From the File menu select New -> Project.

  2. Select GCC C Executable Project Name for template, This sets the items Location, Solution name. After setup click on [OK].

  3. From the multiple devices list select ATmega2561 (ATmega128 for CM5). Click on [OK].

Creating Code and Compling

The following example is about the basic PORT I/O Control.

  1. The following is code from the generated project.

     #define F_CPU 16000000L
     #include <avr/io.h>
     #include <util/delay.h>
     int main(void)
     {
       DDRC  = 0x7F;
       PORTC = 0x7E;
       while (1)
       {
         int i;
         for(i = 0; i <= 6; i++)
         {
           PORTC = ~(1 << i);
           _delay_ms(250);
         }
       }
       return 1;
     }
    
  2. From the Build menu click on [Build Solution] to run the build command.

  3. When build succeeded message appears on the output window then compiling is complete. The firmware’s hex file can be found in the default folder from the project’s folder.

Downloading hex file

Boot Loader

Boot Loader makes the users possible to use the controller. Boot Loader cannot be erased by the users. If it is broken down, the controller cannot be used. Boot Loader is built-in on the controller when it is manufactured in the factory.

The available commands in Boot Loader can be found using “Help” command.

Install/Execute Program

Preparations for installing a firmware of the controller are as follows:

A firmware of the controller can be installed according to the procedure below.

  1. Input “L” command (or Load) in Boot Loader.

  2. Select “Transmit File” in the Files menu of RoboPlus Terminal, and then select the prepared firmware. (hex file)

  3. The file is transmitted. Please do not let the power of the controller turn off, and be careful the cable does not take off while the file is being transmitted.

  4. When the file transmission is completed, you can execute the program using GO command.

    • In case of inputting only “GO” command, the program is executed from 0 address.
    • Like G [Address], if you input execution address (hexadecimal) after “G” command, the program is executed from the location.

Entering/Exiting Boot Loader

Entering Boot Loader

To enter into the boot loader, while pressing the ‘#’ button(Shift + 3), turn on the controller or press down the reset switch.
If you did correctly, following screen page will be shown.

Exiting Boot Loader

If the work is completed, you may exit by jumping to the desired address using “GO” command or by resetting the controller.

How to Use APP/SYS

The program start position can be set by APP/SYS command. Once the program start position is set, the program is executed on the program start position when the power is turned on or reset.

The memory map using Atmega2561 is as below.

Examples

LED Control

Each LED of the controller can be controlled.

Button

Input of the button can be received.

Serial Communication

PC and the controller can perform serial communication.

Buzzer

Buzzer on the controller can be used.

Octave
/Scale
1 2 3 4 5 6 7 8
C 32.7032 65.4064 130.8128 261.6256 523.2511 1046.502 2093.005 4186.009
C# 34.6478 69.2957 138.5913 277.1826 554.3653 1108.731 2217.461 4434.922
D 36.7081 73.4162 146.8324 293.6648 587.3295 1174.659 2349.318 4698.636
D# 38.8909 77.7817 155.5635 311.1270 622.2540 1244.508 2489.016 4978.032
E 41.2034 82.4069 164.8138 329.6276 659.2551 1318.510 2637.020 5274.041
F 43.6535 87.3071 174.6141 349.2282 698.4565 1396.913 2793.826 5587.652
F# 46.2493 92.4986 184.9972 369.9944 739.9888 1479.978 2959.955 5919.911
G 48.9994 97.9989 195.9977 391.9954 783.9909 1567.982 3135.963 6271.927
G# 51.9130 103.8262 207.6523 415.3047 830.6094 1661.219 3322.438 6644.875
A 55.0000 110.0000 220.0000 440.0000 880.0000 1760.000 3520.000 7040.000
A# 58.2705 116.5409 233.0819 466.1638 932.3275 1864.655 3729.310 7458.620
G 61.7354 123.4708 246.9417 493.8833 987.7666 1975.533 3951.066 7902.133

Unit : Hz

MIC

External sounds can be detected through MIC.

IR Sensor

Here you can learn how t o use the ADC of external ports. (This example is using the IR sensor for explanation. )

Read/Write Dynamixel

The location of DYNAMIXEL can be set and read.

Dynamixel Sync Control

Multiple DYNAMIXEL can be controlled by synchronization.

RC-100/ZIGBEE

The controller can be operated using RC-100.