DivNum asservir un moteur pas a pas en position programmable avec un Arduino

fauxjetons
Compagnon
25 Août 2011
1 674
33220 Aquitaine
  • Auteur de la discussion
  • #1
salut

la suite de ce sujet pour comprendre #37

j ai fait un montage complet qui est dans une boite qui fonctionne #12
avec les photos ci dessous

trouver comment asservir un moteur en position en vitesse pour moteur a courant continue
j ai pas réussie a les vérifier avec le logiciel Arduino il y a trop d erreur

pas réussi a trouver les base d un programme sur le net

asservir un moteur pas a pas en position pour Arduino programmable

j ai le bases pour l écran le clavier le moteur

le branchement d un rotary encodeur incrémental 2500p/r - / + 0/25v (outA A3,outB A4 ,outZ A5 )

le branchement d un joystick j ai pas réussi a l exploiter avec le moteur
joyStick PinX = A1 joyStick PinY = A2 joyStick PinSW = 2

une résistance ajustable bouton-rotation a A0

j ai essayer ce programme j ai pas reussi a l exploiter #29

j aurais besoins de votre aide pour les bases du programmes

a plus


nema 23 57HBM20-1000 moteur avec le drivers ss570 avec les connectiques châssis

écran LCD 20 ,4 avec deux type d adresse (0x27,20,4); (0x3f,20,4);
joystick joyStick PinX = A1 joyStick PinY = A2 joyStick PinSW = 2 - chassis + 0/25 volts

arduino uno mega avec adaptateur est connectique

avec un régulateur pour alimenter en tension l Arduino 24/12 volts

une alimentation dessous l arduino est le driver de 18 /30 volts 10 amperes pour alimenter l ensemble en tension

une résistance ajustable bouton-rotation a A0 pour faire varier la vitesse du moteur pas a pas

le montage final dans un boitier avec un clavier 4x5 pour avoir une touche pour chaque fonction
 
Dernière édition:
fauxjetons
Compagnon
25 Août 2011
1 674
33220 Aquitaine
  • Auteur de la discussion
  • #3
salut
merci
ton aide sera la bien venue
est t il possible de l incorporer dans ce programme avec un clavier 4x4

a plus


Code:
    #include <Arduino.h>
    #include <Wire.h>
    #include <LiquidCrystal_I2C.h>
    #include <Keypad.h>
    #include <AccelStepper.h>
    #include <RotaryEncoder.h>

    LiquidCrystal_I2C lcd(0x27,20,4);                                   // Réglez adresse de l ecran LCD 0x27 / 0x3f  affichage 20 caractères et 4 lignes

   
    const byte ROWS = 4;                                                 //  la configuration du clavier
    const byte COLS = 4;
    char keys[ROWS][COLS] = {
    {'1','2','3','A'},
    {'4','5','6','B'},
    {'7','8','9','C'},
    {'.','0','#','D'}
    };

    byte rowPINS[ROWS] = {11,10,9,8};                                   // le numéro de la broche ranger relier du clazvier a uno
    byte colPINS[COLS] = {7,6,5,4};                                     // le numéro de la broche colonnes relier du clazvier a uno

    Keypad kpd = Keypad(makeKeymap(keys),rowPINS,colPINS, ROWS, COLS);


                                                                    //setup vars
                     
int buttonState = 0;                                                // variable for reading the pushbutton status
const int stp = 12;                                                 //connect pin 12 to step
const int dir = 13;                                                 // connect pin 13 to dir
const int Multiplier = 200;                                         // mais  nema 23 / 34  = 100 rapport 1/90 = 360 degrees = 36000 steps / 400  steps = 1 tour moteur / 100  steps  = 1 Degrees      
float Degrees = 0;                                                  // Degrés d'entrée série  nema 23 / 34  = 100 rapport  1/40 = 360 degrees = 16000 steps / 400 steps = 1 tour moteur  = 9 Degrees   impossile a executer          
float ToMove = 0;                                                   // Étapes à suivre     nema 23 = 100 rapport  1/40 = 360 degrees = 16000 steps / 400 steps  + reducteur 1/4.5 = 1800  steps tours = 9 °  200 steps = 1°
float bob = 0;
float Divisions;
float current = 0;
int Mode = 0;
int speed = 0;                                                      //read from potentiometer
int maxspeed = 8000;                                                //max speed in steps per sec
int stepspeed = 8000;                                               //speed in steps per sec
byte percentage = 0;                                                //speed % on LCD
AccelStepper stepper(1, stp, dir);                                  //(mode:1 = driver)

