This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] MSP430F417:使用 PWM 信号控制步进电机

Guru**** 2384020 points
Other Parts Discussed in Thread: MSP430F417
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/991235/msp430f417-controlling-the-step-motor-with-pwm-signals

器件型号:MSP430F417

大家好。

我尝试使用 MSP430F417卡驱动步进电机。 我现在要做的是让步进电机在短路后完全停止。  在谷歌搜索后使用 PWM 信号感觉是正确的选择。

但我仍然不知道如何实现它。 有人能给我一个想法吗?

以下是我的代码:

#include "io430.h"
#include "in430.h"

void begin_counting( unsigned target_count)
{
TA1CTL &= ~BIT4;
TA1R = 0;
TA1CCR0 = target_count;
TA1CCTL0 &= ~CCIFG;
TA1CTL |= BIT4;

}

void main()
{
  WDTCTL =  WDTPW + WDTHOLD;    // Stop the Watchdog
  
  void Delay(int j);
        
  P6SEL  &= ~BIT4;            
  P6DIR  |=  0xFF; 
  P6OUT  &= ~0XFF; 
 
  CCR0 = 128;                               // PWM Periyot/2
  CCTL1 = OUTMOD_7;                         // CCR1 reset/set
  CCR1 = 32;                                // CCR1 PWM duty cycle
  TACTL = TASSEL_2 + MC_3;                  // SMCLK, up-down mode
 
  begin_counting( 20 );
  
  P6OUT |= BIT4; 
  Delay(50);   
  
  while(1){
    
    if((P6IN & BIT5)==0){
   P6OUT &=~BIT4;
   Delay(30);
    }
  }
}

void Delay(int j)
{
  int i;
  for(j=0;j<100;j++)
      for(i=0;i<0xFFFF;i++);
}

谢谢你。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    您可以在此处的 TI Resource Explorer 中找到 PWM 代码示例

    此致、

    James