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.

PWM for a line following Robot?

Other Parts Discussed in Thread: MSP430G2452

Hey,

I am working on a line following robot based on Launch Pad?

I'm using MSP430G2452 IC.

Since robot needs differential driving techniques to be on the line ,I need two PWM signals (same frequency,but two duty cycles) to drive motors.

I need ur help to knw how to do that?

thankz

  • Have a look in the code examples at msp430g2xx2_ta_17.* (or ...ta_16.* if not using external crystal).  This will show you how to run a PWM output.  Then all you need to do is extend the code to add in the second channel (use CCR2).

  • Usually, you use CCR0 for settign the PWM frequency and CCRx for the PWM output. The LaunchPad processor only has 2 CCR units, so this approach won't give you 2 PWM outputs.

    There's an alternative approach: you need to configure the tiemr so it will overflow a full cycle (65536 counts) with the selected PWM frequency. This requires a very high timer clock. E.g. if you clock the timer with 16MHz (MCLK does not need to be as high, to preserve power), your PWM frequency would be only 244 Hz.
    With this setup, however, you can use both, CCR0 and CCR1, to form two independent PWM signals with a duty-cycle resolution of 1/65536.

    With the LaunchPad, you don't have other options in hardware. You can do the PWM in software, but that's rather inaccurate and instable.

    It's possible that one of the upcoming processors for the LaunchPad will have more CCR units or timers (the 'standard' MSPs have up to three timers with up to 7 CCR units), but I don't have any specs and cannot promise anything.

**Attention** This is a public forum