Problem with smooth transition between PWM range?
Posted: Sat Nov 26, 2016 8:27 pm
Hi All
I'm driving a large solenoid via PWM and a NTD5867NLT4G Mosfet on GPIO14. My aim is to give a short burst of full power to initially open the valve, but then the valve can stay fully open with much less holding current so I am then scaling down the PWM range to save power.
Here's exactly what I'm doing:
analogWrite(solenoidPin, 1023);
delay(200);
analogWrite(solenoidPin, 235);
The problem im having is on first run only, the valve opens for the initial 200ms with PWM 1023 but then the ESP seems to have some kind of interruption and struggles to smoothly change the PWM range down to 235, instead the pin goes low, the valve shuts, then PWM starts at 235 but the valve is already shut.
This is only on the first time the ESP runs the sketch after a reboot, otherwise it runs this smoothly and corrects itself on the next loop even after if turn the valve off (analogWrite(solenoidPin, 0)) and then on again via the above code.
Can anyone make any suggestions of what is going on or how I can avoid this please?
I'm driving a large solenoid via PWM and a NTD5867NLT4G Mosfet on GPIO14. My aim is to give a short burst of full power to initially open the valve, but then the valve can stay fully open with much less holding current so I am then scaling down the PWM range to save power.
Here's exactly what I'm doing:
analogWrite(solenoidPin, 1023);
delay(200);
analogWrite(solenoidPin, 235);
The problem im having is on first run only, the valve opens for the initial 200ms with PWM 1023 but then the ESP seems to have some kind of interruption and struggles to smoothly change the PWM range down to 235, instead the pin goes low, the valve shuts, then PWM starts at 235 but the valve is already shut.
This is only on the first time the ESP runs the sketch after a reboot, otherwise it runs this smoothly and corrects itself on the next loop even after if turn the valve off (analogWrite(solenoidPin, 0)) and then on again via the above code.
Can anyone make any suggestions of what is going on or how I can avoid this please?