[项目分享]2019-3-26Arduino切线机剪线机

设置好所需长度和数量的线材后,自动完成切割。
硬件材料
1Arduino UNO
1
电机驱动器
123步进电机
1
12v转5v稳压模块
1支架、螺钉、垫片等
2
轮胎
灵感来源
人工线轴上拉出几千根长500px的22awg电线并不是一件有趣的事。它很无聊,而且很容易出现不准确。需要2个人花上2天才能手动拉完706个22awg电线。如果你只有一个线轴(一次拉1个线),则需要更长的时间。使用Arduino切线机,你需输入所需的长度和数量,即可预先输入所需的长度和数量,就可以自动完成。
[项目分享]2019-3-26Arduino切线机剪线机_第1张图片
[项目分享]2019-3-26Arduino切线机剪线机_第2张图片
[项目分享]2019-3-26Arduino切线机剪线机_第3张图片
[项目分享]2019-3-26Arduino切线机剪线机_第4张图片

[项目分享]2019-3-26Arduino切线机剪线机_第5张图片
[项目分享]2019-3-26Arduino切线机剪线机_第6张图片
[项目分享]2019-3-26Arduino切线机剪线机_第7张图片
[项目分享]2019-3-26Arduino切线机剪线机_第8张图片
[项目分享]2019-3-26Arduino切线机剪线机_第9张图片

#include                //#math
#include  //From Library
Servo servoMain; // Define Servo
#include  // soft serial for LCD
#define stp 2 //define stepper
#define dir 3 //define stepper
#define MS1 4 //define stepper
#define MS2 5 //define stepper
#define MS3 6 //define stepper
#define EN  7 //define stepper

float a;              //variable assignment qty
float b;              //variable assignment inches
float c;              //variable assignment required motor steps
float W;              //removed from functions for now, might need later.
char junk = ' ';      //any random character input. 
char val;             // Data received from the serial port
char user_input;
int x;                //Probably over loaded on assignments, not sure. Remove later and test. 
int y;
int state;
SoftwareSerial mySerial(0, 11); // pin 11 = TX

void setup()          // set up
{
  pinMode(15, OUTPUT); // set the pin to input
  servoMain.attach(9); // servo on digital pin 9
  pinMode(13, OUTPUT); // led on pin 13
  pinMode(stp, OUTPUT); //B.E.D
  pinMode(dir, OUTPUT); //B.E.D
  pinMode(MS1, OUTPUT); //B.E.D
  pinMode(MS2, OUTPUT); //B.E.D
  pinMode(MS3, OUTPUT); //B.E.D
  pinMode(EN, OUTPUT); //B.E.D
  resetBEDPins(); //Set step, direction, microstep and enable pins to default states
  Serial.begin(9600);   // set up Serial library at 9600 bps
  mySerial.begin(9600); // set up serial port for 9600 baud
  Serial.println("Lets Cut Some Wires!"); //welcome message in serial window
  Serial.println("");
  Serial.flush(); //clear the input que. 
}

void loop()

{
  {
  mySerial.write("                "); // clear display
  mySerial.write("                ");

  mySerial.write(254); // move cursor to beginning of first line
  mySerial.write(128);
 
  mySerial.write("Solution Systems  Feed n Cut!");

  delay(2);
  }
  Serial.println("Enter Quantity, Press ENTER");        // user Input request qty
  while (Serial.available() == 0) ;                     // Wait here until input buffer has a character
  {
  
    a = Serial.parseFloat();                           // new command in 1.0 forward
    Serial.print("a = "); Serial.println(a, DEC);

    while (Serial.available() > 0)                      // .parseFloat() can leave non-numeric characters
    { junk = Serial.read() ; }                          // clear the keyboard buffer
  }

  Serial.println("Enter Length in Inches, Press ENTER");
  while (Serial.available() == 0) ;
  {
    
    b = Serial.parseFloat();
    Serial.print("b = "); Serial.println(b, DEC);
    while (Serial.available() > 0)
    { junk = Serial.read() ; }                          // clear the keyboard buffer

    c = (float( b*26 ));

    Serial.print("Motor Steps = ");
    Serial.println(c, DEC); Serial.println();
    }
    
  Serial.println("Ready to Begin? Press ENTER");        // user Input request Y or N?
  digitalWrite(EN, LOW);                                //Pull enable pin low to set FETs active and allow motor control
  while (Serial.available() == 0);                      // If data is available to read,
   { 
     val = Serial.read();                               // read it and store it in val
     if (val == 'y')
     { 
      Serial.println("Here We Go!");
      delay(10);
      for (a; a>0; a--){      // this step checks if the quantity entered (a) is greater than 0,...  and deducts 1 from a.
        Feedft();             // if it is it repeats the step feed and cut function again.
      }
     } 
     else {
     Serial.println("Restarting Setup...");             // otherwise restart
     }
   delay(10);                                           // Wait 10 milliseconds for next reading
  }
  { junk = Serial.read() ; }                           // clear the keyboard buffer
  
}

  
//Reset Big Easy Driver pins to default states
void resetBEDPins(){
  digitalWrite(stp, LOW);
  digitalWrite(dir, LOW);
  digitalWrite(MS1, LOW);  // leaving wired and in sketch for now, not using micro-step control at this time. 
  digitalWrite(MS2, LOW);
  digitalWrite(MS3, LOW);
  digitalWrite(EN, HIGH);
}

//Functions 
void Feedft(){
  Serial.println("Feeding Wire at default step mode.");
  digitalWrite(dir, LOW);                   //Pull direction pin low to move "forward"
  for(x= 1; x

你可能感兴趣的:([项目分享]2019-3-26Arduino切线机剪线机)