ljhlxq 发表于 2010-9-12 11:07:10

用定时器实现步进电机控制方案。

步进电机要做好真正加速、高速、减速的控制过程,还是不容易的。

void Tim1_Configuration(void)//PA8-CH1-T1-DMA1CH5
{
        TIM_TimeBaseInitTypeDefTIM_TimeBaseStructure;
        TIM_OCInitTypeDefTIM_OCInitStructure;
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1,ENABLE);

        TIM_DeInit(TIM1);
        /*TIM1时钟配置*/
        TIM_TimeBaseStructure.TIM_Prescaler = 71;                                                  //
        TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;                  //
        TIM_TimeBaseStructure.TIM_Period = 0xffff;                                                        //
        TIM_TimeBaseStructure.TIM_ClockDivision = 0;
        TIM_TimeBaseInit(TIM1,&TIM_TimeBaseStructure);

        /* Channel 1 Configuration in oc mode */
        TIM_OCStructInit(&TIM_OCInitStructure);
        TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Toggle;                                 //
        TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;           //
        TIM_OCInitStructure.TIM_Pulse =S_50HZ;                                                         //
        TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;                   //输出极性

       
        TIM_OC1Init(TIM1,&TIM_OCInitStructure);                                                   //通道1

        TIM_ClearFlag(TIM1, TIM_FLAG_CC1|TIM_FLAG_CC2|TIM_FLAG_CC3|TIM_FLAG_CC4);
        TIM_ITConfig(TIM1, TIM_IT_CC1, DISABLE);
       
        TIM_OC1PreloadConfig(TIM1,DISABLE);
        TIM_ARRPreloadConfig(TIM1, DISABLE);
        TIM_Cmd(TIM1,DISABLE);
        TIM_CtrlPWMOutputs(TIM1,ENABLE);
}
、、-------------------------------------------------上面是定时器初始化

//下面是定时器中断打开


void NVIC_Configuration(void)
{
        NVIC_InitTypeDef NVIC_InitStructure;
       
        /* Configure one bit for preemption priority */
        NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

        /* Timer1中断*/
        NVIC_InitStructure.NVIC_IRQChannel = TIM1_CC_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);

        /* Enable the TIM2 global Interrupt */
        NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);

        /* Enable the TIM4 global Interrupt */
        NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);

        /* Enable the TIM3 global Interrupt */
        NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);

        /*UART2*/
        NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);

        /*RTC*/
        NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
}


//----------------------------实现控制
long double Tulun_datatemp=0.;
unsigned char MXUpDown_flag=0; //方向的标志
uint32_t COM_Refernce;      //中间变量

unsigned char Tulun_i=0;       //2次作为一个脉冲
unsigned char TLCLOSE_flag=0; //手动关闭运行的标志
unsigned charStart_fre=50;//启动频率
unsigned charAdd_celer=50;//加、减速频率
uint32_tMxmc_timer=0;              //实际运行的脉冲数据

void clear_comref(void)//把中间变量的数据清掉
{
        unsigned char i=0;
        for(i=0;i<9;i++)
        {
                COM_Refernce=0;
        }
}


