Im having a very hard time figuring out whats wrong with a piece of code. I have multiple functions that can control a variable frequency drive. 2 of the 3 functions work correctly while the third does not. If I take the tablesaw function out of the program the jointer function works but with the tablesaw function in it seams the VFD output is being turned on and off everytime through the code. The LED on the 16 channel relay is lit but I think because of the cycling the VFD does not turn on.
Here are the 3 functions
void tablesaw(){
if (TSIState == LOW){
if(BIState == HIGH){
if(CBIState == HIGH){
if(JLIState == HIGH){
if(PLIState == HIGH){
if(DPIState == HIGH){
if(SHIState == HIGH) {
unsigned long currentTSMillis = millis();
digitalWrite(DC, LOW);
digitalWrite(TS, LOW);
if (currentTSMillis - TimerTSON >= 1000){
digitalWrite(VFD, LOW);
TimerPLOFF = millis();
TimerJLOFF = millis();
TimerTSOFF = millis();
TimerCBOFF = millis();
TimerDPOFF = millis();
TimerBOFF = millis();
TimerSHOFF = millis();
}
}
}
}
}
}
}
}
else if (DPIState == LOW){
if(JLIState == LOW){
if(CBIState == LOW){
if(BIState == LOW){
if(SHIState == LOW){
if(PLIState == LOW){
}
}
}
}
}
}
else {
digitalWrite(VFD, HIGH);
unsigned long currentTSMillis = millis();
if (currentTSMillis - TimerTSOFF >= 5000){
digitalWrite(DC, HIGH);
}
if (currentTSMillis - TimerTSOFF >= 30000){
digitalWrite(TS, HIGH);
TimerTSON = millis();
}
}
}
void jointer(){
if (JLIState == LOW){
if(PLIState == HIGH){
if(DPIState == HIGH){
if(CBIState == HIGH){
if(BIState == HIGH){
if(SHIState == HIGH){
if(TSIState == HIGH) {
// turn Planer relay on and Turn on Inverter
unsigned long currentJLMillis = millis();
digitalWrite(DC, LOW);
digitalWrite(JL, LOW);
if (currentJLMillis - TimerJLON >= 1000){
digitalWrite(VFD, LOW);
TimerPLOFF = millis();
TimerJLOFF = millis();
TimerTSOFF = millis();
TimerCBOFF = millis();
TimerDPOFF = millis();
TimerBOFF = millis();
TimerSHOFF = millis();
}
}
}
}
}
}
}
}
else if (DPIState == LOW){
if(PLIState == LOW){
if(CBIState == LOW){
if(BIState == LOW){
if(SHIState == LOW){
if(TSIState == LOW){
}
}
}
}
}
}
else {
digitalWrite(VFD, HIGH);
unsigned long currentJLMillis = millis();
if (currentJLMillis - TimerJLOFF >= 5000){
digitalWrite(DC, HIGH);
}
if (currentJLMillis - TimerJLOFF >= 20000){
digitalWrite(JL, HIGH);
TimerJLON = millis();
}
}
}
void planer(){
if (PLIState == LOW){
if(DPIState == HIGH){
if(JLIState == HIGH){
if(CBIState == HIGH){
if(BIState == HIGH){
if(SHIState == HIGH){
if(TSIState == HIGH) {
// turn Planer relay on and Turn on Inverter
unsigned long currentPLMillis = millis();
digitalWrite(DC, LOW);
digitalWrite(PL, LOW);
if (currentPLMillis - TimerPLON >= 1000){
digitalWrite(VFD, LOW);
TimerPLOFF = millis();
TimerJLOFF = millis();
TimerTSOFF = millis();
TimerCBOFF = millis();
TimerDPOFF = millis();
TimerBOFF = millis();
TimerSHOFF = millis();
}
}
}
}
}
}
}
}
else if (DPIState == LOW){
if(JLIState == LOW){
if(CBIState == LOW){
if(BIState == LOW){
if(SHIState == LOW){
if(TSIState == LOW){
}
}
}
}
}
}
else {
digitalWrite(VFD, HIGH);
unsigned long currentPLMillis = millis();
if (currentPLMillis - TimerPLOFF >= 5000){
digitalWrite(DC, HIGH);
}
if (currentPLMillis - TimerPLOFF >= 20000){
digitalWrite(PL, HIGH);
TimerPLON = millis();
}
}
}
I think that the this part of the code is causing the VFD to be turned back off the LED on the 16 channel relay is lit but the VFD does not turn on (if I put a jumper across the terminals on the relay the VFD comes on). The tablesaw function works correctly.
else {
digitalWrite(VFD, HIGH);
unsigned long currentTSMillis = millis();
if (currentTSMillis - TimerTSOFF >= 5000){
digitalWrite(DC, HIGH);
}
if (currentTSMillis - TimerTSOFF >= 30000){
digitalWrite(TS, HIGH);
TimerTSON = millis();
I also left all the tablesaw code and and just commented out //digitalWrite(VFD, HIGH); in the else statement and the jointer code works... so this tells me the code is running the else statement in the tablesaw code but I dont think it should be..
I have this part in so that if any of the functions are being called for it should skip the final else statement in each function.
else if (DPIState == LOW){
if(JLIState == LOW){
if(CBIState == LOW){
if(BIState == LOW){
if(SHIState == LOW){
if(PLIState == LOW){
}
}
}
}
}
}
Any help is greatly appreciated Im tired of banging my head against the wall. Its probably something silly I just cant find it.
Thanks