Firmware Support for L298H Bridge Boards?

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Firmware Support for L298H Bridge Boards?

#1 Post by Wookbert » 22 Oct 2021, 04:47

I need to control to small 12V DC motors with speed, direction and timer values, and could imagine using ESPEasy for that. I came across the L298N H Bridge board, which seem to be a good companion for my application.

Is this supported in firmware somehow, comparable to the Adafruit Motor Shield v2 plug-in?
HTB1GzhlajDuK1Rjy1zjq6zraFXaB.jpg
HTB1GzhlajDuK1Rjy1zjq6zraFXaB.jpg (110.57 KiB) Viewed 20319 times
HTB1WoXjacnrK1RjSspkq6yuvXXaP.jpg.png
HTB1WoXjacnrK1RjSspkq6yuvXXaP.jpg.png (71.62 KiB) Viewed 20319 times

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#2 Post by Wookbert » 22 Oct 2021, 05:25

Actually, impatient as I am, just ordered two of these:
H3e244f695bb044a3a59ab2050b232237y.jpg
H3e244f695bb044a3a59ab2050b232237y.jpg (127.98 KiB) Viewed 20316 times
H02a691be618a408080e9c3f4f3ecdd224.jpg
H02a691be618a408080e9c3f4f3ecdd224.jpg (295.36 KiB) Viewed 20316 times
He87df4f5e5d0492389d4355368580f01w.jpg
He87df4f5e5d0492389d4355368580f01w.jpg (230.45 KiB) Viewed 20311 times

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Firmware Support for L298H Bridge Boards?

#3 Post by TD-er » 22 Oct 2021, 10:24

Working on it: https://github.com/letscontrolit/ESPEasy/pull/3658
I have actually used the last board you showed for my development.
The idea is to use motors with some kind of encoder to be able to use commands to move to a position, or move till you hit a limit switch.
Also allows speed control, but not yet with PID controlled motor steering based on the encoder feedback.

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#4 Post by Wookbert » 25 Oct 2021, 14:02

I need it to control runtime and speed of a magnetically driven impeller inside an 18 Liter Isopropanol-filled container to wash 3d resin printed parts prior to UV curing.

It would be nice if you add a soft-start option, where one can set the target speed/% value and a number of seconds it takes to accelerate to that speed. Furthermore:
  • Reverse direction after X seconds.
  • Runtime per direction.
  • Number of repetitions.
Any idea when to expect it? Could use it immediately. 🙃 Happy to beta test.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Firmware Support for L298H Bridge Boards?

#5 Post by TD-er » 25 Oct 2021, 15:15

Softstart/stop is not yet present, but you can start/stop it from the rules.
So the reverse after N seconds could be easy to do in the rules by setting a timer.
I guess if you need it for dosing, it is better to use a pulse counter on the motor shaft instead of time based.
And that's what is already implemented in that plugin.
This way it is not related to the mechanical load on the motor, but just the same number of rotations (with some margin due to reaction speed)

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Firmware Support for L298H Bridge Boards?

#6 Post by ThomasB » 25 Oct 2021, 19:42

Any idea when to expect it? Could use it immediately.
If TD-er's plugin is not yet available then consider using nothing but rules to control the DC motors. The L298H works with common GPIO. Two bits per H-Bridge for direction, speed is available by using PWM.

- Thomas

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#7 Post by Wookbert » 28 Oct 2021, 18:02

So here’s my intended design:
Washing Station Impeller Controller.png
Washing Station Impeller Controller.png (154 KiB) Viewed 20106 times
Does this work? Am I missing something? Questions are:
  • Do I need to implement a 3V3<–>5V Logic Level Shifter between the ESP’s GPIO pins and the L298N’s control pins? Got a TXS0108E board at hand.
  • Do I need to add external pull-down resistors on those two Motor Start/Stop buttons?
TIA!

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Firmware Support for L298H Bridge Boards?

#8 Post by ThomasB » 28 Oct 2021, 19:12

