interfacing dc motor with 8051

Discussion in 'Embedded Systems and Microcontrollers' started by bobparihar, Jul 31, 2014.

  1. bobparihar

    Thread Starter Member

    Jul 31, 2014
    93
    0
    i am having problem in simulating DC motor in anticlockwise direction on Proteus 8.0 when connected to AT89C51 micro controller. It works correctly in clockwise direction, but stops in anticlockwise direction.
    here is the code

    Code ( (Unknown Language)):
    1.  
    2. #include<reg51.h>
    3. sbit a=P2^0;  // given to l293d pin
    4. sbit b=P2^1;  //given to l293d pin
    5. void main()
    6. {
    7.    
    8.     while(1)
    9.     {
    10.        
    11.     a=0;
    12.     b=1;
    13.     for(i=0;i<55000;i++);      //delay
    14.     a=1;
    15.     b=0;
    16.     for(i=0;i<55000;i++);
    17.  
    18.     }
    19. }
    20.  
    please help:(
     
    Last edited by a moderator: Jul 31, 2014
  2. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,364
    Try putting delays in between a and b assignments:

    Code ( (Unknown Language)):
    1.  
    2. #include<reg51.h>
    3. sbit a=P2^0;  // given to l293d pin
    4. sbit b=P2^1;  //given to l293d pin
    5. void main()
    6. {
    7.    
    8.     while(1)
    9.     {
    10.        
    11.     a=0;
    12.     for(i=0;i<55000;i++);      //delay
    13.     b=1;
    14.     for(i=0;i<55000;i++);      //delay
    15.     a=1;
    16.     for(i=0;i<55000;i++);      //delay
    17.     b=0;
    18.     for(i=0;i<55000;i++);
    19.  
    20.     }
    21. }
    22.  
    23.  
     
  3. elabsp

    New Member

    Oct 23, 2013
    13
    1
    Be aware in above code b=1 and a=1 both at the same time in line12, which may damage the bridge
     
  4. AfdhalAtiffTan

    Active Member

    Nov 20, 2010
    117
    11
    He's using L293D, not discreet BJTs, so it supposed to be fine.
     
  5. bobparihar

    Thread Starter Member

    Jul 31, 2014
    93
    0
    i want to ask a question here to everyone...
    should i connect the dc motor directly to the output pins of L293D IC or i should connect it using some protection(any resistors,or diodes etc.) at the hardware level.
     
Loading...