User Tools

Site Tools


bdev:filamentextrduer_code

Warning: Undefined array key 6 in /var/www/html/dokuwiki/inc/html.php on line 1453

Warning: Undefined array key -1 in /var/www/html/dokuwiki/inc/html.php on line 1458

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
bdev:filamentextrduer_code [2022/11/06 15:15]
richard created
bdev:filamentextrduer_code [2022/12/01 03:02] (current)
richard
Line 1: Line 1:
 ====== Filabotextruder code 1 ====== ====== Filabotextruder code 1 ======
  
 +5 motor
 <code> <code>
 #include <PID_v1.h>  #include <PID_v1.h> 
-#include <Wire.h> +#include <AccelStepper.h>
-#include <SoftwareSerial.h>+
 #define motorInterfaceType 1 #define motorInterfaceType 1
  
  
-#define THERMISTOR_PINA A11 +struct flowData{ 
-#define TEMPCONTROLA 10+   int bfl; 
 +   int dir; 
 +};
  
 //Define the aggressive and conservative Tuning Parameters //Define the aggressive and conservative Tuning Parameters
Line 19: Line 21:
 double Setpoint, Input, Output, OutputA, OutputB, OutputC; double Setpoint, Input, Output, OutputA, OutputB, OutputC;
 int tme = 250; int tme = 250;
 +
 +int directionA = 0;
 +int directionB = 0;
 +int directionC = 0;
 +int directionD = 0;
 +
 +int ton = 0;
 +
 +int buttonastate = 0;
 +int buttonbstate = 0;
 +int buttoncstate = 0;
 +int buttondstate = 0;
 +
 +
 +int afl = 0;
 +int bfl = 0;
 +int cfl = 0;
 +int dfl = 0;
 +
 +String command;
 +long int currpos;
 +long int pos;
 +
 +//Specify the links and initial tuning parameters
 +PID myPIDA(&Input, &Output, &Setpoint, aggKpA, aggKiA, aggKdA, DIRECT);
 +
 +
 +#define THERMISTOR_PINA A0
 +#define TEMPCONTROLA 13
 +#define PUMP 12
 +
 +int PS[] = {26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 45, 47, 49};
 +
 +// Define some steppers and the pins the will use
 +const int enablePinA = PS[0];
 +const int directionPinA = PS[1];
 +const int stepsPinA = PS[2];
 +
 +const int enablePinB = PS[3];
 +const int directionPinB = PS[4];
 +const int stepsPinB = PS[5];
 +
 +const int enablePinC = PS[6];
 +const int directionPinC = PS[7];
 +const int stepsPinC = PS[8];
 +
 +const int enablePinD = PS[9];
 +const int directionPinD = PS[10];
 +const int stepsPinD = PS[11];
 +
 +//const int speedpotA = A1;
 +//const int gobuttonA = A2;
 +//const int stopbuttonA = A3;
 +
 +const int speedpotA = A4;
 +const int gobuttonA = A5;
 +const int stopbuttonA = A6;
 +const int stepspinA = LOW;
 +
 +const int speedpotB = A7;
 +const int gobuttonB = A8;
 +const int stopbuttonB = A9;
 +const int stepspinB = LOW;
 +
 +const int speedpotC = A10;
 +const int gobuttonC = A11;
 +const int stopbuttonC = A12;
 +const int stepspinC = LOW;
 +
 +const int speedpotD = A13;
 +const int gobuttonD = A14;
 +const int stopbuttonD = A15;
 +const int stepspinD = LOW;
 +
 +AccelStepper stepperA = AccelStepper(motorInterfaceType, stepsPinA, directionPinA);
 +AccelStepper stepperB = AccelStepper(motorInterfaceType, stepsPinB, directionPinB);
 +AccelStepper stepperC = AccelStepper(motorInterfaceType, stepsPinC, directionPinC);
 +AccelStepper stepperD = AccelStepper(motorInterfaceType, stepsPinD, directionPinD);
 +
 +
 +void setup()
 +{  
 +  Serial.begin(115200);
 +  pinMode(stepsPinA, OUTPUT);
 +  pinMode(directionPinA, OUTPUT);
 +  pinMode(enablePinA, OUTPUT);
 +  pinMode(stepsPinB, OUTPUT);
 +  pinMode(directionPinB, OUTPUT);
 +  pinMode(enablePinB, OUTPUT);
 +  pinMode(stepsPinC, OUTPUT);
 +  pinMode(directionPinC, OUTPUT);
 +  pinMode(enablePinC, OUTPUT);
 +  pinMode(stepsPinD, OUTPUT);
 +  pinMode(directionPinD, OUTPUT);
 +  pinMode(enablePinD, OUTPUT);
 +  pinMode(TEMPCONTROLA, OUTPUT);
 +  pinMode(PUMP, OUTPUT);
 +  digitalWrite(enablePinA,HIGH);
 +  digitalWrite(enablePinB,HIGH);
 +  digitalWrite(enablePinC,HIGH);
 +  digitalWrite(enablePinD,HIGH);
 +  digitalWrite(directionPinA, LOW);
 +  digitalWrite(directionPinB, LOW);
 +  digitalWrite(directionPinC, LOW);
 +  digitalWrite(directionPinD, LOW);
 +  digitalWrite(PUMP,LOW);
 +  stepperA.setMaxSpeed(1000*16);
 +  stepperB.setMaxSpeed(1000*16);
 +  stepperC.setMaxSpeed(1000*16);  
 +  stepperD.setMaxSpeed(1000*16);  
 +
 +  //turn the PID on
 +  myPIDA.SetMode(AUTOMATIC);
 +}
 +
 +void loop(){
 +
 +  int speedA = map(analogRead(speedpotA), 0, 1023, 1, 2000);
 +  int speedB = map(analogRead(speedpotB), 0, 1023, 1, 2000);
 +  int speedC = map(analogRead(speedpotC), 0, 1023, 1, 2000);
 +  int speedD = map(analogRead(speedpotD), 0, 1023, 1, 2000);
 +
 +  Input = read_temp("A");
 +  double gap = abs(Setpoint-Input); //distance away from setpoint
 +  myPIDA.SetTunings(aggKpA, aggKiA, aggKdA);
 +  myPIDA.Compute();
 +  analogWrite(TEMPCONTROLA,Output);
 +
 +  int rawvalue = analogRead(THERMISTOR_PINA);
 +  int rawvalueA = rawvalue;
 +  float celsiusA = read_temp("A");
 +
 +  if (levelstreamon == 1) {
 +   Serial.print("A: ");
 +   Serial.print(rawvalueA);
 +   Serial.print(" ");
 +   Serial.println(celsiusA);
 +   Serial.print("Settemp: ");
 +   Serial.println(settemp);   
 +   delay(500);
 +  }
 +/*
 + Serial.print("A go ");
 + Serial.println(digitalRead(gobuttonA));
 + Serial.print("A stop ");
 + Serial.println(digitalRead(stopbuttonA));
 +
 + Serial.print("B go ");
 + Serial.println(digitalRead(gobuttonB));
 + Serial.print("B stop ");
 + Serial.println(digitalRead(stopbuttonB));
 +
 + Serial.print("C go ");
 + Serial.println(digitalRead(gobuttonC));
 + Serial.print("C stop ");
 + Serial.println(digitalRead(stopbuttonC)); 
 +
 + Serial.print("D go ");
 + Serial.println(digitalRead(gobuttonD));
 + Serial.print("D stop ");
 + Serial.println(digitalRead(stopbuttonD));  
 + Serial.println("");
 + delay(500);
 +*/
 +
 +flowData A = {bfl, directionA};
 +flowData *AA = &A;
 +flowData AAA = motorStop(stopbuttonA, enablePinA, directionPinA, AA);
 +directionA = AAA.dir;
 +motorMove(gobuttonA, enablePinA);
 +
 +flowData B = {bfl, directionB};
 +flowData *BB = &B;
 +flowData BBB = motorStop(stopbuttonB, enablePinB, directionPinB, BB);
 +directionB = BBB.dir;
 +motorMove(gobuttonB, enablePinB);
 +
 +flowData C = {bfl, directionC};
 +flowData *CC = &C;
 +flowData CCC = motorStop(stopbuttonC, enablePinC, directionPinC, CC);
 +directionC = CCC.dir;
 +motorMove(gobuttonC, enablePinC);
 +
 +flowData D = {bfl, directionD};
 +flowData *DD = &D;
 +flowData DDD = motorStop(stopbuttonD, enablePinD, directionPinD, DD);
 +directionD = DDD.dir;
 +motorMove(gobuttonD, enablePinD);
 +
 +  if (A.dir == 1) {stepperA.setSpeed(speedA);}else{stepperA.setSpeed(-speedA);}
 +  if (B.dir == 1) {stepperB.setSpeed(speedB);}else{stepperB.setSpeed(-speedB);}
 +  if (C.dir == 1) {stepperC.setSpeed(speedC);}else{stepperC.setSpeed(-speedC);}
 +  if (D.dir == 1) {stepperD.setSpeed(speedD);}else{stepperD.setSpeed(-speedD);}
 +
 + 
 +  stepperD.runSpeed();
 +  stepperC.runSpeed();
 +  stepperB.runSpeed();
 +  stepperA.runSpeed();
 +  
 + if(Serial.available()){
 +    char c = Serial.read();
 +    if (c== '\n'){
 +      currpos = parseCommand(command, currpos);
 +      command = "";
 +    }
 +    else{
 +      command +=c;
 +    }
 + }  
 +}
 +
 +
 +void motorMove(int gobutton, int enablePin){
 + if (digitalRead(gobutton) == 1){
 +   digitalWrite(enablePin, LOW);
 +   Serial.print("move ");
 +   Serial.println(gobutton);
 +  }
 +}
 +
 +flowData motorStop(int stopbutton, int enablePin, int directionPin, flowData *X){
 + if (digitalRead(stopbutton) ==HIGH){
 +  digitalWrite(enablePin, HIGH);
 +  if (X->bfl == 0){
 +   if (X->dir==0){X->dir = 1; digitalWrite(directionPin, HIGH); }else{X->dir=0; digitalWrite(directionPin, LOW);}
 +    X->bfl = 1;
 +   }
 +  } else { X->bfl = 0; }
 +
 +Serial.print("stop ");
 +Serial.println(stopbutton);
 +return *X;
 +}
 +
 +
 +
 +long int parseCommand(String com, long int currpos){
 +  //Serial.print("Your command: ");
 +  //Serial.println(com);
 +
 +  if(com.equalsIgnoreCase("readpot")){
 +   readpotentionmetersanity();
 +  }
 +  else if(com.equalsIgnoreCase("pumpon")){
 +    digitalWrite(PUMP,HIGH);
 +  } 
 +  else if(com.equalsIgnoreCase("pumpoff")){
 +    digitalWrite(PUMP,LOW);
 +  } 
 +  else if(com.equalsIgnoreCase("info")){
 +    Serial.println("Extruder spool speed controller");
 +  }
 +  else if (com.substring(0,7) == "settemp") {
 +    settemp = com.substring(8).toDouble();
 +    Setpoint = settemp;
 +    Serial.print("settemp: ");
 +    Serial.println(settemp);
 +  }
 +  else if(com.equalsIgnoreCase("levelstreamoff")){
 +   levelstreamon = 0;
 +  } 
 +  else if(com.equalsIgnoreCase("levelstreamon")){
 +   levelstreamon = 1;
 +  } 
 +  else if(com.equalsIgnoreCase("readlevel")){
 +     int rawvalue = analogRead(THERMISTOR_PINA);
 +     float celsius = read_temp("A");
 +     Serial.print("A: ");
 +     Serial.println(celsius);
 +  }
 +  else {
 +   Serial.print("Did not recognize ");
 +   Serial.println(com);
 +  }
 +   return currpos;
 +}
 +
 +int readpotentionmetersanity(){
 + int val = analogRead(speedpotA);
 + Serial.print("speed pinA: ");
 + Serial.println(val);
 + val = analogRead(speedpotB);
 + Serial.print("speed pinB: ");
 + Serial.println(val); 
 + val = analogRead(speedpotC);
 + Serial.print("speed pinC: ");
 + Serial.println(val); 
 + val = analogRead(speedpotD);
 + Serial.print("speed pinD: ");
 + Serial.println(val);
 +}
 +
 +
 +#define NUMTEMPS 20
 +short temptable[NUMTEMPS][2] = {
 +   {1, 841}, {54, 255},
 +   {107, 209},
 +   {160, 184},
 +   {213, 166},
 +   {266, 153},
 +   {319, 142},
 +   {372, 132},
 +   {425, 124},
 +   {478, 116},
 +   {531, 108},
 +   {584, 101},
 +   {637, 93},
 +   {690, 86},
 +   {743, 78},
 +   {796, 70},
 +   {849, 61},
 +   {902, 50},
 +   {955, 34},
 +   {1008, 3}
 +};
 +
 +float read_temp(String sensor_type)
 +{
 +   int THERMISTOR_PIN = 0;
 +   if (sensor_type == "A"){
 +    THERMISTOR_PIN = THERMISTOR_PINA;
 +   }
 +   int rawtemp = analogRead(THERMISTOR_PIN);
 +   float current_celsius = 0;
 +
 +   byte i;
 +   for (i=1; i<NUMTEMPS; i++)
 +   {
 +      if (temptable[i][0] > rawtemp)
 +      {
 +         float realtemp  = temptable[i-1][1] + (rawtemp - temptable[i-1][0]) * (temptable[i][1] - temptable[i-1][1]) / (temptable[i][0] - temptable[i-1][0]);
 +
 +         if (realtemp > 255)
 +           realtemp = 255; 
 +           current_celsius = realtemp;
 +           break;
 +      }
 +   }
 +
 +   // Overflow: We just clamp to 0 degrees celsius
 +   if (i == NUMTEMPS)
 +   current_celsius = 0;
 +
 +   return current_celsius;
 +}
 +
 +</code>
 +
 +
 +
 +
 +<code>
 +
 +#include <PID_v1.h> 
 +#include <AccelStepper.h>
 +#define motorInterfaceType 1
 +
 +
 +//Define the aggressive and conservative Tuning Parameters
 +double aggKpA=150, aggKiA=0.5, aggKdA=0;
 +int thermoelectricval = 255;
 +int celsius;
 +int levelstreamon;
 +double settemp = 0;
 +double Setpoint, Input, Output, OutputA, OutputB, OutputC;
 +int tme = 250;
 +
 +int directionA = 0;
 +int directionB = 0;
 +int directionC = 0;
 +
 +int ton = 0;
 +
 +int buttonastate = 0;
 +int buttonbstate = 0;
 +int buttoncstate = 0;
 +int afl = 0;
 +int bfl = 0;
 +int cfl = 0;
 +
 +String command;
 +long int currpos;
 +long int pos;
 +int goA, goB, goC;
  
 //Specify the links and initial tuning parameters //Specify the links and initial tuning parameters
