Components and supplies
Arduino UNO
Big Easy Driver
HPI 1/10th Scale On-Road Touring Wheels and Tires
NEMA 23 Stepper Motor
12 to 5 VDC Regulator/Drop Down
General Hardware; standoffs, screws, washers, etc.
Tools and machines
RotoZip
General Shop Tools, drill, bits, taps, etc.
Project description
Code
Wire Cutter Code
arduino
Load to Arduino UNO, Open a Serial Comm window, It will ask for a length in Inches, desired quantity and if you are ready. Entering Y will proceed with operation.
1//Written by Lonnie Sexton 2017. Special Thanks to Julia B. 2//for the help with fixing a probelm with the code. 3#include <math.h> //#math 4#include <Servo.h> //From Library 5Servo servoMain; // Define Servo 6#include <SoftwareSerial.h> // soft serial for LCD 7#define stp 2 //define stepper 8#define dir 3 //define stepper 9#define MS1 4 //define stepper 10#define MS2 5 //define stepper 11#define MS3 6 //define stepper 12#define EN 7 //define stepper 13 14float a; //variable assignment qty 15float b; //variable assignment inches 16float c; //variable assignment required motor steps 17float W; //removed from functions for now, might need later. 18char junk = ' '; //any random character input. 19char val; // Data received from the serial port 20char user_input; 21int x; //Probably over loaded on assignments, not sure. Remove later and test. 22int y; 23int state; 24SoftwareSerial mySerial(0, 11); // pin 11 = TX 25 26void setup() // set up 27{ 28 pinMode(15, OUTPUT); // set the pin to input 29 servoMain.attach(9); // servo on digital pin 9 30 pinMode(13, OUTPUT); // led on pin 13 31 pinMode(stp, OUTPUT); //B.E.D 32 pinMode(dir, OUTPUT); //B.E.D 33 pinMode(MS1, OUTPUT); //B.E.D 34 pinMode(MS2, OUTPUT); //B.E.D 35 pinMode(MS3, OUTPUT); //B.E.D 36 pinMode(EN, OUTPUT); //B.E.D 37 resetBEDPins(); //Set step, direction, microstep and enable pins to default states 38 Serial.begin(9600); // set up Serial library at 9600 bps 39 mySerial.begin(9600); // set up serial port for 9600 baud 40 Serial.println("Lets Cut Some Wires!"); //welcome message in serial window 41 Serial.println(""); 42 Serial.flush(); //clear the input que. 43} 44 45void loop() 46 47{ 48 { 49 mySerial.write(" "); // clear display 50 mySerial.write(" "); 51 52 mySerial.write(254); // move cursor to beginning of first line 53 mySerial.write(128); 54 55 mySerial.write("Solution Systems Feed n Cut!"); 56 57 delay(2); 58 } 59 Serial.println("Enter Quantity, Press ENTER"); // user Input request qty 60 while (Serial.available() == 0) ; // Wait here until input buffer has a character 61 { 62 63 a = Serial.parseFloat(); // new command in 1.0 forward 64 Serial.print("a = "); Serial.println(a, DEC); 65 66 while (Serial.available() > 0) // .parseFloat() can leave non-numeric characters 67 { junk = Serial.read() ; } // clear the keyboard buffer 68 } 69 70 Serial.println("Enter Length in Inches, Press ENTER"); 71 while (Serial.available() == 0) ; 72 { 73 74 b = Serial.parseFloat(); 75 Serial.print("b = "); Serial.println(b, DEC); 76 while (Serial.available() > 0) 77 { junk = Serial.read() ; } // clear the keyboard buffer 78 79 c = (float( b*26 )); 80 81 Serial.print("Motor Steps = "); 82 Serial.println(c, DEC); Serial.println(); 83 } 84 85 Serial.println("Ready to Begin? Press ENTER"); // user Input request Y or N? 86 digitalWrite(EN, LOW); //Pull enable pin low to set FETs active and allow motor control 87 while (Serial.available() == 0); // If data is available to read, 88 { 89 val = Serial.read(); // read it and store it in val 90 if (val == 'y') 91 { 92 Serial.println("Here We Go!"); 93 delay(10); 94 for (a; a>0; a--){ // this step checks if the quantity entered (a) is greater than 0,... and deducts 1 from a. 95 Feedft(); // if it is it repeats the step feed and cut function again. 96 } 97 } 98 else { 99 Serial.println("Restarting Setup..."); // otherwise restart 100 } 101 delay(10); // Wait 10 milliseconds for next reading 102 } 103 { junk = Serial.read() ; } // clear the keyboard buffer 104 105} 106 107 108//Reset Big Easy Driver pins to default states 109void resetBEDPins(){ 110 digitalWrite(stp, LOW); 111 digitalWrite(dir, LOW); 112 digitalWrite(MS1, LOW); // leaving wired and in sketch for now, not using micro-step control at this time. 113 digitalWrite(MS2, LOW); 114 digitalWrite(MS3, LOW); 115 digitalWrite(EN, HIGH); 116} 117 118//Functions 119void Feedft(){ 120 Serial.println("Feeding Wire at default step mode."); 121 digitalWrite(dir, LOW); //Pull direction pin low to move "forward" 122 for(x= 1; x<c; x++){ //Loop the forward stepping enough times for motion to be visible 123 digitalWrite(stp,HIGH); //Trigger one step forward 124 delay(1); 125 digitalWrite(stp,LOW); //Pull step pin low so it can be triggered again 126 delay(1); 127 } //Need to add a stepper done moving function here!!!!!!!!!!!!!<================== 128 ServoMainCut(); //Run the Cut Function 129 delay(2000); 130 Serial.println("Cutting Wire!"); //Fair Warning..... 131 // RepeatCount(); //Run the repeat function 132 { junk = Serial.read();} //Clear the keyboard buffer 133} 134 135//funtion Servo Cut 136void ServoMainCut(){ 137 digitalWrite(13, HIGH); 138 delay(100); 139 digitalWrite(13, LOW); 140 servoMain.write(177); // CUT!! Turn Servo Left to 176 degrees 141 delay(750); // Wait 1.5 second 142 servoMain.write(65); // Open Cutter Turn Servo Left to 65 degrees 143 digitalWrite(13, HIGH); 144 delay(100); 145 digitalWrite(13, LOW); 146}
Downloadable files
Connection Diag
Connection Diag
Connection Diag
Connection Diag
Comments
Only logged in users can leave comments
30percent
0 Followers
•0 Projects
Table of contents
Intro
47
0