/*******************************************************************************
* Function Name: TIM1_CC_IRQHandler
* Description    : This function handles TIM1 capture compare interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_CC_IRQHandler(void)
{
    uint16_t capture=0;
        uint16_t temp=0;
       
        if(TIM_GetITStatus(TIM1, TIM_IT_CC1) == SET)
    {
      TIM_ClearITPendingBit(TIM1, TIM_IT_CC1 );
      capture = TIM_GetCapture1(TIM1);
                Tulun_i++;
                if(Tulun_i==2)
                {
                        Mxmc_timer++;//2次中断为一个脉冲周期
                        Tulun_i=0;
                }

                temp=TIM1_CC1_handler(COM_Refernce,Mxmc_timer);
      TIM_SetCompare1(TIM1, capture + temp);
    }
}

void step1_start(unsigned char arror)
{
        if(arror==1)//正转
        {
                STEP1_UP;       
        }
        else
        {
                STEP1_DW;
        }

        TIM_ITConfig(TIM1, TIM_IT_CC1, ENABLE);
        TIM_Cmd(TIM1,ENABLE);
}


/**********************************************************        ***
说明:运行过程中,定时器比较功能的实现函数
***************************************************************/
uint16_t TIM1_CC1_handler(uint32_t *ptr,uint32_t ym_data)
{
       uint16_t counter=0;
       static unsigned int i=0;
       static unsigned int temp=0;

       if(TLCLOSE_flag==0)
       {
              if(ym_data<=ptr)//加速阶段
               {
                      counter=500000/(Start_fre+Add_celer*ym_data);//500000为1M频率分为2;
               }
               else
               {
                         counter=500000/ptr;//500000为1M频率分为2;
               }
       }
       else //获得了停止的按钮
       {
               if(i==0)
               {
                       i++;
                        if(ym_data>=ptr)//减速的脉冲数必须为PTR
                        {
                                temp=ptr;
                        }
                        else
                        {
                                temp=ym_data;
                        }
               }
               if(i<temp)
               {
                       counter=500000/(Start_fre+Add_celer*temp-Add_celer*i);//500000为1M频率分为2
                       i++;
               }
               else
               {
                      counter=500000/Start_fre;//500000为1M频率分为2
                       if(Tulun_i==0)
                       {
                                  TIM_Cmd(TIM1,DISABLE);
                                  TIM_ITConfig(TIM1, TIM_IT_CC1, DISABLE);
                               i=0;
                               temp=0;
                               TLCLOSE_flag=0;

                             return 60000;//回一个非常的值
                       }
               }       
       }

       return counter;
}

/**********************************************************        ***
说明:sudu_max表示运行的最高频率;i表示运行的方向正转还是反转
***************************************************************/
void step1_runhand(uint16_t sudu_max,unsigned char i)
{
       unsigned char arror_mx=0;
       double temp_data=0.;           //中间变量
       uint16_t High_fre =0;   //运行的最高频率
       uint32_t StEnd_mcdata=0;//加速与减速需要的脉冲数据

       clear_comref();//先清数组
       if(sudu_max==0)//没有速度退出
       {
          return;
       }
       
       if(i==0x01) //上升,正转
       {
                 arror_mx=1;
                  MXUpDown_flag=1;
       }
       else if(i==0x00)
       {
               arror_mx=0;
               MXUpDown_flag=0;
       }
       
       High_fre=(uint16_t)sudu_max;//运行的最高频率值

       if(High_fre>Start_fre)
       {
                StEnd_mcdata= (uint32_t)(High_fre-Start_fre)/Add_celer;
       }
       else
       {
                StEnd_mcdata=0;
       }
       COM_Refernce=High_fre;
       COM_Refernce=StEnd_mcdata;

       TLCLOSE_flag=0;
       Tulun_i=0;
       Mxmc_timer=0;

       step1_start(arror_mx);
}

ljhlxq 发表于 2010-9-12 11:09:37

上述方案进行简单更改,就可以与步进电机驱动器一起实现,步进电机的加速、减速、高速过程。运行频率10K以上,在我们的控制器里已经成功运行。同时,在我的水晶球数控系统中,运用良好。

ljhlxq 发表于 2010-9-12 11:12:05

还得说上一句,以上应用,参考了九九的定时器应用笔记,表示感谢,对于九九本人,若有需要和项目合作,可以与本人联系。

dmxfeng 发表于 2010-9-12 12:03:41

记号

823032003 发表于 2010-9-12 12:16:35

xuexi

shzxy9865 发表于 2010-9-12 12:44:41

mark~~~~~~~~~~~~~~

youxin2004 发表于 2010-9-12 13:35:17

请问楼主运行在10k以上是什么意思? 用的多少细分来带步进电机?

ljhlxq 发表于 2010-9-12 14:08:43

运行10K,细分为4,步距脚1.8。这个是与步进电机和驱动器有关的。大概1000转每分钟;实际运行700转每分钟,带负载。

ljhlxq 发表于 2010-9-12 14:10:11

有兴趣关注www.hymcu.com.

