Connect with us

Running servo motors with PIC and L293D H-bridge

Discussion in 'Sensors and Actuators' started by WhiteSmith, Jul 25, 2015.

Scroll to continue with content
  1. WhiteSmith

    WhiteSmith

    6
    1
    Jul 25, 2015
    Hello everyone!

    I'm a student of Mechatronics and I have a project in which I have to make a robot that is run by two Y-3009 Modelcraft servos. I have already made a PIC basic circuit with the Quartz crystal and the reset button etc., and also the one with the H-bridge. I made the exact same circuit that is shown in this thread http://www.instructables.com/id/Control-your-motors-with-L293D-and-Arduino/. This was the circuit that my mentor proposed I should use. But now I stumbled into a bit of a problem... I understand I have to mechanically alter my two servos in order to get them working for this concept. I already removed the mechanical protection that disallows the servo to exceed its limits and I shortened the potentiometer so that it is always positioned in its starting position http://www.instructables.com/id/How-to-modify-a-servo-motor-for-continuous-rotatio/. So now my servo should be acting as a DC motor if I understand correctly? Now if I return to the H-bridge... Which two lines do I have to connect to the outputs? Is it the + and ground? or is it the signal and ground? Or maybe even + and signal? An educated guess would say it is the + and ground. And in this case or the previous ones, which one goes where (which goes on which pin of the bridge)? When I correctly plug my servo on the bridge there is still the matter of connecting the bridge to the PIC. There are four pins reserved for the input on the L293D. Which ports of the PIC do I have to route to each pin on the H-bridge? And when I do that, How do I control the motors? I understand it is with PWM? But if it is so, how do I control the direction which the servo should be turning?

    So if anyone ever made anything similar, I would really appreciate it if you could clarify the situation for me or maybe give me some useful links so I could also write which literature I was using?

    I would also like to apologize for my poor English, as I am not a native speaker. Hopefully everything is understood and if not, I will be more than happy to clarify any misunderstandings.

    Thanks in advance!
     
  2. Arouse1973

    Arouse1973 Adam

    5,164
    1,080
    Dec 18, 2013
    If you want to control this as a motor then you use the + and - for control and not the PWM wire.
    Adam
     
  3. WhiteSmith

    WhiteSmith

    6
    1
    Jul 25, 2015
    Tnx for the reply. Any answers regarding my other questions?
     
  4. Arouse1973

    Arouse1973 Adam

    5,164
    1,080
    Dec 18, 2013
    Do you have a circuit diagram? If you do can you post it here?
    Adam
     
  5. WhiteSmith

    WhiteSmith

    6
    1
    Jul 25, 2015
    Ok. These are the two circuits that I currently have on my protoboard: The first one is the H-bridge[​IMG] and the second one is the basic PIC micro controller circuit. [​IMG] So now I need to know how to connect the two circuits. You already stated that I need to connect the + and GND wires of the servo to the H-bridge. There are also 4 inputs on the H-bridge, how/where do I connect those? And then, how do I control the speed/direction of my servos?
     
  6. Colin Mitchell

    Colin Mitchell

    1,418
    314
    Aug 31, 2014
    You have to connected directly to the two wires coming from the motor.
     
  7. Arouse1973

    Arouse1973 Adam

    5,164
    1,080
    Dec 18, 2013
    Hello

    Here is the datasheet and it gives you the logic table for one driver. For your application you need to have it set up so that one of the drivers output is high and the other is low. The motor will go in one direction. If you were to reverse the outputs of the drivers the motor will rotate in the opposite direction. The data sheet shows diodes across the motor for flyback voltage suppression. I would include these in your design.

    http://www.ti.com/lit/ds/symlink/l293.pdf

    Thanks
    Adam
     
  8. WhiteSmith

    WhiteSmith

    6
    1
    Jul 25, 2015
    TY for the quick response. So if I understand correctly, I have to connect the bridge to any two ports of the micro controller, which are able to give a high or a low output, and I simply steer the motors by appointing a logical one or a logical zero on the two ports, following the truth table which is in the datasheet? And thus I can only steer the two modified servos with one speed in both directions?
     
  9. Arouse1973

    Arouse1973 Adam

    5,164
    1,080
    Dec 18, 2013
    I don't know if you can put PWM through this chip. But you could try and PWM the output pin you would be putting high.
    Adam
     
  10. WhiteSmith

    WhiteSmith

    6
    1
    Jul 25, 2015
    My mentor mentioned using PWM, so I thought that's the way to run the servos. I also found some literature on the web that used PWM on the enable pins of the H-bridge but have struggled to understand why and how. So now I'm a little bit confused. Yes, the output of the PIC might be controlled with a PWM and thus controlling the motor speed. But what about the truth table then? There are two enable pins on the bridge and they need to be set to high or low in order for the servos to work one way or the other. The right combination then decides if the servo stops, goes clockwise or counter-clockwise. But how would I use the PWM then..?
     
  11. Arouse1973

    Arouse1973 Adam

    5,164
    1,080
    Dec 18, 2013
    I think from what you just said by using the enable pin to turn the motor on and off will work I have never used this device but can't see why that won't work. So you set one input pin high and one input pin low for the direction you want and then PWM the enable pin.
    Adam
     
  12. WhiteSmith

    WhiteSmith

    6
    1
    Jul 25, 2015
    Yes, I think I can see what you are saying. I also searched the web and found some interesting ideas on this PWM control. However I am still looking for the sample code for MikroC compiler in order to get it working. So if you happen to stumble upon it, please post it here. I will try to test this concept by hooking up my bridge to the PIC and seeing how/if it will work. I will post my results and/or question here.

    TY for the help again.
     
    Arouse1973 likes this.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-