BLDC 电机 加速算法

  • P0_131803
    了解作者
  • 230.7KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-09 01:26
    上传日期
BLDC 电机 加速算法 里面是C语言源码 很容易看得明白 .
PID算法BLDCMotorControl-AVR447.zip
  • PMSM.h
    11.8KB
  • Release
  • Exe
  • AVR447.a90
    7.4KB
  • pid.c
    3.3KB
  • pid.h
    2.6KB
  • www.pudn.com.txt
    218B
  • readme.html
    345B
  • stdint.h
    5KB
  • doxygen
  • main_8c_a18_cgraph.map
    164B
  • stdint_8h.html
    77.9KB
  • main_8c_a40_cgraph.md5
    32B
  • pid_8c__incl.md5
    32B
  • PMSM_8h-source.html
    23.5KB
  • PMSMtables_8h__dep__incl.png
    582B
  • PMSM_8h_a82_cgraph.map
    554B
  • main_8c_a16_cgraph.png
    704B
  • ftv2lastnode.png
    233B
  • PMSM_8h_a83_cgraph.md5
    32B
  • main_8c_a17_cgraph.png
    2.1KB
  • graph_legend.html
    4.5KB
  • tree.html
    6KB
  • ftv2folderopen.png
    261B
  • main_8c_a17_cgraph.md5
    32B
  • pages.html
    1.2KB
  • main_8c_a28_cgraph.png
    1.4KB
  • PMSMtables_8h__dep__incl.md5
    32B
  • main_8c_a19_cgraph.map
    125B
  • main_8c.html
    148.3KB
  • main_8c_a16_cgraph.map
    47B
  • PMSM_8h_a84_cgraph.md5
    32B
  • pid_8h__dep__incl.md5
    32B
  • pid_8c-source.html
    8.6KB
  • PMSM_8h__dep__incl.png
    489B
  • ftv2mnode.png
    194B
  • doxygen.css
    7KB
  • ftv2link.png
    358B
  • PMSM_8h_a81_cgraph.md5
    32B
  • doxygen.png
    1.3KB
  • main_8c_a10_cgraph.map
    394B
  • PMSMtables_8h.html
    17.6KB
  • stdint_8h-source.html
    22.9KB
  • main_8c_a10_cgraph.md5
    32B
  • graph_legend.png
    4KB
  • main_8c__incl.map
    126B
  • PMSM_8h__dep__incl.map
    45B
  • functions_vars.html
    2KB
  • globals_func.html
    7.4KB
  • main_8c__incl.md5
    32B
  • PMSMtables_8h-source.html
    45KB
  • stdint_8h__incl.map
    13B
  • main_8c__incl.png
    2.1KB
  • main_8c_a18_cgraph.md5
    32B
  • globals.html
    18.8KB
  • main_8c_a41_cgraph.md5
    32B
  • main_8c_a10_cgraph.png
    5KB
  • PMSM_8h_a82_cgraph.md5
    32B
  • ftv2node.png
    235B
  • pid_8h__dep__incl.png
    375B
  • ftv2plastnode.png
    165B
  • main_8c_a36_cgraph.map
    355B
  • main_8c_a42_cgraph.map
    475B
  • pid_8h.html
    26.4KB
  • main_8c_a39_cgraph.png
    961B
  • pid_8h-source.html
    5.5KB
  • main_8c_a36_cgraph.png
    5.6KB
  • main_8c_a41_cgraph.png
    3.2KB
  • main_8c_a40_cgraph.map
    554B
  • pid_8h__dep__incl.map
    44B
  • structPMSMflags.html
    8.2KB
  • main_8c_a39_cgraph.md5
    32B
  • main_8c_a16_cgraph.md5
    32B
  • stdint_8h__dep__incl.png
    635B
  • main_8c_a36_cgraph.md5
    32B
  • stdint_8h__dep__incl.map
    77B
  • PMSM_8h_a84_cgraph.png
    7.1KB
  • main_8c_a18_cgraph.png
    2.8KB
  • stdint_8h__incl.md5
    32B
  • ftv2pnode.png
    200B
  • ftv2vertline.png
    229B
  • files.html
    2.1KB
  • PMSMtables_8h__dep__incl.map
    45B
  • ftv2folderclosed.png
    259B
  • main_8c_a24_cgraph.md5
    32B
  • main.html
    2.8KB
  • main_8c_a41_cgraph.map
    203B
  • ftv2doc.png
    255B
  • main_8c_a19_cgraph.md5
    32B
  • ftv2mlastnode.png
    160B
  • globals_type.html
    3.2KB
  • index.html
    342B
  • main_8c_a40_cgraph.png
    8.8KB
  • PMSM_8h_a83_cgraph.png
    3.2KB
  • annotated.html
    1.4KB
  • pid_8c__incl.map
    82B
  • PMSM_8h.html
    130KB
  • globals_vars.html
    2.7KB
  • PMSM_8h_a81_cgraph.map
    49B
  • main_8c_a42_cgraph.md5
    32B
