Paul_KD7HB:
Got it, I think. You just want to add a second pump to the existing system. Probably said that in the beginning, but I missed it.
First, base your program on what is in the first entry in the project guidance part of the forum: Demonstration code for several things at the same time.
Please identify your relay. Your system would be SO much easier if you used a solid state relay to control the pump.
Your first attempt at programming should be to be able to turn the relay on and off for a specific time period, perhaps once per second. Don't worry about the 0-10 volt signal right now.
Paul
Hi!!
Finally i managed to assemble a functional pump. I get an SSR and a piece of code form steeman.be:8080 (Now down, but i have the code):
// constants won't change. Used here to set pin numbers:
const int ledPin = 9; // the number of the LED pin
const int START = 0;
const int IN_PULSE = 1;
const int PULSE_ENDED = 2;
// Variables will change:
int cycleState = START;
int potValue = 0;
// the follow variables are type long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long period = 1023 * 5; // pulse period is ~10 seconds (in milliseconds)
long cycleStart = 0;
// the setup routine runs once when you press reset:
void setup() {
// set the digital pin as output:
pinMode(ledPin, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
switch ( cycleState ) {
case START:
cycleStart = millis();
// read the input on analog pin 0:
potValue = analogRead(A0);
// Serial.println(potValue);
if ( potValue > 0 ) {
// rising edge of pulse
digitalWrite(ledPin, HIGH);
} // else no need to set the pin high, duty cycle is 0%
cycleState = IN_PULSE;
Serial.println("");
Serial.print("START, potvalue: ");
Serial.print(potValue);
Serial.print(", duty: ");
Serial.print(potValue * 0.09765625); // scale back from 0-1024 to 0-100%
Serial.print("%, cycleStart: ");
Serial.println(cycleStart);
break;
case IN_PULSE:
// if the set point is reached, end the high period of the PWM pulse
if ( millis() >= cycleStart + potValue * period / 1024 ) {
if ( potValue < 1023 ) {
// falling edge of pulse
digitalWrite(ledPin, LOW);
} // else no need to set the pin low, duty cycle is 100%
cycleState = PULSE_ENDED;
Serial.print("IN_PULSE, millis: ");
Serial.println( millis() );
}
break;
case PULSE_ENDED:
// if end of PWM period, reset for next period
if ( millis() >= cycleStart + period ) {
cycleState = START;
Serial.print("PULSE_ENDED, millis: ");
Serial.println( millis() );
}
break;
} // end case
} // end loop
It was meant to action a resistance for heating water regulated by a potentiometer, but it was directly applicable to my case. I connect the DCU analogic 0-10V (Acting like a potmeter) output to the Arduino and that did the trick. The motor was 24 VAC, so i use a 220-24V transformer from other stuff (I know is overkill for that, but is what i have) This video shows the operation:
After the success, I made a fancy 3D printed case for the pump, xD, the bad news are that i doesn´t learn too much programing......
Thanks buds!!