Does this work? Am I missing something?
1. D0 (Piezo drive) does not support PWM. So swap it with D8 (ensure motor 2 Start switch is open at boot!). Change 220 ohm to higher value, 4.7K - 10K ohms.
2. D1 & D2 will float during boot/reset, which may cause motors to momentarily run. Install 10K pull-down resistors to prevent this.
3. The L298N Module's 5V output is being used to power the D1 Mini. Check during all operational modes and confirm the VReg IC does not run too hot. Worse case (WiFi initialization) is ~1.5W heat, but runtime should be OK.
Do I need to implement a 3V3<–>5V Logic Level Shifter between the ESP’s GPIO pins and the L298N’s control pins?
L298N inputs are 3.3V compatible. Level shifting unnecessary.
Do I need to add external pull-down resistors on those two Motor Start/Stop buttons?
Assuming you swap D0/D8 (Switches on D0 & D7):
If the wires are short then using internal pullups should be fine. If wires are long, or excessive e-noise causes false switch operation, then add external 10K ohm pullups.

- Thomas

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#9 Post by Wookbert » 28 Oct 2021, 21:04

So, here’s the revision based on Thomas’ feedback. Better?
I’ll attach a small heat sink to the L298N’s Vreg, just to be on the safe side.
Washing Station Impeller Controller (Rev-B).png
Washing Station Impeller Controller (Rev-B).png (834.18 KiB) Viewed 20082 times

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Firmware Support for L298H Bridge Boards?

#10 Post by TD-er » 28 Oct 2021, 21:32

Maybe also try to twist the cables to the motor(s) and to the switches.
This to make sure the switches will not pick up the electric noise generated by the motors.

Don't twist the wires to the limit switches and the motors in the same bundle and perhaps add some variation in the nr of twists per unit of length for both sets of wires.

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Firmware Support for L298H Bridge Boards?

#11 Post by ThomasB » 28 Oct 2021, 21:40

@TD-er mentioned that his plugin will be able to support an encoder. This design doesn't have the spare I/O for that. But if needed, you can incorporate an I2C I/O expander and rearrange the existing I/O.

BTW, the IRLZ44 is a big boy that can handle a lot of Amps. If you need to free up board space then consider using a 2N7000 series MOSFET (TO-92 or SOT-23 pkg).

- Thomas

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Firmware Support for L298H Bridge Boards?

#12 Post by TD-er » 28 Oct 2021, 22:01

You can also simplify the limit switching a bit.
For example just add a diode over the limit switch on 1 end to make sure the motor can only reverse when that limit switch is hit.
This also makes it a fail safe limit switch as it will never allow to get past the limit switch.
N.B. that limit switch is then in series with the motor, as is the diode, which is parallel to that switch.
Then you can still use the other limit switch as a "home" or "base datum" or whatever you call it.
On the other outer limit you can do the same with a normal-closed limit switch and a diode in the other direction parallel to that end switch.

This way you can use a single GPIO pin for determining your "zero position" and have a pin free for use with an encoder.

I mainly tested it with an ESP32, as that one has more GPIO pins.
But it will also work on an ESP8266. Only drawback is then the pulse counting, which takes slightly more resources on an ESP8266. But on the other hand, if you are running out of GPIO pins anyway, does that really matter?

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Firmware Support for L298H Bridge Boards?

#13 Post by ThomasB » 29 Oct 2021, 00:30

Assuming its needed, another way to free up GPIO pins is to use a different H-Bridge motor controller module. The L298 is a very old chip and there are newer choices out there.

For example, the first posted image at the top of this discussion is a board that uses a pair of TA6586 H-bridge chips. It requires only four control lines to control two motors, which saves two GPIO for other things. Also, there are DC motor control ICs out there that can do it via two wires (I2C), which would further reduce I/O pins count.

But it appears that this project is a motor driven solvent stirrer that will be used to wash-off SLA resin. So it's doubtful encoders or limit switches are needed. But good to know that if some extra I/O pins are required then there are "easy" solutions to make it happen.

