This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
Greetings.
I'm currently developing a board that has, among other things, an ESP32-WROVER-E microcontroller and a DRV8220-DRL H-bridge motor driver, which I use to drive a 12 VDC latching solenoid valve, model Aquative Plus from Netafim (click HERE for datasheet of the valve).
The problem is that, when I put the DRV8220 in forward or reverse drive to turn ON/OFF the valve, the microcontroller just resets, and even when that happens, current continues to pass through the valve, which is not good given that it's a latch valve, so it shouldn't have current continuously passing through it.
Now, for some context, here is some data about the board. The board is supposed to run with a battery of 3.7 V, so it has a battery charger IC, but for these tests, I'm putting a power supply directly where the battery should be, which means that I'm "bypassing" the charger IC. After that, I have a Buck-Boost power supply of 3.3 V, which I use to power both the microcontroller and a Boost power supply of 12 V. That Boost PS is the one that powers the valve.
Here is the circuit of the DRV8220 IC:
The IN1 and IN2 pins are connected directly to the MCU.
Also, I have put filter capacitors in the MCU, technically to avoid that reset problem (which obviously doesn't happend). This is the circuit for the "ENABLE" pin of the MCU:
And this is the circuit for the 3V3 line of the MCU:
As extra information, I've tried putting some resistences in series with the valve, in an attempt to try limiting the valve current, but it doesn't prevent the MCU reset.
Also, I've tried the following DRV8220 sequences for driving the valve:
Sequence 1:
Sequence 2:
My guess is that, when driving the valve, a current peak appears, which causes a voltage drop in the 3V3 line, which causes the MCU to reset. But technically I've design all power supplies to stand up to 2 A of current.
Any ideas of what could be happening? If any more information is needed, please let me know. Thank you all.
Update:
I've made a test in which I put a 2 resistors in parallel of 220 and 100 Ohms, both in series with the valve. Also, given that my lab power supply has a configuration with which you can set the maximum current that it can provide, I increased it up to 2 A. With these 2 changes, the valve drives correctly, although I noticed that it reaches almost 1 A when driving it, which seems a bit high for me, but the datasheet of that valve doesn't provide a reference current, so I'm not sure.
After this test, I've tried driving the valve without those resistors, and even with a maximum current configuration of 2 A, the MCU still resets.
It would seem that the solution is to simply put a resistor in series with the valve, but it seems wired to me, because in the datasheet of DRV8220, the circuit examples never show o mention anything about the need of a series resistor. Maybe there's another solution.
Any ideas?
Hey Franco,
I agree with your analysis of what is likely happening. Do you have an oscilloscope or logic analyzer with analog inputs you can use to take a capture of that 3.3V line?
The opposite could also be happening - the solenoid could be causing a spike in voltage causing the MCU to reset to protect itself.
Can you try applying a PWM ramp from 0% to 100% duty cycle over maybe 200ms to try and reduce that startup current spike?
You can also try for testing increasing the bulk capacitor C21 to a larger value like 47uF. The "Rule of thumb" for bulk capacitance is "1 to 4μF of capacitance for each Watt of motor power, so for your 12V * 1A gives us 12uF to 48uF.
FYI instead of series resistors you should try an inductor in series with the load, that should help slow down the current spike. But hopefully you won't need them at all.
Best,
Jacob
Greetings Jacob.
Thanks a lot for your help. Regarding the capture of the 3V3 line, I've made the same test that I mentioned, this is, with no series resistors, and this is what I get in the oscilloscope:
Sorry for the bad quality. As you can see, before driving the valve, the voltage was correct, at around 3V3. Then, when the valve is driven, the voltage drops to around 2.2 V. So yes, definitely, the voltage in the 3V3 line is droping when driving the valve.
Regarding the PWM ramp, sorry for my ignorance, but I didn't understand what you meant. Could you please explain that using a sequence like the one I described for pins IN1 and IN2? For example, something like:
Regarding C21, I understood what you meant. The problem is that, given that I used SMD capacitors, it would be a bit hard to try and replace it for one of the values that you mentioned, especially because I don't any of that kind of capacitors at hand sadly. But I would definitely try to find a way of testing that. Maybe removing that capacitor and soldering a through-hole capacitor instead.
Regarding the inductor, I thougth about that before choosing the resistors, but I also thought: "okey, the valve is an inductive load, if I add an inductor, the voltage drop maybe could get worse". But I could be mistaken. Do you have any value suggestion for that inductor?
Best regards,
Franco.
Franco,
Thanks for the scope shot - how long does the voltage dip last for? If it was due to the valve inrush spike it would only last for a few millieseconds - looks like it constantly stays low which is odd. I think it might be an issue with your boost power supply circuit not the motor driver - boost supply can't supply enough 12V power for the valve. To test this try using an external 12V power supply instead of your boost circuit and see if this still happens, or try a beefier boost converter to make the 12V?
For PWM Ramp, basically instead of turning IN1 from a 0 to a 1 (0% duty cycle to 100% duty cycle), instead accelerate up to 100% duty cycle over time.
1. IN2 = 0. for (int i = 0, i <=100, i++) {ledcWrite(IN1, i); delay(1); // This would ramp up the duty cycle on the IN1 pin from 0 to 100% duty over 100ms (delay 1ms * 100 times)
2. 20ms delay
3. Reverse the loop - for (int i = 100, i >0, i--) {ledcWrite(IN1, i); delay(1);
4. 100ms delay
It won't take much to greatly reduce that current spike, even a PWM over 10ms will help.
Maybe removing that capacitor and soldering a through-hole capacitor instead.
That would be one way, or you could try soldering another 10uF cap stacked on top of your existing cap, or try to solder the leads of a leaded cap to the two sides of the SMD cap.
As you said, even though the valve itself is an Inductor, it may have a low inductance, so extra inductance can help control the peak current. Try a 1uH - 50uH inductor. But first try the other things, as this inductor shouldn't be necessary.
Best,
Jacob
Greetings Jacob.
Thank you very much for your suggestions and explanations.
Thanks for the scope shot - how long does the voltage dip last for? If it was due to the valve inrush spike it would only last for a few millieseconds - looks like it constantly stays low which is odd. I think it might be an issue with your boost power supply circuit not the motor driver - boost supply can't supply enough 12V power for the valve. To test this try using an external 12V power supply instead of your boost circuit and see if this still happens, or try a beefier boost converter to make the 12V?
Firstly, you made me realize 2 things: one is that IN1 and IN2 in my board are not directly connected to the ESP32, but are connected to an I2C I/O expander (part number TCA9534PWR), so when the ESP32 resets, those pins stay in the same logic level, and that's why you see a constant voltage drop. And the other thing is that, looking at my 12V power supply, which is a MIC2288, I see that it has a switching current limit of typical 1.2 A:
Technically, I think that the peak current of the valve is below that value, but maybe I'm mistaken, and that could be the reason of the voltage drop in the 3V3 line. I chose that power supply because I thought that the valve current would be at around 500 mA, but from this test, I have seen current peaks of up to 900 mA. Maybe I need a power supply with higher switch current limit.
Regarding the PWM ramp, now I understand. The problem is, given that, as I said previously, the IN1 and IN2 are connected to the I/O expander, I can't use the PWM functionallity from ESP32. However, I used "vTaskDelays" to approximate a PWM ramp, with this code:
ESP_LOGW(TAG, "Forward Drive ramp up"); for(int i = 0; i < 10; i++) { xLastWakeTime = xTaskGetTickCount(); set_io(OUT2_IN1, 1); xDelayTimeTicks = pdMS_TO_TICKS(i+1); vTaskDelayUntil(&xLastWakeTime, xDelayTimeTicks); xLastWakeTime = xTaskGetTickCount(); set_io(OUT2_IN1, 0); xDelayTimeTicks = pdMS_TO_TICKS(10-i); vTaskDelayUntil(&xLastWakeTime, xDelayTimeTicks); } vTaskDelay(pdMS_TO_TICKS(20)); ESP_LOGW(TAG, "Forward Drive ramp down"); for(int i = 0; i < 10; i++) { xLastWakeTime = xTaskGetTickCount(); set_io(OUT2_IN1, 1); xDelayTimeTicks = pdMS_TO_TICKS(10-i); vTaskDelayUntil(&xLastWakeTime, xDelayTimeTicks); xLastWakeTime = xTaskGetTickCount(); set_io(OUT2_IN1, 0); xDelayTimeTicks = pdMS_TO_TICKS(i+1); vTaskDelayUntil(&xLastWakeTime, xDelayTimeTicks); }
Which generated this signal on IN1 pin:
Given that I have to use FreeRTOS delays, my delay limitation is 1 ms, so it's the best I could get. However, even with this pseudo-PWM ramp, the ESP32 still resets. I can try to solder IN1 and IN2 directly to two ESP32 pins so I can try and use the PWM functionallity, do you say that, even after that test that I've made, it's worth to try that?
Additionally, I've noticed something, that maybe is rather obvious, but just in case. Suppose that you drive the valve forward, and then you reset the MCU, and then it will try to drive the valve forward again. When that happens, you also get a current peak. I think that that's normal, because even if the mechanical part of the valve has already moved in the forward direction, the coil of the valve can still conduct current.
Best regards,
Franco.
Hey Franco,
Seems like the root cause of the 3.3V drop isn't really the motor driver here - it's something else about the system.
Could you try a lighter load, like just a relay or LED or smaller valve to see if you get a smaller or no voltage drop when using a smaller load? Or try with no load?
Suppose that you drive the valve forward, and then you reset the MCU, and then it will try to drive the valve forward again. When that happens, you also get a current peak. I think that that's normal, because even if the mechanical part of the valve has already moved in the forward direction, the coil of the valve can still conduct current.
Yeah correct, the coil will still conduct current even if the valve is already forward. Many actuators/valves use a "Peak and hold" control scheme with current regulation so that the driver regulates the current through the valve to only use as much current as is needed to hold it in place after the initial peak current. Unfortunately DRV8220 doesn't have integrated current regulation.
Greetings Jacob.
Seems like the root cause of the 3.3V drop isn't really the motor driver here - it's something else about the system.
Could you try a lighter load, like just a relay or LED or smaller valve to see if you get a smaller or no voltage drop when using a smaller load? Or try with no load?
I don't know if this helps, but I've tried before with no load connected, this is, pins IN1 and IN2 floating, and it worked fine, because I was first testing if I get the +12V and -12V voltage pulses. A resistor would help? Because I only have that valve model. But just in case, I've tested the valve with some resistors in series with it, and in that case, the MCU didn't reset, that's why I personally think that the problem has to be a current peak caused by the driving of the valve, otherwise it wouldn't work even with resistors in series. What do you think about this?
Yeah correct, the coil will still conduct current even if the valve is already forward. Many actuators/valves use a "Peak and hold" control scheme with current regulation so that the driver regulates the current through the valve to only use as much current as is needed to hold it in place after the initial peak current. Unfortunately DRV8220 doesn't have integrated current regulation.
Oh, okey, now I understand, thank you.
Best regards,
Franco.
Greetings Jacob.
I think I've found some revealing news. I wanted to measure the current that was flowing through the valve when driving it, so I put a series resistor of 100 Ohm with it, and then connected my oscilloscope in parallel to that resistor, so by measuring the voltage drop across the resistor, I could get the current. What I got is this:
As you can see, the maximum voltage across the resistor is about 10.6 V, which means that the maximum current, because the resistor is 100 Ohm, would be 106 mA. However, I'm using a lab power supply to power the board, which has a display that show the load current, and when I drive the valve, I'm pretty sure that I can see a current of a range from 500 mA up to 900 mA. Obviously, the ESP32 and the other components of the board consume current too, but in stationary mode, that current is about 150 mA. This means that theres a current of 250-650 mA that is going somewhere.
In conclusion, I would say that you could be right about that something else about the system is consuming more current than it should when driving the valve. Because, as I said, if I run the driver with no load, that doesn't happend. Any ideas?
If it helps, here are the schematics for all the circuits that are directly or indirectly related to the driver circuit:
Power supply input Buck-Boost Converter 3V3:
Boost Converter 12 V:
Valve 1 driver circuit:
Best regards,
Franco.
Hi Franco,
Thanks for sending the additional details.
I will work with my team to sent you an update.
Thanks,
Ibinu
Greetings Ibinu.
Thank you for your help. However, after making several more test the last few days, I think I have found the problem.
I've made the following tests:
I think that, with these tests, I can say that the problem is that the 12V switching power supply can't provide enough current to the valve. Then, I will replace that PS with one that can supply at least 2A of current.
On the other hand, while running these tests, I searched online for references of latching valve driver circuits, and noticed that in some the put a pretty big capacitor in parallel with the 12V line, with a value in the range of 3000-5000 uF. My guess is that it is used to provide current to the valve in case that the power supply can't provide enough current. But given its size and cost, if I can avoid it, it would be great. Any ideas if it's really necessary? Because in the DRV8220 datasheet it doesn't say anything about that capacitor.
Best regards,
Franco.
Hey Franco,
Glad you found some workarounds/path forward!
There shouldn't be a need for that large of a capacitor if the power supply is sized large enough to be able to provide the current to drive the valve. Large capacitance like that is really only used if you are going to use an undersized power supply, and only drive your load for a few milliseconds like in the case of a latching valve or relay. But for our driver if you are only using the capacitance to handle the inrush peak current it shouldn't need to be more than 50uF for your case.
Best,
Jacob
Greetings Jacob.
Excelent, I understood perfectly. Then, I'm going to just replace the 10 uF capacitor for a 50 uF capacitor in the 12V line, as you suggested. Thank you a lot for your help.
I will let this post open, so when I have the new PCB design and I'm able to test it, I can share the results, so we can confirm that indeed the problem was the power supply.
Best regards,
Franco.
Hi Franco,
Sounds good. Looking forward to hearing about the results.
Best,
David