74HC(T)245 interfacing 5v cifcuits e.g. driving 5v logic level mosfets

Anything not related to STM32
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

74HC(T)245 interfacing 5v cifcuits e.g. driving 5v logic level mosfets

Post by ag123 »

recently i messed a bit with 3d printing

the idea is to interface a stm32 board with a ramps style board e.g.
https://reprap.org/wiki/RAMPS_1.4

it turns out getting Marlin to run on stm32 (say f4xx) is 'pretty easy'
viewtopic.php?f=10&t=1213

then i hit a bummer, ramps 1.4 is 5v board, the logic level mosfets that runs the hotend and bed heaters are 5v based
this effectively means stm32 can't drive them directly as the gate voltages is at least some 4.5 volts.

i started looking at simple transistors as 'level shifters'
starting with simple one transistor
http://electronics-diy.com/electronic_s ... hp?id=1012
https://www.baldengineer.com/low-side-v ... witch.html
https://www.baldengineer.com/low-side-v ... ivers#main
then more elaborate circuits
TI has a very nice article/doc
https://www.ti.com/lit/slua618
other examples
https://www.eevblog.com/forum/beginners ... -a-mosfet/
a main problem is the initial 'simple' one transistor design tends to be *inverting*, this is a big danger as the mosfet is turned on when the gpio pin is off or floating. then as more transistors are added, it solves the problem but that it significantly adds more discrete components for driving a single mosfet.

then i looked at uln2003 driving mosfets, that is similar to transistors, saves some discretes, but that it cause inverting outputs.
https://electronics.stackexchange.com/q ... er-uln2003

then i looked at dedicated gate drivers, i stumbled into one during searches
https://www.infineon.com/cms/en/product ... cs/ir2103/
ir2103 is very good. Specifically, these solve a difficult problem for high side n-mosfet in that they require a bootstrp, just to kick it into action.
however, for this purpose it is an overkill and slightly pricy, but they are useful in the relevant context such high power h-bridges, power amp outputs and mains inverters. those are the use cases where such drivers are justified.

then i discovered another problem. as the ramps board runs at 5V VCC, it turns out although the various motor drivers can run off 3v. But if vcc is 5v the vin high levels are above 3.3v, Which means there'd be problem running even the motor drivers at a 5v vcc. and that 5v vcc is shared to the mosfets which requires at least 4.5v to be of any use.

then finally i stumbled into
74HC(T)245
https://www.nexperia.com/products/analo ... CT245.html

this modest chip fits the use case so well, it translates (buffers) 3.3v logic levels to 5v logic levels and should have no problem driving the ramps board.
and being a cmos device, it has complementary push-pull output stages as like all the gpios and it alleviates the problem of driving mosfet high capacitance gates.
https://markobakula.wordpress.com/power ... e-circuit/
and best of all it saved so many discrete components, transistors, resistors and all, reducing the whole circuit design to simply wires. if one stage has an average of say 6-10 (lets take 10) components. for 8 outputs that is 80 discrete components, it is reduced to a single component.

74HC245 is cmos logic levels, i think stm32 can just about barely drive it at 5v vdd, but borderline.
74HCT245 is more appropriate as it has a VIN high of 2v which leaves lots of room for stm32 to turn it on
74HC(T)245 is one good part to keep around. it is so crucial to interfacing between 3v to 5v logic.
.rpv
Posts: 43
Joined: Wed Dec 18, 2019 10:19 pm

Re: 74HC(T)245 interfacing 5v cifcuits e.g. driving 5v logic level mosfets

Post by .rpv »

Hi, I think that you can use almost any logic converter (like logic gates, schmitt trigger, buffers, ...) to convert 3.3 into 5v and as cheapo-gate-driver, I've seen a few 3d printer controller schematics and the SN74LVC1G125 it's pretty popular (or the quad version), even the steval 3d printer controller uses it.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: 74HC(T)245 interfacing 5v cifcuits e.g. driving 5v logic level mosfets

Post by ag123 »

thanks, that's a pretty nice level shifter chip !
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: 74HC(T)245 interfacing 5v cifcuits e.g. driving 5v logic level mosfets

Post by mrburnette »

