This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
bdev:filamentextrduer_code [2022/11/28 22:30] richard |
bdev:filamentextrduer_code [2022/12/01 03:02] (current) richard |
||
---|---|---|---|
Line 7: | Line 7: | ||
#define motorInterfaceType 1 | #define motorInterfaceType 1 | ||
+ | |||
+ | struct flowData{ | ||
+ | int bfl; | ||
+ | int dir; | ||
+ | }; | ||
//Define the aggressive and conservative Tuning Parameters | //Define the aggressive and conservative Tuning Parameters | ||
Line 21: | Line 26: | ||
int directionC = 0; | int directionC = 0; | ||
int directionD = 0; | int directionD = 0; | ||
- | int directionE = 0; | ||
int ton = 0; | int ton = 0; | ||
Line 29: | Line 33: | ||
int buttoncstate = 0; | int buttoncstate = 0; | ||
int buttondstate = 0; | int buttondstate = 0; | ||
- | int buttonestate = 0; | + | |
int afl = 0; | int afl = 0; | ||
Line 35: | Line 39: | ||
int cfl = 0; | int cfl = 0; | ||
int dfl = 0; | int dfl = 0; | ||
- | int efl = 0; | ||
String command; | String command; | ||
Line 46: | Line 49: | ||
#define THERMISTOR_PINA A0 | #define THERMISTOR_PINA A0 | ||
- | #define TEMPCONTROLA | + | #define TEMPCONTROLA |
+ | #define PUMP 12 | ||
- | + | int PS[] = {26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 45, 47, 49}; | |
- | int PS[] = {26, 28, 30, 32, 34, 36, 40, 42, 44, 46, 48, 50, 52, 24}; | + | |
// Define some steppers and the pins the will use | // Define some steppers and the pins the will use | ||
Line 64: | Line 67: | ||
const int stepsPinC = PS[8]; | const int stepsPinC = PS[8]; | ||
- | const int enablePinD = PS[10]; | + | const int enablePinD = PS[9]; |
- | const int directionPinD = PS[11]; | + | const int directionPinD = PS[10]; |
- | const int stepsPinD = PS[12]; | + | const int stepsPinD = PS[11]; |
- | const int enablePinE | + | //const int speedpotA |
- | const int directionPinE | + | //const int gobuttonA |
- | const int stepsPinE | + | //const int stopbuttonA |
- | const int speedpotA = A1; | + | const int speedpotA = A4; |
- | const int gobuttonA = A2; | + | const int gobuttonA = A5; |
- | const int stopbuttonA = A3; | + | const int stopbuttonA = A6; |
const int stepspinA = LOW; | const int stepspinA = LOW; | ||
- | const int speedpotB = A4; | + | const int speedpotB = A7; |
- | const int gobuttonB = A5; | + | const int gobuttonB = A8; |
- | const int stopbuttonB = A6; | + | const int stopbuttonB = A9; |
const int stepspinB = LOW; | const int stepspinB = LOW; | ||
- | const int speedpotC = A7; | + | const int speedpotC = A10; |
- | const int gobuttonC = A8; | + | const int gobuttonC = A11; |
- | const int stopbuttonC = A9; | + | const int stopbuttonC = A12; |
const int stepspinC = LOW; | const int stepspinC = LOW; | ||
- | const int speedpotD = A10; | + | const int speedpotD = A13; |
- | const int gobuttonD = A11; | + | const int gobuttonD = A14; |
- | const int stopbuttonD = A12; | + | const int stopbuttonD = A15; |
const int stepspinD = LOW; | const int stepspinD = LOW; | ||
- | |||
- | const int speedpotE = A13; | ||
- | const int gobuttonE = A14; | ||
- | const int stopbuttonE = A15; | ||
- | const int stepspinE = LOW; | ||
- | |||
AccelStepper stepperA = AccelStepper(motorInterfaceType, | AccelStepper stepperA = AccelStepper(motorInterfaceType, | ||
AccelStepper stepperB = AccelStepper(motorInterfaceType, | AccelStepper stepperB = AccelStepper(motorInterfaceType, | ||
AccelStepper stepperC = AccelStepper(motorInterfaceType, | AccelStepper stepperC = AccelStepper(motorInterfaceType, | ||
- | |||
AccelStepper stepperD = AccelStepper(motorInterfaceType, | AccelStepper stepperD = AccelStepper(motorInterfaceType, | ||
- | AccelStepper stepperE = AccelStepper(motorInterfaceType, | ||
Line 121: | Line 116: | ||
pinMode(directionPinD, | pinMode(directionPinD, | ||
pinMode(enablePinD, | pinMode(enablePinD, | ||
- | pinMode(stepsPinE, | ||
- | pinMode(directionPinE, | ||
- | pinMode(enablePinE, | ||
- | |||
- | |||
- | |||
pinMode(TEMPCONTROLA, | pinMode(TEMPCONTROLA, | ||
- | + | pinMode(PUMP, | |
- | + | ||
- | + | ||
digitalWrite(enablePinA, | digitalWrite(enablePinA, | ||
digitalWrite(enablePinB, | digitalWrite(enablePinB, | ||
digitalWrite(enablePinC, | digitalWrite(enablePinC, | ||
digitalWrite(enablePinD, | digitalWrite(enablePinD, | ||
- | digitalWrite(enablePinE, | ||
- | |||
digitalWrite(directionPinA, | digitalWrite(directionPinA, | ||
digitalWrite(directionPinB, | digitalWrite(directionPinB, | ||
digitalWrite(directionPinC, | digitalWrite(directionPinC, | ||
digitalWrite(directionPinD, | digitalWrite(directionPinD, | ||
- | digitalWrite(directionPinE, LOW); | + | digitalWrite(PUMP,LOW); |
- | + | ||
- | | + | |
stepperA.setMaxSpeed(1000*16); | stepperA.setMaxSpeed(1000*16); | ||
stepperB.setMaxSpeed(1000*16); | stepperB.setMaxSpeed(1000*16); | ||
stepperC.setMaxSpeed(1000*16); | stepperC.setMaxSpeed(1000*16); | ||
stepperD.setMaxSpeed(1000*16); | stepperD.setMaxSpeed(1000*16); | ||
- | stepperE.setMaxSpeed(1000*16); | ||
//turn the PID on | //turn the PID on | ||
myPIDA.SetMode(AUTOMATIC); | myPIDA.SetMode(AUTOMATIC); | ||
- | |||
} | } | ||
Line 162: | Line 142: | ||
int speedC = map(analogRead(speedpotC), | int speedC = map(analogRead(speedpotC), | ||
int speedD = map(analogRead(speedpotD), | int speedD = map(analogRead(speedpotD), | ||
- | int speedE = map(analogRead(speedpotE), | ||
Input = read_temp(" | Input = read_temp(" | ||
Line 183: | Line 162: | ||
| | ||
} | } | ||
- | bfl = motorStop(stopbuttonA, | + | /* |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | */ | ||
+ | |||
+ | flowData A = {bfl, directionA}; | ||
+ | flowData *AA = &A; | ||
+ | flowData AAA = motorStop(stopbuttonA, | ||
+ | directionA = AAA.dir; | ||
motorMove(gobuttonA, | motorMove(gobuttonA, | ||
- | bfl = motorStop(stopbuttonB, | + | flowData B = {bfl, directionB}; |
+ | flowData *BB = &B; | ||
+ | flowData BBB = motorStop(stopbuttonB, | ||
+ | directionB = BBB.dir; | ||
motorMove(gobuttonB, | motorMove(gobuttonB, | ||
- | bfl = motorStop(stopbuttonC, | + | flowData C = {bfl, directionC}; |
+ | flowData *CC = &C; | ||
+ | flowData CCC = motorStop(stopbuttonC, | ||
+ | directionC = CCC.dir; | ||
motorMove(gobuttonC, | motorMove(gobuttonC, | ||
- | bfl = motorStop(stopbuttonD, | + | flowData D = {bfl, directionD}; |
+ | flowData *DD = &D; | ||
+ | flowData DDD = motorStop(stopbuttonD, | ||
+ | directionD = DDD.dir; | ||
motorMove(gobuttonD, | motorMove(gobuttonD, | ||
- | bfl = motorStop(stopbuttonE, | + | if (A.dir |
- | motorMove(gobuttonE, enablePinE); | + | if (B.dir == 1) {stepperB.setSpeed(speedB); |
+ | if (C.dir == 1) {stepperC.setSpeed(speedC); | ||
+ | if (D.dir == 1) {stepperD.setSpeed(speedD); | ||
- | if (directionA == 1) {stepperA.setSpeed(speedA); | + | |
- | if (directionB == 1) {stepperB.setSpeed(speedB); | + | |
- | if (directionC == 1) {stepperC.setSpeed(speedC); | + | |
- | + | ||
- | + | ||
- | //if (stepperC.distanceToGo() == 0) | + | |
- | // | + | |
- | stepperE.runSpeed(); | + | |
stepperD.runSpeed(); | stepperD.runSpeed(); | ||
stepperC.runSpeed(); | stepperC.runSpeed(); | ||
stepperB.runSpeed(); | stepperB.runSpeed(); | ||
stepperA.runSpeed(); | stepperA.runSpeed(); | ||
+ | | ||
| | ||
char c = Serial.read(); | char c = Serial.read(); | ||
Line 227: | Line 237: | ||
if (digitalRead(gobutton) == 1){ | if (digitalRead(gobutton) == 1){ | ||
| | ||
+ | | ||
+ | | ||
} | } | ||
} | } | ||
- | int motorStop(int stopbutton, int enablePin, int direction, int directionPin, | + | flowData |
if (digitalRead(stopbutton) ==HIGH){ | if (digitalRead(stopbutton) ==HIGH){ | ||
digitalWrite(enablePin, | digitalWrite(enablePin, | ||
- | if (bfl == 0){ | + | if (X->bfl == 0){ |
- | if (direction==0){direction | + | if (X->dir==0){X-> |
- | bfl = 1; | + | |
} | } | ||
- | } else { bfl = 0; } | + | } else { X->bfl = 0; } |
- | return | + | |
+ | Serial.print(" | ||
+ | Serial.println(stopbutton); | ||
+ | return | ||
} | } | ||
Line 250: | Line 265: | ||
| | ||
} | } | ||
+ | else if(com.equalsIgnoreCase(" | ||
+ | digitalWrite(PUMP, | ||
+ | } | ||
+ | else if(com.equalsIgnoreCase(" | ||
+ | digitalWrite(PUMP, | ||
+ | } | ||
else if(com.equalsIgnoreCase(" | else if(com.equalsIgnoreCase(" | ||
Serial.println(" | Serial.println(" | ||
Line 288: | Line 309: | ||
| | ||
| | ||
+ | val = analogRead(speedpotD); | ||
+ | | ||
+ | | ||
} | } | ||
Line 343: | Line 367: | ||
| | ||
} | } | ||
- | |||
</ | </ |