Saturday, June 12, 2010

Arduino HexBridge Shield v2.0

This is what I meant to do the first time.

Recap: I have lots of motor controllers. Some of them work, others do not. But they are almost all based on a combination of MSP430 microcontrollers and a totally isolated, totally modular gate drive solution. Recently I've been feeling the pressure to create a more...populist...solution, which basically means putting it on an Arduino shield. So that's what I did.

Even though v1.0 was a total failure, it gave me a chance to refine the design in ways other than making it not go crazy as soon as it was under any load. I had some extra time to sit around and think about exactly what I would want in an Arduino-based motor controller. Well, not what I would want, but what one would want...you know. ;) Here is the important functionality that I was targeting:

Six semi-independent MOSFET half-bridges. I say semi-independent because each set of three shares a single PWM output. So, at most it can control two motors. But these could be brushless (3-phase) or brushed motors (H-bridge). You can also put channels in parallel for higher current capacity. There should be a simple state selection for each bridge: PWM, low, or float:


This leaves a ton of flexibility, and only occupies one I/O pin per phase, plus the two PWM pins. The "float" state is important for BLDC control or for disabling a phase entirely. I talked about some of the possible configurations in the previous post. On to the new board:


The FETs are the same (IRFS3107 or IRFS3207 or any other D2PAK), but they are arranged differently this time. All the high-side FETs are on the top, and all the low side FETs are on the bottom. This let me move the entire power section out off the side of the board, away from the Arduino and the logic. To conserve horizontal space, I switched to 12-13mm vertical capacitors. They can face up , or down into what will likely be dead space next to the Arduino main board.

Speaking of dead space, I stuffed the DC/DC converter input and output capacitors in the gap between the arduino USB port and power jack and moved everything out of the way of a potential ProtoShield above the whole stack:

Tetris win. Isn't the Arduino supposed to disappear now or something?

Also, the whole board is 2.1" wide now...the width of the Arduino main board. So it is much more compact than the original version. Here's what it looks like all wired up:


Form factor aside, DOES IT WORK? I made some major changes to the gate drive, switching over to the IR21844 integrated half-bridge driver. This is a wonderful chip that automatically handles synchronous rectification with shoot through protection. It also has separate signal and power grounds that can float within ±5V of each other. Because of this, I abandoned optical isolation of the PWM signals for the first time in two years. This worried me, but it seems to work just fine. The ancillary benefit is that the old gate drive, which cost about $15 per half-bridge, is replaced by a $2.50 chip.

To execute the truth table I specified, it needs a bit of supporting logic, in the form of AND gates, comparators, and inverters, but these are dirt cheap. The cool part is the high-Z detector, a window comparator that checks to see if each selector pin is being driven:


If the input pin (which enters from the top of that schematic) is not being driven high or low, it will be pulled to 2.5V by the matched resistors. This is between the threshold of the window comparator, so the output will indicate the high impedance state, and the gate drive for that phase will be disabled. To get to this state from the Arduino, you just set that selector pin as an input.

I started by testing it as an H-bridge with a low-current DC motor, but I quickly got bored and scaled up:

 

This is the SepEx configuration that I described in the previous post. Three of the six outputs are tied together to power the high-current armature winding. Two of the remaining outputs are configured as an H-bridge to control the field. Reversing the field changed the direction of rotation, so the armature need not be reversed. The test motor is from the Cap Kart, which is getting a makeover soon. It's a wheels-up test, so the loads are fairly light (20A armature, 10-15A field current). None of the FETs got warm over the course of testing. If I had a legitimate way of doing current feedback, I would actually put it on the ground and drive it. But for now it's just a demo to show the flexibility afforded by having six output channels.

So, since I have no intention of making more or selling these it's up to you to make them! Here is probably everything you need:

HexBridge Shield Design Files (ZIP, 779kB)

In that folder you will find the schematic, EAGLE files, bill of materials, Gerber files, state table, and sample Arduino code for running the SepEx motor. I would especially like to see a brushless motor controller next...and I have a feeling it will happen very soon.

