Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
Software apps and online services | ||||||
| ||||||
Hand tools and fabrication machines | ||||||
|
One Arduino Mega chip based, 6 unit chemostat culturing system for microbial experiments.
all you need is Arduino Mega, mini peristaltic pump, or (whatever pump you wanna attached) Adafruit motor shield V2.0 o V2.3.
And learn how to stack your shield from here:
<@ARTDIALOG.WINNAME1573577364151>https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/stacking-shields
Then just upload the code (attached)
Use Megunolink control panel (attached in CAD file section) for controlling your machine.
Each shield control 4 pumps, two system.
3 shield control 6 systems, as you will see in the control panel there are 6 reactors.
You can easily adjust your incubation period and the feed/waste ratio.
You will need to calibrate your pumps (Time to Volume "ml").
If any questions, don't hesitate contact me through comments.
<@ARTDIALOG.WINNAME1573577364151>
<@ARTDIALOG.WINNAME1573577364151>
Best of luck.
<@ARTDIALOG.WINNAME1573577364151>
#include <Wire.h>
#include "CommandHandler.h"
#include "TimeLib.h"
#include "MegunoLink.h"
Message MyCSVMessage("Data");
float ODVarT8;
float FEDWASTEVAR1;
float FEDWASTEVAR2;
float Multivar1=0.5;
float Multivar2=0.5;
float Multivar3=0.5;
float Multivar4=0.5;
float Multivar5=0.5;
float Multivar6=0.5;
unsigned long Timediff1;
unsigned long Timediff2;
unsigned long Timediff3;
unsigned long Timediff4;
unsigned long Timediff5;
unsigned long Timediff6;
unsigned long Timediff2a;
unsigned long Timediff2b;
unsigned long Timediff2c;
unsigned long Timediff2d;
unsigned long Timediff2e;
unsigned long Timediff2f;
float addPumpOFF1;
float addPumpOFF2;
float addPumpOFF3;
float addPumpOFF4;
float addPumpOFF5;
float addPumpOFF6;
float TimeVarT2 = millis();
float FLOWINMIN1 = 250;
float FLOWINMIN2 = 250;
float FLOWINMIN3 = 0;
float FLOWINMIN4 = 0;
float FLOWINMIN5 = 0;
float FLOWINMIN6 = 0;
float PUMPONV1 = 0.001;
float PUMPONV2 = 0.001;
float PUMPONV3 = 0.001;
float PUMPONV4 = 0.001;
float PUMPONV5 = 0.001;
float PUMPONV6 = 0.001;
float PUMPOFFV1 = 1000;
float PUMPOFFV2 = 1000;
float PUMPOFFV3 = 1000;
float PUMPOFFV4 = 1000;
float PUMPOFFV5 = 1000;
float PUMPOFFV6 = 1000;
unsigned long previousMillis = 0;
unsigned long previousMillis2 = 0;
unsigned long previousMillis3 = 0;
unsigned long previousMillis4 = 0;
unsigned long previousMillis5 = 0;
unsigned long previousMillis6 = 0;
unsigned long previousMillis2a = 0;
unsigned long previousMillis2b = 0;
unsigned long previousMillis2c = 0;
unsigned long previousMillis2d = 0;
unsigned long previousMillis2e = 0;
unsigned long previousMillis2f = 0;
unsigned long previousMillisT1 = 0;
unsigned long previousMillisT2 = 0;
unsigned long previousMillisT3 = 0;
unsigned long previousMillisT4 = 0;
unsigned long previousMillisT5 = 0;
unsigned long previousMillisT6 = 0;
unsigned long Countdownsec1;
unsigned long Countdownmin1;
unsigned long Countdownhr1;
unsigned long Countdownsec2;
unsigned long Countdownmin2;
unsigned long Countdownhr2;
unsigned long Countdownsec3;
unsigned long Countdownmin3;
unsigned long Countdownhr3;
unsigned long Countdownsec4;
unsigned long Countdownmin4;
unsigned long Countdownhr4;
unsigned long Countdownsec5;
unsigned long Countdownmin5;
unsigned long Countdownhr5;
unsigned long Countdownsec6;
unsigned long Countdownmin6;
unsigned long Countdownhr6;
// Select which 'port' M1, M2, M3 or M4. In this case, M1 (V2)
CommandHandler<100> SerialCommandHandler;
#include <SoftwareSerial.h>
InterfacePanel MyPanel;
#include <Adafruit_MotorShield.h>
Adafruit_MotorShield AFMS(0x60);
Adafruit_MotorShield AFMS1(0x61);
Adafruit_MotorShield AFMS2(0x62);
#include <avr/wdt.h>
Adafruit_DCMotor *myMotor1 = AFMS.getMotor(1);
Adafruit_DCMotor *myMotor2 = AFMS.getMotor(2);
Adafruit_DCMotor *myMotor3 = AFMS.getMotor(3);
Adafruit_DCMotor *myMotor4 = AFMS.getMotor(4);
Adafruit_DCMotor *myMotor1Sh1 = AFMS1.getMotor(1);
Adafruit_DCMotor *myMotor2Sh1 = AFMS1.getMotor(2);
Adafruit_DCMotor *myMotor3Sh1 = AFMS1.getMotor(3);
Adafruit_DCMotor *myMotor4Sh1 = AFMS1.getMotor(4);
Adafruit_DCMotor *myMotor1Sh2 = AFMS2.getMotor(1);
Adafruit_DCMotor *myMotor2Sh2 = AFMS2.getMotor(2);
Adafruit_DCMotor *myMotor3Sh2 = AFMS2.getMotor(3);
Adafruit_DCMotor *myMotor4Sh2 = AFMS2.getMotor(4);
void Cmd_MultipleVaal1(CommandParameter &p)
{
Multivar1 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("Multi1"),Multivar1 );
}
void Cmd_MultipleVaal2(CommandParameter &p)
{
Multivar2 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("Multi2"),Multivar2 );
}
void Cmd_MultipleVaal3(CommandParameter &p)
{
Multivar3 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("Multi3"),Multivar3 );
}
void Cmd_MultipleVaal4(CommandParameter &p)
{
Multivar4 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("Multi4"),Multivar4 );
}
void Cmd_MultipleVaal5(CommandParameter &p)
{
Multivar5 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("Multi5"),Multivar5 );
}
void Cmd_MultipleVaal6(CommandParameter &p)
{
Multivar6 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("Multi6"),Multivar6 );
}
void Cmd_FWValueBB(CommandParameter &p)
{
FEDWASTEVAR1 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("FWValueV"),FEDWASTEVAR1 );
FEDWASTEVAR2= FEDWASTEVAR1*1000;
}
void Cmd_FeedBDown(CommandParameter &p)
{
MyPanel.ShowControl(F("Arrow1"));
myMotor1->setSpeed(FLOWINMIN1);
myMotor1->run(FORWARD);
myMotor1Sh2->setSpeed(200);
myMotor1Sh2->run(FORWARD);
delay(FEDWASTEVAR2);
SerialCommandHandler.Process();
MyPanel.SetNumber(F("PTime"), hour());
MyPanel.SetNumber(F("PTime2"), minute());
MyPanel.SetNumber(F("PTime3"), second());
MyPanel.SetNumber(F("PTime4"), day());
MyPanel.SetNumber(F("PTime5"), month());
}
void Cmd_WasteBDown(CommandParameter &p)
{
MyPanel.ShowControl(F("Arrow2"));
myMotor2->setSpeed(FLOWINMIN1);
myMotor2->run(FORWARD);
myMotor1Sh2->setSpeed(200);
myMotor1Sh2->run(FORWARD);
delay(FEDWASTEVAR2);
SerialCommandHandler.Process();
MyPanel.SetNumber(F("PTime"), hour());
MyPanel.SetNumber(F("PTime2"), minute());
MyPanel.SetNumber(F("PTime3"), second());
MyPanel.SetNumber(F("PTime4"), day());
MyPanel.SetNumber(F("PTime5"), month());
}
void Cmd_PUMPON1(CommandParameter &p)
{
PUMPONV1 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("PUMPONVAL1"), PUMPONV1);
}
void Cmd_PUMPOFF1(CommandParameter &p)
{
PUMPOFFV1 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("PUMPOFFVAL1"), PUMPOFFV1);
ODVarT8=PUMPOFFV1*3600000;
hour(0);
second(0);
minute(0);
Timediff2 = PUMPOFFV1*3600000;
addPumpOFF1 = PUMPOFFV1 + hour();
}
void Cmd_PUMPON2(CommandParameter &p)
{
PUMPONV2 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("PUMPONVAL2"), PUMPONV2);
}
void Cmd_PUMPOFF2(CommandParameter &p)
{
PUMPOFFV2 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("PUMPOFFVAL2"), PUMPOFFV2);
ODVarT8=PUMPOFFV2*3600000;
hour(0);
second(0);
minute(0);
Timediff2 = PUMPOFFV2*3600000;
addPumpOFF2 = PUMPOFFV2 + hour();
}
void Cmd_PUMPON3(CommandParameter &p)
{
PUMPONV3 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("PUMPONVAL3"), PUMPONV3);
}
void Cmd_PUMPOFF3(CommandParameter &p)
{
PUMPOFFV3 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("PUMPOFFVAL3"), PUMPOFFV3);
ODVarT8=PUMPOFFV3*3600000;
hour(0);
second(0);
minute(0);
Timediff2 = PUMPOFFV3*3600000;
addPumpOFF3 = PUMPOFFV3 + hour();
}
void Cmd_PUMPON4(CommandParameter &p)
{
PUMPONV4 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("PUMPONVAL4"), PUMPONV4);
}
void Cmd_PUMPOFF4(CommandParameter &p)
{
PUMPOFFV4 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("PUMPOFFVAL4"), PUMPOFFV4);
ODVarT8=PUMPOFFV4*3600000;
hour(0);
second(0);
minute(0);
Timediff2 = PUMPOFFV4*3600000;
addPumpOFF4 = PUMPOFFV4 + hour();
}
void Cmd_PUMPON5(CommandParameter &p)
{
PUMPONV5 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("PUMPONVAL5"), PUMPONV5);
}
void Cmd_PUMPOFF5(CommandParameter &p)
{
PUMPOFFV5 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("PUMPOFFVAL5"), PUMPOFFV5);
ODVarT8=PUMPOFFV5*3600000;
hour(0);
second(0);
minute(0);
Timediff2 = PUMPOFFV5*3600000;
addPumpOFF5 = PUMPOFFV5 + hour();
}
void Cmd_PUMPON6(CommandParameter &p)
{
PUMPONV6 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("PUMPONVAL6"), PUMPONV6);
}
void Cmd_PUMPOFF6(CommandParameter &p)
{
PUMPOFFV6 = p.NextParameterAsDouble();
MyPanel.SetNumber(F("PUMPOFFVAL6"), PUMPOFFV6);
ODVarT8=PUMPOFFV6*3600000;
hour(0);
second(0);
minute(0);
Timediff2 = PUMPOFFV6*3600000;
addPumpOFF6 = PUMPOFFV6 + hour();
}
//------Reports--------------------------
void Cmd_ReportRefresh(CommandParameter &p)
{
MyPanel.SetText(F("Report2"), "2");
MyPanel.SetNumber(F("Report5"), PUMPOFFV1);
MyPanel.SetNumber(F("Report6"), PUMPONV1);
MyPanel.SetNumber(F("Report8"), FLOWINMIN1);
MyPanel.SetNumber(F("FWValueV"),FEDWASTEVAR1 );
MyPanel.SetNumber(F("PUMPONVAL"), PUMPONV1);
MyPanel.SetNumber(F("PUMPOFFVAL"), PUMPOFFV1);
MyPanel.SetNumber(F("INMINVAL"), FLOWINMIN1);
MyPanel.SetNumber(F("INMINVAL"), FLOWINMIN1);
MyPanel.SetNumber(F("PUMPOFFVAL"), PUMPOFFV1);
SerialCommandHandler.Process();
MyPanel.SetNumber(F("PTime"), hour());
MyPanel.SetNumber(F("PTime2"), minute());
MyPanel.SetNumber(F("PTime3"), second());
MyPanel.SetNumber(F("PTime4"), day());
MyPanel.SetNumber(F("PTime5"), month());
}
//---------------------------------------------------------------------------------
void Cmd_Move1(CommandParameter &p)
{
MyPanel.SetText(F("Switch"), "ON");
MyPanel.SetBackColor(F("Switch"), F("green"));
FLOWINMIN1 = 250;
PUMPONV1 = 0.001;
PUMPOFFV1 = 1000;
unsigned long currentMillis = millis();
unsigned long currenthour = hour(0);
unsigned long currentsec = second(0);
unsigned long currentmin = minute(0);
MyPanel.SetNumber(F("INMINVAL"), FLOWINMIN1);
setTime(00,00,00,01, 01, 0000);
previousMillis = currentMillis;
previousMillis2a = currentMillis;
SerialCommandHandler.Process();
MyPanel.SetNumber(F("PTime"), hour());
MyPanel.SetNumber(F("PTime2"), minute());
MyPanel.SetNumber(F("PTime3"), second());
MyPanel.SetNumber(F("PTime4"), day());
MyPanel.SetNumber(F("PTime5"), month());
}
void Cmd_Move2(CommandParameter &p)
{
MyPanel.SetText(F("Switch"), "ON");
MyPanel.SetBackColor(F("Switch"), F("green"));
FLOWINMIN2 = 250;
PUMPONV1 = 0.001;
PUMPOFFV1 = 1000;
unsigned long currentMillis = millis();
unsigned long currenthour = hour(0);
unsigned long currentsec = second(0);
unsigned long currentmin = minute(0);
MyPanel.SetNumber(F("INMINVAL1"), FLOWINMIN2);
setTime(00,00,00,01, 01, 0000);
previousMillis2 = currentMillis;
previousMillis2b = currentMillis;
SerialCommandHandler.Process();
MyPanel.SetNumber(F("PTime"), hour());
MyPanel.SetNumber(F("PTime2"), minute());
MyPanel.SetNumber(F("PTime3"), second());
MyPanel.SetNumber(F("PTime4"), day());
MyPanel.SetNumber(F("PTime5"), month());
}
void Cmd_Move3(CommandParameter &p)
{
MyPanel.SetText(F("Switch"), "ON");
MyPanel.SetBackColor(F("Switch"), F("green"));
FLOWINMIN3 = 250;
PUMPONV1 = 0.001;
PUMPOFFV1 = 1000;
unsigned long currentMillis = millis();
unsigned long currenthour = hour(0);
unsigned long currentsec = second(0);
unsigned long currentmin = minute(0);
MyPanel.SetNumber(F("INMINVAL2"), FLOWINMIN3);
setTime(00,00,00,01, 01, 0000);
previousMillis3 = currentMillis;
previousMillis2c = currentMillis;
SerialCommandHandler.Process();
MyPanel.SetNumber(F("PTime"), hour());
MyPanel.SetNumber(F("PTime2"), minute());
MyPanel.SetNumber(F("PTime3"), second());
MyPanel.SetNumber(F("PTime4"), day());
MyPanel.SetNumber(F("PTime5"), month());
}
void Cmd_Move4(CommandParameter &p)
{
MyPanel.SetText(F("Switch"), "ON");
MyPanel.SetBackColor(F("Switch"), F("green"));
FLOWINMIN4 = 250;
PUMPONV1 = 0.001;
PUMPOFFV1 = 1000;
unsigned long currentMillis = millis();
unsigned long currenthour = hour(0);
unsigned long currentsec = second(0);
unsigned long currentmin = minute(0);
MyPanel.SetNumber(F("INMINVAL3"), FLOWINMIN4);
setTime(00,00,00,01, 01, 0000);
previousMillis4 = currentMillis;
previousMillis2d = currentMillis;
SerialCommandHandler.Process();
MyPanel.SetNumber(F("PTime"), hour());
MyPanel.SetNumber(F("PTime2"), minute());
MyPanel.SetNumber(F("PTime3"), second());
MyPanel.SetNumber(F("PTime4"), day());
MyPanel.SetNumber(F("PTime5"), month());
}
void Cmd_Move5(CommandParameter &p)
{
MyPanel.SetText(F("Switch"), "ON");
MyPanel.SetBackColor(F("Switch"), F("green"));
FLOWINMIN5 = 250;
PUMPONV1 = 0.001;
PUMPOFFV1 = 1000;
unsigned long currentMillis = millis();
unsigned long currenthour = hour(0);
unsigned long currentsec = second(0);
unsigned long currentmin = minute(0);
MyPanel.SetNumber(F("INMINVAL4"), FLOWINMIN5);
setTime(00,00,00,01, 01, 0000);
previousMillis5 = currentMillis;
previousMillis2e = currentMillis;
SerialCommandHandler.Process();
MyPanel.SetNumber(F("PTime"), hour());
MyPanel.SetNumber(F("PTime2"), minute());
MyPanel.SetNumber(F("PTime3"), second());
MyPanel.SetNumber(F("PTime4"), day());
MyPanel.SetNumber(F("PTime5"), month());
}
void Cmd_Move6(CommandParameter &p)
{
MyPanel.SetText(F("Switch"), "ON");
MyPanel.SetBackColor(F("Switch"), F("green"));
FLOWINMIN6 = 250;
PUMPONV1 = 0.001;
PUMPOFFV1 = 1000;
unsigned long currentMillis = millis();
unsigned long currenthour = hour(0);
unsigned long currentsec = second(0);
unsigned long currentmin = minute(0);
MyPanel.SetNumber(F("INMINVAL5"), FLOWINMIN6);
setTime(00,00,00,01, 01, 0000);
previousMillis6 = currentMillis;
previousMillis2f = currentMillis;
SerialCommandHandler.Process();
MyPanel.SetNumber(F("PTime"), hour());
MyPanel.SetNumber(F("PTime2"), minute());
MyPanel.SetNumber(F("PTime3"), second());
MyPanel.SetNumber(F("PTime4"), day());
MyPanel.SetNumber(F("PTime5"), month());
}
void Cmd_Stop1(CommandParameter &p)
{
MyPanel.SetText(F("Switch"), "OFF");
MyPanel.SetBackColor(F("Switch"), F("red"));
FLOWINMIN1 = 0;
PUMPONV1 = 0.001;
PUMPOFFV1 = 1000;
MyPanel.SetNumber(F("INMINVAL"), FLOWINMIN1);
}
void Cmd_Stop2(CommandParameter &p)
{
MyPanel.SetText(F("Switch"), "OFF");
MyPanel.SetBackColor(F("Switch"), F("red"));
FLOWINMIN2 = 0;
PUMPONV2 = 0.001;
PUMPOFFV2 = 1000;
MyPanel.SetNumber(F("INMINVAL1"), FLOWINMIN2);
}
void Cmd_Stop3(CommandParameter &p)
{
MyPanel.SetText(F("Switch"), "OFF");
MyPanel.SetBackColor(F("Switch"), F("red"));
FLOWINMIN3 = 0;
PUMPONV3 = 0.001;
PUMPOFFV3 = 1000;
MyPanel.SetNumber(F("INMINVAL2"), FLOWINMIN3);
}
void Cmd_Stop4(CommandParameter &p)
{
MyPanel.SetText(F("Switch"), "OFF");
MyPanel.SetBackColor(F("Switch"), F("red"));
FLOWINMIN4 = 0;
PUMPONV4 = 0.001;
PUMPOFFV4 = 1000;
MyPanel.SetNumber(F("INMINVAL3"), FLOWINMIN4);
}
void Cmd_Stop5(CommandParameter &p)
{
MyPanel.SetText(F("Switch"), "OFF");
MyPanel.SetBackColor(F("Switch"), F("red"));
FLOWINMIN5 = 0;
PUMPONV5 = 0.001;
PUMPOFFV5 = 1000;
MyPanel.SetNumber(F("INMINVAL4"), FLOWINMIN5);
}
void Cmd_Stop6(CommandParameter &p)
{
MyPanel.SetText(F("Switch"), "OFF");
MyPanel.SetBackColor(F("Switch"), F("red"));
FLOWINMIN6 = 0;
PUMPONV6 = 0.001;
PUMPOFFV6 = 1000;
MyPanel.SetNumber(F("INMINVAL5"), FLOWINMIN6);
}
//------------------------------------------------------------------------------------
void setup() {
Serial.begin(9600);
Wire.begin();
Multivar1=0.5;
Multivar2=0.5;
Multivar3=0.5;
Multivar4=0.5;
Multivar5=0.5;
Multivar6=0.5;
SerialCommandHandler.AddCommand(F("Go1"), Cmd_Move1);
SerialCommandHandler.AddCommand(F("Go2"), Cmd_Move2);
SerialCommandHandler.AddCommand(F("Go3"), Cmd_Move3);
SerialCommandHandler.AddCommand(F("Go4"), Cmd_Move4);
SerialCommandHandler.AddCommand(F("Go5"), Cmd_Move5);
SerialCommandHandler.AddCommand(F("Go6"), Cmd_Move6);
SerialCommandHandler.AddCommand(F("Stop1"), Cmd_Stop1);
SerialCommandHandler.AddCommand(F("Stop2"), Cmd_Stop2);
SerialCommandHandler.AddCommand(F("Stop3"), Cmd_Stop3);
SerialCommandHandler.AddCommand(F("Stop4"), Cmd_Stop4);
SerialCommandHandler.AddCommand(F("Stop5"), Cmd_Stop5);
SerialCommandHandler.AddCommand(F("Stop6"), Cmd_Stop6);
SerialCommandHandler.AddCommand(F("PUMPDELAYON1"), Cmd_PUMPON1);
SerialCommandHandler.AddCommand(F("PUMPDELAYOFF1"), Cmd_PUMPOFF1);
SerialCommandHandler.AddCommand(F("PUMPDELAYON2"), Cmd_PUMPON2);
SerialCommandHandler.AddCommand(F("PUMPDELAYOFF2"), Cmd_PUMPOFF2);
SerialCommandHandler.AddCommand(F("PUMPDELAYON3"), Cmd_PUMPON3);
SerialCommandHandler.AddCommand(F("PUMPDELAYOFF3"), Cmd_PUMPOFF3);
SerialCommandHandler.AddCommand(F("PUMPDELAYON4"), Cmd_PUMPON4);
SerialCommandHandler.AddCommand(F("PUMPDELAYOFF4"), Cmd_PUMPOFF4);
SerialCommandHandler.AddCommand(F("PUMPDELAYON5"), Cmd_PUMPON5);
SerialCommandHandler.AddCommand(F("PUMPDELAYOFF5"), Cmd_PUMPOFF5);
SerialCommandHandler.AddCommand(F("PUMPDELAYON6"), Cmd_PUMPON6);
SerialCommandHandler.AddCommand(F("PUMPDELAYOFF6"), Cmd_PUMPOFF6);
SerialCommandHandler.AddCommand(F("Feed-BDown"), Cmd_FeedBDown);
SerialCommandHandler.AddCommand(F("FWValueBB"), Cmd_FWValueBB);
SerialCommandHandler.AddCommand(F("Waste-BDown"), Cmd_WasteBDown);
SerialCommandHandler.AddCommand(F("Report-Refresh"), Cmd_ReportRefresh);
SerialCommandHandler.AddCommand(F("MultipleVaaal1"), Cmd_MultipleVaal1);
SerialCommandHandler.AddCommand(F("MultipleVaaal2"), Cmd_MultipleVaal2);
SerialCommandHandler.AddCommand(F("MultipleVaaal3"), Cmd_MultipleVaal3);
SerialCommandHandler.AddCommand(F("MultipleVaaal4"), Cmd_MultipleVaal4);
SerialCommandHandler.AddCommand(F("MultipleVaaal5"), Cmd_MultipleVaal5);
SerialCommandHandler.AddCommand(F("MultipleVaaal6"), Cmd_MultipleVaal6);
//Combination system serial orders
AFMS.begin();
myMotor1-> run(FORWARD);
myMotor2-> run(FORWARD);
myMotor3-> run(FORWARD);
myMotor4-> run(FORWARD);
myMotor1-> run(RELEASE);
myMotor2-> run(RELEASE);
myMotor3-> run(RELEASE);
myMotor4-> run(RELEASE);
AFMS1.begin();
myMotor1Sh1-> run(FORWARD);
myMotor2Sh1-> run(FORWARD);
myMotor3Sh1-> run(FORWARD);
myMotor4Sh1-> run(FORWARD);
myMotor1Sh1-> run(RELEASE);
myMotor2Sh1-> run(RELEASE);
myMotor3Sh1-> run(RELEASE);
myMotor4Sh1-> run(RELEASE);
AFMS2.begin();
myMotor1Sh2-> run(FORWARD);
myMotor2Sh2-> run(FORWARD);
myMotor3Sh2-> run(FORWARD);
myMotor4Sh2-> run(FORWARD);
myMotor1Sh2-> run(RELEASE);
myMotor2Sh2-> run(RELEASE);
myMotor3Sh2-> run(RELEASE);
myMotor4Sh2-> run(RELEASE);
}
void Stopoption(){
}
void loop()
{
uint8_t i;
SerialCommandHandler.Process();
unsigned long currentMillis = millis();
unsigned long currentMillis2 = millis();
unsigned long currentMillis3 = millis();
unsigned long currentMillis4 = millis();
wdt_enable(WDTO_4S);
TimePlot TimeR1("TimeR1");
TimeR1.SendData("TimeR1", Countdownhr1);
Timediff1= currentMillis - previousMillisT1;
Countdownhr1= ((Timediff2a - Timediff1)/3600000);
//----------------------------Reactor 1-------------------------------
if ((currentMillis - previousMillis) <= (PUMPOFFV1*3600000)) {
myMotor1->run(RELEASE);
myMotor2->run(RELEASE);
Countdownsec1= 60 - second();
Countdownmin1= 60 - (minute()+1);
MyPanel.SetNumber(F("TtoNexta"), Countdownhr1);
MyPanel.SetNumber(F("TtoNext2a"),Countdownmin1);
MyPanel.SetNumber(F("TtoNext3a"),Countdownsec1 );
}
else if ((currentMillis - previousMillis) <(((PUMPONV1*Multivar1)+PUMPOFFV1)*3600000)) {
myMotor2->setSpeed(FLOWINMIN1);
myMotor2->run(FORWARD);
}
wdt_reset();
wdt_disable();
wdt_enable(WDTO_2S);
if ((currentMillis - previousMillis2a) >=(((PUMPONV1*Multivar1)+PUMPOFFV1)*3600000)) {
myMotor2->run(RELEASE);
myMotor1->setSpeed(FLOWINMIN1);
myMotor1->run(FORWARD);
}
if ((currentMillis - previousMillis) >= ((PUMPONV1+PUMPOFFV1)*3600000)) {
myMotor1->run(RELEASE);
previousMillis = currentMillis;
previousMillis2a = currentMillis;
wdt_reset();
wdt_disable();
}
//-----------------------------Reactor2---------------------------------
TimePlot TimeR2("TimeR2");
TimeR2.SendData("TimeR2", Countdownhr2);
Timediff2= currentMillis - previousMillisT2;
Countdownhr2= ((Timediff2b - Timediff2)/3600000);
wdt_enable(WDTO_4S);
if ((currentMillis - previousMillis2) <= (PUMPOFFV2*3600000)) {
myMotor3->run(RELEASE);
myMotor4->run(RELEASE);
Countdownsec2= 60 - second();
Countdownmin2= 60 - (minute()+1);
MyPanel.SetNumber(F("TtoNextb"), Countdownhr2);
MyPanel.SetNumber(F("TtoNext2b"),Countdownmin2);
MyPanel.SetNumber(F("TtoNext3b"),Countdownsec2 );
}
else if ((currentMillis - previousMillis2) <(((PUMPONV2*Multivar2)+PUMPOFFV2)*3600000)) {
myMotor4->setSpeed(FLOWINMIN2);
myMotor4->run(FORWARD);
}
wdt_reset();
wdt_disable();
wdt_enable(WDTO_2S);
if ((currentMillis - previousMillis2b) >=(((PUMPONV2*Multivar2)+PUMPOFFV2)*3600000)) {
myMotor4->run(RELEASE);
myMotor3->setSpeed(FLOWINMIN2);
myMotor3->run(FORWARD);
}
if ((currentMillis - previousMillis2) >= ((PUMPONV2+PUMPOFFV2)*3600000)) {
myMotor3->run(RELEASE);
previousMillis2 = currentMillis;
previousMillis2b = currentMillis;
wdt_reset();
wdt_disable();
}
//-----------------------------Reactor3---------------------------------
TimePlot TimeR3("TimeR3");
TimeR3.SendData("TimeR3", Countdownhr3);
Timediff3= currentMillis - previousMillisT3;
Countdownhr3= ((Timediff2c - Timediff3)/3600000);
wdt_enable(WDTO_4S);
if ((currentMillis - previousMillis3) <= (PUMPOFFV3*3600000)) {
myMotor1Sh1->run(RELEASE);
myMotor2Sh1->run(RELEASE);
Countdownsec3= 60 - second();
Countdownmin3= 60 - (minute()+1);
MyPanel.SetNumber(F("TtoNextc"), Countdownhr3);
MyPanel.SetNumber(F("TtoNext2c"),Countdownmin3);
MyPanel.SetNumber(F("TtoNext3c"),Countdownsec3 );
}
else if ((currentMillis - previousMillis3) <(((PUMPONV3*Multivar3)+PUMPOFFV3)*3600000)) {
previousMillis6 = currentMillis;
myMotor2Sh1->setSpeed(FLOWINMIN3);
myMotor2Sh1->run(FORWARD);
}
wdt_reset();
wdt_disable();
wdt_enable(WDTO_2S);
if ((currentMillis - previousMillis2c) >=(((PUMPONV3*Multivar3)+PUMPOFFV3)*3600000)) {
myMotor2Sh1->run(RELEASE);
myMotor1Sh1->setSpeed(FLOWINMIN3);
myMotor1Sh1->run(FORWARD);
}
if ((currentMillis - previousMillis3) >= ((PUMPONV3+PUMPOFFV3)*3600000)) {
myMotor1Sh1->run(RELEASE);
previousMillis3 = currentMillis;
previousMillis2c = currentMillis;
wdt_reset();
wdt_disable();
}
//-----------------------------Reactor4---------------------------------
TimePlot TimeR4("TimeR4");
TimeR4.SendData("TimeR4", Countdownhr4);
Timediff4= currentMillis - previousMillisT4;
Countdownhr4= ((Timediff2d - Timediff4)/3600000);
wdt_enable(WDTO_4S);
if ((currentMillis - previousMillis4) <= (PUMPOFFV4*3600000)) {
myMotor3Sh1->run(RELEASE);
myMotor4Sh1->run(RELEASE);
Countdownsec4= 60 - second();
Countdownmin4= 60 - (minute()+1);
MyPanel.SetNumber(F("TtoNextd"), Countdownhr4);
MyPanel.SetNumber(F("TtoNext2d"),Countdownmin4);
MyPanel.SetNumber(F("TtoNext3d"),Countdownsec4 );
}
else if ((currentMillis - previousMillis4) <(((PUMPONV4*Multivar4)+PUMPOFFV4)*3600000)) {
myMotor4Sh1->setSpeed(FLOWINMIN4);
myMotor4Sh1->run(FORWARD);
}
wdt_reset();
wdt_disable();
wdt_enable(WDTO_2S);
if ((currentMillis - previousMillis2d) >=(((PUMPONV4*Multivar4)+PUMPOFFV4)*3600000)) {
myMotor4Sh1->run(RELEASE);
myMotor3Sh1->setSpeed(FLOWINMIN4);
myMotor3Sh1->run(FORWARD);
}
if ((currentMillis - previousMillis4) >= ((PUMPONV4+PUMPOFFV4)*3600000)) {
myMotor3Sh1->run(RELEASE);
previousMillis4 = currentMillis;
previousMillis2d = currentMillis;
wdt_reset();
wdt_disable();
}
//-----------------------------Reactor5---------------------------------
TimePlot TimeR5("TimeR5");
TimeR5.SendData("TimeR5", Countdownhr5);
Timediff5= currentMillis - previousMillisT5;
Countdownhr5= ((Timediff2e - Timediff5)/3600000);
wdt_enable(WDTO_4S);
if ((currentMillis - previousMillis5) <= (PUMPOFFV5*3600000)) {
myMotor1Sh2->run(RELEASE);
myMotor2Sh2->run(RELEASE);
Countdownsec5= 60 - second();
Countdownmin5= 60 - (minute()+1);
MyPanel.SetNumber(F("TtoNexte"), Countdownhr5);
MyPanel.SetNumber(F("TtoNext2e"),Countdownmin5);
MyPanel.SetNumber(F("TtoNext3e"),Countdownsec5 );
}
else if ((currentMillis - previousMillis5) <(((PUMPONV5*Multivar5)+PUMPOFFV5)*3600000)) {
myMotor2Sh2->setSpeed(FLOWINMIN5);
myMotor2Sh2->run(FORWARD);
}
wdt_reset();
wdt_disable();
wdt_enable(WDTO_2S);
if ((currentMillis - previousMillis2e) >=(((PUMPONV5*Multivar5)+PUMPOFFV5)*3600000)) {
myMotor2Sh2->run(RELEASE);
myMotor1Sh2->setSpeed(FLOWINMIN5);
myMotor1Sh2->run(FORWARD);
}
if ((currentMillis - previousMillis5) >= ((PUMPONV5+PUMPOFFV5)*3600000)) {
myMotor1Sh2->run(RELEASE);
previousMillis5 = currentMillis;
previousMillis2e = currentMillis;
wdt_reset();
wdt_disable();
}
//-----------------------------Reactor6---------------------------------
TimePlot TimeR6("TimeR6");
TimeR6.SendData("TimeR6", Countdownhr6);
Timediff6= currentMillis - previousMillisT6;
Countdownhr6= ((Timediff2f - Timediff6)/3600000);
wdt_enable(WDTO_4S);
if ((currentMillis - previousMillis6) <= (PUMPOFFV6*3600000)) {
myMotor3Sh2->run(RELEASE);
myMotor4Sh2->run(RELEASE);
Countdownsec6= 60 - second();
Countdownmin6= 60 - (minute()+1);
MyPanel.SetNumber(F("TtoNextf"), Countdownhr6);
MyPanel.SetNumber(F("TtoNext2f"),Countdownmin6);
MyPanel.SetNumber(F("TtoNext3f"),Countdownsec6 );
}
else if ((currentMillis - previousMillis6) <(((PUMPONV6*Multivar6)+PUMPOFFV6)*3600000)) {
myMotor4Sh2->setSpeed(FLOWINMIN6);
myMotor4Sh2->run(FORWARD);
}
wdt_reset();
wdt_disable();
wdt_enable(WDTO_2S);
if ((currentMillis - previousMillis2f) >=(((PUMPONV6*Multivar6)+PUMPOFFV6)*3600000)) {
myMotor4Sh2->run(RELEASE);
myMotor3Sh2->setSpeed(FLOWINMIN6);
myMotor3Sh2->run(FORWARD);
}
if ((currentMillis - previousMillis6) >= ((PUMPONV6+PUMPOFFV6)*3600000)) {
myMotor3Sh2->run(RELEASE);
previousMillis6 = currentMillis;
previousMillis2f = currentMillis;
wdt_reset();
wdt_disable();
}
}
Comments