- Thomas

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#14 Post by Wookbert » 29 Oct 2021, 11:28

Those two switches aren’t limiter switches, but simply push buttons to start the timer.

This setup is for impellers at the bottom of two 18 liter containers filled with isopropanol, which are driven – magnetically attached – by geared, 210 rpm max. DC motors below the containers.

The messy 3d resin print will hang upside down in the container. On pushing the button the impeller will start the motor for 2 minutes, where at halftime the motor will reverse direction in order for the Isopropanol to reach recesses opposite the twirl direction.

Once started the push button acts as emergency stop.

First container is for coarse wash, second for fine & clean wash.

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#15 Post by Wookbert » 29 Oct 2021, 17:32

ThomasB wrote: 29 Oct 2021, 00:30 For example, the first posted image at the top of this discussion is a board that uses a pair of TA6586 H-bridge chips. It requires only four control lines to control two motors, which saves two GPIO for other things. Also, there are DC motor control ICs out there that can do it via two wires (I2C), which would further reduce I/O pins count.
Well, thank you for putting that idea into my head. 😩👹🤪 I would indeed have use for extra GPIOs: There’s also the timer for the UV-LEDs of my Wash & Cure station. Thankfully that ZK-5AD board (based on those TA6586) isn't available on Amazon nor ebay here in Germany, so it'll arrive in 3-4 weeks from AliExpress earliest, which makes me force to work with the L298N board meanwhile. Needless to say that I ordered the ZK-5AD anyway (USD 3.73 incl. shipping is a no-brainer).

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#16 Post by Wookbert » 29 Oct 2021, 22:28

ThomasB wrote: 28 Oct 2021, 19:12 1. D0 (Piezo drive) does not support PWM. So swap it with D8 (ensure motor 2 Start switch is open at boot!). Change 220 ohm to higher value, 4.7K - 10K ohms.
2. D1 & D2 will float during boot/reset, which may cause motors to momentarily run. Install 10K pull-down resistors to prevent this.
Can I replace all 10K resistors (including those for pull up and pull down) with 4.7K? I have plenty of 4.7K ones laying around, but no 10K at hand. No problem though, if needed, electronic component retailer is just a 10 minute walk down the street.

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Firmware Support for L298H Bridge Boards?

#17 Post by Ath » 29 Oct 2021, 22:30

Energy consumption will be slightly higher, but that walk to the store will probably cost you more energy :lol:
/Ton (PayPal.me)

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#18 Post by Wookbert » 29 Oct 2021, 22:38

I might need to walk anyway, as I’m thinking about getting a small heat sink for the Vreg. No idea how critical that is.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Firmware Support for L298H Bridge Boards?

#19 Post by TD-er » 29 Oct 2021, 22:47

Average current will be around 100 mA.
Thus if you use a linear voltage regulator from 12V to 5V, you will see a drop of 7V.
It will generate 0.7Watt of heat.

78Mxx modules have a worst case thermal resistance of 100 degree C/Watt.
So at 0.7 Watt, the junction temperature can be as high as 70C above ambient temperature.
But it is soldered to a larger copper trace, thus it will have a lower thermal resistance.
Hard to say how much lower.

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Firmware Support for L298H Bridge Boards?

#20 Post by ThomasB » 29 Oct 2021, 23:01

My 2 cents:
Can I replace all 10K resistors (including those for pull up and pull down) with 4.7K? I have plenty of 4.7K ones laying around, but no 10K at hand.
4.7K will be fine. Not worth the time to walk to the store to buy 10K values. But that's a very popular resistor value, so next time you order parts put some 10K 1/8W resistors on the list.
I’m thinking about getting a small heat sink for the Vreg. No idea how critical that is.
Not expected to be needed. Wait and check the VReg during use, then decide if it needs a heatsink. I suspect worst case will be when the WiFi router signal is missing for extended time, so check that condition too.