For anyone wishing an easy read to review logic level issues:
https://learn.sparkfun.com/tutorials/logic-levels/all
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: 74HC(T)245 interfacing 5v cifcuits e.g. driving 5v logic level mosfets

Post by ag123 »

thanks @mrburnette.

on a sidenote, i noted that there are quite a lot of (cheap?) 'level shifter' modules based around txs0108
https://www.aliexpress.com/wholesale?ca ... xt=txs0108

datasheet
https://www.ti.com/product/TXS0108E
these are probably ok to drive 74hcxx hcmos logic at 5v, but that VOH spec is VCCb x 0.67 ~ 3.35v
those would drive TTL, 74LS TTL levels and marginally 74HCxx levels, but it falls short of the 4.5v min required to turn on the gate of that logic level mosfet

the other chip TXB0108 does proper translation and give VOH at VCC - 0.4
https://www.ti.com/product/TXB0108

for those looking for 'translation modules', it is better to skip the 'cheap' ones, as that is probably 'cost optimized' rather than 'spec optimized'.
sparkfun, adafruit has the real TXB0104, TXB0108 modules. somewhat premium for the convenience and quality.
for those driving for 'cheap' i'd guess it'd be better to just get the chips e.g. TXB0108, 74HCT245 etc and hand solder them on 'adapter boards'
https://www.aliexpress.com/wholesale?ca ... 20+adapter
at least u'd not land with a txs0108 which is pretty 'useless' (doesn't fit the purpose).
.rpv
Posts: 43
Joined: Wed Dec 18, 2019 10:19 pm

Re: 74HC(T)245 interfacing 5v cifcuits e.g. driving 5v logic level mosfets

Post by .rpv »

@ag123 are you using a ramps or are designing your own board?

Here it's the ST STEVAL-3DP001V1 3d printer controller:

https://www.st.com/en/evaluation-tools/ ... umentation

on the tab documentation, Product Specifications pdf they included the schematic.


The bigtreetech brand it's quite popular, they use an 74HCT365 as gate-driver:

https://raw.githubusercontent.com/bigtr ... 02-SCH.pdf

they have a few controller boards published on:
https://github.com/bigtreetech?tab=repositories

I remember saw a design using an schmitt trigger (probably was the SN74LVC1G17), but I can't remember where I saw it.


Using a logic IC as gate driver isn't ideal but Marlin probably it's using arduino default frequencies which it's pretty slow, so it won't matter much.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: 74HC(T)245 interfacing 5v cifcuits e.g. driving 5v logic level mosfets

Post by ag123 »

thanks @.rpv

the SKR boards from bigtreetech are very good, and i'd likely get one of them at a next round.

instead i've got, these ramps 1.4, ramps 1.6
https://www.aliexpress.com/item/32971662146.html
https://www.aliexpress.com/wholesale?ca ... =ramps+1.6

ramps 1.6 has a slightly better design with heatsink on the heater mosfets.
and of course they are a significant margin cheaper than the well developed SKR boards.
the other reason for using a 'crude' ramps board is i want to separate the high power drive circuits from the microcontroller, as those are the parts which are more likely to fail.

i got these as i've a couple of stm32f407vet6 black - boards around
https://stm32-base.org/boards/STM32F407 ... -V2.0.html
https://www.aliexpress.com/wholesale?ca ... 32f407vet6

rather than 'wasting' them, i decided i'd use it with the ramps board.
how they get connected is 'dupont wires' - yup that works ;)
https://www.youtube.com/watch?v=eI3fxTH6f6I
and a side advantage is all the 'spare' pins on the mcu can be used for other purposes e.g. run a lcd etc. this is unlike a hardwired board where everything is on board and the pin uses can be redefined as appropriate.

