Tuesday, 18 June 2013

Electronics: Moving the train (Part II) - H-Bridge

Hi you all guys,

After reading the PWM signals theorical and practical posts I hope that you all know perfectly how to control DC Motor's velocity. Thus, let's move forward and see how we could control the direction as well.

The pictures below show how the H-Bridge concept works. Note that when transistors S2 and S3 are enabled, electricity goes through the motor from its right side to its left one and the motor therefore moves forward. In contrast, when  transistors S1 and S4 are enabled instead, electricity goes through the motor from its left side to its right one and the motor then moves backward.



Thus, the DC Motors directions may be controlled by enabling and disabling transistors.

However, there are easier solutions such the L298, which is an integrated chip that internally has two h-bridges and therefore provides full control of 2 motors. Those who don't know about it yet, below is a link where you will find its datasheet.:


In addition, there are some PCBs that are already prepared for being used with this L298. In the picture below you will see the PCB which I used:


As you can see, on the left side of the PCB are placed the inputs and on the right side are the outputs. Specifically, ENA, IN1 and IN2 provide the control for the MotorA while the ENB, IN3 and IN4 provides the control for the MotorB. The ENA and ENB receives a 5V PWM signal each and the IN1-IN2 and ÍN3-N4 pairs work as told in the true table below.

 IN1/IN3    IN2/IN4  Motor status
´ 0               0              Stopped
  0               1              Move forward
  1               0              Move backward
  1               1              Emergency break

Unfortunately, the L298 is prepared for current peaks lower than 2,5A on each channel and 3A on both channels working in parallel. The DC Motor, which my trains use, may consume current peaks higher than 3A, so by the moment I am using another PCB which is prepared for current peaks around 10A. You will find a picture of this PCB below.



Please, leave your comments!!!

See you guys!

5 comments:

  1. Hello Oriol,

    thanks for the tutorial.

    What's the last board you are showing, the one for the 10 Amp? Any reference or commercial name?

    Regards

    Carles

    ReplyDelete
    Replies
    1. Hi Carles,

      Thank you for your comment.

      Below you will find a link where you can buy it if you like.

      http://www.ebay.com/itm/3-36V-Dual-15A-H-Bridge-DC-Motor-Driver-30A-for-Robot-Car-Arduino-Compatible-/181162800942?pt=LH_DefaultDomain_0&hash=item2a2e24f72e

      As you can see, the seller tells which each bridge can be fed with 15A. I have tested it working between 8 and 10 Amp and it seems to work quite good.

      Best regards,
      Oriol

      Delete
  2. Hello again Oriol,

    One piece of advice for those wiring their own L298: Current Sensing pins must be connected to ground or it will not work. This kept me puzzled for a while since this is not common with other bridges like the L293 and I know that it has also stopped other colleagues.

    Current Sensing pin allows you to monitor current through the system by connecting it to ground with a small value resistor (think 0.1 ohm) and measuring the voltage across it. If no current sensing is needed in the setup, then just direct connection to ground is fine.

    Regards

    Carles

    ReplyDelete
    Replies
    1. Thank you very much Carles for your comment :)

      I know what you mean because it happened to me as well, that's why I use PCBs already assembled instead of single components. :P

      By the way, what is your project about?

      Delete
    2. Well, it is about making an N-scale train autonomous. I'm building a decoder for every train with AtTinys and controlling the setup with an Arduino.

      Delete