- Thomas

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#21 Post by Wookbert » 30 Oct 2021, 02:17

Sorry to pester you again, but I have little to no clue on electronics:
  • That IRLZ44 looks a bit overkill to me. Can I use something smaller/cheaper in TO-92-3 package? BC547C? BC548C? BC337-40?
  • Also: Which diode exactly?

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Firmware Support for L298H Bridge Boards?

#22 Post by ThomasB » 30 Oct 2021, 03:10

That IRLZ44 looks a bit overkill to me. Can I use something smaller/cheaper in TO-92-3 package? BC547C? BC548C? BC337-40?
Any small signal general purpose N-Channel MOSFET is fine. For example, the popular 2N7000 series is available in TO-93.
Or a small signal BJT (NPN), such as BC547 / BC548 / 2N2222 / 2N3904 / etc can be used. With these choices I'd reduce the base resistor value (use 2.2K to 4.7K ohms).
Which diode exactly?
Nothing special, a 1N400x series diode is commonly used for flyback protection on small inductive loads. But if the "buzzer" is Piezoelectric, rather than Magnetic, then feel free to omit the diode since it won't be needed. BTW, the info I found on the SFM-27 Buzzer (P/N on your schematic) says it is Piezo.

- Thomas

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#23 Post by Wookbert » 12 Nov 2021, 01:39

So based on Thomas’ explanations, I replaced the L298H board with a ZK-5AD, which contains two TA6586 H-bridges, and requires only 4 GPIOs instead of 6. Board arrived yesterday. Here’s the revised/resulting schematic. If understood correctly the Wemos relay shield, which I added to switch the UV-LED curing section, already has the 10K pull down resistor on board (see schematic here).

Each motor draws approx. 450 mA @ 12.25V, full workload. Shouldn't be a problem for the ZK-5AD, which is rated at 5A continuous and 9A peak (per motor or in total?).

Any faults?
ZK-5AD based Wash & Cure schematic.png
ZK-5AD based Wash & Cure schematic.png (343.81 KiB) Viewed 19369 times

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Firmware Support for L298H Bridge Boards?

#24 Post by ThomasB » 12 Nov 2021, 05:01

I noticed that the relay shield is setup to use GPIO-D1, but your design has it on D2. So I suggest revising the drawing by swapping D1 with D2 (on the Wemos). That will allow the relay shield's signals to mate correctly with the Wemos D1 Mini.
If understood correctly the Wemos relay shield, which I added to switch the UV-LED curing section, already has the 10K pull down resistor on board
Great.

The Relay board's status LED has a 10K current limit on it. With a 3.3V control signal, that little LED might be too dark to see without night vision goggles. :)

- Thomas

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Firmware Support for L298H Bridge Boards?

#25 Post by TD-er » 12 Nov 2021, 08:58

One other thing...
If you're using that specific DC/DC converter as shown in the schematic, then make sure to pour in some nail polish on the trimmer after you set it to 5V.

Looked through the chosen GPIOs and they seem OK to me. (Disclaimer: still on my first cup of coffee of today)

