Controlling mulitiple solenoids with arduino UNO using 16V DC or 14V AC

I am trying to control multiple (12) twincoil solenoids (the type in n-guage railway turnouts (minitrix)). I would be operating max 4 at any one time.

What is the best way to use an arduino UNO to achieve this? I have set up a test project to operate 2 solenoids using MOSFETs (I have 2 types IRF520 and IRF830). The test seems to work ok.

Instructions that came with them state that they should be used 14-16V AC, but have read online that 16V DC also works. In my test I can get a single one to operate at 12V DC, but 2 or more wont work at this voltage. I need a bigger power pack :slight_smile: .

Is 16V AC or 16V DC be better suited to my project. Does it matter? I am also concerned about about whether my circuit can handle either. Are Mosfets the best way to turn on/ off 16V or would relay's or something else be better (I have started with Mosfets as they are smaller)-

I am looking for some guidance to point me in the right direction.

Below is the Sketch I have used.

/*
  Turnout version 0,1
  Test with 4 buttons controlling 2 turnouts
  
*/
const int switchPin1 = 2; //turnout switch buttons
const int switchPin2 = 3;
const int switchPin3 = 4;
const int switchPin4 = 5;
const int turnOut1a = 11; //turnout 1 straight track
const int turnOut1b = 10; // turnout 1 branch track (note that there can be either right or left branches)
const int turnOut2a =9;
const int turnOut2b = 8;
int switchState1 = 0; //Sets switch to off
int switchState2 = 0;
int switchState3 = 0; //Sets switch to off
int switchState4 = 0;
int turnOutState1 = 0;
int turnOutState2 = 0;// TurnOut is set to Straight (1= turnOut set to branch)
void setup() {
  Serial.begin(9600); //opens serial port
  pinMode(switchPin1, INPUT);
  pinMode(switchPin2, INPUT);
  pinMode(switchPin3, INPUT);
  pinMode(switchPin3, INPUT);

  pinMode(turnOut1a, OUTPUT);
  pinMode(turnOut1b, OUTPUT);
  pinMode(turnOut2a, OUTPUT);
  pinMode(turnOut2b, OUTPUT);

}

void loop() {
  switchState1 = digitalRead(switchPin1);
  if (switchState1 == HIGH) {
    digitalWrite(turnOut1a, HIGH);
    delay(150);
    digitalWrite(turnOut1a, LOW);
    digitalWrite(turnOutState1, LOW);
    Serial.print(turnOutState1);
  }
  else {
    digitalWrite(turnOut1a, LOW);
  }

switchState2 = digitalRead(switchPin2);
if (switchState2 == HIGH) {
  digitalWrite(turnOut1b, HIGH);
  delay(150);
  digitalWrite(turnOut1b, LOW);
  digitalWrite(turnOutState1, HIGH);
  Serial.print(turnOutState1);
}
else {
  digitalWrite(turnOut1b, LOW);
}
switchState3 = digitalRead(switchPin3);
  if (switchState3 == HIGH) {
    digitalWrite(turnOut2a, HIGH);
    delay(150);
    digitalWrite(turnOut2a, LOW);
    digitalWrite(turnOutState2, LOW);
    Serial.print(turnOutState2);
  }
  else {
    digitalWrite(turnOut2a, LOW);
  }

switchState4 = digitalRead(switchPin4);
if (switchState4 == HIGH) {
  digitalWrite(turnOut2b, HIGH);
  delay(150);
  digitalWrite(turnOut2b, LOW);
  digitalWrite(turnOutState2, HIGH);
  Serial.print(turnOutState2);
}
else {
  digitalWrite(turnOut2b, LOW);
}


{


//Serial.println(" = TurnOut1a"); // Name of turnout
//Serial.print(turnOutState); //print turnout straight  (0) or branch (1)
//Serial.println(" = SwitchState1"); // name of turnout
//Serial.print(switchState1);
//Serial.println(" = SwitchState2"); // name of turnout
//Serial.print(switchState2);
}
}

The MosFETs are the better way to go. Either of those two you mentioned will work just fine. If you can't turn on two solenoids at one time, your power supply is not supplying enough current - you will need a bigger power supply.

Also, you drawing does not look correct. Your buttons don't appear to be connected to anything on the high side (where the red wire appears) That would need to be connected to 5V. You can save yourself some components by using the internal pull-up resistors of the arduino and wire your switch to ground rather than 5V. No external resistors needed. It does change the logic (HIGH = not pressed, LOW = pressed)

As for the AC vs DC voltage. 16V DC is going to deliver a lot more current than 16Vac so you might be shortening the life of your solenoids.

Thanks for your answer! , you are correct with regards to my drawing. I have forgotten to add in the 5v from the arduino. Corrected now below.
I have ordered a Capacitor Discharge Unit CDU2C which is designed to send a very short pulse and (hopefully) not burn out the solenoids. (they only need to operate for a fraction of a second).

Do I need to alter my circuit depending on whether I am using AC or DC? or can I just swap them out?

Bonus question: Is there a way, apart from trial and error of calculating how much voltage/current is needed to throw 2, 3, or 4 solenoids?

robecq:
Thanks for your answer! , you are correct with regards to my drawing. I have forgotten to add in the 5v from the arduino. Corrected now below.
I have ordered a Capacitor Discharge Unit CDU2C which is designed to send a very short pulse and (hopefully) not burn out the solenoids. (they only need to operate for a fraction of a second).

Do I need to alter my circuit depending on whether I am using AC or DC? or can I just swap them out?

Swap what out? Those CDU still work at the nominal voltage of the system (12V) so you will still need those MosFETs since the Arduino is at 5V.

Bonus question: Is there a way, apart from trial and error of calculating how much voltage/current is needed to throw 2, 3, or 4 solenoids?

Look at the datasheet for the motors. The link you provided mentioned upwards of 4A per motor (seems very high). You can always hook up a scope and capture the signal.