foxaunt 发表于 2010-9-12 14:11:09

MARK

MCU678 发表于 2010-9-12 14:58:23

mark

cyxavr 发表于 2010-9-12 15:03:47

mark

slj0620 发表于 2010-9-12 15:13:42

定时器停中断有点太占用资源了

ljhlxq 发表于 2010-9-12 15:33:12

12楼的想法在我设计之初,也是这样认为。可以用DMA的方式,关键看你的系统怎么设计

slj0620 发表于 2010-9-12 15:50:16

我就用TIM和DMA设计的一片带两个电机口,实际可支持到100K以上(程序速度优化),只在加速到恒速,恒速到减速,加速到减速切换过程中断

ljhlxq 发表于 2010-9-12 16:04:00

14楼是高手,有幸认识。希望有很好的想法,并且实现了的话,可以拿出来共勉。

ljhlxq 发表于 2010-9-13 10:36:40

对于文本显示器+PLC的方案;工业触摸屏+PLC的方案;在工业上已经非常成熟了,呵呵,最近做个项目,替代那个PLC.
由于PLC的价格相对而言,肯定比较高,用STM32替代PLC,那么与文本显示器、工业触摸屏就有个通信协议的问题,大家不知道有没有相关经验,一般而言,与文本、触摸屏就是RS232或RS485通信,目前我就用STM32替代了台达(DVP)的PLC,关键是MODBUS-RTU协议的实现,呵呵,可能还有些问题,所以,大家有没好的点子、经验,来晒晒。
我这个主题发到了AVR32中去了,请大家在这也进行一下讨论???????????????????????

wjc1956 发表于 2010-9-13 12:10:55

mark

slj0620 发表于 2010-9-13 13:07:55

我就用TIM和DMA设计的一片带两个电机口,实际可支持到100K以上(程序速度优化)主要部分程序
void DMA_Configuration(void)
{

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);

DMA_DeInit(DMA1_Channel5);
DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)TIM1_PSC_Address;
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&MotorIncCurve ;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = 5;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel5, &DMA_InitStructure);
DMA_ITConfig(DMA1_Channel5,DMA_IT_TC,ENABLE);
DMA_ClearITPendingBit(DMA1_IT_TC5);
//DMA_Cmd(DMA1_Channel5, ENABLE);
}

//******************************************************************************
//TIM1_Init For MotorA
//******************************************************************************
void TIM1_Init_For_MotorA()
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);

TIM_TimeBaseStructure.TIM_Prescaler =0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period = 3;
TIM_TimeBaseStructure.TIM_ClockDivision =TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_RepetitionCounter =0;
TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);

TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = 2;//Polarity_High
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;