void setup()
{
  lcd.init();                                                       // initialize the lcd
  pinMode(stp, OUTPUT);
  pinMode(dir, OUTPUT);
  pinMode(buttonPin, INPUT);                                        // initialize the push button
  pinMode(A0, INPUT);                                               // initialize the potentiometer
  Serial.begin(9600);
  stepper.setMaxSpeed(maxspeed);                                    // stepper max speed
  stepper.setSpeed(stepspeed);                                      // stepper speed
  stepper.setAcceleration(600);                                     // stepper acceleration: not needed
  stepper.setCurrentPosition(0);                                    // stepper current position

                                                                    // Print welcome message to the LCD.
  lcd.backlight();
  lcd.print("Rotary Table Control");
  lcd.setCursor(0,2);    lcd.print("  usinages.com");
  lcd.setCursor(0,3);    lcd.print("    Vibram    ");
  delay(1000);

lcd.begin(20,4);

  Mode = GetMode();
}

void software_Reset() // Restarts program from beginning but does not reset the peripherals and registers
{
asm volatile ("  jmp 0");
}

float GetNumber()
{
   float num = 0.00;
   float decimal = 0.00;
   float decnum = 0.00;
   int counter = 0;
   char key = kpd.getKey();
   lcd.setCursor(0,0);   lcd.print("Entrer degres puis");
   lcd.setCursor(0,1);   lcd.print("Appuyer => [#].");
   lcd.setCursor(0,3);   lcd.print("RAZ => [D]");
   lcd.setCursor(8,2);
   bool decOffset = false;

   while(key != '#')
   {
      switch (key)
      {
         case NO_KEY:
            break;

         case '.':
           if(!decOffset)
           {
             decOffset = true;
           }
            lcd.print(key);
            break;

         case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
           if(!decOffset)
           {
            num = num * 10 + (key - '0');
            lcd.print(key);
           }
           else if((decOffset) && (counter <= 1))
           {
            num = num * 10 + (key - '0');
            lcd.print(key);
            counter++;
           }
           break;

         case 'D':
           software_Reset();
         break;
      }

      decnum = num / pow(10, counter);
      key = kpd.getKey();
   }
  return decnum;
}

float GetDivisions()
{
   float num = 0.00;
   char key = kpd.getKey();
   lcd.clear();
   lcd.setCursor(0,0);   lcd.print("Entrer Nbr Div puis");
   lcd.setCursor(0,1);   lcd.print("appuyer => [#].");
   lcd.setCursor(0,3);   lcd.print("RAZ =>[D]");
   lcd.setCursor(8,2);

   while(key != '#')
   {
      switch (key)
      {
         case NO_KEY:
            break;

         case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
            num = num * 10 + (key - '0');
            lcd.print(key);
            break;

        case 'D':
          software_Reset();
          break;
      }
      key = kpd.getKey();
   }
  return num;
}

int TigRotation()
{
   int num = 0;
   char key = kpd.getKey();
   lcd.clear();
   lcd.setCursor(0,0);  lcd.print("Entrer Nbr Rot puis");
   lcd.setCursor(0,1);  lcd.print("appuyer => [#].");
   lcd.setCursor(0,3);  lcd.print("Reset [D]");
   lcd.setCursor(8,2);

   while(key != '#')
   {
      switch (key)
      {
         case NO_KEY:
            break;

         case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
            num = num * 10 + (key - '0');
            lcd.print(key);
            break;

        case 'D':
          software_Reset();
          break;
      }
      key = kpd.getKey();
}

  return num;
}
int GetMode()
{
  int mode = 0;
  lcd.setCursor(0,0);  lcd.print("Selection du Mode");
  lcd.setCursor(0,1);  lcd.print("Divisions => [A]");
  lcd.setCursor(0,2);  lcd.print("Degres => [B]");
  lcd.setCursor(0,3);  lcd.print("TIG/MIG => [C]");

  while(mode == 0)
  {
  char key = kpd.getKey();
  if(key == 'A')
  {
    mode = 1;
  }

  else if(key == 'B')
  {
    mode = 2;
  }
  else if(key == 'C')
  {
    mode = 3;
  }
  }

lcd.clear();
return mode;
}

