EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / NXP 8051 – DC Motor Interfacing

NXP 8051 – DC Motor Interfacing

|

Microcontroller › 8051 › NXP 8051 – DC Motor Interfacing

  • This topic has 3 replies, 3 voices, and was last updated 13 years, 4 months ago by matrixworld20.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • September 27, 2012 at 11:18 am #1973
    posie
    Participant

     

    Hello friends..

     

    I’m using NXP p89v51rd2 micro-controller. I want to run two 12v DC motors for which I’m using L293D driver.

     

    I’m actuating the motors using data sent via serial port.. i.e Both the motors to run simultaneously when I send a character ‘S’ through serial port and stop when I send a character ‘R’.

     

    This is my code :

     

     

    #include <intrins.h>
    #include “p89v51rx2.h”
     
    sbit motora=P2^0;
    sbit motorb=P2^1;
    char getCharacter (void);    
     
    void main (void)
    {
    char chr;
    SCON = 0x50;
    TMOD = 0x20;
    TH1  = 0xFD;
    TR1  = 1;
    T1=1;
    while(1)
    {
    chr = getCharacter ();
    if (chr == ‘S’)
    {
    motora=1;
    motorb=0;
    }
    else if(chr == ‘R’)
    {
    motora=0;
    motorb=0;
    }
     
    }
    }
     
    char getCharacter (void)
    {
           char chr;
           while (RI != 1) {;}
    chr = SBUF;
    RI = 0;
           return(chr);
    }
     
    The problem is when I send ‘S’ though the terminal…the two motor are moving just a single step (as if its a stepper motor )
     
    Just a single step… and when I send ‘S’ again..it moves another step..
     
    I used Vs = 12v (Motor voltage) from the Micro-Controller Development board…Is that the problem ??
     
    What might be the issue ???
    September 27, 2012 at 6:30 pm #8622
    AJISH ALFRED
    Participant

    Hi,

    please share your schematic also, it could happen due to hardware issues sometimes.

    September 30, 2012 at 3:06 pm #8632
    matrixworld20
    Participant

    when u send ‘s’ then only your loop is activated  for a moment after that both if loop not getting any code so it does not working,,,, u can check it by pressing ‘s’ countineusly..

     

    sory for poor english

    September 30, 2012 at 3:18 pm #8633
    matrixworld20
    Participant
     
    status=1;
    while(1)
    {
    chr = getCharacter ();
    if (chr == ‘S’)
    {
    status=0;
    }

    if (chr == ‘R’)
    {
    status=1;
    }
     
    //====================================
    if(status==0)
    {
    motora=1;
    motorb=0;
    }
     
    if(status==1)

    {
    motora=0;
    motorb=0;
    }
     
     
     
    and imp , u should have seperate the power source for both…  bcoz motor shrink more current probably it will damage controller
  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • ANOTHER OLD PROJECT REDO February 7, 2026
  • Do i need a buffer? February 7, 2026
  • wall transformer polarity February 7, 2026
  • Supply vs performance query February 7, 2026
  • BPF February 7, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise