Limit output current with atmega and LM25011

Hello,

as described in this topic, I realized a first prototype of my board based on atmega328p to control multiple solenoid valves (2 proportional and 9 ON/OFF valves).

This is the PCB schematics and this is the board made with EAGLE.

This is the valves datasheet and the valves has these parameters:

V = 12Vcc, R = 3.7 Ohm, I = 1.80A

The main power source is a battery rated 12VDC, 40Ah.

The board does not work properly since it usually get stuck and freeze after few seconds of operation.

In order to improve the board, I added some capacitors to act like a noise filter: a big one on the main power supply and other caps on VCC (7) and GND ( 8 ) and AREF (21) and GND (22) and AVCC (20) and GND (22) on the atmega328p. With all these filters, the board can work longer, but after few minutes it crashes again.

At the moment, I need to find a solution to limit the current output for the solenoids at 1.8A since after some measurements I found out that they will draw up to 3A on my board.
This cannot be possible and so I need to find a way to limit the current.

I was thinking to use the LM25011, but after reading its datasheet, I'm not able to understand which is the value for the sense resistor in order to limit the output current at 1.8A.

Can you help me, please?

Do you think the LM25011 will be suitable for my application?
Can you give me some tips on how to use it, please?

Thank you

If you added a 3 ohm resistor in series with the solenoids that would do the job...

the max dissipation would be about 10 watts, so I'd use a 15W rated device.

Since you have several valves, each of which can take up to 3A in your present circuit,
the peak current could cause your battery voltage to sag low enough to drop below the limit of your 7805 regulator - try putting a scope on the 12v and see if this happens - could be why the processor crashes

regards

Allan.

Thank you for your support!

I've already added a 2 Ohm 10W resistor in series with the solenoids: in this case, the board works OK for 10-15 minutes, but the resistor become very hot. May be, with a 15W resistor the situation could be better, but then what about the power consumption? will it be too high?

I tried to power the board also with a AGM battery with 12VDC and 200Ah, but I still have the same problem, unfortunately.

I was thinking to use a solution based on LM25011 which is a switching regulator with current limit feature.
This is its datasheet.

By using the online calculator, I've set the input/output voltage and the maximum output current and I've obtained this circuit:

Do you think this solution should be OK for my board?
I was thinking to connect the Vin to my MOSFET output.

I don't know where I will find a resistor with a value almost equals to 0, by the way.

You could use the PWM facility to drive the solenoid via a MOSFET - the power dissipation
would then be very small. Use a schottky diode reverse-biased across the coil to stop high voltage transients, and limit the average current in software...

regards

Allan.

allanhurst:
You could use the PWM facility to drive the solenoid via a MOSFET

Can you explain me better, please?
I'm sorry, but I can't understand how to do this.

Limiting the current by software, you mean to set PWM lowern than 100%?

Look in the arduino reference section.. The pwm function drives an approximatley 1kHz variable pulsewidth signal to a digital output. It can be driven by values 0.. 255 ie fully off to fully on

regards

Allan.

I already know this, but the problem is that if I use a lower PWM, then the full range between valve_close and valve_fully_opened will not be very accurate.

I'm using a remote transmitter (a Futaba) to control the proportional valves and so if I use a lower PWM, the output range will give to the valve a twitch behavior.

This is my current code.
I already tried with PWM from 0 to 200, or 0 to 180 but the joystick wasn't very accurate.
And even with this solution, the board didn't worked perfectly.

int ch1;
int ch2;
int ch3;

  int pin_sx_PWM;
  int pin_sx1;
  int pin_sx2;
  int stick_sx;

  int pin_dx_PWM;
  int pin_dx1;
  int pin_dx2;

  int pin_pistone1;
  int pin_pistone2;

  int motore_switch;
  int starter;

  int a = 0;
  int b = 0;

void setup() {


 pinMode(6, OUTPUT); // PWM OUTPUT FOR PROPORTIONAL VALVE SX
 pinMode(3, OUTPUT); // PWM OUTPUT FOR PROPORTIONAL VALVE DX
 
 pinMode(8, INPUT); // RECEIVER INPUT CH1
 pinMode(9, INPUT); // RECEIVER INPUT CH2
 
 pinMode(7, OUTPUT); // STARTER RELAY
 pinMode(A0, OUTPUT); // MOT1A
 pinMode(A2, OUTPUT); // MOT1B // era A1 ma ora genera blocchi

 pinMode(A3, OUTPUT); // MOT2A
 pinMode(5, OUTPUT); // MOT2B // settato a P_OUT con uscita PWM ** DA RISOLVERE
 
   
 Serial.begin(115200); // Pour a bowl of Serial

}