void loop()
{
  if(Mode == 1)
  {
    Divisions = GetDivisions();
    Degrees = (360/Divisions);
  }
  if(Mode == 2)
  {
    Degrees = GetNumber();
  }
  if(Mode == 3)
  {
    Degrees = (TigRotation()*360);
  }

    lcd.clear();
    lcd.setCursor(0,3);    lcd.print("Av.[A] Arr[B] Fin[C]");
    char key = kpd.getKey();
    while(key != 'C')
    {
    speed = analogRead(A0);
    stepspeed = map(speed,0,1023,1,maxspeed);
    percentage = map(speed,0,1023,1,100);
    stepper.setSpeed(stepspeed);
    lcd.setCursor(0,0);    lcd.print("POS:");     lcd.print(current);
    lcd.setCursor(0,1);    lcd.print("DPM:");     lcd.print(Degrees);
    lcd.setCursor(11,0);   lcd.print("Vit.");
    lcd.setCursor(17,0);   lcd.print("   ");
    lcd.setCursor(17,0);   lcd.print(percentage); lcd.print("%");
    lcd.setCursor(0,1);    lcd.print("DPM:");     lcd.print(Degrees);
      key = kpd.getKey();

      if(key == 'A')
      {
        if(current + Degrees <= 360)
        {
         current = ((stepper.currentPosition()/ Multiplier) + Degrees);
        }
        else
        {
         current = (stepper.currentPosition()/ Multiplier) + Degrees-360;
        }

       ToMove = Degrees*Multiplier;
       // stepper.setSpeed(stepspeed);
       // Serial.println(ToMove);
       stepper.move(ToMove);
       Serial.println(ToMove);
       stepper.setSpeed(-stepspeed);
       Serial.println(stepper.speed());
       lcd.setCursor(0,2);    lcd.print("App.Bouton =>Av.");
      }
      if(key == 'B')
      {
        if(current - Degrees >= 0)
        {
         current = ((stepper.currentPosition()/ Multiplier) - Degrees);
         }
         else
         {
          current = (stepper.currentPosition()/ Multiplier) - Degrees + 360;
         }
       ToMove = Degrees*Multiplier*-1;
       stepper.move(ToMove);
       Serial.println(ToMove);
       stepper.setSpeed(-stepspeed);
       Serial.println(stepper.speed());
       lcd.setCursor(0,2);   lcd.print("App.Bouton =>Arr.");
       }

    buttonState = digitalRead(buttonPin);
    if (buttonState == LOW) {
      lcd.setCursor(0,2);
       lcd.print("Rotation P=>Bouton");
       while (stepper.distanceToGo() != 0)
        {
        stepper.runSpeedToPosition();
        }
        lcd.setCursor(0,2);   lcd.print("                    ");
      }
     }
     lcd.clear();
}
 
Dernière édition:
fauxjetons
Compagnon
25 Août 2011
1 674
33220 Aquitaine
  • Auteur de la discussion
  • #4
salut
c est ce que j ai trouver de mieux
il fonctionne avec un encodeur rotatif incrémental de 400 est ce montage #10

il ne veux rien s avoir avec le montage qui est dans la boite #12
avec l encodeur rotatif incrémental de 2500



a plus


Code:
 #include <LiquidCrystal_I2C.h>
  LiquidCrystal_I2C lcd(0x3f,20,4);       // adresse ecran LCD 0x27 / 0x3f  affichage 20 caractères et 4 lignes


     #define stepPin 12
     #define dirPin  13
     #define outputA A3
     #define outputB A4

int counter = 0;
int angle = 0;
int aState;
int aLastState;

void setup() {
lcd.begin(20,4);
lcd.init();
lcd.backlight();

  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);
  pinMode (outputA,INPUT);
  pinMode (outputB,INPUT);

  aLastState = digitalRead(outputA);
}
void loop() {
  aState = digitalRead(outputA);

  if (aState != aLastState){ 
     if (digitalRead(outputB) != aState) {
       counter ++;
       angle ++;
       rotateCW();
     }
     else {
       counter--;
       angle --;
       rotateCCW();
     }
     if (counter >=30 ) {
      counter =0;
     }

     lcd.setCursor(0,0); lcd.print("Position: "); lcd.print(int(angle*(-1.8))); lcd.print("deg");
      
   }
  aLastState = aState;
}
void rotateCW() {
  digitalWrite(dirPin,LOW);
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(1000);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(1000);
}
void rotateCCW() {
  digitalWrite(dirPin,HIGH);
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(1000);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(1000);
}
howtomechatronics.com/tutorials/arduino/rotary-encoder-works-use-arduino/
 
