related to microcontroller

i am working with 8051 microcontroller.........the relay is connected with 5vdc motor and i am connecting relay at the port p0.0.i am using the following code to rotate the motor.......

setb p0.0
call delay(30 microseconds)
clr p0.0

the problem is the motor is rotating continuously........it doesnt come to stop,though i have given the clear instruction.......can anyone help me out.......please.............

Replies

  • Harshad Italiya
    Harshad Italiya
    Which Compiler you are using??

    Can you please tell me that Relay is Remain in Normal Postion??

    Then i think your Output Pin can not Drive the Relay...
    What is the Rating of the Relay?
  • hai itz me
    hai itz me
    i am using keil software which consists of assembler and compiler.............
    it generates hex code...........
    you said that the pin is not able to drive the relay..............If it is so,then how the motor is running............
  • scorpionmaks
    scorpionmaks
    well, i would like to see your full code, but first make sure the following things are verified.
    i) Make sure proper Pull Up is provided to P0 pins.
    ii) Verify the motor is in STOP state before you make P0.0 high.
    iii) Use the simulator in Keil to verify that the delay loop is executing as desired. Make sure it's not hanging up in continuous loop.

    PS: Please introduce yourself in introduction section.:smile:
  • debu
    debu
    @hai itz me: If your motor is rotating continuously, chances are you have connected your motor to the NO (Normally Open) pin of your relay. You can't drive a Relay using your uC's pin. You need to drive it using a transistor. I reccomend you use a BC547 npn.

    Regards,

    Debu ๐Ÿ˜€
  • hai itz me
    hai itz me
    ya....i am using ULN2003A instead of BC547.................
    whether motor need to be connected to NO or NC ................
  • silverscorpion
    silverscorpion
    First of all, you need to use pull up resistors if you use port 0 in 8051. I suggest you use some
    other port, say port 2 for ex..
    And then, you can use a motor driver IC like L293D or L298, for easy interface on micro
    controller and motor. It's really easy to do. Particularly, L298 even has an inbuilt PWM generator.
    But if for some reasons like want of high power, you need to use relay, then you can use a
    H-Bridge circuit for DC motor control. Search the net for H bridge configurations.

    Above all, I think the main problem is with the code. You are calling a function named delay. What's inside the function? How does it generate delay? Do you use timers? There might be errors in the function. And I do think that's where the problem lies.
  • harshitpatwa
    harshitpatwa
    First of all what is controlling voltage of 8051? I suppose it is 5v . If it is 5v connect motor to port pin directly. Make sure u configure pin as output. Increse delay and then check and troubleshoot by varying delay.It will definetly work.
  • debu
    debu
    silverscorpion
    ... Particularly, L298 even has an inbuilt PWM generator...
    Really???? ๐Ÿ˜’

    @hai itz me:Connect the -ve of the motor with GND, and connect the +ve of the motor with the NC of your relay. Connect the COM of the relay with the 12v supply.

    When the relay turns on, the motor will turn.

    Hope this helps.

    Regards,

    Debu ๐Ÿ˜€
  • hai itz me
    hai itz me
    Thank u so much for your valuable answers............
  • sauravgoswami
    sauravgoswami
    well now share the results with us,the above posts have covered all possibilities...

You are reading an archived discussion.

Related Posts

Hey, i need help in understanding the function of each components in the circuit or how it works. https://img3.imageshack.us/img3/7220/cctdiagram.jpg Any help here would be greatly appreciated.๐Ÿ˜€ thanks.
Well I am facing a kind of problem. I was trying to get some hosting plans for a domain name which I had registered some time ago. Now the person...
I am trying to write a program to initialize General purpose Input Output ports. The microcontroller I need to initialize the ports on - is a C8051F330 chip. https://www.keil.com/dd/docs/datashts/silabs/c8051f33x.pdf I...
I have two dual axis ADXL203 accelerometers. However, I am supposed to get acceleration data in three dimensions. My professor advised me to get dual axis instead of triaxial accelerometers...
I have some acceleration data that I received from an accelerometer and used an A/D converter before sending the data to my computer... how do I use Matlab to integrate...