void loop() {

  digitalWrite(7, LOW);
 
 //  analogWrite(6, 128); // SET PWM FOR SX VALVE
   
  ch2 = pulseIn(9, HIGH, 25000); // CANALE 2, STICK SINISTRO up/down
  ch1 = pulseIn(8, HIGH, 25000); // CANALE 1, STICK DESTRO up/down

 
if ((ch2 > 1518) && (ch2 < 1923) && (ch1 > 1489) && (ch1 < 1521) ){


ch2 = map(ch2, 1520, 1918, 0, 255);

ch2 = constrain(ch2, 0, 255); // DA VERIFICARE QUESTA FUNZIONA

if (ch2 > 0){
 
  digitalWrite(A0, HIGH);
  digitalWrite(A2, LOW);
  digitalWrite(A3, HIGH);
  digitalWrite(5, LOW);
  delay(50);
  analogWrite(6, ch2); // SET PWM FOR SX VALVE
  analogWrite(3, ch2); // SET PWM FOR DX VALVE
  }
  else {

  analogWrite(6, 0); // TURN OFF PWM FOR SX VALVE
  analogWrite(3, 0); // TURN OFF PWM FOR DX VALVE
  delay(50);
  digitalWrite(A0, LOW);
  digitalWrite(A2, LOW);
  digitalWrite(A3, LOW);
  digitalWrite(5, LOW);
 
    }

}



else if ((ch2 < 1490) && (ch2 > 1095) && (ch1 > 1489) && (ch1 < 1521) ){


ch2 = map(ch2, 1103, 1500, 255, 0);

ch2 = constrain(ch2, 0, 255); // DA VERIFICARE QUESTA FUNZIONA


if (ch2 > 5){
  digitalWrite(A0, LOW);
  digitalWrite(A2, HIGH);
  digitalWrite(A3, LOW);
  digitalWrite(5, HIGH);
 
  delay(50);
  analogWrite(6, ch2); // SET PWM FOR SX VALVE
  analogWrite(3, ch2); // SET PWM FOR DX VALVE
  }
  else {

  analogWrite(6, 0); // TURN OFF PWM FOR SX VALVE
  analogWrite(3, 0); // TURN OFF PWM FOR DX VALVE
  delay(50);
  digitalWrite(A0, LOW);
  digitalWrite(A2, LOW);
  digitalWrite(A3, LOW);
  digitalWrite(5, LOW);
    }
 
}

// GESTIONE STICK DX per STERZATA POSTO

else if ((ch1 > 1520) && (ch1 < 1923) && (ch2 > 1491) && (ch2 < 1519)){

ch1 = map(ch1, 1520, 1918, 0, 255);

ch1 = constrain(ch1, 0, 255); // DA VERIFICARE QUESTA FUNZIONA

if (ch1 > 5){
 
  digitalWrite(A0, HIGH);
  digitalWrite(A2, LOW);
  digitalWrite(A3, LOW);
  digitalWrite(5, HIGH);
  delay(50);
  analogWrite(6, ch1); // SET PWM FOR SX VALVE
  analogWrite(3, ch1); // SET PWM FOR DX VALVE
  }
  else {
     //  Serial.println("STOP");
  analogWrite(6, 0); // TURN OFF PWM FOR SX VALVE
  analogWrite(3, 0); // TURN OFF PWM FOR DX VALVE
  delay(50);
  digitalWrite(A0, LOW);
  digitalWrite(A2, LOW);
  digitalWrite(A3, LOW);
  digitalWrite(5, LOW);
 
    }

}

else if ( (ch1 < 1490) && (ch2 > 1100) && (ch2 > 1490) && (ch2 < 1520)){
//Serial.println("SINISTRA");
ch1 = map(ch1, 1103, 1500, 255, 0);

ch1 = constrain(ch1, 0, 255); // DA VERIFICARE QUESTA FUNZIONA


if (ch1 > 5){
  digitalWrite(A0, LOW);
  digitalWrite(A2, HIGH);
  digitalWrite(A3, HIGH);
  digitalWrite(5, LOW);
 
  delay(50);
  analogWrite(6, ch1); // SET PWM FOR SX VALVE
  analogWrite(3, ch1); // SET PWM FOR DX VALVE
  }
  else {
   //    Serial.println("STOP");
  analogWrite(6, 0); // TURN OFF PWM FOR SX VALVE
  analogWrite(3, 0); // TURN OFF PWM FOR DX VALVE
  delay(50);
  digitalWrite(A0, LOW);
  digitalWrite(A2, LOW);
  digitalWrite(A3, LOW);
  digitalWrite(5, LOW);
    }
 
}
else {
  //   Serial.println("STOP");
  analogWrite(6, 0); // TURN OFF PWM FOR SX VALVE
  analogWrite(3, 0); // TURN OFF PWM FOR DX VALVE
  delay(50);
  digitalWrite(A0, LOW);
  digitalWrite(A2, LOW);
  digitalWrite(A3, LOW);
  digitalWrite(5, LOW);
  }

delay(400);
           
}