Oh and about the H-bridges.
I looked through the datasheet and although it states to be able to handle 5A of current, I really doubt it can that much current in that package. (can't dissipate heat very well and the pins are rather thin for such currents)
450 mA is fine and the current during startup will probably be even more, but still nowhere near the absolute max rating of 9A.

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#26 Post by Wookbert » 12 Nov 2021, 10:56

ThomasB wrote: 12 Nov 2021, 05:01 I noticed that the relay shield is setup to use GPIO-D1, but your design has it on D2. So I suggest revising the drawing by swapping D1 with D2 (on the Wemos). That will allow the relay shield's signals to mate correctly with the Wemos D1 Mini.
The relay shields I have are version 2, which can be configured through a solder bridge on which pin to use:

Image
ThomasB wrote: 12 Nov 2021, 05:01 The Relay board's status LED has a 10K current limit on it. With a 3.3V control signal, that little LED might be too dark to see without night vision goggles. :)
The 3v3 pin on the v2 relay shield isn't even connected, when looking at the PCB traces. LED works properly with 5V, but isn't need in my installation anyway.

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#27 Post by Wookbert » 12 Nov 2021, 11:57

To make things more complicated: The 3 push buttons shown in my diagram are optionally LED backlit. It would be a nice UI gimmick, if they e.g. would blink/pulse when the respective controlled device is running (so IPA washer motor/UV LED chamber). As all GPIO are occupied, question is how this could be solved.

My thought would be to attach a PCA9685 board, but which of the existing GPIOs connection could be relocated to this board in order to free two GPIOs on the ESP8266 required make room for the PCA9685? The 3 push buttons for motor/relay control probably not, but what about the 4 motor control GPIOs?

Or should I better switch to an ESP32 board, which has more GPIOs if I see it correctly? But ESPEasy is very experimental on that, as I read in the Wiki.

Image

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Firmware Support for L298H Bridge Boards?

#28 Post by Ath » 12 Nov 2021, 13:10

What you read on the Wiki is ca. 3 or 4 years old, that is no longer maintained, so mostly outdated.
ESPEasy on the (regular) ESP32 is very stable, it is the, stIll rather rare, ESP32-S2 that's not very stable yet, partly because of issues/instability in the Arduino base libraries for that model.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Firmware Support for L298H Bridge Boards?

#29 Post by TD-er » 12 Nov 2021, 14:19

Yep, ESP32 is good to go.
ESP32-S2 is "experimental" right now, but based on Ton's surprise last night when I wrote about my doubts on its stability, I guess that's also slightly less experimental than expected :)
At least the ESP32-S2 does have even more GPIO pins, so you might already want to order one for later (not yet to be used in projects which leave the desk)

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#30 Post by Wookbert » 12 Nov 2021, 16:19

Just ordered this ESP32 NodeMCU v1. Proper choice?

S2 = v2? Saw that there are NodeMCU boards v1, v2, v3 and even v4 available... Pretty confusing, as the ESPEasy hardware compatibility list doesn't list v1, but only v2 and v3.

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Firmware Support for L298H Bridge Boards?

#31 Post by Ath » 12 Nov 2021, 16:43

S2 is the ESP32-S2, a different chip from the 'regular' ESP32, that has only 1 core, but more GPIO pins, but as said, 'experimental' support in ESPEasy, not yet ready for prime-time, but usable for workbench tests.
There is a NodeMCU with ESP32-S2 available, like here and here (that''s very similar to my test unit, the Saloa 1R, with on-board NeoPixel, almost usable to light up a room :lol: )

For now, go with the regular ESP32 (4MB or 16MB Flash), that's tried and tested with ESPEasy.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Firmware Support for L298H Bridge Boards?

#32 Post by Ath » 12 Nov 2021, 16:43

Wookbert wrote: 12 Nov 2021, 16:19 S2 = v2? Saw that there are NodeMCU boards v1, v2, v3 and even v4 available... Pretty confusing, as the ESPEasy hardware compatibility list doesn't list v1, but only v2 and v3.
Again, outdated documentation.
/Ton (PayPal.me)

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#33 Post by Wookbert » 12 Nov 2021, 16:49

Googled and also realized that ESP32-S2 means a different Espressif chip. But again: What about the different NodeMCU board versions? Is the v1 I just ordered good to go? Or why better go for v2 or v3?

Also: Where can I find info on the boot state of the individual pins (high vs. low) of the ESP32 NodeMCU board under ESPEasy?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Firmware Support for L298H Bridge Boards?

#34 Post by TD-er » 12 Nov 2021, 16:59

That V1 version you linked looks OK.

Just make sure not to buy the NodeMCU like board which has yellow pin headers.
Not that the yellow pin headers are bad, but there has been an apparently HUGE bulk of ESP32 nodes which were sold with yellow pin headers which does have some errors in the silk screen and some really odd design issues on the PCB.