the need for that 5v interfacing is 'unfortunate', initially i've mainly considered just the mosfet, but it turns out due to the 5v vcc to all the motor drivers, it is necessary to level shift all the stm32 outputs. i think even without the 'level shifters' stm32 would drive the motor drivers at 5v at the borderline.
that is because hcmos VinH is 2/3 VCC ~ 3.35v, but accordingly i think some of then turns on at 2.5v. so it is borderline. But i'd guess as this is going to be a 3d printer, it is worth the extra effort to do that level shifting rather than gamble with the signal levels at least to improve reliability.
the integrated circuits 74HCT245, 74HCT365 and the appropriate dedicated level shifters are valuable for the purpose, helps reduce parts counts enormously to a single chip, and not least are a mosfet driver in addition. the 'mosfet driver' is the hard part as it requires 4.5v rather than just ordinary cmos levels. 74HCT245 is apparently more common as more vendors stock them, it is probably deemed a 'generic' ('general purpose') chip to have around to meet arbitrary line buffering/interfacing requirements. 74HCT245 is 'bidirectional', but 'bidirectional' is quite 'useless' in this context, but it is useful when used as a switched bus.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: 74HC(T)245 interfacing 5v cifcuits e.g. driving 5v logic level mosfets

Post by ag123 »

i studied the ramps board a 2nd time

apparently the mosfet section has no dependency on 5v vcc
ramps mosfet section
ramps mosfet section
mosfet.png (31.97 KiB) Viewed 3622 times
https://reprap.org/wiki/RAMPS_1.4
https://github.com/bigtreetech/ramps-1.6

the resistors etc are however sized for a 5v board.
this could mean i can run the ramps board at just 3.3v (besides the mosfets) !

i'm going to try this 1st, it removes all the 'level shifting' requirements except for the mosfets.
stm32 straight to ramps !
.rpv
Posts: 43
Joined: Wed Dec 18, 2019 10:19 pm

Re: 74HC(T)245 interfacing 5v cifcuits e.g. driving 5v logic level mosfets

Post by .rpv »

Is your board like this:

https://raw.githubusercontent.com/bigtr ... 2B-SCH.pdf

?

if so you can connect vcc to 3v3, all but the mosfet should work with 3v3 as VCC, you just need to level up the PWM to 5v, this also because the thermistors are connected to VCC and those are direct connected to the analog pins on the mcu.

Also, you should double check if the mosfets on your board are logic level suitable, on the schematic the mosfets are: STP55NF06 and those are OK with 5v PWM.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: 74HC(T)245 interfacing 5v cifcuits e.g. driving 5v logic level mosfets

Post by ag123 »

thanks @.rpv
my board is just 1 version earlier than the 1.6+, it is 1.6 without the +
https://github.com/bigtreetech/ramps-1. ... iagram.pdf

the board with + is intended for slightly different (better?) trinamic tmc2130 drivers with spi
https://www.trinamic.com/products/integ ... s/tmc2130/
https://www.aliexpress.com/item/32970150483.html

these are somewhat pricier compared to tmc2208, tmc2209 etc
https://www.aliexpress.com/wholesale?ca ... xt=tmc2208

after i studied the details, tmc2130 is capable of being driven completely from spi, that is a very good thing.
unfortunately, the software based digital control protocol and registers for tmc2130 is not documented, instead, 1'd need to get a tmc4361 to pair up with it.
https://www.trinamic.com/products/integ ... c4361a-la/

after some considerations, i decided to get with the 'cheaper' tmc2208, tmc2209 and even plain old A4988 as the spi based tmc2130 offers very little more than tmc2208 without the spi based motor driver based protocol.

if this works i'd just have to worry about the mosfets, interfacing circuits are significantly simplier, reducing to just needing to interface just 3 mosfets

edit:
oops incorrect, TMC2130 can be controlled via spi, at least a register is made known, the rest (the motor ramp waveforms) have to be 'reverse engineered'
https://github.com/teemuatlut/TMC2130Stepper/issues/68
https://github.com/teemuatlut/TMC2130Stepper
but that means it will be a big win if you use something like stm32f4xx with high speeds floating point, as you can calculate all the motor waveforms sine/cosine and all on the fly and run them all only over spi ! that reduce 12 interfacing pins (EN, STEP, DIR x X,Y,Z,E) to just 7

ramps 1.6+ is worth buying with tmc2130 as controllers. the tmc2130 drivers are the most expensive components (premium for all that features)
https://www.aliexpress.com/item/32922663535.html
note though that 1 may need to do a lot of 'reverse engineering' needed for the motor driving waveforms, there doesn't seem to be a documented implementation.
but one can fallback to the 'legacy' (common today) step, dir modes with all the extra wires, and additional driver config over spi
Post Reply

Return to “Off topic”