2074 views|0 replies

2015

Posts

0

Resources
The OP
 

The principle of motor PWM speed regulation based on MSP430 microcontroller [Copy link]

/*
Program description: Use timer TA to generate a fixed-cycle square wave, and control the high-level time of the square wave to control
the average output power. This control method is called PWM modulation.
The timer TA of the MSP430 microcontroller can output two PWM modulation waveforms without CPU intervention
. Use one of them (TA1) to drive the motor through a transistor. Just
write the CCR1 register to change the duty cycle at any time, thereby changing the motor power. This control
method has low power loss (the control element does not consume power when it is turned on/off) and is highly efficient.

*/
//
//
// MSP430FE425
// -----------------
// | XIN|-
// | | 32kHz
// | XOUT|-
// | |
// | P1.2/TA1|----->Transistor drive--->small motor
// | (CCR1) | _ _ _ _
// | | _| |__| |__| |__| |_
// | | 40%~100% PWM
//

#include <MSP430X42X.h>

void Sys_Init()
{
WDTCTL=WDTPW+WDTHOLD; //Disable watchdog
FLL_CTL0|=XCAP18PF; //Configure crystal load capacitance
P1DIR |= BIT2; // P1.2 output
P1SEL |= BIT2; // P1.2 TA1 otions
TACTL = TASSEL_1 + MC_1; // ACLK, up mode
CCR0 = 500; // PWM Period
CCTL1 = OUTMOD_7; // CCR1 reset/set
CCR1 = 200; // CCR1 PWM duty cycle

}

void main( void )
{ int i;
char SpeedMode=0;
Sys_Init();
while(1)
{
for(i=0;i<4000;i++); //Delay

if(SpeedMode==0) //In acceleration mode
{
CCR1++; //Duty cycle keeps increasingif
(CCR1>=500) SpeedMode=1; //After reaching 100%, it switches to deceleration mode
}
if(SpeedMode==1) //In deceleration mode
{
CCR1--; //Duty cycle keeps decreasingif
(CCR1<=200) SpeedMode=0; //After reaching 40%, it switches to acceleration mode
}
}
}

This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list