RobG 1,892 Posted April 5, 2011 Share Posted April 5, 2011 Here's my little demo of how to use SN754410 with LaunchPad. Timer's CCR1 is used to control duty cycle via P1.2 P1.0 and P1.1 to control direction (setting both to the same level, 0 or 1, will cause dynamic breaking.) Vcc1 of SN754410 is connected to LP's Vcc, Vcc2 is connected to a separate power supply (6V in my case.) Between outputs and Vcc/Vss I put some Schottky's just in case. EDIT: SN754410 logic side (Vcc1) requires 5V, it may not work correctly when powered from LP's Vcc. Next week I will add more examples with bigger motor and some MOSFETs. #include // DEMO counter unsigned int demoCounter = 0; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P1OUT |= BIT1; // Direction control - left P1OUT &= ~BIT0; // Direction control - right // Both 0 or 1 - dynamic break P1DIR |= BIT0 + BIT1 + BIT2; // Bit 2 is connected to enable and will be used for PWM P1SEL |= BIT2; // P1.2 TA1 option select CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 1000; // ~8ms CCTL1 = OUTMOD_3; // CCR1 set/reset CCR1 = 950; // CCR1 duty cycle, slow in the beginning TACTL = TASSEL_2 + MC_1 + ID_3; // SMCLK/8, upmode _bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt } // Timer A0 interrupt service routine #pragma vector = TIMERA0_VECTOR __interrupt void Timer_A (void) { // DEMO movement demoCounter++; if(demoCounter == 800) CCR1 = 900; if(demoCounter == 1600) CCR1 = 500; if(demoCounter == 2000) CCR1 = 250; if(demoCounter == 2400) CCR1 = 0; if(demoCounter == 2800) CCR1 = 900; if(demoCounter == 3200) { P1OUT |= BIT0; // switch direction P1OUT &= ~BIT1; } if(demoCounter == 3600) CCR1 = 0; if(demoCounter == 4000) CCR1 = 900; if(demoCounter == 4400) { P1OUT |= BIT1; // switch direction P1OUT &= ~BIT0; } if(demoCounter == 4800) { P1OUT |= BIT0; // switch direction P1OUT &= ~BIT1; } if(demoCounter == 5200) { CCR1 = 500; P1OUT |= BIT1; // switch direction P1OUT &= ~BIT0; demoCounter = 0; } // END DEMO movement } blar, zeke, Jake and 4 others 7 Quote Link to post Share on other sites
bluehash 1,581 Posted April 5, 2011 Share Posted April 5, 2011 Good job on using PWM instead of keeping P1.2 always high. Quote Link to post Share on other sites
RobG 1,892 Posted April 6, 2011 Author Share Posted April 6, 2011 As I was working on my next experiment with 754410, it has suddenly stopped working. When I was testing it, everything was suggesting that the chip is fried. A quick look at the data sheet and the problem is solved, Vcc1, the logic side, requires 5V supply. Logic inputs can still be driven with 3.3V levels, but the Vcc1 has to be 5V. That said, most of the times LP's power is enough, it's just sometimes that 754410 is not working. Quote Link to post Share on other sites
JMLB 24 Posted April 6, 2011 Share Posted April 6, 2011 TP3 will give you 5V if not TP1 will I can't remember. I solder a socket so I can use it when ever I want. (provided by gatesphere) RobG 1 Quote Link to post Share on other sites
Jessters 3 Posted April 22, 2011 Share Posted April 22, 2011 Have had the same problem off and on. I have needed to design a few H bridge implementations for several different projects, and while not all ran off the LaunchPad, all were MSP430 projects... so the same 3.3V issue. I have ended up using a buffer and inverter as standard practice to; A) separate the MCU from the rest of the circuit, and rectify the VCC issue, and cut pin count per motor down to 2 pins. The attached circuit doesn't even require a reference ground to the MCU. The final product in regards to that schematic has a pair of 24v 8Amp DC motors running off PWM output from a G2231 MCU. RobG 1 Quote Link to post Share on other sites
DarthMessiah15 0 Posted May 17, 2011 Share Posted May 17, 2011 anyone know if it's tp3 or tp1 that's 5volts? Quote Link to post Share on other sites
SugarAddict 227 Posted May 17, 2011 Share Posted May 17, 2011 TP1 is EZ_VBUS, TP3 is GND. Quote Link to post Share on other sites
gatesphere 45 Posted May 17, 2011 Share Posted May 17, 2011 Yeah, as SugarAddict stated, TP1 is the USB's voltage, so it should be around 5v. A simple wire or pin soldered into the hold will allow you to access it, just make sure that neither TP1 or TP3 touch the USB port, or you'll create a short. Quote Link to post Share on other sites
kenemon 29 Posted November 9, 2011 Share Posted November 9, 2011 TP3 ground TP1 5V mfpek 1 Quote Link to post Share on other sites
mfpek 0 Posted December 7, 2014 Share Posted December 7, 2014 my project is this circuit but i need to control it with buttons. and i am really confused. how can i add buttons for control the motor to this code? i'll much appreciate for your helps. really. Quote Link to post Share on other sites
enl 227 Posted December 7, 2014 Share Posted December 7, 2014 @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. mfpek 1 Quote Link to post Share on other sites
RobG 1,892 Posted December 7, 2014 Author Share Posted December 7, 2014 It's very simple @@mfpek, just configure 2 pins as inputs with interrupts and add ISR Something like this #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { if (P1IFG & SWITCH1_BIT) { //faster if(CCR1 < 1000) // CCR1 < CCR0 CCR1++; P1IFG &= ~SWITCH1_BIT; } if (P1IFG & SWITCH2_BIT) { //slower if(CCR1 > 0) CCR1--; P1IFG &= ~SWITCH2_BIT; } } Quote Link to post Share on other sites
mfpek 0 Posted December 8, 2014 Share Posted December 8, 2014 okey then first things first. i am an electronics engineering student, english is not my native tongue and i have a semester project about controlling a dc motor with msp430. project includes direction and pwm controlled acceleration. i've done the direction part using a l293d so far. circuit schema that i am using is in attachments and code is; #include "io430.h"#include "in430.h" #define Button_forward P1IN_bit.P0#define Button_reverse P1IN_bit.P1#define Button_Stop P1IN_bit.P2#define IN_1 P2OUT_bit.P0#define IN_2 P2OUT_bit.P1#define EN_A P2OUT_bit.P2#define EN_B P2OUT_bit.P3 void main(void){WDTCTL = WDTPW + WDTHOLD; DCOCTL=CALDCO_1MHZ;BCSCTL1=CALBC1_1MHZ; P1DIR &= ~(BIT0 + BIT1 + BIT2);P2OUT = 0x00;P2DIR |= BIT0 + BIT1 + BIT2 + BIT3; EN_A = 1;EN_B = 0; for(;;){if(Button_forward){IN_1 = 1;IN_2 = 0;}else if(Button_reverse){IN_1 = 0;IN_2 = 1;}else if(Button_Stop){IN_1 = 0;IN_2 = 0;}}} i am not good at embedded coding so i am trying to keep it as possible as easy and understandable. so here is the deal. i need two more buttons for slowing down and speeding up the motor. that's where i am lost. Quote Link to post Share on other sites
mfpek 0 Posted December 8, 2014 Share Posted December 8, 2014 @@RobG which pins on msp should use for switch1_bit and switch2_bit? Quote Link to post Share on other sites
enl 227 Posted December 8, 2014 Share Posted December 8, 2014 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. mfpek 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.