I am running one here from that batch and it does work OK, but only when powered via USB (connected to a PC) and don't use the pins close to the USB port.

Something similar applies to those ESP32 boards in the much larger traditional Arduino board form factor. Those cannot be run from something like an USB power bank. You really have to connect them to a PC.
That powering issue is happening on quite a lot of ESP32 boards out there.


Another difference among ESP32 boards is the number of GPIO pins made available.
So you may want to check if the board you're looking at does have enough GPIO pins made available.
The one with the most pins I know of, has 38 pins., but there are ones with 30 pins.

Not all exta pins are usable though as they are connected to the flash chip.

Image


Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#36 Post by Wookbert » 12 Nov 2021, 17:02

Thank a lot! The new readthedocs documentation clearly lacks some pictures, that's why I most of the time fall back to the old wiki.

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#37 Post by Wookbert » 13 Nov 2021, 04:58

Sorry for pestering you folks, and once again thanks a lot for your patience and support! So, here’s the latest revision, now based on the ESP32. According to your Wiki section Best pins to use on ESP32, GPIOs 16 to 36 seem to be pretty unproblematic. 34,35, 36 (and 39) are input only, so I connected the push buttons to those. Hope that’s right.
  • Any obvious errors?
  • The status LEDs which came with the push buttons are 12V, but also run on 5V. Question is: Can I drive them directly from the GPIO pins? If so, resistors required? Or should I drive them with 12V using MOSFETs? (Got a bunch of NDP6020P laying around. Would those work?)
ESP32 + ZK-5AD based Wash & Cure schematic.png
ESP32 + ZK-5AD based Wash & Cure schematic.png (537.07 KiB) Viewed 19237 times

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Firmware Support for L298H Bridge Boards?

#38 Post by ThomasB » 13 Nov 2021, 05:19

The status LEDs which came with the push buttons are 12V, but also run on 5V. Question is: Can I drive them directly from the GPIO pins?
Maybe. Connect each of them to 3V and see what happens. If they light up, and you like the brightness, then it is your lucky day.
If so, resistors required?
If they are rated for 12V then the current limit resistor is already installed. Its resistor won't be the correct value for a 3V application, but your ESP32 will be safe.
Or should I drive them with 12V using MOSFETs?
That should be your fallback plan. Would be great if you can avoid the extra parts.

A lot of features have been added since your first post. Are you sure that ESPEasy's rule pages will accommodate every feature you plan to code?

- Thomas

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#39 Post by Wookbert » 13 Nov 2021, 06:22

ThomasB wrote: 13 Nov 2021, 05:19 Connect each of them to 3V and see what happens. If they light up, and you like the brightness, then it is your lucky day.
The brightness is OK at 5V, but I assume that they might be too dark at 3V3.

ThomasB wrote: 13 Nov 2021, 05:19
Or should I drive them with 12V using MOSFETs?
That should be your fallback plan. Would be great if you can avoid the extra parts.
Well, got 10 pcs. NDP6020P at hand anyway. If they fit, that wouldn't be an issue.
ThomasB wrote: 13 Nov 2021, 05:19
Or should I drive them with 12V using MOSFETs?
A lot of features have been added since your first post. Are you sure that ESPEasy's rule pages will accommodate every feature you plan to code?
Not the slightest clue, to be honest. It'll be up to my partner in crime, and I could imagine that we come up with a couple of follow-up questions. 😃 In worst case I have to backpedal a bit feature-wise.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Firmware Support for L298H Bridge Boards?

#40 Post by TD-er » 13 Nov 2021, 11:22

Not sure if those "input only" pins can be set to have a pull-up resistor.
And if they can, those pull-up resistors are of quite high resistance.
So better add something like a 10k or 4k7 pull-up resistor on the GPIO pins of those switches.
Otherwise the cables running to the switches may act as an antenna.
Also a good idea to twist those cables to the switches if they are a bit longer. (whenever you can twist it, it is a good idea to do so)

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#41 Post by Wookbert » 13 Nov 2021, 19:12