TIM_OC1Init(TIM1, &TIM_OCInitStructure);
TIM_DMACmd(TIM1, TIM_DMA_Update, ENABLE);
TIM_CtrlPWMOutputs(TIM1, ENABLE);
//TIM_Cmd(TIM1, ENABLE);

}
//******************************************************************************
//MOTORA_RUN
//******************************************************************************
void MotorA_Run(unsigned char MotorA_Dir,unsigned MotorA_Pulse)
{
MotorA_BUMPFlag=0;
GPIO_WriteBit(MotorA_EnPin,Bit_SET);
GPIO_WriteBit(MotorA_SONPin,Bit_RESET);
GPIO_WriteBit(MotorA_RSTPin,Bit_SET);

if(MotorA_Dir) GPIO_WriteBit(MotorA_DirPin,Bit_SET);
else GPIO_WriteBit(MotorA_DirPin,Bit_RESET);


if(MotorA_Pulse)
{
if(MotorA_Pulse==1)
   {
   IncSpeedStepNumberA=MotorA_Pulse+1;
   ConSpeedStepNumberA=0;
   NecSpeedStepNumberA=0;
   MotorA_CurveChangeStep=NecSpeed;
   }
else if(MotorA_Pulse<=(CurveStepNumber*2))
   {
   IncSpeedStepNumberA=MotorA_Pulse/2+MotorA_Pulse%2;
   ConSpeedStepNumberA=0;
   NecSpeedStepNumberA=MotorA_Pulse/2;
   MotorA_CurveChangeStep=IncSpeed;
   }
else if((MotorA_Pulse>(CurveStepNumber*2)))
   {
   IncSpeedStepNumberA=CurveStepNumber;
   ConSpeedStepNumberA=MotorA_Pulse-(CurveStepNumber*2);
   NecSpeedStepNumberA=CurveStepNumber;
   MotorA_CurveChangeStep=IncSpeed;
   }
   
if(ConSpeedStepNumberA)MotorA_ConSpeedFlag=1;
else MotorA_ConSpeedFlag=0;

DMA1_Channel5->CCR &= 0xFFFFFFFE;//DisableDMA1_Channel5
DMA1_Channel5->CNDTR=IncSpeedStepNumberA;//DMA_BufferSize
DMA1_Channel5->CMAR=(u32)&MotorIncCurve;//DMA_MemoryBaseAddr
DMA1_Channel5->CCR |=0x0080;//DMA_MemoryInc_Enable
DMA1_Channel5->CCR |=0x0001;//DMA启动

TIM1->PSC =MotorIncCurve;
TIM1->EGR =TIM_PSCReloadMode_Immediate;
//TIM1->RCR =0;
//TIM1->ARR =5;
TIM_DMACmd(TIM1, TIM_DMA_Update, ENABLE);
//TIM_CtrlPWMOutputs(TIM1, ENABLE);
TIM1->CR1 |=0x0001;//定时器启动

MotorA_RunFlag=1;
}
}

