I have a project I am currently working on where I want to use pulse solenoids to control water flow. In the past I used regular solenoids which I could just use a simple MOSFET and the code was super simple. Although now with pulse solenoids needing to reverse polarity I am just stumped. I have IBT_2's, L9110S's, also an adafruit motor driver V2.3...I am able to get some of these to open the close solenoids, but I just don't have any forum of control over the solenoids like I need.
the IBT_2's are opening and closing but they are not doing so in the correct timing.
#define buttonPin 3
int ROPEN = 9;
int RCLOSED = 8;
int JOPEN = 6;
int JCLOSED = 5;
int POPEN = 12;
int PCLOSED = 13;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
Serial.begin(9600);
pinMode(buttonPin, INPUT_PULLUP);
pinMode(ROPEN, OUTPUT);
pinMode(RCLOSED, OUTPUT);
pinMode(JOPEN, OUTPUT);
pinMode(JCLOSED, OUTPUT);
pinMode(POPEN, OUTPUT);
pinMode(PCLOSED, OUTPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == LOW) {
digitalRead(buttonPin);
digitalWrite(ROPEN, HIGH); // POWER TO SOLENOID 2(RIM) TO OPEN SOLENOID
delay(200); // DELAY 1.5 SECONDS
digitalWrite(ROPEN, LOW);
delay(4900);
digitalWrite(RCLOSED, HIGH);
delay(200);
digitalWrite(RCLOSED, LOW);
digitalWrite(JOPEN, HIGH);
delay(200);
digitalWrite(JOPEN, LOW);
delay(5000);
digitalWrite(JCLOSED, HIGH);
delay(200);
digitalWrite(JCLOSED, LOW);
} else {
digitalWrite(RCLOSED, HIGH);
delay(200);
digitalWrite(RCLOSED, LOW);
delay(200);
digitalWrite(JCLOSED, HIGH);
delay(200);
digitalWrite(JCLOSED, LOW);
}
}
Sorry for the really rough sketch, but this is the wiring I have for the R solenoid and all the others follow the same.
Note - the high current I have the solenoid hooked into M+ & M- and on the I+ & I- I have a ext power supply.
I use a similar code to this for the L9110S as well those didn't seem to do anything except get the boards extremely warm quickly.
Lastly if I use the adafruit motorsheild V2.3 and follow the instructions online for a DC motor I can get the solenoids to click open and closed by just using the DCmotortest example sketch. However, the delays on that code do not add up to what is actually occurring. For example, if I set the delays to 5 the solenoid is clicking on and off at 3 second splits. Although all other Arduino code I have used 5 would be 5 milliseconds so it being 3 seconds makes no sense to me.
#include <Adafruit_MotorShield.h>
// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);
// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
// You can also make another motor on port M2
//Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Adafruit Motorshield v2 - DC Motor test!");
if (!AFMS.begin()) { // create with the default frequency 1.6KHz
// if (!AFMS.begin(1000)) { // OR with a different frequency, say 1KHz
Serial.println("Could not find Motor Shield. Check wiring.");
while (1);
}
Serial.println("Motor Shield found.");
// Set the speed to start, from 0 (off) to 255 (max speed)
myMotor->setSpeed(255);
myMotor->run(FORWARD);
// turn on motor
myMotor->run(RELEASE);
}
void loop() {
uint8_t i;
Serial.print("tick");
myMotor->run(FORWARD);
for (i=0; i<255; i++) {
myMotor->setSpeed(i);
delay(5);
}
for (i=255; i!=0; i--) {
myMotor->setSpeed(i);
delay(5);
}
Serial.print("tock");
myMotor->run(BACKWARD);
for (i=0; i<255; i++) {
myMotor->setSpeed(i);
delay(5);
}
for (i=255; i!=0; i--) {
myMotor->setSpeed(i);
delay(5);
}
Serial.print("tech");
myMotor->run(RELEASE);
delay(1000);
}
I know this is a lot of information and I likely am doing something wrong in my code I'm sure, otherwise maybe I just am not wiring everything up properly. I am looking for any and all guidance since I have been digging around online for awhile and cannot find much info on Arduino controlling pulse solenoids that need polarity reversing to open/close.
THANKS
Edit: Amazon Pulse Solenoids info
Specification:
Condition: 100% Brand New
Material: Plastic
Color: White
Working Voltage: DV 4.5V
Coil Resistance: 15Ω± 5% (at 20 Celsius)
Pulse Width: 30ms
Pipe Size: G1/2"
Working Pressure: 0.02 - 1.0MPa
Medium Temperature: 1 - 80 Celsius
Service Life: About 300,000 Times
Dimensions(L * W): Approx. 7.2 * 6.5cm / 2.8 * 2.6in
Weight: Approx. 181g