内容介绍
/* This file has been prepared for Doxygen automatic documentation generation.*/ /*! \file ********************************************************************* * * \brief * Motor control implementation. * * This file contains the full implementation of the motor control, * except the PID-controller. * * \par Application note: * AVR447: Sinusoidal driving of three-phase permanent motor using * ATmega48/88/168 * * \par Documentation * For comprehensive code documentation, supported compilers, compiler * settings and supported devices see readme.html * * \author * Atmel Corporation: http://www.atmel.com \n * Support email: avr@atmel.com * * $Name: RELEASE_1_0 $ * $Revision: 1.8 $ * $RCSfile: main.c,v $ * $Date: 2006/03/27 07:20:51 $ \n ******************************************************************************/ #include <ioavr.h> #include <inavr.h> #include "stdint.h" #include "PMSM.h" #include "PMSMtables.h" #if (SPEED_CONTROL_METHOD == SPEED_CONTROL_CLOSED_LOOP) #include "pid.h" #endif /*! \brief Motor control flags placed in I/O space for fast access. * * This variable contains all the flags used for motor control. * It is placed in GPIOR0 register, which allows usage of several * fast bit manipulation/branch instructions. */ __io volatile PMSMflags_t fastFlags @0x1e; /*! \brief Increment used for sine table iteration. * * This variable holds the increment used for sine table iteration. * It is stored in an 8.8 fixed point format. */ __no_init __regvar volatile uint16_t sineTableIncrement @14; /*! \brief Index into sine table * * This variable is used as an index into the sine table. It is * stored in a 8.8 fixed point format, so it can be directly incremented by * sineTableIncrement. Only the high byte is used as table index. */ __no_init __regvar volatile uint16_t sineTableIndex @12; /*! \brief The number of 'ticks' between two hall sensor changes. * * This variable is used to count the number of 'ticks' between each hall * sensor change. One 'tick' is one PWM period, 510 CPU clock cycles. This is * used to calculate sine table increment. The speed of the motor is inversely * proportional to this value. */ __no_init __regvar volatile uint16_t commutationTicks @10; /*! \brief The amplitude of the generated sine waves. * * This variable controls the amplitude of the generated sine waves. * The range is 0-255. */ __no_init __regvar volatile uint8_t amplitude @9; /*! \brief The lead angle or advance commutation angle * * This variable specifies a shift in the sine table that will * generate advance commutaiton. For a 192 element sine table, an increase * of one in advanceCommutationSteps will result in 1.875 degrees lead * angle. */ __no_init __regvar volatile uint8_t advanceCommutationSteps @8; /*! \brief Index to the end of the current commutation sector * * This variable holds the index where the next commutation sector starts, * including the advance commutation angle. * * It is used to prevent the output from going further until the hall sensors * changes. */ __no_init __regvar volatile uint8_t sineTableNextSectorStart @7; /*! \brief Current measurement * * The most recent current measurement is stored in this variable. It is not * used for any purpose in this implementation, but the measurement is * updated. */ volatile uint8_t current; //! The most recent speed input measurement. volatile uint8_t speedInput; /*! \brief Speed controller run flag. * * This variable is set to TRUE every time the speed controller should be run. */ volatile uint8_t SpeedControllerRun = FALSE; #if (SPEED_CONTROL_METHOD == SPEED_CONTROL_CLOSED_LOOP) //! Struct used to hold PID controller parameters and variables. pidData_t pidParameters; #endif /*! \brief Main function / initialization * * The main function initializes all subsystems needed for motor control * and enables interrupts, which kicks off the fully interrupt-driven * motor control. The main function goes into an eternal loop where it * does nothing. */ void main(void) { //Initialize peripherals. PortsInit(); TimersInit(); PinChangeIntInit(); ADCInit(); SetAdvanceCommutation(0); #if (SPEED_CONTROL_METHOD == SPEED_CONTROL_CLOSED_LOOP) PID_Init(PID_K_P, PID_K_I, PID_K_D, &pidParameters); #endif //Do not start until everything is ready. CheckEmergencyShutdown(); //Initialize fastflags. Use temporary variable to avoid several accesses to //volatile variable. { PMSMflags_t fastFlagsInitial; // Set motorStopped to FALSE at startup. This will make sure that the motor // is not started if it is not really stopped. If it is stopped, this variable // will quickly be updated. fastFlagsInitial.motorStopped = FALSE; // Set motorSyncronized to FALSE at startup. This will prevent the motor from being // driven until the motor is in synch or stopped. fastFlagsInitial.motorSynchronized = FALSE; fastFlagsInitial.actualDirection = DIRECTION_UNKNOWN; fastFlagsInitial.desiredDirection = 0; fastFlagsInitial.driveWaveform = WAVEFORM_UNDEFINED; fastFlags = fastFlagsInitial; } DesiredDirectionUpdate(); // Enable Timer1 capture event interrupt. TIMSK1 |= (1 << ICIE1); //Enable interrupts globally and let motor driver take over. __enable_interrupt(); for(;;) { if (SpeedControllerRun) { SpeedController(); SpeedControllerRun = FALSE; } } } /*! \brief Initializes I/O port directions and pull-up resistors * * This function initializes all I/O ports with correct * direction and pull-up resistors, if needed. */ static void PortsInit(void) { #if (HALL_PULLUP_ENABLE == TRUE) // Set hall sensor pins as input, pullups enabled. PORTC = (1 << H1_PIN) | (1 << H2_PIN) | (1 << H3_PIN); #endif // PORTD outputs DDRD = (1 << REV_ROTATION_PIN) | (1 << TACHO_OUTPUT_PIN); //Enable pull-up on direction signal. PORTD |= (1 << DIRECTION_COMMAND_PIN); } /*! \brief Initializes and synchronizes Timers * * This function sets the correct prescaler and starts all * three timers. The timers are synchronized to ensure that * all PWM signals are aligned. */ static void TimersInit(void) { //Set all timers in "Phase correct mode". Do not enable outputs yet. TCCR0A = (1 << WGM00); TCCR1A = (1 << WGM11); TCCR2A = (1 << WGM20); //Set top value of Timer/counter1. ICR1 = 0xff; //Synchronize timers TCNT0 = 0; TCNT1 = 2; TCNT2 = 4; // Start all 3 timers. TCCR0B = (0 << CS01) | (1 << CS00); TCCR1B = (1 << WGM13) | (0 << CS11) | (1 << CS10); TCCR2B = (0 << CS21) | (1 << CS20); } /*! \brief Initialize pin change interrupts. * * This function initializes pin change interrupt on hall * sensor input pins input, emergency shutdown * input and motor direction control input. */ static void PinChangeIntInit(void) { // Initialize pin change interrupt on emergency shutdown pin. PCMSK0 = (1 << PCINT5); // Initialize pin change interrupt on hall sensor inputs. PCMSK1 = (1 << PCINT10) | (1 << PCINT9) | (1 << PCINT8); // Initialize pin change interrupt on direction input pin. PCMSK2 = (1 << PCINT18); // Enable pin change interrupt on ports with pin change signals PCICR = (1 << PCIE2) | (1 << PCIE1) | (1 << PCIE0); } /*! \brief Initializes the ADC * * This function initializes the ADC for speed reference measurements. * The ADC will operate in free-running mode, and reading is done in the * ADC complete interrupt service routine. */ s
评论
    相关推荐
    • C语言算法
      C语言算法集 第一章 适合初学算法和计算机编程的学生
    • C语言 算法
      很多例子与介绍,有助于理解算法深意
    • c语言算法书籍
      c语言算法书籍
    • c语言算法大全
      c语言入门算法大全,对于新手学习c语言特别的有帮助
    • C语言算法
      C语言算法C语言算法
    • 拓扑 排序 C语言 算法
      拓扑 排序 C语言 算法 拓扑 排序 C语言 算法 绝对可以 欢迎下载
    • c语言算法
      很不错的软件设计者学习的基础算法.c语言
    • 椭圆C语言算法
      图形学课要求的椭圆扫描线算法#include #include #include #include #include "stdefine.h" void Ellipse(int xo, int yo, int a, int b) { BOOL flag = FALSE; int x; int y; long aa; long bb; long d;...
    • 经典c语言算法
      介绍了一些经典的算法,优化程序,提高效率,清晰思路。
    • c语言算法
      算法c语言,有很多,减压看