/*******************************************************************************
* Function Name: DMA1_Channel5_IRQHandler
* Description    : This function handles DMA1 Channel 5 interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/

void DMA1_Channel5_IRQHandler(void)
{

DMA1->IFCR = DMA1_IT_TC5;//清DMA中断标志
if(MotorA_CurveChangeStep==NecSpeed)
{
   TIM1->CR1 &= 0xfffe;//定时器停止
   MotorA_RunFlag=0;
}

if(MotorA_ConSpeedFlag)MotorA_CurveChangeStep++;
else MotorA_CurveChangeStep +=2;

if(MotorA_CurveChangeStep==ConSpeed)
{
DMA1_Channel5->CCR &= 0xFFFFFFFE;//Disable DMA1_Channel5
DMA1_Channel5->CNDTR=ConSpeedStepNumberA;//DMA_BufferSize
DMA1_Channel5->CMAR=(u32)&MotorIncCurve;//DMA_MemoryBaseAddr
DMA1_Channel5->CCR &=0xff7f;//DMA_MemoryInc_Disable
DMA1_Channel5->CCR |=0x0001;//DMA启动

//TIM1->PSC=MotorIncCurve;
//TIM1->CR1 |= 0x0001;//定时器启动
}
if(MotorA_CurveChangeStep==NecSpeed)
{
DMA1_Channel5->CCR &=0xFFFFFFFE;//Disable DMA1_Channel5
DMA1_Channel5->CNDTR=NecSpeedStepNumberA+1;//DMA_BufferSize
DMA1_Channel5->CMAR=(u32)&MotorNecCurve-NecSpeedStepNumberA];//DMA_MemoryBaseAddr
DMA1_Channel5->CCR |=0x0080;//DMA_MemoryInc_Enable
DMA1_Channel5->CCR |=0x0001;//DMA启动

//TIM1->PSC=MotorNecCurve;
//TIM1->CR1 |= 0x0001;//定时器启动
}
}


#pragma location=".Curve8"
//100K
const unsigned shortMotorCurve8 =
{
0xf6ea,0xe02c,0xc56b,0xad01,0x98bd,0x885d,0x1226,0x0ffc,0x0e77,0x0d51,0x0c6a,
0x0bac,0x0b0e,0x0a86,0x0a11,0x09aa,0x094e,0x08fc,0x08b2,0x086f,0x0832,0x07f9,
0x07c5,0x0795,0x0768,0x073e,0x0717,0x06f2,0x06d0,0x06af,0x0690,0x0673,0x0657,
0x063d,0x0624,0x060c,0x05f5,0x05df,0x05ca,0x05b6,0x05a2,0x0590,0x057e,0x056d,
0x055c,0x054c,0x053c,0x052d,0x051f,0x0511,0x0503,0x04f6,0x04ea,0x04dd,0x04d1,
0x04c6,0x04ba,0x04af,0x04a4,0x049a,0x0490,0x0486,0x047c,0x0473,0x046a,0x0461,
0x0458,0x044f,0x0447,0x043f,0x0437,0x042f,0x0427,0x0420,0x0418,0x0411,0x040a,
0x0403,0x03fd,0x03f6,0x03ef,0x03e9,0x03e3,0x03dd,0x03d7,0x03d1,0x03cb,0x03c5,
0x03bf,0x03ba,0x03b5,0x03af,0x03aa,0x03a5,0x03a0,0x039b,0x0396,0x0391,0x038c,
0x0388,0x0383,0x037e,0x037a,0x0376,0x0371,0x036d,0x0369,0x0365,0x0360,0x035c,
0x0358,0x0354,0x0351,0x034d,0x0349,0x0345,0x0342,0x033e,0x033a,0x0337,0x0333,
0x0330,0x032d,0x0329,0x0326,0x0323,0x031f,0x031c,0x0319,0x0316,0x0313,0x0310,
0x030d,0x030a,0x0307,0x0304,0x0301,0x02fe,0x02fb,0x02f9,0x02f6,0x02f3,0x02f0,
0x02ee,0x02eb,0x02e8,0x02e6,0x02e3,0x02e1,0x02de,0x02dc,0x02d9,0x02d7,0x02d5,
0x02d2,0x02d0,0x02cd,0x02cb,0x02c9,0x02c7,0x02c4,0x02c2,0x02c0,0x02be,0x02bc,
0x02b9,0x02b7,0x02b5,0x02b3,0x02b1,0x02af,0x02ad,0x02ab,0x02a9,0x02a7,0x02a5,
0x02a3,0x02a1,0x029f,0x029d,0x029b,0x029a,0x0298,0x0296,0x0294,0x0292,0x0290,
0x028f,0x028d,0x028b,0x0289,0x0288,0x0286,0x0284,0x0283,0x0281,0x027f,0x027e,
0x027c,0x027a,0x0279,0x0277,0x0276,0x0274,0x0273,0x0271,0x0270,0x026e,0x026c,
0x026b,0x0269,0x0268,0x0267,0x0265,0x0264,0x0262,0x0261,0x025f,0x025e,0x025d,
0x025b,0x025a,0x0258,0x0257,0x0256,0x0254,0x0253,0x0252,0x0250,0x024f,0x024e,
0x024d,0x024b,0x024a,0x0249,0x0247,0x0246,0x0245,0x0244,0x0243,0x0241,0x0240,
0x023f,0x023e,0x023d,0x023b,0x023a,0x0239,0x0238,0x0237,0x0236,0x0234,0x0233,
0x0232,0x0231,0x0230,0x022f,0x022e,0x022d,0x022c,0x022b,0x0229,0x0228,0x0227,
0x0226,0x0225,0x0224,0x0223,0x0222,0x0221,0x0220,0x021f,0x021e,0x021d,0x021c,
0x021b,0x021a,0x0219,0x0218,0x0217,0x0216,0x0215,0x0214,0x0213,0x0212,0x0211,
0x0211,0x0210,0x020f,0x020e,0x020d,0x020c,0x020b,0x020a,0x0209,0x0208,0x0207,
0x0207,0x0206,0x0205,0x0204,0x0203,0x0202,0x0201,0x0201,0x0200,0x01ff,0x01fe,
0x01fd,0x01fc,0x01fc,0x01fb,0x01fa,0x01f9,0x01f8,0x01f7,0x01f7,0x01f6,0x01f5,
0x01f4,0x01f4,0x01f3,0x01f2,0x01f1,0x01f0,0x01f0,0x01ef,0x01ee,0x01ed,0x01ed,
0x01ec,0x01eb,0x01ea,0x01ea,0x01e9,0x01e8,0x01e7,0x01e7,0x01e6,0x01e5,0x01e5,
0x01e4,0x01e3,0x01e3,0x01e3,0x01e3,0x01e3,0x01e3,0x01e3,0x01e3,0x01e3,0x01e3,
0x01e3,0x01e3,0x01e3,0x01e3,0x01e3,0x01e3,0x01e3,0x01e3,0x01e3,0x01e3,0x01e3,
0x01e3,0x01e3,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,
0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,
0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,
0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,
0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,
0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,
0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,
0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,
0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,
0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,
0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,0x01e2,
0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,
0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,
0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,
0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,
0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,
0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,
0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,
0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,
0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,
0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,
0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,
0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,
0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,
0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,0x01e1,
0x01e1,0x01e1,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,0x01e0,
0x01e0
};

ljhlxq 发表于 2010-9-13 13:21:27

MARK。
18楼的无私贡献

ljhlxq 发表于 2010-9-25 13:17:13

具体实现,上图和相关资料了。
http://cache.amobbs.com/bbs_upload782111/files_33/ourdev_585503B0ESX2.JPG
(原文件名:3.JPG)

http://cache.amobbs.com/bbs_upload782111/files_33/ourdev_585504HQ6RQS.JPG
(原文件名:4.JPG)

http://cache.amobbs.com/bbs_upload782111/files_33/ourdev_585505IHSGCY.JPG
(原文件名:1.JPG)

点击此处下载 ourdev_585506K4SS8H.zip(文件大小:312K) (原文件名:THB7128芯片说明书.zip)
点击此处下载 ourdev_585507VF53WO.zip(文件大小:24K) (原文件名:原理图.zip)

xiaomage_2000 发表于 2010-9-25 16:29:56

这个要顶~

ljhlxq 发表于 2010-10-18 14:12:28

对于STM32中实现圆弧插补算法?有没有好的意见和建议?

lgnq 发表于 2010-10-18 17:17:32

mark

zxc2769 发表于 2010-10-21 19:30:25

MARK

albert_lu 发表于 2010-10-23 05:58:04

MARK

tigerchen 发表于 2010-10-23 13:56:55

mark,多谢了

acmilann 发表于 2010-10-25 19:52:51

mark,研究不透,思考中……

yu_studio 发表于 2010-10-25 20:24:40

先记下,有时间好好看看

tongyf 发表于 2010-11-23 15:30:16

学习,帮顶

tkxlll 发表于 2010-11-24 17:55:31

学习拉。收藏。

28182900 发表于 2011-1-14 12:24:05

坐在马桶上常常被扔下的BoB!!!溅得满屁股花~~哪位高人掌握了压水花的技术近来传授小弟呀?

gpfrank 发表于 2011-1-14 12:44:19

mark 好的。

willbai 发表于 2011-1-16 15:19:00

学习了,赞!

tigerchen 发表于 2011-1-23 13:26:52

mark。很好啊

sailing8 发表于 2011-2-9 10:11:37

正在找这个资料,必须顶!

lzy_0323 发表于 2011-2-9 11:15:45

mark!

aaroncy79 发表于 2011-2-10 09:18:31

mark

sufeila 发表于 2011-2-10 09:21:38

MARK 步进电机

fjb0522 发表于 2011-2-22 19:23:51

做个标记,有项目可用

tangwei039 发表于 2011-2-22 23:27:31

确实值得参考

gzfslt 发表于 2011-2-23 11:54:37

mark

huzcmail 发表于 2011-2-24 09:57:52

mark

gpfrank 发表于 2011-2-24 17:13:40

mark 研究中

cong2010 发表于 2011-2-28 13:58:11

步进电机,不错,准备要用,可以借鉴

gallle 发表于 2011-2-28 15:01:37

回复【31楼】28182900
坐在马桶上常常被扔下的bob!!!溅得满屁股花~~哪位高人掌握了压水花的技术近来传授小弟呀?
-----------------------------------------------------------------------

哈哈,每天半斤 巴豆

zj_t 发表于 2011-3-1 21:58:35

定时器加减速,MARK

li0713 发表于 2011-3-1 22:24:33

好东西!!学习一下

kevinvan 发表于 2011-3-11 14:25:59

mark

zywh 发表于 2011-3-19 22:21:34

好东西。。。。

newhz 发表于 2011-5-18 13:16:14

刚买了楼主的板子,这个的顶。

wenfeiexe 发表于 2011-5-18 17:59:15

mark

luzj05 发表于 2011-5-18 18:29:18

呵呵
不错~

shanyan 发表于 2011-5-18 18:34:09

我的STM32+文本显示器+控制2个步进电机:http://cache.amobbs.com/bbs_upload782111/files_39/ourdev_640753E55XB4.jpg
(原文件名:ourdev_640061FSR6MU.jpg)

shanyan 发表于 2011-5-18 18:35:17

带加减速,恒速回零!

win100 发表于 2011-7-10 21:08:10

标记,步进电机

beipan1982 发表于 2011-7-11 22:34:26

好东西啊

hpyanghua 发表于 2011-7-12 10:13:49

MARK。。。。

wellrun 发表于 2011-7-17 00:40:22

dma的方案值得参考,不过要动态实现s形曲线估计不容易

yanghai-M 发表于 2011-7-17 10:01:47

我使用TMC429来实现加,减速控制,效果很不错点击此处下载 ourdev_658546DDMAM9.pdf(文件大小:2.76M) (原文件名:3轴控制芯片SD,SPI 输出 .pdf)

kevin_ares 发表于 2011-7-17 10:57:34

mark,

每次脉冲一个中断,

两个电机,高速的时候啥都不用干了

wind2100 发表于 2011-7-17 17:11:49

有不用定时器中断 做步进电机的吗?

john78 发表于 2011-7-17 21:46:17

回复【59楼】yanghai-M
我使用tmc429来实现加,减速控制,效果很不错点击此处下载(原文件名:3轴控制芯片sd,spi 输出 .pdf)

-----------------------------------------------------------------------
tmc429-什么价格?

wxws 发表于 2011-8-1 08:01:35

同问

Joyliz 发表于 2011-8-1 08:50:46

先记着,有时间慢慢研究!

along0425 发表于 2011-8-1 13:51:07

正在调试,参考了,谢谢

Feco 发表于 2011-8-1 14:06:55

mark

jiang47 发表于 2011-8-9 11:10:56

要用STM32控制6个42型的步进电机,过来学习学习。

xuanxs 发表于 2011-8-28 13:27:32

程序,看的不是很明白

hong_hong789 发表于 2011-8-29 12:00:31

mark

251131250 发表于 2011-9-14 20:11:10

mark,学习了马上要做的东西

kumosheng 发表于 2011-9-19 14:36:52

这个不标记上,对不起自己,好东西。

lihe 发表于 2011-10-10 15:35:42

mark

wwqq 发表于 2011-10-17 12:46:06

mark

aibama 发表于 2011-10-18 22:06:06

学习

lihe 发表于 2011-10-20 13:42:36

回复【18楼】slj0620
-----------------------------------------------------------------------
你好,我想用dma去对定时器分频。结果DMA没有反应。大家帮忙看看呀。
#define TIM1_PSC_ADDRESS   0x40010028

uint16_t SRC_Buffer = {2};
int main(void)
{
SystemInit();
TIM_Config();

RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);
/* Time Base configuration */
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period = TimerPeriod;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;

TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);

/* Channel 3 Configuration in PWM mode */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = 3414;
TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_High;
TIM_OC3Init(TIM1, &TIM_OCInitStructure);
TIM_Cmd(TIM1, ENABLE);
/* DMA enable*/
DMA_Cmd(DMA2_Stream6, ENABLE);
/* TIM1 Update DMA Request enable */
TIM_DMACmd(TIM1, TIM_DMA_Update, ENABLE);
/* Main Output Enable */
TIM_CtrlPWMOutputs(TIM1, ENABLE);
while (1)
{ }
}
void TIM_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
DMA_InitTypeDef DMA_InitStructure;

/* GPIOA and GPIOB clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB, ENABLE);

/* GPIOA Configuration: Channel 3 as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_8 ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_TIM1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_TIM1);

/* GPIOB Configuration: Channel 3N as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource15, GPIO_AF_TIM1);

/* DMA clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2 , ENABLE);

DMA_DeInit(DMA2_Stream6);
DMA_InitStructure.DMA_Channel = DMA_Channel_6;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(TIM1_PSC_ADDRESS) ;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)SRC_Buffer;
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
DMA_InitStructure.DMA_BufferSize = 1;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_PeripheralDataSize_HalfWord;

DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;

DMA_Init(DMA2_Stream6, &DMA_InitStructure);
}

gylsxcn 发表于 2011-10-20 21:24:24

正在搞不进电机

maxsuntech 发表于 2011-11-24 08:24:12

mark

gpfrank 发表于 2011-11-24 09:59:13

mark

yangpeng 发表于 2011-11-25 00:48:47

关注!!!!

52171314 发表于 2011-11-25 01:00:19

LZ想得过于麻烦了

ddrfft 发表于 2011-11-25 08:21:52

到网上搜索下 激光雕刻机 光驱;你会的到文章 里面使用avr 8位 实现运动控制功能 并能进行G代码解析 参考下那个代码吧 灰常不错我想应该可以转到stm上的 8位 实现了 直线运动 梯形加减速 直线插补 圆弧插补。。。。。16M晶振步进频率可以到30k。 内部使用 命令缓冲序列形式缓存20个命令序列;如果做舞台灯用只用把运动序列改为死的 或者放到eep中进行合理加载 进行类似循环播放的形式 应该灰常不错,估计控制舞台灯轻松。
点击此处下载 ourdev_698790ER2TJG.zip(文件大小:45K) (原文件名:simen-grbl-74576a8.zip)

ministar 发表于 2011-12-29 22:44:01

学习,顶一下!

tianfe2010 发表于 2012-2-15 19:03:55

回复【83楼】ministar
-----------------------------------------------------------------------

学习

schlang 发表于 2012-6-4 17:30:58

mark一下,学习ing

bbandpp 发表于 2012-6-14 22:38:28

学习下,电机的

cdlxzlp 发表于 2012-10-23 22:37:30

看 到了 就顶一个

zooky 发表于 2012-10-24 09:11:02

步进控制,收藏

hisun 发表于 2012-12-9 13:12:24

slj0620 发表于 2010-9-13 13:07 static/image/common/back.gif
我就用TIM和DMA设计的一片带两个电机口,实际可支持到100K以上(程序速度优化)主要部分程序
void DMA_Conf ...

请问19楼中的const unsigned shortMotorCurve8这个大数据表格是怎么计算出来的?知道的科谱一下计算方法啊。

lcmdw 发表于 2012-12-17 22:03:23

mark{:smile:}

geiter001 发表于 2013-2-28 18:13:42

hisun 发表于 2012-12-9 13:12 static/image/common/back.gif
请问19楼中的const unsigned shortMotorCurve8这个大数据表格是怎么计算出来的?知道的科谱一下 ...

这样的问题有得到解答吗?我也有这样的问题啊!知道的可以说说。

99252598 发表于 2013-4-27 14:05:44

必须顶起 但是没看明白

dayaue 发表于 2013-4-28 14:44:25

mark , 我要控制5个电机

jiang316300541 发表于 2013-8-18 22:38:53

mark      

yuexiangquan 发表于 2013-9-11 09:26:29

正在研究步进电机加速。不是很明白,学习学习

魏东江 发表于 2013-9-18 15:53:50

MARK                                                

szmini2006 发表于 2013-9-18 17:17:08

做过这个东西,深知其做好不容易

wugq_sh 发表于 2013-9-18 21:56:49


MARK 步进电机

ZHAOBO10375 发表于 2013-9-26 21:12:33

不能在中间过程计数吧

gaoxiaohu110 发表于 2016-3-29 22:32:47

这个大赞!不知道能不能实现100K+的频率!
页: [1] 2
查看完整版本: 用定时器实现步进电机控制方案。