• As a pre-project, I took a look at the TI DRV3388 Dual H-Bridge. Quite an interesting and convenient device. Initially I expected to manage the control of the individual sides of the H-Bridge in my code. But with this device it is all taken care of. The device can be controlled with both plain steady logic level and with PWM. It can drive two (2) brushed motors or one (1) four-lead stepper. Datasheet - extract and .pdf - attached.

    The test circuit and test code includes two buttons that increase / decrease duty cycle across the range of 0..100%. The motor starts by itself between about 25% and 30%, but slowing down it is possible to get down to between 20% and 25% (no load). I used 1KHz and 1.2KHz for PWM frequency, but did not (yet) check with oscilloscope if they are the optimal one. The frequency can be heard watching / listening to the attached clip.


    5 Attachments

  • The whole chip is controlled with a negSleep signal - like a +chipSelect. Each bridge is controlled with two (2) leads: one is for direction and mode, the other is for PWM - very simple. The breakout board was very cheap. It has only minimal pins... the current control is disabled / tied to ground. A negFault is provided as output indicating signal faults, over current, over temperature, and under voltage.

    // DRV3388test.js
    
    var ms =        // motors
        [ {}        // motor 0 does not exist
        , { id: 1   // motor 1
          , dr: 0   // direction 2/1/0/-1-2 f/s-forw/stop/rev-s/f
          , sp: 0   // speed / duty 0..1
          , ps:     // pins
            [ B8    // DRV3388 AIN1  (BRD7)
            , B9    // DRV3388 AIN2  (BRD8)
            ]
          }
        , { id: 2   // motor 2
          , dr: 0   // direction 2/1/0/-1-2 f/s-forw/stop/rev-s/f
          , sp: 0   // speed / duty 0..1
          , ps:     // pins
            [ B6    // DRV3388 BIN1  (BRD11)
            , B7    // DRV3388 BIN2  (BRD12)
            ]
          }
        ]
      , slp=B10     // DRV3388 nSleep (BRD1)
      , flt=B1      // DRV3388 nFault (BRD6)
      , fltInd=LED1 // fault indicator
      , fltWId=null // fault watch id
      , onInd=LED2  // on indicator (not sleep)
      , on=false    // false not active
      , frq=1200    //
      , ddf=1.20    // duty delta faster as fraction
      , dds=0.84    // duty delta slower as fraction
    //  , ddf=1.11    // duty delta faster as fraction
    //  , dds=0.90    // duty delta slower as fraction
      , dmn=0.24    // duty min as fraction
      , dmx=1.00    // duty max as fraction
      , sbt=A10     // slower button (blue)
      , sbtWId=null // slower button watch id
      , fbt=A0      // faster button (red)
      , fbtWId=null // faster button watch id
      , rpt=150     // repeate check interval
      , cmi=1       // current motor id
      ;
    
    
    function doFlt(e) {
      digitalWrite(fltInd, ! e.state);
    }
    
    function setup() {
      if (fltWId) fltWId=clearWatch(fltWId);
      if (sbtWId) sbtWId=clearWatch(sbtWId);
      if (fbtWId) fbtWId=clearWatch(fbtWId);
      pinMode(slp,"output");
      pinMode(flt,"input");
      ms.forEach(function(m,x){ if (x>0) {
        m.dr=0;
        m.sp=0;
        pinMode(m.ps[0],"output");
        pinMode(m.ps[1],"output");
        stp(x); }}); // stop
      on(0);
      fltInd.reset();
      fltWId=setWatch(doFlt,flt
                ,{edge:"both",repeat:true});
      pinMode(sbt,"input_pullup");
      pinMode(fbt,"input_pullup");
      sbtWId=setWatch(slower,sbt
               ,{edge:"falling",repeat:true,debounce:10­});
      fbtWId=setWatch(faster,fbt
               ,{edge:"falling",repeat:true,debounce:10­});
    }
    
    function ffd(mid,dty) { // forward fast decay w/ duty
      var m=ms[mid], ps=m.ps;
      if (m.dr!=2) { m.dr=2;
        digitalWrite(ps,0); }
      console.log("f:",Math.round(dty*100));
      analogWrite(ps[0],m.sp=dty,{freq:frq});
    }
    function fsd(mid,dty) { // forward slow decay w/ duty
      var m=ms[mid], ps=m.ps;
      if (m.dr!=1) { m.dr=1;
        digitalWrite(ps,0); }
      digitalWrite(ps[0],1);
      console.log("f:",Math.round(dty*100));
      analogWrite(ps[1],m.sp=dty,{freq:frq});
    }
    function rfd(mid,dty) { // reverse fast decay w/ duty
      var m=ms[mid], ps=m.ps;
      if (m.dr!=-2) { m.dr=-2;
        digitalWrite(ps,0); }
      console.log("r:",Math.round(dty*100));
      analogWrite(ps[1],m.sp=dty,{freq:frq});
    }
    function rsd(mid,dty) { // forward slow decay w/ duty
      var m=ms[mid], ps=m.ps;
      if (m.dr!=-1) { m.dr=-1;
        digitalWrite(ps,0);
        digitalWrite(ps[1],1); }
      console.log("r:",Math.round(dty*100));
      analogWrite(ps[0],m.sp=dty,{freq:frq});
    }
    function stp(mid) {
      global["rfdrsdnopfsdffd".substr(6+ms[mid­].dr*3,3)](mid,0);
    }
    
    function slower(e,mid) {
      var d=ms[mid=mid||cmi].sp*=dds;
      if (d<dmn) {
        stp(mid);
      } else {
        global["rfdrsdnopfsdffd".substr(6+ms[mid­].dr*3,3)](mid,d);
      } setTimeout(more,rpt,sbt,slower);
    }
    function faster(e,mid) {
      var s=ms[mid=mid||cmi].sp,d=(s<dmn)?dmn:((d=­s*=(ddf))>dmx)?dmx:d;
      global["rfdrsdnopfsdffd".substr(6+ms[mid­].dr*3,3)](mid,d);
       setTimeout(more,rpt,fbt,faster);
    }
    function more(btn,sorf) {
      if ( ! digitalRead(btn)) sorf();
    }
      
    function on(on) {
      on=on||on===undefined;
      digitalWrite(slp,on);
      digitalWrite(onInd,on);
    }
    
    function nop(){}
    
    function hlt(){ onInit(); }
    
    function onInit() {
      setup();
      on();
      ms[1].dr=2;
      ms[2].dr=2;
    }
    
    setTimeout(onInit,999); // while dev'g, remove before upload for save()
    
  • Nice - thanks! The 2.7v - 10.8v supply is great! It's often hard to find decent H-bridge drivers that will work off of a single LiPo battery

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Exploring DRV3388 2xH-Bridge 2.7..10.8V 1.5A for 3.3V control (2..5.75V)

Posted by Avatar for allObjects @allObjects

Actions