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.

I NEED CODE TO ACCELERATE AND DECCELERATE STEPPER MOTOR USING TIMERS IN MSP430F133.



Hi I m working on MSP430F133 I WANT ACCELERATION AND DECCELERATION FOR STEPPER MOTOR USING TIMERS. I HAVE A CODE TO ROTATE STEPPER MOTOR IN CONSTANT SPEED I M USING STEPPER SERVO MOTOR AND STEPPER CONTROLLER. HERE IS THE CODE.

PLZ TELL ME WAT TO CHANGE IN THE STEPPER MOTOR TO ACCELERATE AND DECCELERATE. PLZ REPLY SOON

#include <msp430f133.h>

unsigned int count=5;

#ifndef __DisableCalData

               

#define CALDCO_8MHZ_         (0x10FEu) /* DCOCTL Calibration Data for 1MHz */

READ_ONLY DEFC( CALDCO_8MHZ     , CALDCO_8MHZ_)

#define CALBC1_8MHZ_         (0x10FFu) /* BCSCTL1 Calibration Data for 1MHz */

READ_ONLY DEFC( CALBC1_8MHZ     , CALBC1_8MHZ_)

 

#endif /* #ifndef __DisableCalData */

 

 

void main(void)

{

 

WDTCTL = WDTPW + WDTHOLD;       // Stop watchdog timer

       BCSCTL1 = CALBC1_8MHZ;     // Set range

         DCOCTL = CALDCO_8MHZ;     // Set DCO step and modulation

 

      

 

P1DIR |= BIT0;                   // Set P1.0 to output direction

P1OUT &= ~BIT0;                 // Set the red LED off

 

P5DIR |= BIT4;                   // Set P1.6 to output direction

P5OUT &= ~BIT4;                 // Set the green LED off

TA0CCR0 = 30;                 // Count limit (16 bit)

TA0CCTL0 = 0x10;                 // Enable Timer A0 interrupts, bit 4=1

TA0CTL = TASSEL_2 + MC_1;

     // LPM0 (low power mode) interrupts enabled}     // Timer A0 with ACLK, count UP

 

TBCCR0 = 250;                 // Count limit (16 bit)

TBCCTL0 = 0x10;                 // Enable Timer A1 interrupts, bit 4=1

TBCTL = TBSSEL_2+ MC_1;       // Timer A1 with ACLK, count UP

 

     _BIS_SR(LPM0_bits + GIE);

 

}

 

#pragma vector=TIMERB0_VECTOR

__interrupt void TimerB3CCR0InterruptServiceRoutine() {

 

   P1OUT ^= BIT0;                 // Toggle red LED

}

 

#pragma vector=TIMERA0_VECTOR   // Timer0 A0 interrupt service routine

 

__interrupt void Timer0_A0 (void) {

  

     P5OUT ^= BIT4;

    

                     // Toggle green LED

}

  • WHAT TO CHANGE IN THE ABOVE CODE TO ACCELERATE AND DECCELERATE STEPPER MOTOR
  • naveen moodi said:
    PLZ TELL ME WAT TO CHANGE IN THE STEPPER MOTOR TO ACCELERATE AND DECCELERATE. PLZ REPLY SOON

    Hi, this phrase and understanding of how this forum work is fundamental.. So change to courtesy form and PLEASE GRASP in deep we are not here to serve none.

     Your homework is your problem not our.

  • Please don't shout. Text in all uppercase hurts the eyes :)
    You should understand your code. Then you know what to do.
    Your code uses two timers to toggle the two stepper motor lines. To change stepping frequency, you need to change the timer speed.
    Reading the users guide chapters about timers will tell you what you need to know. It's quite simple.

    However, using interrupts to manually toggle the I/O pins, and using two timers for a rather synchronized job, is unnecessarily complex. You can use the PWM output for controlling the output signals in hardware. And one timer has more than one CCR unit and can therefore control more than one PWM output, especially if the frequency of the two is the same and only the trigger point changes.
  • Jens-Michael Gross said:
    Please don't shout. Text in all uppercase hurts the eyes :)

     And don't use imperative form to forum members too ;)

     JMG, I feel the learning area about forum usage, we can learn what changed than try at our expense and leave new subscriber in that area to just avoid these refinement struggling never is useful to none.

     Ok this is forbidden and forum are lowering level day by day...

**Attention** This is a public forum