Designed an 8-channel high-side non-inverting switch board

I ran into a problem that the ESP32 couldn’t source enough current to reliably drive the LV8727; especially not two of them in parallel for the Y axis on my router. The LV8727 are common-positive, so I can’t just invert the signal and use n-MOSFETs to switch ground.

Even if I switch to opto-isolated TB6600 drivers and invert the logic signals, I still have to drive the opto-isolators, and that would require the enable GPIOs on my ESP32 to source about 70mA; just too much. The LV8727 will drive higher voltage to the steppers (45V) which gives me more headroom; one more reason to make a high-side swith.

I kept thinking there must be an inexpensive part to just buy to solve this problem, but I didn’t find it yet. (Yes, I know about typical MOSFET/resistor level shifters, as well as integrated level shifters like the TXB0104 and TXS0108E; they shift voltage, but won’t source much current. Already went down that path.)

Hopefully posting this project will cause someone to tell me what I’m missing, and I can give up and buy something simple and cheap that I didn’t figure out how to search for.

I haven’t tested this. Not even breadboarded it yet. But I rendered it!

I’d appreciate circuit review.

Edit: Now with PDF of schematic, I guess not everyone keeps kicad around to look at random circuits. :slight_smile:

1 Like

“On the new Cohesion3D LaserBoard the outputs for external drivers are done via actual hardware open drain inverter IC’s, meaning that you can run the integrated drivers that are on regular gpio and external drivers that are on open drain at the same time and with no firmware/ config tweaks.”

I would encourage you to look into a hex OD inverter IC.

Thanks @raykholo!

Do you just invert in software then? I thought of that, but figured as long as I was un-inverting I could handle larger range of voltage and current with a small incremental part count.

The purpose of it being an open drain inverter is that all the stuff is done in hardware - that component.

I connect all the + of the external driver to +5v.
The regular step dir en signals go through that chip and then the outputs are the - of each signal on the driver.

1 Like

So, if I read that correctly, you are doing low-side switching.

That’s fine for opto-isolated with separate inputs, as with the typical TB6600 external drivers. But how does that work with common-ground applications? My problem domain includes EN/STEP/DIR/GND logic interface on LV8727 that the ESP32 couldn’t successfully drive. The whole point of this board is to be a logic-level-input high-side switch.

I guess those parts are cheap, and e.g. the MC74HC05A is $0.30 in tens, and it has 15ns propagation delay, so I could just stack them and they would still take less space and be easier to solder than the individual MOSFETs they replace, and would be faster. But still limited to 25mA/pin. I guess I could tie together 4 inputs and have them drive 4 outputs because 25mA would be enough for a single logic channel on the LV8727. [Edit: I remembered wrong: it’s 40mA at 3.3V and I think around 50-55mA at 5V though I don’t see where I wrote that down; I don’t remember whether it’s ohmic but I think it was less than the 60mA that it would be if it were pure ohmic.]

I must be confused about the application because that rendering looks very complex?
Are you planning to drive the LV8727 directly or use a stepper driver assy. []

The assy’s inputs are optocouplers which do not require that much current they just need a ground sink which is the easiest in your case.

In any case:

  • You can use a transistor or Mosfet with the input designed to switch at 3.3V
  • Or you can use a level shifter and open collector/drain logic devices
  • The ULN 2001 series has lots of drive 300-500ma and hints that it is cmos compatible
  • Or you can use Cmos logic devices with open
    If you have polarity problems you can put an inverter chip in from of the driver chip

Why are you driving the stepper with ESP anyway :slight_smile:

I may misunderstand what you’re doing, but have you considered P-FETs for high side switching? This may just convert the problem to “well the ESP32 can’t sink that much either” but I don’t know.

The latter, but logic inputs on that are directly connected, no optos, and they are shared ground so I can’t use nFETs because GND is shared. I measured current at LV8727 stepper configuration information at 40mA per pin at 3.3v. With four of them on a single EN line that’s trying to pull 160mA from one ESP32 pin, which… it turns out doesn’t work well. :roll_eyes:

That’s how I got into this in the first place.

This board holds channels of which each channel holds a pair of MOSFETs with associated needed resistors (current limiting, pull up, and pull down) to make a non-inverting driver. The nFET drives the pFET.

I went hunting for an example I didn’t create, so maybe this writeup is clearer?

I just made a PDF of my schematic.

I could drive pFETs straight from the GPIOs by inverting the signals in software, but I do need to have pull-up resistors that pull them all the way up or they won’t actually turn off, which means that the GPIO is exposed to full supply voltage for the pFET, which is at least 5V and in the general case (with this board I can drive other devices, so as high as 20V or 30V depending on the FETs I choose) could be higher. I’ve heard that ESP32 are tolerant of 5V with a large enough current-limiting resistor, but that might make it slower than using an nFET for gate drive, and if I use an nFET for gate drive I don’t have to invert the signals, so win-win.

Because I can put a gcode file on an SD card and not have to have a separate real computer supervising a router. I can use my phone as a pendant. It’s a really nice setup IMHO.

I’m getting really tired already of dealing with a USB cord connected to the OX, and I haven’t done very much yet.

Is this the assy you are using … they use input optocouplers (6n137)?

Don’t understand how you measured 40ma at 3.3 v??? Doesn’t the pin get grounded???

Connect 3.3V at the + terminal and ground the -signal through an milliammeter and see what that current is, should be low its an led? Like 3 ma. [(3.3v-1.8)/470ohms]. @5v it should be 6.8ma.

You may be able to connect 3.3v to the anode of the optocoupler and use the esp directly. If not it is easy to drive it with an open collector/drain to gnd.

By the way this is a lot cheaper:


I’m using the makerbase one you linked to before, as sent from @Brandon_Satterfield in his closing-up-shop sale. I measured 40mA at 3.3v by running (separately, one at a time) enable, step/clock, and dir lines from my ESP32 through my fluke 87V. (If it works, it must be a fluke.) The current closely matched the published typical current for those lines in the LV8727 datasheet. I can’t see any optos when I try to peer under that huge heatsink.

The only saving grace is that EN is active-low and I had always-enable turned on in grbl config, so it wasn’t normally trying to pull 160mA, but step and dir on my two Y drivers together (I’m not driving both steppers off a single driver) were pulling 80mA on an ongoing basis.

If you look closely at the makerbase units you linked to, you’ll see that the input lines are labeled as EN CLK DIR GND which means that fairly obviously you can’t switch the lines by putting an nFET on the ground for each line separately when ground is shared…

Separately, my TB6600 driver modules (I have 6 of them) pull 16mA at 3.3V and 17mA at 5V per channel through their opto-isolators, measured both with my fluke and with my bench power supply (no surprise they agree; I calibrated the PS with the fluke). I don’t assume that optos will pull only 7-10mA generally.

The LV8727s will run up to 45V; the TB6600 really shouldn’t be run above 36V or so IIRC. Ultimately I may end up with the TB6600s in the router if I put the LV8727s in the mill and run it at 45V. That I haven’t decided yet.

That is not obvious to me at all… each line gets a mosfet connected to - (clk, -dir, -enb) and can be switched to ground. The fact that they share a ground is OBVIOUSLY irrelevant.

Something is wrong with my understanding as this situation is normal for stepper drives and I do not have this kind of input current problem and they all essentially work the same way using simple single ended drivers.

According to this datasheet, the logic pin input current is max. 70uA (micro!) at 5V and high level needs only 2V. This could by directly driven by the ESP32 without any problem.

1 Like

@cprezzi you are quite right. I thought that µA would have made more sense for logic level current. I wonder why I (thought I) saw much higher current in practice. I guess I must have accidentally selected µA instead of mA range on the meter, and then read in the datasheet what I thought I had seen? I normally start with a higher range and then go down to lower ranges when measuring current.

Seems clear that my next step needs to be to again measure current.