Line 24: Line 411:
  
  
 +#define THERMISTOR_PINA A11
 +#define TEMPCONTROLA 10
 +
 +// Define some steppers and the pins the will use
 const int stepsPinA = 11; const int stepsPinA = 11;
 const int directionPinA = 12; const int directionPinA = 12;
 const int enablePinA = 2; const int enablePinA = 2;
- 
  
 const int stepsPinB = 3; const int stepsPinB = 3;
Line 36: Line 426:
 const int directionPinC = 8; const int directionPinC = 8;
 const int enablePinC = 9; const int enablePinC = 9;
 +
  
 const int gobuttonA = A0; const int gobuttonA = A0;
 const int stopbuttonA = A1; const int stopbuttonA = A1;
 const int speedpotA = A2; const int speedpotA = A2;
 +const int stepspinA = LOW;
  
 const int gobuttonB = A5; const int gobuttonB = A5;
 const int stopbuttonB = A6; const int stopbuttonB = A6;
 const int speedpotB = A3; const int speedpotB = A3;
 +const int stepspinB = LOW;
  
 const int gobuttonC = A7; const int gobuttonC = A7;
-const int stopbuttonC = A10;+const int stopbuttonC = A8;
 const int speedpotC = A4; const int speedpotC = A4;
 +const int stepspinC = LOW;
  
