[Solved] Why ACS70331 and ACS712 make ESP32 crash when current changes?

human890209
Posts: 54
Joined: Wed Aug 15, 2018 8:56 am

[Solved] Why ACS70331 and ACS712 make ESP32 crash when current changes?

Postby human890209 » Wed Apr 15, 2020 2:10 pm

[Solved] DC motor without the spark cap crashed everything.

Hi, My ESP32 dev boad is MH-ET ESP32MiniKit.
Lately, I tried to use ACS70331and ACS712 to measure the current of my robot's DC motor. But ESP32 crashed when the current changed rapidly.

The motor's stall current I measured from my multimeter is about 1.6~2A. So first I tried ACS70331-2P5B3 which range is -2.5A~+2.5A and a 3.3V sensor.
The current result is good when the motor has no load or small load. Everything is fine, the system never crashed. But I tried to put some friction to the wheel with my hand to test and even stop the wheel to make the motor stall. If the current of the motor changed severely by hold and release the wheel repeatedly. ESP32 crashed with random reasons like invalid instruction, load prohibited, write prohibited, watchdog... on core 1 or core 0 cause I use both cores for my robot system.
I checked with the backtraces of the reboot report. And the last function is unreasonable. I thought there should be a hardware failure.

And I tried to use the ADS1015 module to test the voltage of ACS70331. But ESP32 still crashed. And I found out even I tried not to connect the wire between ACS70331's output pin and ADS1015's input pin. ESP32 also crashed. It was not about ADC values at all.
I only connected ACS70331's GND pin to my ESP32 system's GND and used a separate battery to supply voltage for the ACS70331. The current change also crashed ESP32.
And I add an extra battery to supply power for my ESP32MiniKit board to help the USB cable. Nothing changed. ESP32 crashed easily.
Then I thought maybe my ACS70331 sensor was broken, I replaced it with a new chip, but the problem still existed.

I replaced ACS70331 with ACS712-05B which is -5A~5A 5v sensor.
I used a voltage converter to set ADS1015 into the 5V stage and measured ACS712-05B's output with it. The result is good for a small load just like ACS70331. But the 'heavy-duty' test also made the ESP32 crash. But the chance is smaller, about 20% of ACS70331. ESP32 seemed tougher with ACS712.
I tested with ACS712-30A which is -30A~30A range 5V sensor, ESP32 also crashed. It felt like the same as ACS712-05B.

By the way, If I hold the wheel to stall the motor for a couple of seconds, the value result is good and ESP32 won't crash. The current changing crashed ESP32.

And sometimes especially tested with ACS712 (ESP32 is tougher), the CP210X of ESP32MiniKit will crash first. I lost the serial connection to report the values. I added a simple blink to identify if ESP32 was still working, it seemed ESP32 did not reboot when Serial is down.
I tested ACS70331 again, I got a reboot report, ESP32 was down first.

What's the cause of the crash? How to deal with it?
Last edited by human890209 on Thu Apr 16, 2020 9:12 am, edited 1 time in total.

ESP_Sprite
Posts: 9577
Joined: Thu Nov 26, 2015 4:08 am

Re: Why ACS70331 and ACS712 make ESP32 crash when current changes?

Postby ESP_Sprite » Wed Apr 15, 2020 8:27 pm

I'm having a hard time believing the sensor itself makes the ESP32 crash; it's way more likely that the current through the sensor changes abrubtly enough to mess things up, either directly (is your ESP32 connected to the same power supply as the motor?) or indirectly (are the cables to the motor close to the ESP32 or its associated cables?)

human890209
Posts: 54
Joined: Wed Aug 15, 2018 8:56 am

Re: Why ACS70331 and ACS712 make ESP32 crash when current changes?

Postby human890209 » Thu Apr 16, 2020 12:33 am

