Resetting esp32
Resetting esp32
I have what I think is the minimal circuit to run a motor off a battery using a esp32 on wifi. I suppose I could eliminate the charging board for the lifepo4, but I don;t think it makes any difference. I have the esp32 (wemos mini d1, but same happens with nodemcu) serving a web page with faster/slower buttons and all that seems fine, it gives the right feedback and the response of the motor is as expected.
When I set it to run faster it just stops. I get a boot message and it starts again and works fine again until I turn up the speed.
What I don't understand is I thought the idea of the motor controller was to avoid these things interacting, ie the motor can draw power from it's battery, and same for the esp32. But it seems the more the motor draws the more likely the esp to reset.
I'm a decent enough programmer, but it's the hardware side I'm struggling with. I have seen advice about putting capacitors across the power input to the esp32. I might try that at some point it seems I would need two capacitors a 104 and a larger one. And some people mention a Schottky diode. I'd rather get it right first time
Any help appreciated.
Rob
When I set it to run faster it just stops. I get a boot message and it starts again and works fine again until I turn up the speed.
What I don't understand is I thought the idea of the motor controller was to avoid these things interacting, ie the motor can draw power from it's battery, and same for the esp32. But it seems the more the motor draws the more likely the esp to reset.
I'm a decent enough programmer, but it's the hardware side I'm struggling with. I have seen advice about putting capacitors across the power input to the esp32. I might try that at some point it seems I would need two capacitors a 104 and a larger one. And some people mention a Schottky diode. I'd rather get it right first time
Any help appreciated.
Rob
- Attachments
-
- curcuit diagram.jpg (107.09 KiB) Viewed 8749 times
Re: Resetting esp32
You didnt post any logs, but is there printed by any chance log like this one?
Code: Select all
Brownout detector was triggered
Re: Resetting esp32
The motor and esp each have their own battery, but GND is connected. The motor is inductive, from a changing load or speed it can dip or spike it's power supply. Perhaps it is dumping energy into GND which raises it's potential, decreases the gap between GND and vdd giving you temporary low voltage.
Definitely look for the brownout detector as chegewara mentioned, that is the clearest indicator the esp saw low voltage and panicked.
If you have a scope, probe what your 3.3v to the esp is doing.
Usually things with motors like power tools have pretty large caps across the motor terminals, over 100uF electrolytic. 104 (0.1uF) is tiny.
It also helps to have bypass caps near the esp32, ideally one .1uF and one 1uF, close as possible to the vdd pins.
You could also do something like an optoisolator for your pwm signals so that the motor and esp circuit are truly isolated.
Definitely look for the brownout detector as chegewara mentioned, that is the clearest indicator the esp saw low voltage and panicked.
If you have a scope, probe what your 3.3v to the esp is doing.
Usually things with motors like power tools have pretty large caps across the motor terminals, over 100uF electrolytic. 104 (0.1uF) is tiny.
It also helps to have bypass caps near the esp32, ideally one .1uF and one 1uF, close as possible to the vdd pins.
You could also do something like an optoisolator for your pwm signals so that the motor and esp circuit are truly isolated.
Re: Resetting esp32
I did expect to see the brownout message, but it is not there. So I am not really sure why it resets. I think it reboots twice, and then works. I am very new to this. I've broken a couple by forgetting to disconnect the usb when I put a 9v battery on v5.0 (hopefully I am getting wiser ).
I am away from this for today, but will put the logs up when I get back to it. At first it was gibberish until I realised there must be a default baud rate and used that for my serial message, so I could see the error. Living and learning
The previous message look like useful things to pursue. I think as I'm running it on v3.3 there is little leeway. Having said that it does it on usb too, and if I put 9v in the v5.0 pin.
I have some bigger capacitors to try.
I assume isolating the grounds would be a bad idea?
Ideally I would run the whole thing off one lipo battery, but I do like the idea that the lifepo4 is always in the voltage range for the v3.3 pin.
I am away from this for today, but will put the logs up when I get back to it. At first it was gibberish until I realised there must be a default baud rate and used that for my serial message, so I could see the error. Living and learning
The previous message look like useful things to pursue. I think as I'm running it on v3.3 there is little leeway. Having said that it does it on usb too, and if I put 9v in the v5.0 pin.
I have some bigger capacitors to try.
I assume isolating the grounds would be a bad idea?
Ideally I would run the whole thing off one lipo battery, but I do like the idea that the lifepo4 is always in the voltage range for the v3.3 pin.
Re: Resetting esp32
Just to clarify the motor is a 0 - 6v "high torque" motor. It is in a garden railway loco and the standard set up for the kit would just be an on/off switch giving 3v. So it is not a big motor.
Another thought. Could it be the mini motor controller is not as well behaved as a bigger one? I have a bigger one with heat sink etc, and if memory serve this had the same fault early on. Apologies, I have tried a few things starting with it all on a breadboard with a nodemcu and now it is installed in a loco with a d1 and different batteries and different motor controller. None of the configurations have been free of this problem, so I clearly misunderstand something.
Another thought. Could it be the mini motor controller is not as well behaved as a bigger one? I have a bigger one with heat sink etc, and if memory serve this had the same fault early on. Apologies, I have tried a few things starting with it all on a breadboard with a nodemcu and now it is installed in a loco with a d1 and different batteries and different motor controller. None of the configurations have been free of this problem, so I clearly misunderstand something.
Re: Resetting esp32
You need a bulk cap for the motor V+ supply, try that first. If you look at the L298N datasheet pg 8, it shows a 470uF cap.
And in this article, the module he's using has a 220uF cap for each motor. https://lastminuteengineers.com/l298n-d ... -tutorial/
A larger motor controller would allow for higher sustained current, running a larger motor. If high current / heat dissipation is not your issue, a larger motor driver probably wouldn't address it.
And in this article, the module he's using has a 220uF cap for each motor. https://lastminuteengineers.com/l298n-d ... -tutorial/
A larger motor controller would allow for higher sustained current, running a larger motor. If high current / heat dissipation is not your issue, a larger motor driver probably wouldn't address it.
Re: Resetting esp32
Hi Becorey. I didn't understand.
My motor should go in both directions, do I put the capacitor on the input to the motor controller, or can I get a big enough one to go on the motor which does not have polarity? The diddy one across the motor terminals is to reduce noise, I'm not expecting it to smooth the load, sorry I should have been clearer about that. Again I don't know if that is necessary or the right way to address that problem. It is all stuffed into quite a small space and I don't know if noise from the motor could even cause a microprocessor to reset.
The link did not mention a capacitor (although it was very interesting). Was that the right url?
Rob
My motor should go in both directions, do I put the capacitor on the input to the motor controller, or can I get a big enough one to go on the motor which does not have polarity? The diddy one across the motor terminals is to reduce noise, I'm not expecting it to smooth the load, sorry I should have been clearer about that. Again I don't know if that is necessary or the right way to address that problem. It is all stuffed into quite a small space and I don't know if noise from the motor could even cause a microprocessor to reset.
The link did not mention a capacitor (although it was very interesting). Was that the right url?
Rob
Re: Resetting esp32
Here are the reset codes, mixed in with a few message of my own to try and see what is going on
- v100
- message incoming v100
- sent the data
- ets Jun 8 2016 00:22:57
- rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
- configsip: 0, SPIWP:0xee
- clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
- mode:DIO, clock div:1
- load:0x3fff0018,len:4
- load:0x3fff001c,len:1044
- load:0x40078000,len:8896
- load:0x40080400,len:5816
- entry 0x400806ac
- ets Jun 8 2016 00:22:57
- rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
- configsip: 0, SPIWP:0xee
- clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
- mode:DIO, clock div:1
- load:0x3fff0018,len:4
- load:0x3fff001c,len:1044
- load:0x40078000,len:8896
- load:0x40080400,len:5816
- entry 0x400806ac
- 6
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- server is:
- 192.168.1.17
Re: Resetting esp32
Yes, put the bulk cap on the input to the motor driver. Electrolytic caps have polarity and also tons of capacitance in small space. Think of the motor driver as just redirecting the input DC voltage to the positive or negative motor terminal to control direction (and also pwm to control speed). So a cap across the motor terminals would see flipping polarity. But a cap from the VCC driver supply to GND will always have the same polarity applied.
The article doesn't talk about the cap but it had a good photo of the board, that's why I linked it, but it doesn't directly talk about the bulk capacitance issue.
The article doesn't talk about the cap but it had a good photo of the board, that's why I linked it, but it doesn't directly talk about the bulk capacitance issue.
Re: Resetting esp32
OK. I now understand there is a capacitor on each type of l298n I have used. The one I have been using is 100 and the other with the heatsink has bigger capacitors.
I now wonder if this is why the motor can run fast for a bit, perhaps during that time the capacitor on the motor controller discharges, and then it starts drawing current from the esp32 power source.
I can put a bigger capacitor on the power supply of the controller, I'll post results here.
I now wonder if this is why the motor can run fast for a bit, perhaps during that time the capacitor on the motor controller discharges, and then it starts drawing current from the esp32 power source.
I can put a bigger capacitor on the power supply of the controller, I'll post results here.
Who is online
Users browsing this forum: Baidu [Spider] and 43 guests