-int directionA = 0; 
-int directionB = 0; 
-int directionC = 0; 
  
-int ton 0+AccelStepper stepperA AccelStepper(motorInterfaceType, stepsPinA, directionPinA)
- +AccelStepper stepperB AccelStepper(motorInterfaceType, stepsPinB, directionPinB)
-int buttonastate 0+AccelStepper stepperC AccelStepper(motorInterfaceType, stepsPinC, directionPinC);
-int buttonbstate 0; +
-int buttoncstate = 0; +
-int afl = 0; +
-int bfl = 0; +
- +
-String command; +
-long int currpos; +
-long int pos;+
  
-void setup() { +void setup() 
-  // put your setup code here, to run once:+ 
   Serial.begin(115200);   Serial.begin(115200);
   pinMode(stepsPinA, OUTPUT);   pinMode(stepsPinA, OUTPUT);
Line 74: Line 457:
   pinMode(directionPinB, OUTPUT);   pinMode(directionPinB, OUTPUT);
   pinMode(enablePinB, OUTPUT);   pinMode(enablePinB, OUTPUT);
-  pinMode(speedpotAINPUT); +  pinMode(stepsPinCOUTPUT); 
-  pinMode(gobuttonAINPUT); +  pinMode(directionPinCOUTPUT); 
-  pinMode(stopbuttonAINPUT); +  pinMode(enablePinCOUTPUT); 
-  pinMode(speedpotBINPUT); +  pinMode(TEMPCONTROLAOUTPUT); 
-  pinMode(gobuttonB, INPUT); + 
-  pinMode(stopbuttonBINPUT); +  digitalWrite(enablePinA,HIGH); 
-  pinMode(speedpotCINPUT); +  digitalWrite(enablePinB,HIGH); 
-  pinMode(gobuttonC, INPUT); +  digitalWrite(enablePinC,HIGH);
-  pinMode(stopbuttonCINPUT);+
  
-  digitalWrite(enablePinA,LOW); 
-  digitalWrite(enablePinB,LOW); 
   digitalWrite(directionPinA, LOW);   digitalWrite(directionPinA, LOW);
   digitalWrite(directionPinB, LOW);   digitalWrite(directionPinB, LOW);
   digitalWrite(directionPinC, LOW);   digitalWrite(directionPinC, LOW);
-  currpos = 0;+   
 +  stepperA.setMaxSpeed(1000*16); 
 +  stepperB.setMaxSpeed(1000*16); 
 +  stepperC.setMaxSpeed(1000*16);   
 + 
 + //turn the PID on 
 +  myPIDA.SetMode(AUTOMATIC);
 } }
  
