📄 config_motor.h
字号:
/**
* @file config_motor.h
*
* Copyright (c) 2005 Atmel.
*
* @brief This module provide services to define config for motor control.
* This file is included by config.h in order to access to system wide
* configuration.
* @version 1.0 (CVS revision : $Revision: 1.3 $)
* @date $Date: 2006/07/12 12:58:26 $
* @author $Author: raubree $
*****************************************************************************/
/*_____ I N C L U D E S ____________________________________________________*/
#include "compiler.h"
#include "mcu.h"
#include "inavr.h"
#ifndef _CONFIG_MOTOR_H_
#define _CONFIG_MOTOR_H_
/**
* @brief This enumeration contains the 6 differents values for the Hall Sensors
* See design document. In this application, just 3 hall sensor are used
* Hall Sensor : position 1 to 6
*/
#ifdef USE_INTERNAL_COMPARATORS
/* enum with the bemf signals from comparator outputs */
// enum {HS_001=3,HS_010=6,HS_011=2,HS_100=5,HS_101=1,HS_110=4};
enum {HS_011=2,HS_001=3,HS_101=1,HS_100=5,HS_110=4,HS_010=6};
#else
/* enum with the bemf signals from port inputs */
enum {HS_001=1,HS_010=2,HS_011=3,HS_100=4,HS_101=5,HS_110=6};
#endif
/**
* @brief Define the two states of the motor
*/
enum {RUN = TRUE, STOP = FALSE};
/**
* @brief Define Direction of rotor : CCW and CW
*/
enum {CCW = TRUE, CW = FALSE};
/**
* @brief Define Type of Pulse Width Modulation
*/
#define HIGH_AND_LOW_PWM
/**
* @brief Define the voltage during the ramp up sequence
*/
#define DUTY_RAMP_UP 140
/**
* @brief Define the different kinds of regulation
*/
enum {OPEN_LOOP = 0, SPEED_LOOP = 1, CURRENT_LOOP = 2, POSITION_LOOP = 3};
// Here you have to define your control coefficients
// Kp for the proportionnal coef
// Ki for the integral coef
// Kd for the derivative coef
// Speed regulation coefficients
//#define Kp_speed 16//1 MMT motor//8 MAXON moto
#define Kp_speed 6
#define Ki_speed 2
#define Kd_speed 0
#define Klin_speed 185 /* to linearize the duty cycle responds */
// Current regulation coefficients
#define Kp_cur 1
#define Ki_cur 3
#define Kd_cur 0
// Position regulation coefficients
#define Kp_pos 9 //8
#define Ki_pos 3 //1
#define Kd_pos 20 //5
// All PID coef are multiplied by 2^Kmul
// For exemple : kp = 1 => Kp = 1 * 2^K_scal = 1 * 2^4 = 16
// To get the right result you have to divide the number by 2^K_scal
// So execute a K_scal right shift
#define K_speed_scal 5
#define K_cur_scal 4
#define K_pos_scal 5
// Speed measurement
// K_SPEED = (60 * 255)/(p * t_timer0 * speed_max(rpm))
// with p : number of pairs of poles.
// and t_timer0 : 8us @ 8MHz / 4us @ 16MHz
//#define K_SPEED 77116 /* 6200 rpm/ 4 pairs/ @8MHz */
#define K_SPEED 136607 /* 7000 rpm/ 4 pairs/ @16MHz */
/* speed(rpm) = measured_speed * 60 / (K_SPEED * 4E-6 * p) */
/* the result must be multiplied by 27.45 to get a value in rpm */
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -