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.

Need Code Example for Controlling the MSP430G25530 with a BLDC motor

Other Parts Discussed in Thread: MSP430G2553, MSP430F5529, MSP-FET

I'm working on interfacing the MSP430G2553 Development Kit to a BLDC Motor. I have a problem on the programming part. Can someone send me programming code for controlling the BLDC Motor with the MSP430G2553?

Also if you could provide steps to create a header file in Code Composer Studio 5.3.

  • Hi,

    usually, when asking a question on a forum, you don't ask for people to do your work for you.  I suspect that most people are going to ignore your post and you won't get a response.  I suggest you change your post like this:

    1) Please don't use all capitals.  It is hard to read and looks like you're yelling.

    2) If you have a problem, tell us where it is and what it is and what you've already done.  For instance, if it's a problem in one function in your code, you could say "This function should do X, but it does Y.  I've already tried Z but it still failed to give the correct output.".  Don't just say you have a problem, that's not effective.

    3) Often people don't just have code solutions ready to go for a particular problem.  You will have to spend time trying to figure out how your BLDC motor works and what commands are needed to be sent.  

    Mike

  • @Sandesh - I would recommend updating your post to not be all caps. Very tough to read otherwise. Next if you could summarize your question for the thread title and as well change it from being all caps.

  • Thans for advasing me( actually i am new here and new to msp430) ,, can u please tell me how to create and insert header file in ccs5.3 

  • sandesh warwadekar said:
    i am new here and new to msp430

    And also new to C, which is no problem here, but this forum is not for learning the C languish, it’s special for discussing and solving technical problems related to the MSP430 MCU’s.

    Header files are related to the C languish and not specific CCS, if you would Google for ‘C books’ how can explain you all this, you will find a lot.

    Also you could try to explain what you expect the header file will do for you or your program, then maybe someone can help you here.

  • can i use the msp430g2553 value line kit for controlling BLDC motor. my projects needs 6 pwm for drive circiut (mosfet ckt)  and 3 feedback signal comming from hall sensor to microcontroller ,,and also one ADC input to microcontroller...plz tell whether i use msp430g2553  or if not then which msp430XXXX  series microcontroller i use. 

  • sandesh warwadekar said:
    can i use the msp430g2553 value line kit for controlling BLDC motor

    I would not suggest. It does not have timer with enough PWM channels. Check motor control brochure where C2000 and Tiva C microcontrollers advised

  • First you need to know what motor size you need 10, 100 or maybe even 200 Amp, then select the proper driver for it and when then having the proper parameters to control these you can calculate your MCU need and how it has to operate.

    You can start to exercise with: http://www.ti.com/tool/DRV8839EVM?keyMatch=DRV8839EVM&tisearch=Search-EN

  • i want to control bldc motor with  msp430g2553 value line kit ..

    **Motor specifications are:

    (1)24v DC,30W,3000RPM,BLDC Motor with three integrated hall sensor

    **Drive circuit have N-channel MOSFETS (IC HIRF840)  ratings are as follows

    (2)Vdss=500v,,I d=8A,,I dm=32A,,Vgs=20v

    A code written in code composer studio v5.3   for generation of 8-channel pwm from msp430g2553 value line kit

    //
    // 8-channel PWM example for MSP430G2553
    //
    // Written by Ted Burke - last updated 4-4-2014
    //
     
    #include <msp430.h>
     
    // PWM channels duty cycle array
    int pw[] = {1000,1000,1000,1000,1000,1000,1000,1000};
     
    int main( void )
    {
        WDTCTL = WDTPW + WDTHOLD; // Disable watchdog timer
     
        P1DIR = 0b00111111; // Make P1.0-5 outputs
     
        // Configure Timer A0 Compare interrupts
        TA0CTL = TASSEL_2 + MC_1 + ID_0; // "up" mode, input divider = 1
        TA0CCR0 = 2500;                  // set timer period to 2.5ms
        TA0CCTL0 = CCIE;                 // enable CC0 interrupt
        TA0CCR1 = 1500;                  // set pulse width to 1.5ms
        TA0CCTL1 = CCIE;                 // enable CC1 interrupt
        _BIS_SR(GIE);                    // global interrupt enable
     
        // From this point on, we only need to write values
        // into the pw[] array to set the duty cycle on all
        // eight PWM channels (P1.0-7), or to be precise,
        // whichever channels are actually enabled as digital
        // outputs (six in this case).
     
        //
        // A quick example to test: Do a different number of
        // angle steps on each of the six PWM outputs. 1 step
        // on channel 0, 2 steps on channel 1, 3 steps on
        // channel 2, and so on.
        //
        int channel, counter = 0;
        while(1)
        {
            counter++;
            for (channel=0 ; channel<6 ; ++channel)
            {
                pw[channel] = 1000 + (counter%(channel+1))*100;
            }
            __delay_cycles(500000);
        }
     
        return 0;
    }
     
    //
    // Timer A0 CC0 interrupt service routine.
    // This ISR is triggered when Timer A0 reaches
    // its maximum value TA0CCR0 and resets to zero.
    // This ISR starts a pulse on one PWM channel
    // every 2.5ms. It cycles through all eight channels
    // in turn. After starting the pulse, it sets
    // the TA0CCR1 register to the pulse width of
    // the current pin so that the pulse will be
    // ended by the partner ISR after the appropriate
    // time delay (for this channel's duty cycle).
    //
    #pragma vector=TIMER0_A0_VECTOR
    __interrupt void Timer_A0_CC0(void)
    {
        static n=0;         // PWM channel index
     
        P1OUT = 1 << n;     // Set P1.n high
        TA0CCR1 = pw[n];    // Set timer for current pin's pulse width
     
        n = (n+1)%8;        // Move on to next PWM channel
        TA0CCTL0 &= ~CCIFG; // Reset CC interrupt flag
    }
     
    //
    // Timer A0 CC1 interrupt service routine.
    // This ISR is responsible for ending each PWM
    // pulse on all channels. It is triggered when
    // Timer A0 matches TA0CCR1, which is at a
    // different time for each PWM channel.
    //
    #pragma vector=TIMER0_A1_VECTOR
    __interrupt void Timer_A1_CC1(void)
    {
        P1OUT = 0;
        TA0CCTL1 &= ~CCIFG;
    }
    can this is work properly.. bcz msp430g2553  have 2 pwm channels...I have  not get precise pwm for motor,,,,plz tell me any further modification i need to do with this code ,,, or i have to shift on other microcontroller...
    some says c2000 can be used but can it programed  in c language or it have any devolpment kit....  plz tell whether i go for this or shift to other ti development kit
  • sandesh warwadekar said:
    can this is work properly..

    Perhaps. Actually it depends on your expectations - what do you define as "work properly". For example there are plenty of atmega88 (which does not have enough PWM channels either) -based made in china "ESC brushless speed controllers" which happens to work, but when you ask any serious quadcopter builder he will tell you to select another controller which is built on (undisclosed here;) uC having at least three hardware PWM channels of timer with emergency stop input

  • how many pwm channel i can crete ffrom msp430g2553..can msp430g2553  TA and TB both can create  4 pwm signals. please tell me on what parameters pwm outputs are define(like CCR0 OR CCR1)..can i CCR1,2,3  WITH CCR0 of timerA,,and CCR1,2,3  WITH CCR1 of timerB  in msp430g2553.  please clear my dout on how actually pwm generated in msp430g2553 launchpad kit

  • sandesh warwadekar said:
    TA and TB both can create  4 pwm signals.

    You can't control single motor using PWM generated from two timers unless they are synchronized. There are no timer synchronization on msp430g2553

  • i have  the BLDC motor control  source code for " MSP430F5529"   which have written by

    """* Bhargavi Nisarga
    * Texas Instruments Inc.
    * Dec 2010
    * Built with IAR Version:4.2 and CCS v4.2"""

    ,,,,PROBLEM is how to debug(compile)this code on to the msp430f5529 IC.. without the msp430g5529 LaunchPad   ..please tell me .. can msp430f5529  come without lauchpad kit??

    how i can debug source code in msp430f5529  without the launch pad kit,,,, please tell any another alternative available for this///

    NOW I have msp430g2553  launchpad(development kit)  with me,,, can i do something with that launchpad  so that i can compile msp430f5529 source code.

  • sandesh warwadekar said:
    how i can debug source code in msp430f5529  without the launch pad kit,,,, please tell any another alternative available for this///

    Board with msp430f5529 + MSP-FET. Why f5529 LaynchPad is not good enough for you you?

    sandesh warwadekar said:
    NOW I have msp430g2553  launchpad(development kit)  with me,,, can i do something with that launchpad  so that i can compile msp430f5529 source code.

    Yes, you can compile source code. Thou this is all what you can do with it.

  • Ilmars, you can synchronize timers. This can be done by either software (depending on MCLK vs. timer clock speed, this can be very tricky) or by hardware (clock them through TAxCLK connected to ACLK out, set them up, then activate the ACLK output. The timers will run synchronized until you mess with TAxCCR0 or TAxCFG.

     However, I too suggest using an MSP with timers that fit better. Some MSPs have a TimerA with 5 CCR registers (so 4 synchronized PWM outputs) or a TimerB with 7 CCRs and the possibility to even synchronize the change of the PWM outputs.

    I don’t recommend debugging realtime applications with a debugger. While you hit a breakpoint bad things may happen to your realtime-dependent hardware, as the CPU is stopped.

  • Ilmars said:
    There are no timer synchronization on msp430g2553

    You can synchronize timers. This can be done by either software (depending on MCLK vs. timer clock speed, this can be very tricky) or by hardware (clock them through TAxCLK connected to ACLK out, set them up, then activate the ACLK output. The timers will run synchronized until you mess with TAxCCR0 or TAxCFG.

     However, I too suggest using an MSP with timers that fit better. Some MSPs have a TimerA with 5 CCR registers (so 4 synchronized PWM outputs) or a TimerB with 7 CCRs and the possibility to even synchronize the change of the PWM outputs.

    I don’t recommend debugging realtime applications with a debugger. While you hit a breakpoint bad things may happen to your realtime-dependent hardware, as the CPU is stopped.

**Attention** This is a public forum