TD-er wrote: 13 Nov 2021, 11:22 Not sure if those "input only" pins can be set to have a pull-up resistor.
Does this schematic and this schematic, respectively the ESP32-WROOM-32 datasheet answer that question?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Firmware Support for L298H Bridge Boards?

#42 Post by TD-er » 13 Nov 2021, 19:41

I meant in software.
I just checked in ESPEasy (Hardware tab) and there you can't select the pull-up resistors, so I am pretty sure there are none present in the ESP32 for those input-only pins.
This means you must add those yourself.

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#43 Post by Wookbert » 13 Nov 2021, 20:10

TD-er wrote: 13 Nov 2021, 11:22 Also a good idea to twist those cables to the switches if they are a bit longer. (whenever you can twist it, it is a good idea to do so)
As I'll also have the LED wires going to each button (so LED + switch signal): Are we talking 4x1 twisted or 2x2 twisted?

P.S.: My partner in crime is getting megalomaniac with the number of GPIOs available on the ESP32: Going to add two hall sensors to monitor the propeller speed 🤪

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Firmware Support for L298H Bridge Boards?

#44 Post by TD-er » 13 Nov 2021, 20:28

2x2 twisting.
Just twist the lines of related signals in both directions.
The idea is that when the line picks up a signal, it may add to the voltage on that line. However if it is twisted, the same disturbance signal is inverted in the next half of the twist.
So the netto added signal is close to 0.

The ESP32 is capable of accurately measuring quite high frequencies.
I tested it with a signal generator and upto 200 kHz was no problem at all.
Above is probably still not a problem, but then the resolution of the internal timing may attribute a lot to the calculated frequency so it showed quite an offset in reported frequency.
Also the quality of the used cables then may start to play a role. Having 30cm breadboard wires attached to crocodile clamps on a desk filled with running ESP boards is probably not the most clean setup for this :)

I don't know how fast a Hall effect sensor may react and I don't know what the effect of fast moving magnets is near electronic circuits... Well I do have some idea about it and I don't think it is a very good idea ;)
Maybe adding a light diode and a LED to count pulses is a better idea?
Either reflective or counting passages of a hole.

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#45 Post by Wookbert » 13 Nov 2021, 21:06

TD-er wrote: 13 Nov 2021, 20:28 I don't know how fast a Hall effect sensor may react and I don't know what the effect of fast moving magnets is near electronic circuits... Well I do have some idea about it and I don't think it is a very good idea ;)
Maybe adding a light diode and a LED to count pulses is a better idea?
Either reflective or counting passages of a hole.
We’re getting nowhere near those 200 kHz: The motor does 210 rpm max (without load) and the propeller is magnetically attached (through the bottom of the container and the board on which the container sits and under which the motor is mounted) with 5 magnets. So 1.050 impulses/minutes at worst.
IMG_1886.JPG
IMG_1886.JPG (847.85 KiB) Viewed 19105 times
IMG_1888.JPG
IMG_1888.JPG (1.26 MiB) Viewed 19105 times
IMG_1890.JPG
IMG_1890.JPG (472.69 KiB) Viewed 19105 times
Here’s a video showing my PoC and measurement of the current under load:
https://www.youtube.com/watch?v=lSUYcrrn7t4

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Firmware Support for L298H Bridge Boards?

#46 Post by ThomasB » 13 Nov 2021, 21:12

My 2-cents regarding the wire twisting: If you are extending the switch's GPIO input wires over a long length, then twist. Plus use low value pull-ups (1K - 2.2K) installed close to the ESP32. However, if all this stuff is going in the same enclosure, and the input wire lengths are just a few cm long, then twisting is rarely needed.
Well, got 10 pcs. NDP6020P at hand anyway. If they fit, that wouldn't be an issue.
Those are 24A rated P-Channel. Not the best choice. I suggest a N-Channel MOSFET. Since you only need to control the LED the current rating can be small. I'm a fan of the 2N7000 for this application. As an alternative, an NPN such as 2N2222 is a common choice. Plenty of equivalents out there, just check your parts inventory for something similar.

