The OpenServo consists of three main software components.
Embedded Bootloader
Embedded Application code
Host Control software
Embedded bootloader When the OpenServo is powered on, the first thing that is executed is the bootloader. The bootloader allows for new application code to uploaded within 3 seconds of power on. The bootloader initialises at the standard address of 0x7F by default. This behaviour can be altered.
Embedded Application code Once the bootloader has timed out, the application code is booted. The application code is the main controller of the servo hardware. The main application code is uploaded to the servo from the bootloader, facilitating simple updates of the OpenServo application firmware.
Host Control software Once the OpenServo is booted and running, you can communicate with it using the TWI (I2C) interface. You will need a host controller to communicate with the OpenServo, whether that is a PC to I2C bridge, or another MCU.
Used code for the first OpenServo prototype. It has less registers than the -dev branch.
The first 5 files in this folder are created after compile the .c and .h files below:
ATmega328_OpenServo.eep
ATmega328_OpenServo.elf
ATmega328_OpenServo.hex -> What we flash in the microcontroller.
ATmega328_OpenServo.lss
ATmega328_OpenServo.map -> To see information about where things are.
After we have the Makefile and the README.txt.
The code is organized in modules where each has a functionality:
adc #12
curve #15
eeprom #14
enc
motion #19
pid #13
power #16
pulsectl
pwm #30
registers #18
seek(obsolete)
swi2c
timer #20
twi #22
watchdog #17 .
To finish the analize the code we have this special files:
config.h #21-> File where differents options for the servo can be set.
Openservo.h -> File where some parameters like device type and subtype, software version and defalut TWI address i specified.
main.c -> Where programme is executed. Here the different modules are initialized and where the main processing loop for the servo is. It basically looks for new position, power or TWI commands to be processed.
The code is organized in modules where each has a functionality:
adc #12
1_1. alert
1_2. backemf
1_3. banks
curve #15
eeprom #14
enc <---------- not in dev
4_1. filter
4_2. heartbeat
motion #19
pid #13
power #16
pulsectl
8_1 pwm-std
pwm #30
registers #18
seek(obsolete)
11_1 step
swi2c <--------------- not in dev
timer #20
twi #22
watchdog #17 .
To finish the analize the code we have this special files:
config.h #21-> File where differents options for the servo can be set.
Openservo.h -> File where some parameters like device type and subtype, software version and defalut TWI address i specified.
main.c -> Where programme is executed. Here the different modules are initialized and where the main processing loop for the servo is. It basically looks for new position, power or TWI commands to be processed.
folder which allow for a standard 4 pole stepper motor to be driven from an AVR attiny84
[TODO]
AVR_VelocityControl
the algorithm compares the seek velocity with the actual velocity measured with the back-emf method and generates an apropriate motor PWM (PI+FF algorithm)
[TODO]
OpenServo v4
The code as V3-dev has a config folder where this files appeared:
motor_hardware.h
pindefs_OSv2.h
pindefs_OSv3.h
pindefs_OSv4.h <-- Not in V3-dev
pindefs_RobotFuzz_OpenStep.h
pindefs_example.h
servo_hardware.h
target_platform.h
Then there is a folder called include with this .h files:
OpenServoCommon.h -> Device type, subtype, version major, minor and default twi address defined.
banks.h -> the accesible register ordered in banks. Important banks 0 and 1.
config.h -> This file contains overridable defaults for the OpenServo hardware. This also serves to load up the config files of the hardware available in the config/ directory.
getter.h -> This is a class masquerading as a "library" in the standard Wiring fashion.
i2c_module.h -> include "libmaple/i2c.h". Three functions: void i2c_module_init();void funcrx(i2c_msg msg); void functx(i2c_msg msg);
os_adc.h -> Current, Position, BackEMF and Temperature extern declarations.
packetcommands.h -> TWI commands.(0x80 - 0x98)
pid.h -> pid interface.
pwm.h -> pwm interface.
pwm_os.h -> Same as above.
randomizer.h -> A useless front-end to the standard C random number interface. This is basically the same thing as the wirish functions randomSeed() and random().
registers.h -> registers of OpenServo.
setup.h
The we have the impelementation of the functions in cpp:
FreeRTOSConfig.h -> Configuration file of FreeRTOS.
adc.cpp -> Implementation of os_adc.h functions.
banks.cpp -> Implementation of Banks.h. Contains WProgram.h
i2c_module.cpp -> I2c_module implementation
main.cpp -> See real-main,cpp
make-helper.sh
packetprocess.cpp -> For TWI command implementation. Uses WProgram.h
pid.cpp -> PID implementation
pwm.cpp -> PWM implementation. Uses WProgram.h to encapsulate.
real-main.cpp -> Main. Uses a scheduler. Also uses FreeRTOSCongi.h file.
registers.cpp -> Registers implementation.
rules.mk -> Makefile
setup.cpp -> Configure the default pin configuration on startup of the device, setup modules and setup OpeServo.
Differences between code:
V3 and V3-dev
In V3 there is bootcrt.s file that is not in V3-dev
In V3- dev there is a config folder and this modules are added 1_1. alert, 1_2. backemf, 1_3. banks, 4_1. filter, 4_2. heartbeat, 8_1 pwm-std, 11_1 step.
In V3-dev enc and swi2c modules used to connect an encoder are deleted.
V3-dev and V4.
Main differences: V4 is written in .cpp. Also uses FreeRTOS, to create task and schedule them and WProgram.h, that encapsulates code, for example pinMode() and digitalWrite() also used in Arduino.
Analized Code
After compiling the code you have to be sure that the .hex files have been created. If not verify in the proyect properties if if the Generate Hex file for Flash memory and EEPROM are checked:
Changes in the code:
Interruption names have changed and have new name: (pulsectl??)
Identify and comment the code of OpenServo
Software Components
The OpenServo consists of three main software components.
Embedded bootloader When the OpenServo is powered on, the first thing that is executed is the bootloader. The bootloader allows for new application code to uploaded within 3 seconds of power on. The bootloader initialises at the standard address of 0x7F by default. This behaviour can be altered.
Embedded Application code Once the bootloader has timed out, the application code is booted. The application code is the main controller of the servo hardware. The main application code is uploaded to the servo from the bootloader, facilitating simple updates of the OpenServo application firmware.
Host Control software Once the OpenServo is booted and running, you can communicate with it using the TWI (I2C) interface. You will need a host controller to communicate with the OpenServo, whether that is a PC to I2C bridge, or another MCU.
Link
There are two repositories for the OpenServo proyect:
OpenServo v1 to 3
The folders here are:
OpenServo folder
Inside this folder there are different versions of OpenServo:
AVR_OpenServo_V3.
Used code for the first OpenServo prototype. It has less registers than the -dev branch.
The first 5 files in this folder are created after compile the .c and .h files below:
After we have the Makefile and the README.txt.
The code is organized in modules where each has a functionality:
To finish the analize the code we have this special files:
AVR_OpenServo_V3-dev.
Code under development. More interesting features.
The first 5 files in this folder are created after compile the .c and .h files below:
There is a config folder where some files with parameters are defined:
The code is organized in modules where each has a functionality:
To finish the analize the code we have this special files:
AVR_OpenServo_v3_experimental
[TODO]
AVR_OpenStepper
folder which allow for a standard 4 pole stepper motor to be driven from an AVR attiny84 [TODO]
AVR_VelocityControl
the algorithm compares the seek velocity with the actual velocity measured with the back-emf method and generates an apropriate motor PWM (PI+FF algorithm) [TODO]
OpenServo v4
The code as V3-dev has a config folder where this files appeared:
Then there is a folder called include with this .h files:
The we have the impelementation of the functions in cpp:
Differences between code:
V3 and V3-dev
V3-dev and V4.
Analized Code
After compiling the code you have to be sure that the .hex files have been created. If not verify in the proyect properties if if the Generate Hex file for Flash memory and EEPROM are checked:
Changes in the code: Interruption names have changed and have new name: (pulsectl??)
Bootloader ATmega
See #25