Hi all, I am new to Arduino and have little experience programming. I am working on a pump control for heating and want to have a time off delay timer for the circulators without the use of delay(). There are multiple pumps so a delay() would block the other pumps. I am using the productivity open P1am plc.
this is a snipping of the code.
type or paste covoid loop() {
//*****DHW****
if (P1.readDiscrete (2,4) == HIGH){
P1.writeDiscrete (HIGH, 1,4); //DWH PUMP ON
}
else
P1.writeDiscrete(LOW, 1,4);
//****end switch for heat****
if (P1.readDiscrete(2,1) || P1.readDiscrete(2,2) || P1.readDiscrete(2,3) || P1.readDiscrete(2,4) == HIGH){
P1.writeDiscrete(HIGH, 1,8);
}
else{
P1.writeDiscrete(LOW, 1,8);
}de here
Ideally, the plan is to have the end switch go low while each of the pumps keep water circulating through the boiler for around 60 seconds to prevent the eco from opening.
Well, the end switch just turns the boiler on and off. I would like the delay to start as soon as the end switch opens, turns boiler off, that way the water will continues circulating through the heat exchanger for around 60 seconds. The additional pump timing will remove heat from the exchanger and prevent the unit from locking out due to high temperature.
Trying to be gentle, but I can’t see the ‘end’ switch defined in your code.
Perhaps you should name your program elements so we know what they are.
BTW, by now, you should be leaning toward a millis() solution.
Because we can’t see the whole program, it will probably be a static timer variable - somewhere near that ‘end’ switch.
What you could do in the future - both for to yourself and us… is #define or ‘name’ whatever P1.readDiscrete(2,1) and his friends are…
Yes, we could probably resolve your question now, but why not learn something on the way through.
You don’t pass an exam by attending, you have to add something to the process…
Here’s a start…
// global
#define minRunDuration (60L * 1000)
—- or —-
const unsigned long minRunDuration (60L * 1000);
unsigned long whenStarted; // keep track of the start event
//****end switch for heat****
if (P1.readDiscrete(2,1) || P1.readDiscrete(2,2) || P1.readDiscrete(2,3) || P1.readDiscrete(2,4) == HIGH){
whenStarted = millis();
P1.writeDiscrete(HIGH, 1,8);
}
else if (millis() - whenStarted > minRunDuration) {
P1.writeDiscrete(LOW, 1,8);
}
Sorry I had to wait 24 hours before I could post again because I am new. I agree with you 100% about learning something new and thank you for your patients. I attempted to #define P1.readDiscrete(2,4) dhwTT and the compiler had numerous errors. Is it possible they cannot be defined?