Arduino切线机剪线机-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 4036|回复: 3

Arduino切线机剪线机

[复制链接]
发表于 2019-3-26 00:37 | 显示全部楼层 |阅读模式
本帖最后由 Arduino_xyz 于 2019-3-26 00:41 编辑

01.jpg
设置好所需长度和数量的线材后,自动完成切割。
硬件材料
1*Arduino UNO
1*电机驱动器
1*23步进电机
1*12v转5v稳压模块
1*支架、螺钉、垫片等
2*轮胎
灵感来源
人工线轴上拉出几千根长20cm的22awg电线并不是一件有趣的事。它很无聊,而且很容易出现不准确。需要2个人花上2天才能手动拉完706个22awg电线。如果你只有一个线轴(一次拉1个线),则需要更长的时间。使用Arduino切线机,你需输入所需的长度和数量,即可预先输入所需的长度和数量,就可以自动完成。
切线机_01.png
切线机_02.png
切线机_03.png
切线机_04.png
切线机_05.png
切线机_06.png
切线机_07.png
切线机_08.png
09.jpg
[mw_shl_code=arduino,true]#include <math.h>               //#math
#include <Servo.h> //From Library
Servo servoMain; // Define Servo
#include <SoftwareSerial.h> // 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<c; x++){                      //Loop the forward stepping enough times for motion to be visible
    digitalWrite(stp,HIGH);                 //Trigger one step forward
    delay(1);
    digitalWrite(stp,LOW);                  //Pull step pin low so it can be triggered again
    delay(1);
  }                                         //Need to add a stepper done moving function here!!!!!!!!!!!!!<==================
   ServoMainCut();                          //Run the Cut Function
   delay(2000);   
   Serial.println("Cutting Wire!");         //Fair Warning.....
  // RepeatCount();                           //Run the repeat function
  { junk = Serial.read();}                  //Clear the keyboard buffer
}

//funtion Servo Cut
void ServoMainCut(){
   digitalWrite(13, HIGH);
   delay(100);
   digitalWrite(13, LOW);
   servoMain.write(177); // CUT!! Turn Servo Left to 176 degrees
   delay(750);          // Wait 1.5 second
   servoMain.write(65); // Open Cutter Turn Servo Left to 65 degrees
   digitalWrite(13, HIGH);
   delay(100);
   digitalWrite(13, LOW);
}[/mw_shl_code]

发表于 2019-3-26 11:21 | 显示全部楼层
有想法,点赞点赞
发表于 2019-4-12 09:13 | 显示全部楼层
好东西,谢谢分享!!!
发表于 2020-4-29 14:33 | 显示全部楼层
厉害啊~ 请教下楼主用的舵机的扭矩?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-28 11:46 , Processed in 0.080789 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表