Dernière édition:
fauxjetons
Compagnon
25 Août 2011
1 674
33220 Aquitaine
  • Auteur de la discussion
  • #5
salut
j ai trouver des programmes qui fonctionne

avec certaine configuration est il sont facile a utiliser dir 13 step 12
il sont facile a configurer est a comprendre
a plus

Code:
    /*     Simple Stepper Motor Control Exaple Code
     * 
     *  by Dejan Nedelkovski, www.HowToMechatronics.com
     *
     */
    // defines pins numbers
    const int stepPin = 12;
    const int dirPin = 13;

    void setup() {
      // Sets the two pins as Outputs
      pinMode(stepPin,OUTPUT);
      pinMode(dirPin,OUTPUT);
    }
    void loop() {
      digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
      // Makes 200 pulses for making one full cycle rotation
      for(int x = 0; x < 200; x++) {
        digitalWrite(stepPin,HIGH);
        delayMicroseconds(500);
        digitalWrite(stepPin,LOW);
        delayMicroseconds(500);
      }
      delay(1000); // One second delay
  
      digitalWrite(dirPin,LOW); //Changes the rotations direction
      // Makes 400 pulses for making two full cycle rotation
      for(int x = 0; x < 400; x++) {
        digitalWrite(stepPin,HIGH);
        delayMicroseconds(500);
        digitalWrite(stepPin,LOW);
        delayMicroseconds(500);
      }
      delay(1000);
    }
create.arduino.cc/projecthub/
 
Dernière édition:
fauxjetons
Compagnon
25 Août 2011
1 674
33220 Aquitaine
  • Auteur de la discussion
  • #6
salut
ici un autre
que je vais essayer d incorporer
pour avoir la vitesse variable en fonction
a plus
Code:
    const int stepPin = 12;            // Defines pins numbers
    const int dirPin = 13;
    int customDelay,customDelayMapped; // Defines variables
  
    void setup() {
                                       // Sets the two pins as Outputs
      pinMode(stepPin,OUTPUT);
      pinMode(dirPin,OUTPUT);
  
      digitalWrite(dirPin,HIGH);         //Enables the motor to move in a particular direction
    }
    void loop() {
    
      customDelayMapped = speedUp();      // Gets custom delay values from the custom speedUp function
                                          // Makes pules with custom delay, depending on the Potentiometer, from which the speed of the motor depends
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(customDelayMapped);
      digitalWrite(stepPin, LOW);
      delayMicroseconds(customDelayMapped);
    }
                                       // Function for reading the Potentiometer
    int speedUp() {
      int customDelay = analogRead(A0); // Reads the potentiometer
      int newCustom = map(customDelay, 0, 1023, 300,4000); // Convrests the read values of the potentiometer from 0 to 1023 into desireded delay values (300 to 4000)
      return newCustom;
    }
howtomechatronics.com/tutorials/arduino/how-to-control-stepper-motor-with-a4988-driver-and-arduino/
 
Dernière édition:
fauxjetons
Compagnon
25 Août 2011
1 674
33220 Aquitaine
  • Auteur de la discussion
  • #7
salut
j ai trouver cela pour le filetage ou les avances
a plus
473973


473975
473982


Code:
// included libraries
// liquid crystal l2c library and lcd function
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
#include <AccelStepper.h>
AccelStepper stepper(AccelStepper::DRIVER,10,9);
// Speed sensor variables
const int SensorPin = 2;        // the number of the IR sensor input pin
int sensorState;                // the current state from the input pin
int lastSensorState = LOW;      // the previous InputState from the input pin
long lastDebounceTime = 0.00;   // the last time the output pin was toggled
long debounceDelay = 1.00;      // the debounce time; increase if the output flickers
long time;
long endTime;
long startTime;
volatile float RPM = 0.00;
float stepperRPM = 0.00;
float lnTime = 0.00;
int lcdRPM = 0;
int lastRPM = 0;

//button variables
const int n = 2;
const int buttonPin[n] = {3,4};
int buttonState[n] = {LOW,LOW};
int lastButtonState[n]= {LOW,LOW};
bool buttonFlags[n] = {LOW, LOW};

//three way switch variables
const int leftPin = 6;
const int rightPin = 5;

//screen variables
const int x = 2;
int currentX = 0;
int currentY = 0;
String screens[x][5] = {{"TPI","Dir","LatheRPM ","ServoRPM","tpi/mm"}, {"Pitch","Dir","LatheRPM","ServoRPM","tpi/mm"}};

//user input variables
const int nTPI = 18;
const int nPitch = 11;
int tpi[nTPI] = {256, 128, 64, 56, 48, 40, 32, 24, 20, 18, 16, 14, 13, 12, 11, 10, 9, 8};
int currentTPI = 0;
float pitch[nPitch]={0.40, 0.45, 0.50, 0.70, 0.70, 0.80, 1.00, 1.25, 1.50, 2.00, 2.50};
int currentPitch = 0;
//String dir[2] = {"CW ","CCW"};
//String currentDir = "CW";

//internal timer to send data
unsigned long prevMillis = 0;
const long interval = 1000;

//lathe parameters
float servoRPM = 0.00;
//int direction = 1;

// =========================== setup ===========================
void setup()
{
  lcd.init();
  lcd.backlight();
  lcd.begin(20,4);
  Serial.begin(9600);
  for(int i=0; i < n; i++)
  {
    pinMode(buttonPin[i], INPUT);
    //Serial.print("Button: ");
    //Serial.println(buttonPin[i]);
  }
  pinMode(SensorPin, INPUT);
  endTime = 0;
  printScreen();
  // stepper stuff
  stepper.setEnablePin(8);
  stepper.disableOutputs();
  stepper.setMaxSpeed(2250);
  stepper.setAcceleration(300);
}
// =========================== main loop ===========================
void loop()
{
  setButtonFlags();
  resolveButtonFlags();
  sendData();
  speedSensor();
  if (digitalRead(leftPin) == HIGH)
  {
    //direction = 1;
    lcd.setCursor(4,1);
    lcd.print("CW ");
    lcd.setCursor(9,3);
    lcd.println(servoRPM);
    lcd.rightToLeft();
    lcd.print("   ");
    lcd.leftToRight();
    lcd.setCursor(9,2);
    lcd.println(lcdRPM);
    lcd.rightToLeft();
    lcd.print("   ");
    lcd.leftToRight();
    delay(5);
    stepper.enableOutputs();
    stepper.setSpeed(stepperRPM);
    stepper.run();
    while(stepper.isRunning())
    {
      speedSensor();
      stepper.setSpeed(stepperRPM);
      stepper.run();
      if(digitalRead(buttonPin[1]) == HIGH)
      {
        stepper.setSpeed(-1500);
        stepper.run();
      }
      if(digitalRead(leftPin)==LOW)
      {
        stepper.disableOutputs();
        lcd.setCursor(4,1);
        lcd.print("OFF");
        break;
      }
    }
  }
  else if (digitalRead(rightPin) == HIGH)
  {
    //direction = -1.00;
    lcd.setCursor(4,1);
    lcd.print("CCW");
    lcd.setCursor(9,3);
    lcd.println(servoRPM);
    lcd.rightToLeft();
    lcd.print("   ");
    lcd.leftToRight();
    lcd.setCursor(9,2);
    lcd.println(lcdRPM);
    lcd.rightToLeft();
    lcd.print("   ");
    lcd.leftToRight();
    delay(5);
    stepper.enableOutputs();
    stepper.setSpeed(-stepperRPM);
    stepper.run();
    while(stepper.isRunning())
    {
      speedSensor();
      stepper.setSpeed(-1*stepperRPM);
      stepper.run();
      if(digitalRead(buttonPin[1]) == HIGH)
      {
        stepper.setSpeed(1500);
        stepper.run();
      }
      if(digitalRead(rightPin)==LOW)
      {
        stepper.disableOutputs();
        lcd.setCursor(4,1);
        lcd.print("OFF");
        break;
      }
    }
  }
}
// =========================== set input flags ===========================
void setButtonFlags()
{
  for(int i=0; i < n; i++)
  {
    buttonState[i] = digitalRead(buttonPin[i]);
    delay[1];
    if(buttonState[i] != lastButtonState[i])
    {
      if(buttonState[i] == HIGH)
      {
        //Serial.print("Button: ");
        //Serial.println(buttonPin[i]);
        buttonFlags[i] = HIGH;
      }
    }
    lastButtonState[i] = buttonState[i];
  }
}
// =========================== resolve button flags ===========================
void resolveButtonFlags()
{
  for(int i = 0; i < n; i++)
  {
    if(buttonFlags[i] == HIGH)
    {
      buttonAction(i);
      buttonFlags[i] = LOW;
      printScreen();
    }
  }
}
// =========================== button action ===========================
void buttonAction(int button)
{
  if (button == 0)
  {
    if (currentX == x-1)
    {
      currentX = 0;
    }
    else
    {
      currentX++;
    }
  }
  if (button == 1)
  {
    if (currentX == 0)
    {
      if(currentTPI == nTPI-1)
      {
        currentTPI = 0;
      }
      else
      {
        currentTPI++;
      }
    }
  else if (currentX == 1)
    {
      if(currentPitch == nPitch-1)
      {
        currentPitch = 0;
      }
      else
      {
        currentPitch++;
      }
    }
  }
}
// =========================== print screen ===========================
void printScreen()
{
  lcd.clear();
  lcd.print(screens[currentX][0]);
  lcd.setCursor(0,1);
  lcd.print(screens[currentX][1]);
  lcd.setCursor(0,2);
  lcd.print(screens[currentX][2]);
  lcd.setCursor(0,3);
  lcd.print(screens[currentX][3]);
  lcd.setCursor(14,0);
  lcd.print(screens[currentX][4]);
  if(currentX == 0)
  {
    lcd.setCursor(4,0);
    lcd.println(tpi[currentTPI]);
    lcd.rightToLeft();
    lcd.print("   ");
    lcd.leftToRight();
    lcd.setCursor(4,1);
    lcd.print("OFF");
  }
  else if (currentX == 1)
  {
    lcd.setCursor(6,0);
    lcd.println(pitch[currentPitch]);
    lcd.rightToLeft();
    lcd.print("   ");
    lcd.leftToRight();
    lcd.setCursor(4,1);
    lcd.print("OFF");
  }
}
// =========================== Speed Sensor loop ===========================
void speedSensor()
{
  time = millis();
  int currentSensorState = digitalRead(SensorPin);

  if (currentSensorState != lastSensorState)
  {
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay)
  {
    if (currentSensorState != sensorState)
    {
      sensorState = currentSensorState;
      if (sensorState == LOW)
      {
        calculateRPM(); // Real RPM from sensor
        if (currentX == 0)
        {
          englishCalc();
        }
        else if (currentX == 1)
        {
          metricCalc();
        }
      }
    }
  }
  lastSensorState = currentSensorState;
  lcdRPM = RPM;
}