19 comments:

  1. Thanks for publishing your work. I'm looking into Arduino-based control for next winter's project and your code/pcb will no doubt save a lot of time. Simon

    ReplyDelete
  2. there isn't supervisory circuitry? current and/or temperature sensing?
    Anyway: excelent job!

    ReplyDelete
  3. Thanks. Yes, it is bring-your-own-protection-logic.

    ReplyDelete
  4. I think we are a lot to want it without know how. do you sell yours ?

    ReplyDelete
  5. For those of us who don't get bored and therefore don't have a need to "scale up," would this Arduino shield be appropriate for running brushless RC car motors without the use of an ESC?

    ReplyDelete
  6. Yes, but you would effectively be creating the ESC from scratch. The board is only a power stage and includes none of the sensing and protection circuitry of a commercial ESC. At a minimum, you would need some back EMF sensing circuitry to do sensorless commutation.

    ReplyDelete
  7. Hi, I am building a motor controller too but I don't have experience with Mosfet IC drivers, I have looked at IRS2184 datasheet but I have doubt with the Grounds, I should understand that the the IC has internal isolate with Vss for logic ground and COM for the power circuit?.

    Thanks in advance for your answer, by the way, the information on your blog is great!

    ReplyDelete
    Replies
    1. Hi Andres,

      Thank you! I believe the 2184 has only one ground for both logic and power (COM), although it does have a level shifter built into the chip so that it can tolerate small transients that cause the grounds to shift with respect to each other. The 21844 has two separate grounds, Vss and COM. In the datasheet, it says they can be as much as +/-5V different from each other. I normally tie them together with a small resistor.

      Delete
    2. Thanks for your answer Shane, in your experience the 21844 is good for circuit protection in case of a failure at power circuit or I should go by galvanic isolation?.

      Delete
    3. I would always favor galvanic isolation if you have room for it on your board, but if not, the 21844 should do an okay job. I've had power stages fail that have killed the 21844 but not the microcontroller.

      Delete
  8. Well i see this is an old one.. but i need to ask..

    Would it be possible to use the hexbridge for positioning of a BLDC motor (using it as a servo).. Most of the gimbal servos is way to small.. Im looking into driving BLDC motors as servos for a CNC machine. Seems to be quite inexpensive compared to ordinary AC Servos.

    ReplyDelete
    Replies
    1. Certainly possible, although you will have to solve the problem of how to sense the position of the motor. It can be done with an encoder, a resolver, Hall effect sensors, or a potentiometer. Then there is just some feedback control code to write. :)

      Delete
  9. Hallo shane , Ive build your halfbridge-circut on a breadboard. I used a ir2184 dirver. At frist the Halfbridge works fine and fast. (10kHz) But if i put more load on it. (more than 2a at 48V) the Driver gets hot and demaged :( My DCbuscompasidor is 400v and 40uf. Is this too less . Or is the delaytime (400ns) to low? Has the bus capacidor any effect on the driver or the currrent though the Mosfets(200v 54A) ?

    Finaly how much Load have u already given to your hexbridge without demage. ? (f,U,I,duty)?

    nice Project best wishes

    ReplyDelete
    Replies
    1. There are a number of reasons it could be getting hot, but I think a larger DC bus capacitor is a good place to start. 40uF seems low. You can check dV = I/C*dt = 2A/40uF*50us = 2.5V. That's not too bad for a 48V bus, but maybe the current ripple is too high for that capacitor. It would not necessarily explain the IR2184 getting hot - that should not depend on load current.

      The hexbridge as-built on the PCB I have tested to 48V and ~30A peak / 20A continuous at 15.6kHz. PWM Duty cycle was low, probably 10% (low resistance load). It can handle more current if you parallel the legs.

      Delete
  10. Hi I cant download the file anymore. Would you please help me ?

    ReplyDelete
  11. I second Ahmed's comment. I have made something similar but with four half bridges and current measurement although have no idea how to go about driving these ir21844's. Could you link to a code example or something?

    ReplyDelete
  12. Hi! Same with me. I can not download the file. Could you send it to me per email? blub(at)smart.ms

    ReplyDelete