Jump to content
43oh

Some times dc motor doens't stop working in my project


Recommended Posts

First of all a question, I just have to change the  jumpers J3 connections if I use serial communication right?
 
Hello, I've a project where the msp430g2553 makes an access control by password.
 
The launch pad receives a password from a matrix keypad, and turns on a motor to lock the door, or to lock the door if a button is pressed from inside the "room"
 
The project works fine, but sometimes the dc motor doesn't stop working, and it is happening randomly. 
 
can somebody help me?
 
sorry for my terrible english

 

the code and a circuit layout:

 

/*lock door control*//* matrix keypad: S

post-37575-0-48200500-1403709739_thumb.jpg

Link to post
Share on other sites

I think one thing you're doing wrong is driving the lock and unlock functions wrong. You should be using the 1,2EN pin (pin 1) on the L293D to enable the motors, and pins 2, 7 to control motor direction. If 2 is high and 7 is low, motor goes one way; if 2 is low and 7 is high motor goes opposite.

This does mean you'd have to take VCC off pin 1 and run that to another assigned pin on the MSP430.

 

I don't have an L293D to test, but maybe something like below. Think of it like setting motor direction, then enabling the motors to spin.

//if enable is low motor will not spin; lock and unlock signals do not matter 
const lockEnable = X;           // X is launchpad pin to control drive enable

// to unlock door:
digitalWrite(lockEnable, LOW);  // disable the drive circuit - guarantees motors won't run
digitalWrite(unlock, LOW );     // set motor to unlock direction
digitalWrite(lock, HIGH );      // lock must be opposite of unlock or motor won't spin
digitalWrite(lockEnable, HIGH); // enable the drive circuit
delay(500);                     // wait 1/2 second
digitalWrite(lockEnable, LOW);  // disable the drive circuit
digitalWrite(open, HIGH);       // turn on OPEN LED
digitalWrite(close, LOW);       // turn off CLOSE LED

...

// to lock door:
digitalWrite(lockEnable, LOW);  // disable the drive circuit - guarantees motors won't run
digitalWrite(unlock, HIGH );    // set motor to lock direction
digitalWrite(lock, LOW );       // lock must be opposite of unlock or motor won't spin
digitalWrite(lockEnable, HIGH); // enable the drive circuit
delay(500);                     // wait 1/2 second
digitalWrite(lockEnable, LOW);  // disable the drive circuit
digitalWrite(open, LOW);        // turn off OPEN LED
digitalWrite(close, HIGH);      // turn on CLOSE LED
Link to post
Share on other sites

abecedarian

 

I think I cant put a pull down resitor ai pin 1 of L293D, because its the enable pin. That is really what you ment?

Yes, that's what I meant. A 4.7k resistor from pin 1 to ground, but only after moving pin 1 off of VCC and connecting it to a GPIO pin on the MSP430.

 

msp pin ----+---- L293D pin 1
            |
            >
            < - 4.7k
            >
            |
gnd --------+
Link to post
Share on other sites

Yes, that's what I meant. A 4.7k resistor from pin 1 to ground, but only after moving pin 1 off of VCC and connecting it to a GPIO pin on the MSP430.

 

msp pin ----+---- L293D pin 1
            |
            >
            < - 4.7k
            >
            |
gnd --------+

now I understood totally makes sense

Link to post
Share on other sites

I think I fixed this (but  I am still testing)

 

I created an enable pin, that is the same wich enables the L293D

 

const int enable = 19;

pinMode(enable, OUTPUT);

 

so, every time the motor works, I put (enable, HIGH) and after the work I put it LOW (enable, LOW)

 

like that:

 

 digitalWrite(enable, HIGH); // enable the motor to work
 digitalWrite(Lock, LOW); // turn on the motor
 delay (500);
 digitalWrite(Lock, HIGH);// turn off the motor
 digitalWrite(enable, LOW); // disable the motor to work
 
and I put a pull down resitor like this:
 
msp pin 19 ----+---- L293D pin 1
                                                  |
                                                  >
                                                 < - 4.7k
                                                 >
                                                 |
                                                 gnd --------+
Link to post
Share on other sites

If it were me, I'd use code like I posted earlier. Maybe put them into functions.

 

Disable the motor driver, set the motor direction, enable the motor driver, pause then disable the motor driver.

 

The resistor in the circuit will hold the 'enable' pin at ground until the MSP takes the pin high.

Here's the basic circuit:

post-26656-0-18125300-1403723337_thumb.png

Link to post
Share on other sites

If it were me, I'd use code like I posted earlier. Maybe put them into functions.

 

Disable the motor driver, set the motor direction, enable the motor driver, pause then disable the motor driver.

 

The resistor in the circuit will hold the 'enable' pin at ground until the MSP takes the pin high.

Here's the basic circuit:

attachicon.gifdoorlock.png

Thank for your answer man, you really helped me.

Link to post
Share on other sites

I am doing tests in my code, and now I have noticed a problem, when I turn on the launch pad, it recognizes the status (lock or unlock), but the motor doesn't work. Then if I change the status once, It start working ok.

Link to post
Share on other sites

What does your code look like now?

Im still working and  I solved the problem of my last post, I think the only thing I need now is to be able to read the button '*' when the dor is unlocked, to lock it.

The code I am using is commented in portuguese, you may not understand.

 

/*Controle Porta do Quarto 3.0*/
 
/* teclado: S
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...