Jump to content
43oh

mfpek

Members
  • Content Count

    18
  • Joined

  • Last visited

Reputation Activity

  1. Like
    mfpek reacted to RobG in LaunchPad, DC Motor, PWM   
    You have to keep 0.1uF as close as possible to Vcc pin. Something like this
    with peripherals.bmp
     
  2. Like
    mfpek reacted to RobG in LaunchPad, DC Motor, PWM   
    Which processor do you have?
  3. Like
    mfpek reacted to RobG in LaunchPad, DC Motor, PWM   
    Have you figured this out yet?
    You monitor switches 2 different ways in your code, while loop and ISR. Pick one, it will make things a lot easier.
    Disconnect ENB and SENSB, those belong to the second bridge.
    Connect ENA to P2.3 (where ENB was connected before.)
    Configure P2.3 as timer output TA0.1 (P2SEL.) I am using TA0.1 in my code, but on pin P1.2
     
    BTW, which processor are you using? F2132?
  4. Like
    mfpek reacted to RobG in LaunchPad, DC Motor, PWM   
    Input pins are used to control direction. Enable pin is used to control the speed by turning both drivers (in1 & in2 ) on and off.
    You should see PWM signal on P2.3, to verify, connect LED (with resistor) to P2.3 and GND and you should see it dim.
  5. Like
    mfpek reacted to RobG in LaunchPad, DC Motor, PWM   
    Ah, that makes big difference, your schematic says F2132.
     
    Connect EN_A to P2.6 instead of P2.3 (BTW, there was a mistake in my previous post, it was ENA instead on EN_A.)
    Also, added little delay to the loop. Otherwise you would not be able to adjust speed, it would just go up to 100% and down to 0% with a single press.
    #include "msp430g2553" // I don't have io430.h, so I will use standard defines #define Button_forward BIT0 //P1IN_bit.P0 #define Button_reverse BIT1 //P1IN_bit.P1 #define Button_stop BIT2 //P1IN_bit.P2 #define Button_fast BIT3 //P1IN_bit.P3 #define Button_slow BIT4 //P1IN_bit.P4 #define IN_1 BIT0 //P2OUT_bit.P0 #define IN_2 BIT1 //P2OUT_bit.P1 #define EN_A BIT6 //P2OUT_bit.P2 void main(void) { WDTCTL = WDTPW + WDTHOLD; DCOCTL = CALDCO_1MHZ; BCSCTL1 = CALBC1_1MHZ; // we need to use P2.6 which by default are xtal pins, clear SELs P2SEL = 0; P2SEL2 = 0; //configure timer CCR0 = 99; // we use smaller number so that you don't have to press fast/slow 1000 times CCTL1 = OUTMOD_3; CCR1 = 50; TACTL = TASSEL_2 + MC_1; // configure outputs P2OUT = 0x00; P2DIR |= IN_1 + IN_2; //configure timer's output P2DIR |= EN_A; P2SEL |= EN_A; // configure inputs (all pins are inputs by default, so this is not really necessary) // I am assuming fast & slow switches are connected to P1.3 & P1.4 same way as the other 3 are, with resistors. P1DIR &= ~(Button_forward + Button_reverse + Button_stop + Button_fast + Button_slow); while (1) { _delay_cycles(200000); if (P1IN & Button_forward) { // again, no io430.h, so I will use standard way P2OUT |= IN_1; P2OUT &= ~IN_2; } else if (P1IN & Button_reverse) { P2OUT &= ~IN_1; P2OUT |= IN_2; } else if (P1IN & Button_stop) { P2OUT &= ~IN_1; P2OUT &= ~IN_2; } else if (P1IN & Button_fast) { if (CCR1 < CCR0) { CCR1++; } } else if (P1IN & Button_slow) { if (CCR1 > 0) { CCR1--; } } } }
  6. Like
    mfpek reacted to RobG in LaunchPad, DC Motor, PWM   
    I don't have F2132 or io430.h so I cannot test your code, but try the code below.
    All switches are connected the same way, ENA is connected to P2.3 instead of P2.2
    Code removed, see later posts
  7. Like
    mfpek reacted to kenemon in LaunchPad, DC Motor, PWM   
    TP3 ground TP1 5V
  8. Like
    mfpek reacted to enl in LaunchPad, DC Motor, PWM   
    @mfpek: Could you please give a bit more detail? What do ou mean 'control it with buttons'? With a microcontroller? If so, MSP430 or a different one?  No microcontroller? I don't think anyone can really provide an answer without more information.
     
    Is this for a school assignment? (if so, it is good practice tosay so and to tell us what school/course/level) Also, is English not your primary language? Again, that is something worth mentioning before you get the 'sounds like homework, ask your teacher' response.
  9. Like
    mfpek reacted to enl in LaunchPad, DC Motor, PWM   
    Any pin you want to use that is not already in use will work  if you don't use interrupts. If you do use interrupts, then the pin must support that, which should include the unused P1 pins.
     
    If you don't need the start-stop function, you could re purpose the existing buttons for increase forward/decrease reverse and increase reverse/decrease forward. If you need to keep the existing function, add two more. In and case, with the run forward and run reverse as it is, I would put in code to protect from changing direction while the motor is running, including a delay to insure that the motor is stopped before restart.
×
×
  • Create New...