Commit from tof (2008-02-20 13:18 CET) =============== correction de pas mal de bugs dans le test. celui ci devrait etre a peu pres fonctionnel
aversive_projects tof2007/taillage_engrenages_final/.config 1.2 aversive_projects tof2007/taillage_engrenages_final/adc_config.h 1.2 aversive_projects tof2007/taillage_engrenages_final/main.c 1.2 aversive_projects tof2007/taillage_engrenages_final/pap_goto_pos.c 1.2 aversive_projects tof2007/taillage_engrenages_final/pap_goto_pos_config.h 1.2 =========================================================== aversive_projects/tof2007/taillage_engrenages_final/.config (1.1 -> 1.2) =========================================================== @@ -75,14 +75,14 @@ CONFIG_MODULE_WAIT=y CONFIG_MODULE_LIST=y CONFIG_MODULE_SCHEDULER=y -CONFIG_MODULE_SCHEDULER_CREATE_CONFIG=y +# CONFIG_MODULE_SCHEDULER_CREATE_CONFIG is not set # CONFIG_MODULE_TIME is not set # CONFIG_MODULE_TIME_CREATE_CONFIG is not set # # Communication modules # -# CONFIG_MODULE_UART is not set +CONFIG_MODULE_UART=y # CONFIG_MODULE_UART_CREATE_CONFIG is not set # @@ -91,7 +91,7 @@ # CONFIG_MODULE_PWM is not set # CONFIG_MODULE_PWM_CREATE_CONFIG is not set CONFIG_MODULE_ADC=y -CONFIG_MODULE_ADC_CREATE_CONFIG=y +# CONFIG_MODULE_ADC_CREATE_CONFIG is not set # # IHM modules @@ -110,7 +110,7 @@ # CONFIG_MODULE_KBD_MATRIX_4X4 is not set # CONFIG_MODULE_KBD_MATRIX_4X4_CREATE_CONFIG is not set CONFIG_MODULE_KBD_MATRIX_4X4_4PORT=y -CONFIG_MODULE_KBD_MATRIX_4X4_4PORT_CREATE_CONFIG=y +# CONFIG_MODULE_KBD_MATRIX_4X4_4PORT_CREATE_CONFIG is not set # CONFIG_MODULE_MULTISERVO is not set # CONFIG_MODULE_MULTISERVO_CREATE_CONFIG is not set ================================================================ aversive_projects/tof2007/taillage_engrenages_final/adc_config.h (1.1 -> 1.2) ================================================================ @@ -1,7 +1,7 @@ #ifndef _ADC_CONFIG_H_ #define _ADC_CONFIG_H_ -// mappage des entrées ADC (noms utilisateur) +// mappage des entrees ADC (noms utilisateur) #define MUX_ADC_X MUX_ADC1 #define MUX_ADC_Y MUX_ADC2 #define MUX_ADC_Z MUX_ADC0 @@ -9,17 +9,12 @@ // constantes venant de l'ADC travaillant sur 10 bits -#define JOYSTICK_MAX_VALUE 1024 -#define JOYSTICK_NEUTRE 512 - -#define JOYSTICK_ZONE_MORTE 128 // zone morte de 1/4 de la course - -// calcul de la valeur nette maximale -#define JOYSTICK_H (JOYSTICK_MAX_VALUE - JOYSTICK_NEUTRE - JOYSTICK_ZONE_MORTE) -#define JOYSTICK_B ( 0 - JOYSTICK_NEUTRE + JOYSTICK_ZONE_MORTE) -#define JOYSTICK_NET_VALEUR_MAX (JOYSTICK_H>-JOYSTICK_B ? JOYSTICK_H : -JOYSTICK_B) +#define JOYSTICK_EXCURSION 480 // valeur brute max en + ou - theoriquement 512, mais les halls ne sont pas vraiment rail2rail +#define JOYSTICK_NEUTRE 512 // mi-course +#define JOYSTICK_ZONE_MORTE 64 // zone morte de 1/8 +#define JOYSTICK_NET_VALEUR_MAX (JOYSTICK_EXCURSION - JOYSTICK_ZONE_MORTE) #endif // _ADC_CONFIG_H_ ========================================================== aversive_projects/tof2007/taillage_engrenages_final/main.c (1.1 -> 1.2) ========================================================== @@ -15,7 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Revision : $Id: main.c,v 1.1 2008-02-11 14:32:29 tof Exp $ + * Revision : $Id: main.c,v 1.2 2008-02-20 12:18:12 tof Exp $ * */ @@ -25,7 +25,7 @@ #include <adc.h> //#include <uart.h> #include <stdio.h> -#include <aversive_pgmspace.h> +#include <avr/pgmspace.h> #include <scheduler.h> #include <lcd.h> #include <kbd.h> @@ -100,7 +100,7 @@ break; case KBD_RELEASED: - printf("\f"); + //printf("\f"); g_affichage_joy_active = 1; break; } @@ -111,7 +111,7 @@ int main(void) { - // uart désactivée + // uart (debug) //uart_init(); //fdevopen((void *)uart0_send,NULL,0); @@ -124,7 +124,7 @@ lcd_init(LCD_DISP_ON); fdevopen((void*)lcd_dev_putc ,NULL, 0); - printf_P(PSTR("\fBonjour\ntest des moteurs")); + printf_P(PSTR("\fBonjour 17/02 2\ntest des moteurs")); wait_ms(1000); printf_P(PSTR("\f")); @@ -133,8 +133,8 @@ scheduler_add_periodical_event_priority(pap_manage, NULL, 1, 250); //high prio à 4kHz int max_speed = PAP_FREQ_MAX; // vitesse max pendant le deplacement vers un point - int min_speed = PAP_FREQ_MAX / 100; // vitesse de démarrage - int acceleration = 20 ; // accélération max. unités = pas² / 25.6ms + int min_speed = 0; // vitesse de démarrage + int acceleration = 10 ; // accélération max. unités = pas² / 25.6ms pap_set_parameters(PAP_X , max_speed, min_speed , acceleration); // X pap_set_parameters(PAP_Y , max_speed, min_speed , acceleration); // Y ================================================================== aversive_projects/tof2007/taillage_engrenages_final/pap_goto_pos.c (1.1 -> 1.2) ================================================================== @@ -68,15 +68,18 @@ int speed; speed = g_speed[papnum]; + if(speed< g_speed_target[papnum]) { speed += g_accel[papnum]; MAX(speed, g_speed_max[papnum]); + MAX(speed, g_speed_target[papnum]); } else if(speed> g_speed_target[papnum]) { speed -= g_accel[papnum]; MIN(speed, -g_speed_max[papnum]); + MIN(speed, g_speed_target[papnum]); } g_speed[papnum] = speed; @@ -251,17 +254,17 @@ switch (g_mode[papnum]) { case PAP_POSITION: - g_speed_target[papnum] = pos_mode_calc_speed(0); - speed = speed_mode_calc_speed(0); + g_speed_target[papnum] = pos_mode_calc_speed(papnum); + speed = speed_mode_calc_speed(papnum); break; case PAP_STOP: g_speed_target[papnum] = 0; case PAP_SPEED: - speed = speed_mode_calc_speed(0); + speed = speed_mode_calc_speed(papnum); break; } - pap_out_set_freq(0, speed); + pap_out_set_freq(papnum, speed); } } ========================================================================= aversive_projects/tof2007/taillage_engrenages_final/pap_goto_pos_config.h (1.1 -> 1.2) ========================================================================= @@ -30,9 +30,9 @@ /* axe Div */ #define PAP_3_DIR_PORT PORTB -#define PAP_3_DIR_PIN 1 +#define PAP_3_DIR_PIN 0 #define PAP_3_CLK_PORT PORTB -#define PAP_3_CLK_PIN 2 +#define PAP_3_CLK_PIN 1 // user defined names #define PAP_X 0 @@ -44,7 +44,7 @@ #define PAP_FREQ_MAX 100 // avec 4 kHz de frequence, on est a 39 Hz (25.6ms) -#define PAP_WAIT() {wait_4cyc(3);} +#define PAP_WAIT() {wait_4cyc(10);} Commit from enseirb on branch b_eirbot (2008-02-20 20:26 CET) ====================================== AX-12 servomotors library added + aversive modules/devices/servo/ax12/Makefile 1.1.2.1 + aversive modules/devices/servo/ax12/ax12.c 1.1.2.1 + aversive modules/devices/servo/ax12/ax12.h 1.1.2.1 + aversive modules/devices/servo/ax12/ax12_address.h 1.1.2.1 + aversive modules/devices/servo/ax12/config/ax12_config.h 1.1.2.1 ============================================ aversive/modules/devices/servo/ax12/Makefile (1.1.2.1) ============================================ @@ -0,0 +1,6 @@ +TARGET = ax12 + +# List C source files here. (C dependencies are automatically generated.) +SRC = ax12.c + +include $(AVERSIVE_DIR)/mk/aversive_module.mk ========================================== aversive/modules/devices/servo/ax12/ax12.c (1.1.2.1) ========================================== @@ -0,0 +1,358 @@ +#include "ax12.h" + +void AX12_init(AX12* s) +{ + s->hardware_send = NULL; + s->hardware_recv = NULL; + s->hardware_switch = NULL; + + return; +} + +//_________________________________________________________ +//_________________________________________________________ + +void AX12_set_hardware_send( AX12* s, void(*pf)(uint8_t) ) +{ + s->hardware_send = pf; + return; +} + +void AX12_set_hardware_recv( AX12* s, uint8_t(*pf)(void) ) +{ + s->hardware_recv = pf; + return; +} + +void AX12_set_hardware_switch( AX12* s, void(*pf)(uint8_t) ) +{ + s->hardware_switch = pf; +} + +//_________________________________________________________ +//_________________________________________________________ + +uint8_t AX12_checksum(AX12_Packet* packet) +{ + uint8_t checksum=0; + + checksum += packet->id; + checksum += packet->instruction; + + // Packet also contain length = number of params + 2 + checksum += packet->nparams + 2; + + int i; + for(i=0;i<packet->nparams;i++) + checksum += packet->params[i]; + + return ~checksum; +} + +uint8_t AX12_send(AX12* s, AX12_Packet* packet) +{ + + // Switch line to write + (s->hardware_switch)(AX12_STATE_WRITE); + + // Header + (s->hardware_send)(0xFF); + (s->hardware_send)(0xFF); + + // AX12 ID + (s->hardware_send)( packet->id ); + + // Packet length + (s->hardware_send)( packet->nparams + 2 ); + + // Instruction + (s->hardware_send)( packet->instruction ); + + // Params + int i; + for(i=0;i<(packet->nparams);i++) + (s->hardware_send)( packet->params[i] ); + + // Checksum + (s->hardware_send)( AX12_checksum(packet) ); + + // Switch line back to read + (s->hardware_switch)(AX12_STATE_READ); + + return 0; +} + +uint8_t AX12_recv(AX12* s, AX12_Packet* packet) +{ + uint8_t c; + int length; + + // Switch line to read + (s->hardware_switch)(AX12_STATE_READ); + + c = (s->hardware_recv)(); + if(c != 0xFF) + return -1; + + c = (s->hardware_recv)(); + if(c != 0xFF) + return -1; + + packet->id = (s->hardware_recv)(); + + length = (s->hardware_recv)(); + packet->nparams = length - 2; + + packet->error = (s->hardware_recv)(); + + int i; + for(i=0;i<(length-2);i++) + packet->params[i] = (s->hardware_recv)(); + + // Checksum + c = (s->hardware_recv)(); + + if( c != AX12_checksum(packet) ) + return -2; + + return 0; +} + +//_________________________________________________________ +//_________________________________________________________ + +uint8_t AX12_write_byte(AX12* s, uint8_t id, AX12_ADDRESS address, uint8_t data) +{ + AX12_Packet p,rp; + + p.id = id; + p.instruction = AX12_WRITE; + p.nparams = 2; + + // memory address + p.params[0] = (uint8_t)address; + + // value + p.params[1] = data; + + // send packet + AX12_send(s,&p); + + // We talk broadcast, no reply + if(p.id == AX12_BROADCAST_ID) + return 0; + + // recv packet + AX12_recv(s,&rp); + + return rp.error; +} + +uint8_t AX12_write_int(AX12* s, uint8_t id, AX12_ADDRESS address, uint16_t data) +{ + AX12_Packet p,rp; + + p.id = id; + p.instruction = AX12_WRITE; + p.nparams = 3; + + // memory address + p.params[0] = (uint8_t)address; + + // value (low) + p.params[1] = 0xFF & data; + + // value (high) + p.params[2] = data>>8; + + // send packet + AX12_send(s,&p); + + // We talk broadcast, no reply + if(p.id == AX12_BROADCAST_ID) + return 0; + + // receive status packet + AX12_recv(s,&rp); + + return rp.error; +} + +uint8_t AX12_read_byte(AX12* s, uint8_t id, AX12_ADDRESS address) +{ + AX12_Packet p, rp; + + p.id = id; + p.instruction = AX12_READ; + p.nparams = 2; + + // memory address + p.params[0] = (uint8_t)address; + + // data length + p.params[1] = 1; + + // send packet + AX12_send(s,&p); + + // wait for reply packet + AX12_recv(s,&rp); + + return rp.params[0]; +} + +uint16_t AX12_read_int(AX12* s, uint8_t id, AX12_ADDRESS address) +{ + AX12_Packet p, rp; + + p.id = id; + p.instruction = AX12_READ; + p.nparams = 2; + + // memory address + p.params[0] = (uint8_t)address; + + // data length + p.params[1] = 2; + + // send packet + AX12_send(s,&p); + + // wait for reply packet + AX12_recv(s,&rp); + + return (rp.params[0] + ((rp.params[1])<<8) ); +} + +//_________________________________________________________ +//_________________________________________________________ + +uint8_t AX12_set_position(AX12* s,uint8_t id, uint16_t position) +{ + return AX12_write_int(s,id,AA_GOAL_POSITION_L,position); +} + +uint8_t AX12_set_position2(AX12* s, uint8_t id, + uint16_t position, + uint16_t speed) +{ + AX12_Packet p,rp; + + p.id = id; + p.instruction = AX12_WRITE; + p.nparams = 5; + + // memory address + p.params[0] = AA_GOAL_POSITION_L; + // position + p.params[1] = 0xFF & position; + p.params[2] = position>>8; + // speed + p.params[3] = 0xFF & speed; + p.params[4] = speed>>8; + + // send packet + AX12_send(s,&p); + + // We talk broadcast, no reply + if(p.id == AX12_BROADCAST_ID) + return 0; + + // receive status packet + AX12_recv(s,&rp); + + return rp.error; +} + +uint8_t AX12_set_position3(AX12* s,uint8_t id, + uint16_t position, + uint16_t speed, + uint16_t torque) +{ + AX12_Packet p,rp; + + p.id = id; + p.instruction = AX12_WRITE; + p.nparams = 7; + + // memory address + p.params[0] = AA_GOAL_POSITION_L; + // position + p.params[1] = 0xFF & position; + p.params[2] = position>>8; + // speed + p.params[3] = 0xFF & speed; + p.params[4] = speed>>8; + // torque + p.params[5] = 0xFF & torque; + p.params[6] = torque>>8; + + // send packet + AX12_send(s,&p); + + // We talk broadcast, no reply + if(p.id == AX12_BROADCAST_ID) + return 0; + + // receive status packet + AX12_recv(s,&rp); + + return rp.error; +} + +uint16_t AX12_get_position(AX12* s, uint8_t id) +{ + return AX12_read_int(s,id,AA_PRESENT_POSITION_L); +} + +uint16_t AX12_get_speed(AX12* s, uint8_t id) +{ + return AX12_read_int(s,id,AA_PRESENT_SPEED_L); +} + +uint16_t AX12_get_load(AX12* s, uint8_t id) +{ + return AX12_read_int(s,id,AA_PRESENT_LOAD_L); +} + +uint8_t AX12_ping(AX12* s, uint8_t id) +{ + AX12_Packet p,rp; + + p.id = id; + p.instruction = AX12_PING; + p.nparams = 0; + + // send packet + AX12_send(s,&p); + + // We talk broadcast, no reply + if(p.id == AX12_BROADCAST_ID) + return 0; + + // recv packet + AX12_recv(s,&rp); + + return rp.error; +} + +uint8_t AX12_reset(AX12* s, uint8_t id) +{ + AX12_Packet p,rp; + + p.id = id; + p.instruction = AX12_RESET; + p.nparams = 0; + + // send packet + AX12_send(s,&p); + + // We talk broadcast, no reply + if(p.id == AX12_BROADCAST_ID) + return 0; + + // recv packet + AX12_recv(s,&rp); + + return rp.error; +} ========================================== aversive/modules/devices/servo/ax12/ax12.h (1.1.2.1) ========================================== @@ -0,0 +1,190 @@ + +/* + * Copyright Droids Corporation, Microb Technology, Eirbot (2005) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Revision : $Id: ax12.h,v 1.1.2.1 2008-02-20 19:26:40 enseirb Exp $ + * + */ + +/** @file ax12.h + * @brief This module provides functions for using a Robotis AX-12 numeric servo + * motor. + * @todo + * - Manage the "Status Return Level" + * + * AX12 servos uses a full duplex uart. + * This module DOESN'T use ATmega's uart, user have to provide + * 3 functions to control the full duplex uart : + * - send char. + * - write char. + * - switch direction + */ + +#ifndef _AX12_H_ +#define _AX12_H_ + +#include <stdlib.h> +#include <utils.h> + +#include "ax12_address.h" +#include "ax12_config.h" + +//__________________________________________ + +// Half duplex uart switch +#define AX12_STATE_READ 0 +#define AX12_STATE_WRITE 1 + +// Error bits +#define AX12_ERROR_VOLTAGE 0 +#define AX12_ERROR_ANGLE_LIMIT 1 +#define AX12_ERROR_OVERHEAT 2 +#define AX12_ERROR_RANGE 3 +#define AX12_ERROR_CHECKSUM 4 +#define AX12_ERROR_OVERLOAD 5 +#define AX12_ERROR_INSTRUCTION 6 + +// Address (see ax12_address.h) +#define AX12_BROADCAST_ID 0xFE + +// AX-12 instruction set +#define AX12_PING 0x01 +#define AX12_READ 0x02 +#define AX12_WRITE 0x03 +#define AX12_REG_WRITE 0x04 +#define AX12_ACTION 0x05 +#define AX12_RESET 0x06 +#define AX12_SYNC_WRITE 0x83 + +//__________________________________________ + +typedef struct AX12 +{ + void (*hardware_send)(uint8_t); + + uint8_t (*hardware_recv)(void); + + void (*hardware_switch)(uint8_t); + +}AX12; + +typedef struct AX12_Packet +{ + uint8_t id; + uint8_t instruction; + + // Size of AX12_Packet::params + uint8_t nparams; + uint8_t params[MAX_PARAMS]; + + // Used in status packet + uint8_t error; + +}AX12_Packet; + +//___________ Interface ____________ + +void AX12_init(AX12*); + +//___________ Hardware layer _____________ + +/** @brief Set the function called when writing a character. */ +void AX12_set_hardware_send( AX12*, void(*)(uint8_t) ); + +/** @brief Set the function called when reading a character. */ +void AX12_set_hardware_recv( AX12*, uint8_t(*)(void) ); + +/** @brief Set the function called when switching line direction */ +void AX12_set_hardware_switch( AX12*, void(*)(uint8_t) ); + +//___________ Low level layer ____________ + +/** @brief Compute AX12 packet checksum */ +uint8_t AX12_checksum(AX12_Packet* packet); + +/** @brief Send a formated AX12 instruction packet */ +uint8_t AX12_send(AX12*, AX12_Packet* packet); + +/* @brief Receive a formated AX12 status packet */ +uint8_t AX12_recv(AX12*, AX12_Packet* packet); + +//___________ Medium level layer _________ + +// ////////////////// WARNING ///////////////////////// +/* The following functions assume that AX12 always + * answer with a status packet + * (Status Return Level = 0x02 in AX12 EEPROM area) */ +// ////////////////// WARNING ///////////////////////// + +/** @brief Write byte in AX-12 memory + * @return Error code from AX-12 (0 means okay)*/ +uint8_t AX12_write_byte(AX12*, + uint8_t id, + AX12_ADDRESS address, + uint8_t data); + +/** @brief Write integer (2 bytes) in AX-12 memory + * @return Error code from AX-12 (0 means okay) + * + * address : data low + * address+1 : data high + */ +uint8_t AX12_write_int(AX12*, + uint8_t id, + AX12_ADDRESS address, + uint16_t data); + +/** @brief Read byte from AX-12 memory */ +uint8_t AX12_read_byte(AX12*, uint8_t id, AX12_ADDRESS address); + +/** @brief Write integer (2 bytes) from AX-12 memory */ +uint16_t AX12_read_int(AX12*, uint8_t id, AX12_ADDRESS address); + +//___________ High level layer _________ + +/** @brief Set AX12 position */ +uint8_t AX12_set_position(AX12*,uint8_t id, uint16_t position); + +/** @brief Set AX12 position and moving speed */ +uint8_t AX12_set_position2(AX12*, uint8_t id, + uint16_t position, + uint16_t speed); + +/** @brief Set AX12 position, moving speed and torque*/ +uint8_t AX12_set_position3(AX12*,uint8_t id, + uint16_t position, + uint16_t speed, + uint16_t torque); + +/** @brief Read AX12 position */ +uint16_t AX12_get_position(AX12*, uint8_t id); + +/** @brief Read AX12 speed */ +uint16_t AX12_get_speed(AX12*, uint8_t id); + +/** @brief Read AX12 load */ +uint16_t AX12_get_load(AX12*, uint8_t id); + + + +/** @brief Ping an AX12 and return error register */ +uint8_t AX12_ping(AX12*, uint8_t id); + +/** @brief Reset AX12 back to factory settings */ +uint8_t AX12_reset(AX12*, uint8_t id); + +#endif/*_AX12_H*/ ================================================== aversive/modules/devices/servo/ax12/ax12_address.h (1.1.2.1) ================================================== @@ -0,0 +1,60 @@ +#ifndef _AX12_INSTRUCTIONS_H_ +#define _AX12_INSTRUCTIONS_H_ + +/** @brief AX-12 control table */ +typedef enum _AX12_ADDRESS +{ + AA_MODEL_NUMBER_L = 0x00, + AA_MODEL_NUMBER_H, + AA_FIRMWARE, + AA_ID, + AA_BAUD_RATE, + AA_DELAY_TIME, + AA_CW_ANGLE_LIMIT_L, + AA_CW_ANGLE_LIMIT_H, + AA_CCW_ANGLE_LIMIT_L, + AA_CCW_ANGLE_LIMIT_H, + AA_RESERVED_1, + AA_HIGHEST_LIMIT_TEMP, + AA_LOWEST_LIMIT_VOLTAGE, + AA_HIGHEST_LIMIT_VOLTAGE, + AA_MAX_TORQUE_L, + AA_MAX_TORQUE_H, + AA_STATUS_RETURN_LEVEL, + AA_ALARM_LED, + AA_ALARM_SHUTDOWN, + AA_RESERVED_2, + AA_DOWN_CALIBRATION_L, + AA_DOWN_CALIBRATION_H, + AA_UP_CALIBRATION_L, + AA_UP_CALIBRATION_H, + AA_TORQUE_ENABLE, + AA_LED, + AA_CW_COMPLIANCE_MARGIN, + AA_CCW_COMPLIANCE_MARGIN, + AA_CW_COMPLIANCE_SLOPE, + AA_CCW_COMPLIANCE_SLOPE, + AA_GOAL_POSITION_L, + AA_GOAL_POSITION_H, + AA_MOVING_SPEED_L, + AA_MOVING_SPEED_H, + AA_TORQUE_LIMIT_L, + AA_TORQUE_LIMIT_H, + AA_PRESENT_POSITION_L, + AA_PRESENT_POSITION_H, + AA_PRESENT_SPEED_L, + AA_PRESENT_SPEED_H, + AA_PRESENT_LOAD_L, + AA_PRESENT_LOAD_H, + AA_PRESENT_VOLTAGE, + AA_PRESENT_TEMP, + AA_PRESENT_REGINST, + AA_RESERVED_3, + AA_MOVING, + AA_LOCK, + AA_PUNCH_L, + AA_PUNCH_H + +}AX12_ADDRESS; + +#endif/*_AX12_INSTRUCTIONS_H_*/ ======================================================== aversive/modules/devices/servo/ax12/config/ax12_config.h (1.1.2.1) ======================================================== @@ -0,0 +1,7 @@ +#ifndef _AX12_CONFIG_H_ +#define _AX12_CONFIG_H_ + +#define MAX_PARAMS 32 + + +#endif/*_AX12_CONFIG_H_*/ Commit from enseirb on branch b_eirbot (2008-02-20 20:47 CET) ====================================== AX-12 library updated, with some tests aversive config/config.in 1.48.2.2 aversive config/generate_aversive_config 1.26.2.2 aversive modules/devices/servo/ax12/ax12.h 1.1.2.2 + aversive modules/devices/servo/ax12/test/.config 1.1.2.1 + aversive modules/devices/servo/ax12/test/Makefile 1.1.2.1 + aversive modules/devices/servo/ax12/test/ax12_config.h 1.1.2.1 + aversive modules/devices/servo/ax12/test/error_config.h 1.1.2.1 + aversive modules/devices/servo/ax12/test/main.c 1.1.2.1 + aversive modules/devices/servo/ax12/test/uart_config.h 1.1.2.1 ========================= aversive/config/config.in (1.48.2.1 -> 1.48.2.2) ========================= @@ -275,6 +275,11 @@ dep_bool ' |-- Create Default servo config' CONFIG_MODULE_MULTISERVO_CREATE_CONFIG \ $CONFIG_MODULE_MULTISERVO +bool 'AX-12' CONFIG_MODULE_AX12 + +dep_bool ' |-- Create Default AX-12 config' CONFIG_MODULE_AX12_CREATE_CONFIG\ + $CONFIG_MODULE_AX12 + mainmenu_option next_comment comment 'Brushless motor drivers (you should enable pwm modules to see all)' ======================================== aversive/config/generate_aversive_config (1.26.2.1 -> 1.26.2.2) ======================================== @@ -21,6 +21,7 @@ CONFIG_MODULE_VT100,ihm/vt100 CONFIG_MODULE_LCD,devices/ihm/lcd CONFIG_MODULE_MULTISERVO,devices/servo/multiservo + CONFIG_MODULE_AX12,devices/servo/ax12 CONFIG_MODULE_ENCODERS_MICROB,devices/encoders/encoders_microb CONFIG_MODULE_ENCODERS_EIRBOT,devices/encoders/encoders_eirbot CONFIG_MODULE_TRAJECTORY_MANAGER,devices/robot/trajectory_manager ========================================== aversive/modules/devices/servo/ax12/ax12.h (1.1.2.1 -> 1.1.2.2) ========================================== @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Revision : $Id: ax12.h,v 1.1.2.1 2008-02-20 19:26:40 enseirb Exp $ + * Revision : $Id: ax12.h,v 1.1.2.2 2008-02-20 19:47:16 enseirb Exp $ * */ @@ -37,8 +37,8 @@ #ifndef _AX12_H_ #define _AX12_H_ -#include <stdlib.h> -#include <utils.h> +#include <aversive.h> +#include <stdlib.h> #include "ax12_address.h" #include "ax12_config.h" ================================================ aversive/modules/devices/servo/ax12/test/.config (1.1.2.1) ================================================ @@ -0,0 +1,227 @@ +# +# Automatically generated by make menuconfig: don't edit +# + +# +# Hardware +# +# CONFIG_MCU_AT90S2313 is not set +# CONFIG_MCU_AT90S2323 is not set +# CONFIG_MCU_AT90S3333 is not set +# CONFIG_MCU_AT90S2343 is not set +# CONFIG_MCU_ATTINY22 is not set +# CONFIG_MCU_ATTINY26 is not set +# CONFIG_MCU_AT90S4414 is not set +# CONFIG_MCU_AT90S4433 is not set +# CONFIG_MCU_AT90S4434 is not set +# CONFIG_MCU_AT90S8515 is not set +# CONFIG_MCU_AT90S8534 is not set +# CONFIG_MCU_AT90S8535 is not set +# CONFIG_MCU_AT86RF401 is not set +# CONFIG_MCU_ATMEGA103 is not set +# CONFIG_MCU_ATMEGA603 is not set +# CONFIG_MCU_AT43USB320 is not set +# CONFIG_MCU_AT43USB355 is not set +# CONFIG_MCU_AT76C711 is not set +# CONFIG_MCU_ATMEGA8 is not set +# CONFIG_MCU_ATMEGA48 is not set +# CONFIG_MCU_ATMEGA88 is not set +# CONFIG_MCU_ATMEGA8515 is not set +# CONFIG_MCU_ATMEGA8535 is not set +# CONFIG_MCU_ATTINY13 is not set +# CONFIG_MCU_ATTINY2313 is not set +# CONFIG_MCU_ATMEGA16 is not set +# CONFIG_MCU_ATMEGA161 is not set +# CONFIG_MCU_ATMEGA162 is not set +# CONFIG_MCU_ATMEGA163 is not set +# CONFIG_MCU_ATMEGA165 is not set +# CONFIG_MCU_ATMEGA168 is not set +# CONFIG_MCU_ATMEGA169 is not set +# CONFIG_MCU_ATMEGA32 is not set +# CONFIG_MCU_ATMEGA323 is not set +# CONFIG_MCU_ATMEGA325 is not set +# CONFIG_MCU_ATMEGA3250 is not set +# CONFIG_MCU_ATMEGA64 is not set +# CONFIG_MCU_ATMEGA645 is not set +# CONFIG_MCU_ATMEGA6450 is not set +CONFIG_MCU_ATMEGA128=y +# CONFIG_MCU_AT90CAN128 is not set +# CONFIG_MCU_AT94K is not set +# CONFIG_MCU_AT90S1200 is not set +CONFIG_QUARTZ=8000000 + +# +# Generation options +# +# CONFIG_OPTM_0 is not set +# CONFIG_OPTM_1 is not set +# CONFIG_OPTM_2 is not set +# CONFIG_OPTM_3 is not set +CONFIG_OPTM_S=y +CONFIG_MATH_LIB=y +# CONFIG_FDEVOPEN_COMPAT is not set +# CONFIG_MINIMAL_PRINTF is not set +CONFIG_STANDARD_PRINTF=y +# CONFIG_ADVANCED_PRINTF is not set +CONFIG_FORMAT_IHEX=y +# CONFIG_FORMAT_SREC is not set +# CONFIG_FORMAT_BINARY is not set + +# +# Base modules +# +CONFIG_MODULE_CIRBUF=y +# CONFIG_MODULE_CIRBUF_LARGE is not set +# CONFIG_MODULE_FIXED_POINT is not set +# CONFIG_MODULE_VECT2 is not set +# CONFIG_MODULE_SCHEDULER is not set +# CONFIG_MODULE_SCHEDULER_CREATE_CONFIG is not set +# CONFIG_MODULE_SCHEDULER_USE_TIMERS is not set +CONFIG_MODULE_SCHEDULER_TIMER0=y +# CONFIG_MODULE_SCHEDULER_MANUAL is not set +# CONFIG_MODULE_TIME is not set +# CONFIG_MODULE_TIME_CREATE_CONFIG is not set + +# +# Communication modules +# +CONFIG_MODULE_UART=y +CONFIG_MODULE_UART_CREATE_CONFIG=y +# CONFIG_MODULE_I2C is not set +# CONFIG_MODULE_I2C_MASTER is not set +# CONFIG_MODULE_I2C_MULTIMASTER is not set +# CONFIG_MODULE_I2C_CREATE_CONFIG is not set +# CONFIG_MODULE_MF2_CLIENT is not set +# CONFIG_MODULE_MF2_CLIENT_USE_SCHEDULER is not set +# CONFIG_MODULE_MF2_CLIENT_CREATE_CONFIG is not set +# CONFIG_MODULE_MF2_SERVER is not set +# CONFIG_MODULE_MF2_SERVER_CREATE_CONFIG is not set + +# +# Hardware modules +# +# CONFIG_MODULE_TIMER is not set +# CONFIG_MODULE_TIMER_CREATE_CONFIG is not set +# CONFIG_MODULE_TIMER_DYNAMIC is not set +# CONFIG_MODULE_PWM is not set +# CONFIG_MODULE_PWM_CREATE_CONFIG is not set +# CONFIG_MODULE_ADC is not set +# CONFIG_MODULE_ADC_CREATE_CONFIG is not set + +# +# IHM modules +# +# CONFIG_MODULE_MENU is not set +# CONFIG_MODULE_VT100 is not set +# CONFIG_MODULE_RDLINE is not set +# CONFIG_MODULE_RDLINE_CREATE_CONFIG is not set +# CONFIG_MODULE_RDLINE_KILL_BUF is not set +# CONFIG_MODULE_RDLINE_HISTORY is not set +# CONFIG_MODULE_PARSE is not set + +# +# External devices modules +# +# CONFIG_MODULE_LCD is not set +# CONFIG_MODULE_LCD_CREATE_CONFIG is not set +# CONFIG_MODULE_MULTISERVO is not set +# CONFIG_MODULE_MULTISERVO_CREATE_CONFIG is not set +CONFIG_MODULE_AX12=y +CONFIG_MODULE_AX12_CREATE_CONFIG=y + +# +# Brushless motor drivers (you should enable pwm modules to see all) +# +# CONFIG_MODULE_BRUSHLESS_3PHASE_DIGITAL_HALL is not set +# CONFIG_MODULE_BRUSHLESS_3PHASE_DIGITAL_HALL_CREATE_CONFIG is not set +# CONFIG_MODULE_BRUSHLESS_3PHASE_DIGITAL_HALL_DOUBLE is not set +# CONFIG_MODULE_BRUSHLESS_3PHASE_DIGITAL_HALL_DOUBLE_CREATE_CONFIG is not set + +# +# Encoders +# +# CONFIG_MODULE_ENCODERS_MICROB is not set +# CONFIG_MODULE_ENCODERS_MICROB_CREATE_CONFIG is not set +# CONFIG_MODULE_ENCODERS_EIRBOT is not set +# CONFIG_MODULE_ENCODERS_EIRBOT_CREATE_CONFIG is not set + +# +# Robot specific modules +# +# CONFIG_MODULE_ROBOT_SYSTEM is not set +# CONFIG_MODULE_POSITION_MANAGER is not set +# CONFIG_MODULE_TRAJECTORY_MANAGER is not set +# CONFIG_MODULE_BLOCKING_DETECTION_MANAGER is not set +# CONFIG_MODULE_OBSTACLE_AVOIDANCE is not set + +# +# Control system modules +# +# CONFIG_MODULE_CONTROL_SYSTEM_MANAGER is not set +# CONFIG_MODULE_PID is not set +# CONFIG_MODULE_PID_CREATE_CONFIG is not set +# CONFIG_MODULE_RAMP is not set +# CONFIG_MODULE_QUADRAMP is not set +# CONFIG_MODULE_QUADRAMP_DERIVATE is not set +# CONFIG_MODULE_BIQUAD is not set +# CONFIG_MODULE_QUADRAMP_DERIVATE is not set +# CONFIG_MODULE_BIQUAD is not set + +# +# Crypto modules +# +# CONFIG_MODULE_AES is not set +# CONFIG_MODULE_AES_CTR is not set +# CONFIG_MODULE_MD5 is not set +# CONFIG_MODULE_MD5_HMAC is not set +# CONFIG_MODULE_RC4 is not set + +# +# Encodings modules +# +# CONFIG_MODULE_BASE64 is not set +# CONFIG_MODULE_HAMMING is not set + +# +# Debug modules +# +# CONFIG_MODULE_DIAGNOSTIC is not set +# CONFIG_MODULE_DIAGNOSTIC_CREATE_CONFIG is not set +CONFIG_MODULE_ERROR=y +CONFIG_MODULE_ERROR_CREATE_CONFIG=y + +# +# Programmer options +# +CONFIG_AVRDUDE=y +# CONFIG_AVARICE is not set + +# +# Avrdude +# +# CONFIG_AVRDUDE_PROG_FUTURELEC is not set +# CONFIG_AVRDUDE_PROG_ABCMINI is not set +# CONFIG_AVRDUDE_PROG_PICOWEB is not set +# CONFIG_AVRDUDE_PROG_SP12 is not set +# CONFIG_AVRDUDE_PROG_ALF is not set +# CONFIG_AVRDUDE_PROG_BASCOM is not set +# CONFIG_AVRDUDE_PROG_DT006 is not set +# CONFIG_AVRDUDE_PROG_PONY_STK200 is not set +CONFIG_AVRDUDE_PROG_STK200=y +# CONFIG_AVRDUDE_PROG_PAVR is not set +# CONFIG_AVRDUDE_PROG_BUTTERFLY is not set +# CONFIG_AVRDUDE_PROG_AVR910 is not set +# CONFIG_AVRDUDE_PROG_STK500 is not set +# CONFIG_AVRDUDE_PROG_AVRISP is not set +# CONFIG_AVRDUDE_PROG_BSD is not set +# CONFIG_AVRDUDE_PROG_DAPA is not set +# CONFIG_AVRDUDE_PROG_JTAG1 is not set +CONFIG_AVRDUDE_PORT="/dev/parport0" + +# +# Avarice +# +CONFIG_AVARICE_PORT="/dev/ttyS0" +CONFIG_AVARICE_DEBUG_PORT=1234 +CONFIG_AVARICE_PROG_MKI=y +# CONFIG_AVARICE_PROG_MKII is not set ================================================= aversive/modules/devices/servo/ax12/test/Makefile (1.1.2.1) ================================================= @@ -0,0 +1,22 @@ +TARGET = main + +# repertoire des modules +AVERSIVE_DIR = ../../../../.. +# VALUE, absolute or relative path : example ../.. # + +# List C source files here. (C dependencies are automatically generated.) +SRC = $(TARGET).c + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC = + +######################################## + +-include .aversive_conf +include $(AVERSIVE_DIR)/mk/aversive_project.mk ====================================================== aversive/modules/devices/servo/ax12/test/ax12_config.h (1.1.2.1) ====================================================== @@ -0,0 +1,7 @@ +#ifndef _AX12_CONFIG_H_ +#define _AX12_CONFIG_H_ + +#define MAX_PARAMS 32 + + +#endif/*_AX12_CONFIG_H_*/ ======================================================= aversive/modules/devices/servo/ax12/test/error_config.h (1.1.2.1) ======================================================= @@ -0,0 +1,31 @@ +/* + * Copyright Droids Corporation, Microb Technology, Eirbot (2005) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Revision : $Id: error_config.h,v 1.1.2.1 2008-02-20 19:47:16 enseirb Exp $ + * + */ + +#ifndef _ERROR_CONFIG_ +#define _ERROR_CONFIG_ + +/** enable the dump of the comment */ +#define ERROR_DUMP_TEXTLOG + +/** enable the dump of filename and line number */ +#define ERROR_DUMP_FILE_LINE + +#endif =============================================== aversive/modules/devices/servo/ax12/test/main.c (1.1.2.1) =============================================== @@ -0,0 +1,79 @@ +#include <aversive.h> +#include <uart.h> +#include <math.h> + +#include <ax12.h> + +void send_char(uint8_t c) +{ + + sbi(UCSR0A,TXC0); + while(!(UCSR0A & (1<<UDRE0))) nop(); + + UDR0 = c; + + while(!(UCSR0A & (1<<TXC0))) nop(); + +} + +uint8_t recv_char(void) +{ + char c; + + while( !( UCSR0A &(1<<RXC0))) nop(); + + c = UDR0; + + return c; +} + +void switch_uart(uint8_t state) +{ + switch(state) + { + case AX12_STATE_WRITE: + sbi(PORTB,0); + break; + + case AX12_STATE_READ: + cbi(PORTB,0); + break; + + default:break; + } + + return; +} + +int main(void) +{ + AX12 ax12; + + AX12_init(&ax12); + AX12_set_hardware_send(&ax12, send_char); + AX12_set_hardware_recv(&ax12, recv_char); + AX12_set_hardware_switch(&ax12, switch_uart); + + // Initialize full duplex uart direction port + sbi(DDRB,0); + sbi(PORTB,0); + + uart_init(); // Set baudrates according to uart_config.h + + // Set some AX12 parameters + AX12_write_int(&ax12,0xFE,AA_PUNCH_L,0x20); + AX12_write_int(&ax12,0xFE,AA_TORQUE_LIMIT_L,0x3FF); + AX12_write_int(&ax12,0xFE,AA_MOVING_SPEED_L,0x300); + AX12_write_byte(&ax12,0xFE,AA_ALARM_LED,0xEF); + + double d=0; + int i; + while(1) + { + d+=0.08; + for(i=1;i<6;i++) + AX12_set_position(&ax12,i,0x1FF + 0x130*cos(d+i*2.0)); + } + + return 0; +} ====================================================== aversive/modules/devices/servo/ax12/test/uart_config.h (1.1.2.1) ====================================================== @@ -0,0 +1,72 @@ +/* + * Copyright Droids Corporation, Microb Technology, Eirbot (2005) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Revision : $Id: uart_config.h,v 1.1.2.1 2008-02-20 19:47:16 enseirb Exp $ + * + */ + +/* Droids-corp 2004 - Zer0 + * config for uart module + */ + +#ifndef UART_CONFIG_H +#define UART_CONFIG_H + +/* + * UART0 definitions + */ + +/* compile uart0 fonctions, undefine it to pass compilation */ +#define UART0_COMPILE + +/* enable uart0 if == 1, disable if == 0 */ +#define UART0_ENABLED 1 + +/* enable uart0 interrupts if == 1, disable if == 0 */ +#define UART0_INTERRUPT_ENABLED 1 + +#define UART0_BAUDRATE 38400 + +/* + * if you enable this, the maximum baudrate you can reach is + * higher, but the precision is lower. + */ +#define UART0_USE_DOUBLE_SPEED 0 +//#define UART0_USE_DOUBLE_SPEED 1 + +#define UART0_RX_FIFO_SIZE 4 +#define UART0_TX_FIFO_SIZE 4 +//#define UART0_NBITS 5 +//#define UART0_NBITS 6 +//#define UART0_NBITS 7 +#define UART0_NBITS 8 +//#define UART0_NBITS 9 + +#define UART0_PARITY UART_PARTITY_NONE +//#define UART0_PARITY UART_PARTITY_ODD +//#define UART0_PARITY UART_PARTITY_EVEN + +#define UART0_STOP_BIT UART_STOP_BITS_1 +//#define UART0_STOP_BIT UART_STOP_BITS_2 + + + + +/* .... same for uart 1, 2, 3 ... */ + +#endif + Commit from enseirb on branch b_eirbot (2008-02-20 21:04 CET) ====================================== header changes aversive modules/devices/servo/ax12/ax12.h 1.1.2.3 ========================================== aversive/modules/devices/servo/ax12/ax12.h (1.1.2.2 -> 1.1.2.3) ========================================== @@ -1,6 +1,7 @@ /* - * Copyright Droids Corporation, Microb Technology, Eirbot (2005) + * Copyright Droids Corporation, Microb Technology, Eirbot (2008) + * Brossillon JD. <[EMAIL PROTECTED]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Revision : $Id: ax12.h,v 1.1.2.2 2008-02-20 19:47:16 enseirb Exp $ + * Revision : $Id: ax12.h,v 1.1.2.3 2008-02-20 20:04:51 enseirb Exp $ * */
_______________________________________________ Avr-list mailing list Avr-list@droids-corp.org CVSWEB : http://cvsweb.droids-corp.org/cgi-bin/viewcvs.cgi/aversive WIKI : http://wiki.droids-corp.org/index.php/Aversive DOXYGEN : http://zer0.droids-corp.org/doxygen_aversive/html/ BUGZILLA : http://bugzilla.droids-corp.org COMMIT LOGS : http://zer0.droids-corp.org/aversive_commitlog