ESP_Sprite wrote: (is your ESP32 connected to the same power supply as the motor?) or indirectly (are the cables to the motor close to the ESP32 or its associated cables?)
The motor is powered by a separate Motor Only battery. The circuit of the motor is very simple. A 7.4V battery module with switch and connect the motor with an ACS sensor's Current pins between the motor and the battery.
I think the cable of the motor should get more than 5cm away from the ESP32 system.
And I also tried to not connect any wire between ACS and ESP32 to check if a “Radio” attack existed. Nope, 5cm away no Radio attack...

I will try to arrange the position of the devices and use a USB oscilloscope to find some clues later.

I use a USB oscilloscope to measure the 3.3V supply voltage of ACS70331.
ACSPowerSupply: 7.4V battery No.1 -> 3.3V converter module(MP2225) -> ACS70331 Power
MotorCircuit: 7.4V battery No.2 + -> Switch -> ACS70331 Inputs -> Motor -> 7.4V Battery No.2 -
I placed ACS70331 in the center, oscilloscope on the left, 3.3v supply parts on the left, motor parts on the right, connected them with 20cm dupont cable. I think the radio interference is weak.

Motor Switch OFF, a nearly flat line about 3.28V, good.
Motor Switch ON, a wave line, it's okay.
Motor ON,Heavy Test,some huge pulse line, then USB oscilloscope freeze.
Restarted the PC software, couldn't connect the oscilloscope.
Replugged the USB cable of the oscilloscope then restarted the software, successfully reconnected.

I replaced the 3.3V converter module(MP2225) with the AMS1117-3.3 LDO module and tested it again.
USB oscilloscope froze again during the heavy test.

[update]
The crash of the USB oscilloscope was really weird, I switched to my newer laptop. The oscilloscope didn't crash there.
When I started the heavy test, the 3.3V power supply line is really noisy. Some spike is nearly 0v~6v.
I tested my ESP32 with ACS70331 on my laptop. It still crashed.
Does the noisy spikes cause ESP32's hardware to execute the wrong instruction or mess up its memory?

human890209
Posts: 54
Joined: Wed Aug 15, 2018 8:56 am

Re: Why ACS70331 and ACS712 make ESP32 crash when current changes?

Postby human890209 » Thu Apr 16, 2020 7:32 am

[update]
I continued to test the voltage with my laptop and the USB oscilloscope.
During the heavy test, ACS70331's power supply got spikes.
The 7.4V battery's output got spikes which were huge.
And I added another voltage converter to convert another 3.3V from the same battery and test the output, it seems the same spikes as the ACS70331's 3.3V.
So the 7.4V battery is haunted by ACS70331, I guess if my ESP32 uses that as power supply it will crash.

I added another 7.4V battery, used it as the second voltage converter's power. No connection between them and the ACS70331 system. I measured the 3.3V output voltage. It did get small spikes. The heavy-duty spikes were similar to ACS70331's no-load spikes. I think if add an ESP32 it won't crash, but there indeed had radio interferes.

I connected the GND pin of ACS70331's battery to the separate 7.4V battery's GND pin and tested. Hudge spikes showed again. Haunted.

If I don't connect the GND between the 2 systems, it's hard to measure the output of ACS70331. If I add an ADS1015, I guess the I2C still needs a common GND to communicate. Is there any easier practice for a noisy voltage supply?

ESP_Sprite
Posts: 9577
Joined: Thu Nov 26, 2015 4:08 am

Re: Why ACS70331 and ACS712 make ESP32 crash when current changes?

Postby ESP_Sprite » Thu Apr 16, 2020 8:26 am

I think you may need to get rid of the crap that your motor puts on the line, as it seems to get into everything else (power lines, magnetic fields etc), as evidenced by your USB scope crashing. There's some hints online if you search for 'reduce interference dc motor', e.g. here.

human890209
Posts: 54
Joined: Wed Aug 15, 2018 8:56 am

Re: Why ACS70331 and ACS712 make ESP32 crash when current changes?

Postby human890209 » Thu Apr 16, 2020 9:07 am

[update]
It's DC motor's spark pulses. I replaced the motor with another motor with a cap on it, got a flat line.
I tested with the better motor. ESP32 didn't crash.

Thanks a lot. @ESP_Sprite

Who is online

Users browsing this forum: No registered users and 145 guests