If you decide to install a driver transistor then I recommend powering the "12V" rated LED with 12V rather than 5V. This will provide max brightness and eliminate the current draw from the 5V VReg.

- Thomas

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#47 Post by Wookbert » 15 Nov 2021, 05:38

Boy, this is getting crazy.... Here’s the latest revision.

We (myself and my mentioned partner in crime) also came to the conclusion that Arduino is probably the better platform to implement all those features. Still we'd appreciate your feedback/input.
  • Hall Sensors: We've seen that the majority of those sensor have an operating voltage starting at 4.5V. In that case we'd connect them to Vcc 5V and put a 5–>3V3 level shifter between the Hall Sensors and the ESP’s GPIOs. We are however looking at sensors which work with 3V3, which is why there is no level shifter and why they are connected to 3V3.
  • GND from the ZK-5AD Motor Driver Board is now additionally connected to the ESP32’s GND pin. Recommendable?
  • Instead or wiring a battery of individual MOSFETs, we came up with the ULN2003 Darlington array.
myWaCS Schematic Draft 2021-11-15.png
myWaCS Schematic Draft 2021-11-15.png (2.42 MiB) Viewed 19029 times

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Firmware Support for L298H Bridge Boards?

#48 Post by TD-er » 15 Nov 2021, 09:09

Level switching of a 5V input level should not be that hard to do, as it could be done with just a few resistors.
However, you may want to have a look at this topic: viewtopic.php?f=2&t=8737&p=54993&hilit= ... sor#p54993
This flow sensor also uses a hall effect sensor and it wasn't as easy to connect as one would expect.

And about being 5V tolerant, see this topic started by ThomasB: viewtopic.php?f=5&t=8845

Just curious, why do you want to implement all from scratch in Arduino? What is ESPEasy missing here?

Wookbert
Normal user
Posts: 132
Joined: 06 Nov 2020, 03:17

Re: Firmware Support for L298H Bridge Boards?

#49 Post by Wookbert » 15 Nov 2021, 14:32

Hall Sensors
Well, those are totally new to me personally, will have to see how that works. Saw that there are for different types: bipolar, unipolar, omnidirectional and linear. The first two I understand, the second two I couldn't find any video explanation.

The magnets in the wheel which drives the propeller have all the same orientation, and/but are pretty strong. Just have to see how sensitive the hall sensor is, also to the magnetic field of the nearby motor (see above pictures).

I’ll get the AH3661, as it's the cheapest sensor working with 3V3, which I can pick it up down the road.

Arduino vs. ESPEasy
We intend to create a simple Browser-based UI using Web sockets for setting the parameters such as timers, motor speed etc. The problem is that with ESPEasy this wouldn't be self-hosting and instead require an external server. If I understood my PiC correctly with Arduino it could be self-contained. Also we aren't sure if everything we have in mind can be achieved via ESPRules.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Firmware Support for L298H Bridge Boards?

#50 Post by TD-er » 15 Nov 2021, 14:50

Hall effect sensors are typically just an analog sensor.
Meaning the output is proportional to the magnetic field.
However for some applications you would rather have quite a discrete signal difference between field present and not present.
Thus the response is either linear or it is made more logarithmic.

The material used in a hall effect sensor reacts to a magnetic field.
For your use case I think you will need a sensor which is more directional, or else it is really hard to distinguish a magnet close to the sensor or on further away.
A directional hall effect sensor does have some ferrite core embedded in the sensor to make it more directional sensitive.

For a more flexible approach to operate the ESPeasy node, you may also want to have a look at the "dashboard" feature.
It isn't documented very well, but there was quite some activity to implement a nice dashboard here on the forum lately.
You can create events, which can be used to control settings, send commands etc.

Post Reply

Who is online

Users browsing this forum: No registered users and 36 guests