Mosfet PWM Signal has large spikes.

I am using a TIP120 Mosfet with an Arduino Uno to control a solenoid valve (see here). As listed in the datasheet, it must be driven with a PWM signal of 1200 Hz. The valve should be used in another context than here, however I am using an Arduino in a first step to test the valve (to characterise its behaviour).

I connected the valve analogously to this schematic.

I changed the PWM-frequency to 1200 HZ using this tutorial.

When I am now changing the duty cycle of the AnalogWrite of the Arduino, I notice that the solenoid valve almost only draws current from D=230 and upwards, below this, current draw is very small and the valve is closed.

For debugging purposes, I used an oscilloscope to check the PWM signal that goes into the valve (Probe between Drain and GND). I could see the following behaviour, which seems very odd to me (please check images)

Image 1: Duty cycle of D = 25 (x-axis: 200μs/div and y-axis: 40V/div)
Image 2: Duty cycle of D = 221 (x-axis: 200μs/div and y-axis: 40V/div)

Connecting just a resistor as a load (instead of the valve) results in the PWM square wave that I am familiar with.

  1. What could be the reason for this spiky PWM signal (my guess is that it might be due to the inductance of the coil) and what might I do to resolve the issue?
  2. Why does the Solenoid valve only draw current when the duty cycle of the AnalogWrite is above (approx) 230? I think that this should not be the common behaviour. Preferably I would like to use the entire span of the Analog Write to set the orifice size of the valve.

Also, if it might be of use, here is my code (PWM.h is an import to change the standard PWM frequency):

#include <PWM.h>

int PWM_PIN = 10;
int pwmval = 0;
int32_t frequency = 1200;

void setup() {
  
  InitTimersSafe();
  
  bool success = SetPinFrequencySafe(PWM_PIN, frequency);
  
  Serial.begin(9600);
  pinMode(PWM_PIN,OUTPUT);
  Serial.println("Send a value between 1 and 255");
}

void loop() {
  if (Serial.available() > 1) {
      pwmval =  Serial.parseInt();
      Serial.print("Set Speed to: ");
      Serial.println(pwmval);
      analogWrite(PWM_PIN, pwmval);
      Serial.println("done!");
  }
}

Hope that anybody can help.

Image_1_D=221.png

Image_2_D=25.png

Image_1_D=221.png

Image_2_D=25.png

That's confusing because the TIP120 is NOT a MOSFET. It does not have a drain. So what are you actually using, a MOSFET or a TIP120?

Steve

Hi Steve

Sorry, rookie mistake, I thought a TIP120 is a Mosfet since it has the appearance of a Mosfet. So yes, I am using the TIP120. Have looked into this, as it seems to me, a TIP120 functions almost equivalently to a mosfet, with the difference that it is driven by current, rather than by voltage. I have a resistor (2000 ohm) at the input of the the gate and hence I should not have an excessive amount of current from the 5V analog write. In this case I was measuring the voltage between collector and GND in the images.

As I am not an expert in this field: Should I expect different behaviour when using a TIP120? I am gueessing my main problems will remain even when using a MOSFET (unfortunately I don't have any available to test it)

Thanks

It looks like you forgot the freewheel diode across the solenoid, or its burnt out.

What is your power supply? Is it decoupled? Did you look at the supply rail with
the 'scope too?

Hi,

Thanks, the flyback diode was indeed burnt out! Replaced it and now the PWM signal looks flawless! Power supply is indeed decoupled. Only weird thing is still that the duty cycle seems only to have an effect on orifice size in the region from D = 140 and upwards. Anything below that and the valve is completly closed.

Sounds entirely non-weird to me, solenoids act against a spring, you have to overcome the spring
before they can move. The magnetic circuit is usually highly non-linear with plunger position too.
The effective gap dimensions change with the position - and magnetic circuits are all about gap.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.