// =========================== RPM calculation ===========================
void calculateRPM()
{
  startTime = lastDebounceTime;
  lnTime = startTime - endTime;
  RPM = 60000.00 / (startTime - endTime);
  endTime = startTime;
}
// =========================== send speed data ===========================
void sendData()
{
  unsigned long currentMillis = millis();
  if(currentMillis - prevMillis >= interval)
  {
    prevMillis = currentMillis;
    lcd.setCursor(9,2);
    lcd.println(lcdRPM);
    lcd.rightToLeft();
    lcd.print("   ");
    lcd.leftToRight();
    lcd.setCursor(9,3);
    lcd.println(servoRPM);
    lcd.rightToLeft();
    lcd.print("   ");
    lcd.leftToRight();
    lcdRPM = 0;
  }
}
// =========================== english stepper speed ===========================
void metricCalc()
{
    stepperRPM = 1.529 * 0.315 * 400 * RPM * pitch[currentPitch] / 60.00;
    servoRPM = 0.482 * RPM * pitch[currentPitch];
}
// =========================== metric stepper speed ===========================
void englishCalc()
{
    stepperRPM = 1.529 * 8.00 * 400.00 * RPM / ( tpi[currentTPI] * 60.00 );
    servoRPM = 1.529 * 8.00 * RPM / tpi[currentTPI];
}
hackster.io/nsr5058/lathe-electronic-lead-screw-52a9c5




473971


1557676283651.png
 
Dernière édition:
La dernière réponse à ce sujet date de plus de 6 mois
Haut