CrazyEngineers
  • related to microcontroller

    hai itz me

    Member

    Updated: Oct 25, 2024
    Views: 993
    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.............
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Harshad Italiya

    MemberMar 31, 2009

    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?
    Are you sure? This action cannot be undone.
    Cancel
  • hai itz me

    MemberApr 1, 2009

    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............
    Are you sure? This action cannot be undone.
    Cancel
  • scorpionmaks

    MemberApr 1, 2009

    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:
    Are you sure? This action cannot be undone.
    Cancel
  • debu

    MemberApr 1, 2009

    @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 😀
    Are you sure? This action cannot be undone.
    Cancel
  • hai itz me

    MemberApr 1, 2009

    ya....i am using ULN2003A instead of BC547.................
    whether motor need to be connected to NO or NC ................
    Are you sure? This action cannot be undone.
    Cancel
  • silverscorpion

    MemberApr 2, 2009

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • harshitpatwa

    MemberApr 2, 2009

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • debu

    MemberApr 2, 2009

    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 😀
    Are you sure? This action cannot be undone.
    Cancel
  • hai itz me

    MemberApr 2, 2009

    Thank u so much for your valuable answers............
    Are you sure? This action cannot be undone.
    Cancel
  • sauravgoswami

    MemberApr 3, 2009

    well now share the results with us,the above posts have covered all possibilities...
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register