-void loop() {+void loop(){
  
-   Input read_temp("A"); +  int speedA map(analogRead(speedpotA), 0, 1023, 1, 2000); 
-   double gap abs(Setpoint-Input); //distance away from setpoint +  int speedB map(analogRead(speedpotB), 0, 102312000); 
-   myPIDA.SetTunings(aggKpAaggKiAaggKdA); +  int speedC = map(analogRead(speedpotC), 0, 1023, 12000);
-   myPIDA.Compute(); +
-   analogWrite(TEMPCONTROLA,OutputA);+
  
-   int rawvalue = analogRead(THERMISTOR_PINA); 
-   int rawvalueA = rawvalue; 
-   float celsiusA = read_temp("A"); 
  
 +  Input = read_temp("A");
 +  double gap = abs(Setpoint-Input); //distance away from setpoint
 +  myPIDA.SetTunings(aggKpA, aggKiA, aggKdA);
 +  myPIDA.Compute();
 +  Serial.print("outputA ");
 +  Serial.println(OutputA);
 +  analogWrite(TEMPCONTROLA,OutputA);
  
 +  int rawvalue = analogRead(THERMISTOR_PINA);
 +  int rawvalueA = rawvalue;
 +  float celsiusA = read_temp("A");
  
-  Serial.print(""); 
-   
-  digitalWrite(stepsPinA, HIGH); 
-  digitalWrite(directionPinA, LOW); 
-  digitalWrite(enablePinA, HIGH);   
- 
- 
-  digitalWrite(stepsPinB, LOW); 
-  digitalWrite(directionPinB, LOW); 
-  digitalWrite(enablePinB, LOW);  
- 
-  digitalWrite(stepsPinC, LOW); 
-  digitalWrite(directionPinC, HIGH); 
-  digitalWrite(enablePinC, LOW);  
- 
- 
-/* 
   if (levelstreamon == 1) {   if (levelstreamon == 1) {
    Serial.print("A: ");    Serial.print("A: ");
Line 132: Line 506:
    delay(500);    delay(500);
   }   }
- 
- 
  
  if (digitalRead(stopbuttonA) ==HIGH){  if (digitalRead(stopbuttonA) ==HIGH){
 +  digitalWrite(enablePinA, HIGH);
 +  goA = 0;
   if (bfl == 0){   if (bfl == 0){
    if (directionA==0){directionA = 1; digitalWrite(directionPinA, HIGH); }else{directionA=0; digitalWrite(directionPinA, LOW);}    if (directionA==0){directionA = 1; digitalWrite(directionPinA, HIGH); }else{directionA=0; digitalWrite(directionPinA, LOW);}
Line 145: Line 519:
  
  if (digitalRead(gobuttonA) == 1){  if (digitalRead(gobuttonA) == 1){
 +   digitalWrite(enablePinA, LOW);
    Serial.println("moving A");    Serial.println("moving A");
-   runnerA();+   goA = 1;
   }   }
  
  if (digitalRead(stopbuttonB) ==HIGH){  if (digitalRead(stopbuttonB) ==HIGH){
 +  digitalWrite(enablePinB, HIGH);
 +  goA = 0;
   if (bfl == 0){   if (bfl == 0){
    if (directionB==0){directionB = 1; digitalWrite(directionPinB, HIGH); }else{directionB=0; digitalWrite(directionPinB, LOW);}    if (directionB==0){directionB = 1; digitalWrite(directionPinB, HIGH); }else{directionB=0; digitalWrite(directionPinB, LOW);}
Line 159: Line 536:
  
  if (digitalRead(gobuttonB) == 1){  if (digitalRead(gobuttonB) == 1){
-  Serial.println("moving B"); +   digitalWrite(enablePinB, LOW); 
-   runnerB();+   Serial.println("moving A"); 
 +   goA = 1;
   }   }
  
- if (digitalRead(stopbuttonC) ==HIGH){ +if (digitalRead(stopbuttonC) ==HIGH){ 
-  if (bfl == 0){+  goC = 0; 
 +  digitalWrite(enablePinC, HIGH); 
 +  if (cfl == 0){
    if (directionC==0){directionC = 1; digitalWrite(directionPinC, HIGH); }else{directionC=0; digitalWrite(directionPinC, LOW);}    if (directionC==0){directionC = 1; digitalWrite(directionPinC, HIGH); }else{directionC=0; digitalWrite(directionPinC, LOW);}
     Serial.print(directionC);     Serial.print(directionC);
     Serial.println(" direction changed");     Serial.println(" direction changed");
-    bfl = 1;+    cfl = 1;
    }    }
-  } else { bfl = 0; }+  } else { cfl = 0; }
  
  if (digitalRead(gobuttonC) == 1){  if (digitalRead(gobuttonC) == 1){
 +  digitalWrite(enablePinC, LOW);
   Serial.println("moving C");   Serial.println("moving C");
-   runnerC();+  goC = 1;
   }   }
-  */ 
  
 +  if (directionA == 1) {stepperA.setSpeed(speedA);}else{stepperA.setSpeed(-speedA);}
 +  if (directionB == 1) {stepperB.setSpeed(speedB);}else{stepperB.setSpeed(-speedB);}
 +  if (directionC == 1) {stepperC.setSpeed(speedC);}else{stepperC.setSpeed(-speedC);}
  
      
- if(Serial.available()) +  //if (stepperC.distanceToGo() == 0) 
- {+ //stepperC.moveTo(-stepperC.currentPosition()); 
 +  stepperC.runSpeed(); 
 +  stepperB.runSpeed(); 
 +  stepperA.runSpeed(); 
 + 
 + if(Serial.available()){
     char c = Serial.read();     char c = Serial.read();
-    if (c== '\n') +    if (c== '\n'){
-    {+
       currpos = parseCommand(command, currpos);       currpos = parseCommand(command, currpos);
       command = "";       command = "";
     }     }
-     +    else{
-    else +
-    {+
       command +=c;       command +=c;
     }     }
- } +  
- delay(30);+
 } }
  
-long int parseCommand(String com, long int currpos) +long int parseCommand(String com, long int currpos){
-{+
   //Serial.print("Your command: ");   //Serial.print("Your command: ");
   //Serial.println(com);   //Serial.println(com);
Line 245: Line 628:
 } }
  
- 
-int runnerA(){ 
-   int stpper = 1; 
-   int speed = analogRead(speedpotA); 
-   int stepdelay = map(speed, 0, 1023, 1, 2000); 
-   while(stpper > 0){ 
-   speed = analogRead(speedpotA); 
-   stepdelay = map(speed, 0, 1023, 1, 2000); 
-   digitalWrite(stepsPinA,HIGH); // Output high 
-   delayMicroseconds(stepdelay); // Wait 1/2 a ms 
-   digitalWrite(stepsPinA,LOW); // Output high 
-   delayMicroseconds(stepdelay); // Wait 1/2 a ms 
-   if (digitalRead(stopbuttonA) ==HIGH){ break; } 
- } 
- return 0; 
-} 
- 
-int runnerB(){ 
-   int stpper = 1; 
-   int speed = analogRead(speedpotB); 
-   int stepdelay = map(speed, 0, 1023, 1, 2000); 
-   while(stpper > 0){ 
-   speed = analogRead(speedpotB); 
-   stepdelay = map(speed, 0, 1023, 1, 2000); 
-   digitalWrite(stepsPinB,HIGH); // Output high 
-   delayMicroseconds(stepdelay); // Wait 1/2 a ms 
-   digitalWrite(stepsPinB,LOW); // Output high 
-   delayMicroseconds(stepdelay); // Wait 1/2 a ms 
-   if (digitalRead(stopbuttonB) ==HIGH){ break; } 
- } 
- return 0; 
-} 
- 
-int runnerC(){ 
-   int stpper = 1; 
-   int speed = analogRead(speedpotB); 
-   int stepdelay = map(speed, 0, 1023, 1, 2000); 
-   while(stpper > 0){ 
-   speed = analogRead(speedpotC); 
-   stepdelay = map(speed, 0, 1023, 1, 2000); 
-   digitalWrite(stepsPinC,HIGH); // Output high 
-   delayMicroseconds(stepdelay); // Wait 1/2 a ms 
-   digitalWrite(stepsPinC,LOW); // Output high 
-   delayMicroseconds(stepdelay); // Wait 1/2 a ms 
-   if (digitalRead(stopbuttonC) ==HIGH){ break; } 
- } 
- return 0; 
-} 
  
 #define NUMTEMPS 20 #define NUMTEMPS 20
Line 346: Line 681:
    return current_celsius;    return current_celsius;
 } }
- 
 </code> </code>
  
bdev/filamentextrduer_code.1667747717.txt.gz · Last modified: 2022/11/06 15:15 by richard