Components and supplies
Resistor 10k ohm
LED (generic)
Arduino Mega 2560
Capacitor 100 nF
6-36V IR Photoelectric Sensor Switch
Relay shield
Tools and machines
Soldering iron (generic)
Project description
Code
FJ_Grinder_Controls.ino
arduino
Support Code for grinder
1//--- Checks value of analoginput --------------------------- 2int read(int pinNumber) { 3 return analogRead(pinNumber); 4} 5//--- Checks the Motion Button ------------------------------- 6boolean motionButtonPressed() 7{ 8 return (analogRead(motionButton) > 200); 9} 10//--- Turn the pin ON ---------------------------------------- 11void turnOn(int pinNumber) { 12 digitalWrite(pinNumber, ON); 13} 14//------------------------------------------------------------ 15//--- Turn the pin OFF --------------------------------------- 16void turnOff(int pinNumber) { 17 digitalWrite(pinNumber, OFF); 18} 19//------------------------------------------------------------ 20//--- Return true if the pin is ON --------------------------- 21bool isOn(int pinNumber) { 22 return (digitalRead(pinNumber) == ON); 23} 24//------------------------------------------------------------ 25//--- Return true if the pin is OFF -------------------------- 26bool isOff(int pinNumber) { 27 return (digitalRead(pinNumber) == OFF); 28} 29//---------------------------------------------------------------------------- 30// Give some time between actions to check if the e-stop button was pressed--- 31void giveMeSomeTime() { 32 for (int i = 0; i < 1; i++) 33 { 34 delay (delayTime); 35 } 36} 37// Shutdown the process ---------------------------------------------------- 38void shutdown() { 39 for (int a = 0; a < 1; a++) 40 { 41 turnOff(reverse); 42 turnOff(forward); 43 } 44} 45void INFO() { 46 47 Serial.println("Select what you want"); 48 Serial.println("1 = Relays, 2 = Sensors"); 49 50 while (Serial.available() == 0); 51 int selection = Serial.read() - '0'; 52 switch (selection) { 53 54 case 1: 55 Serial.println("Relays"); 56 infoRelays(); 57 break; 58 case 2: 59 Serial.println("Sensors"); 60 sensorInfo(); 61 break; 62 } 63} 64 65void sensorInfo() { 66 67 while (state = true) { 68 while (Serial.available() == 0); 69 int selection = Serial.read() - '0'; 70 71 switch (selection) { 72 case motionButton: 73 while (state == true) { 74 Serial.print(sensorString[selection]); 75 Serial.print(": "); 76 Serial.println(analogRead(sensor[selection])); 77 choice = Serial.read() - '0'; 78 if (choice == 0) { 79 state = false; 80 } 81 } 82 break; 83 case frontSensor: 84 while (state == true) { 85 Serial.print(sensorString[selection]); 86 Serial.print(": "); 87 Serial.println(analogRead(sensor[selection])); 88 choice = Serial.read() - '0'; 89 if (choice == 0) { 90 state = false; 91 } 92 } 93 break; 94 case backSensor: 95 while (state == true) { 96 Serial.print(sensorString[selection]); 97 Serial.print(": "); 98 Serial.println(analogRead(sensor[selection])); 99 choice = Serial.read() - '0'; 100 if (choice == 0) { 101 state = false; 102 } 103 } 104 break; 105 default: 106 return; 107 break; 108 } 109 } 110} 111 112void infoRelays () { 113 while (true) { 114 while (Serial.available() == 0); 115 int command = Serial.read() - '0'; 116 117 switch (command) { 118 119 case forward: 120 turnOn(relays[command]); 121 Serial.print("Relay1 ON: "); 122 Serial.print(relays[command]); 123 Serial.print(" "); 124 Serial.println(relaysString[command]); 125 break; 126 127 case reverse: 128 turnOn(relays[command]); 129 Serial.print("Relay2 ON: "); 130 Serial.print(relays[command]); 131 Serial.print(" "); 132 Serial.println(relaysString[command]); 133 break; 134 135 case 0: 136 Serial.println("Exiting Sheild..."); 137 break; 138 139 default: 140 shutdown(); 141 Serial.println("Shutdown"); 142 break; 143 } 144 if (command == 0) { 145 break; 146 } 147 } 148} 149 150 151
Stacker_Code.ino
arduino
Code for the automatic stacker
1/* Written By: Amos Parmenter 2 Jun 11, 2014 "Revised July 16, 2014" 3 Parmenter INT. 4 5 This is for the small green automatic stacker at the 6 end of the finger jointer after the mulder. The purpouse 7 is to stack one full layer of boards onto the outfeed 8 chain deck in front of the machine. It runs in a cycle 9 motion to acomplish this task and will use an array of 10 sensor to determine postion of the forks the boards lay 11 on to determine where and when the cylce is complete and 12 ready to cycle again. 13 14 * Be sure to read the tab for the function calls. 15 I keep all of the function off the main tab to 16 make the code easier to read or find the values 17 I am looking for. It helps the debuging process. 18 19*/ 20#define ON LOW 21#define OFF HIGH 22 23//--- Sensors -------------------------- 24int button = 0; // The switch to start thde cycle 25int allForward = 5; // The sensor that says im forward 26int unit = 1; // This sensor sees the unit 27int allBack = 3; // The sensor that says im all the way back 28int allUp = 2; // The sensor that says im all the way up 29// I have three open filters on the shield for more sensors 30//-------------------------------------- 31//--- Relays --------------------------- 32int up = 39; // The relay going up 33int down = 41; // The relay going down 34int forward = 43; // The relay going forward 35int reverse = 45; // The relay going reverse 36int brake = 47; // The relay for the brake 37 38// I have three relays left unused. 39// int relay = 49; 40// int relay = 51; 41// int relay = 53; 42//-------------------------------------- 43 44void setup() { 45 Serial.begin(9600); 46 47 pinMode(unit, INPUT); 48 pinMode(allForward, INPUT); 49 pinMode(allBack, INPUT); 50 pinMode(button, INPUT); 51 pinMode(allUp, INPUT); 52 53 pinMode(forward, OUTPUT); // This sets Relay 1 as an output 54 digitalWrite(forward, OFF); // Turns the relay off 55 pinMode(reverse, OUTPUT); // This sets Relay 2 as an output 56 digitalWrite(reverse, OFF); // Turns the relay off 57 pinMode(up, OUTPUT); // This sets Relay 3 as an output 58 digitalWrite(up, OFF); // Turns the relay off 59 pinMode(down, OUTPUT); // This sets Relay 4 as an output 60 digitalWrite(down, OFF); // Turns the relay off 61 pinMode(brake, OUTPUT); // This sets Relay 5 as an output 62 digitalWrite(brake, OFF); // Turns the relay off 63 64} 65 66void loop() { 67 Serial.println(aRead(allForward)); 68 69 if (analogRead(button) >= 200 ) { 70 turnOn(brake); // Disengages the brake of on the F/R Motor 71 while (isOn(brake)) { 72 turnOn(brake); 73 turnOn(forward); // Sends the F/R motor FORWARD 74 delay(1000); 75 if (aRead(allForward) >= 200 ){ 76 delay(20); 77 break; 78 } 79 } 80 } 81 82if (aRead(allForward) >= 200) { 83 turnOff(forward); // Turns the F/R motor OFF 84 turnOn(down ); // This is the U/D Motor turning going DOWN 85 delay(1000); 86 turnOff(brake); // Engages the brake of on the F/R Motor 87} 88 89if (aRead(unit) >= 200) { 90 turnOn(brake); // This Disengages the F/R brake 91 while (isOn(brake)) { 92 turnOn(brake); 93 turnOn(reverse); // This sends the F/R Motor REVERSE 94 if (aRead(allBack) >= 150) 95 break; 96 } 97} 98 99if (aRead(allBack) >= 200 && aRead(allUp) <= 200 ) { 100 turnOff(reverse); // This turns the F/R Motor OFF 101 delay(1250); 102 turnOff(brake); // Engages the F/R brake 103 turnOff(down); 104 turnOn(up ); // Sends the U/D Motor UP 105} 106 107if (aRead(allBack) >= 200 && aRead(allUp) >= 200) { 108 shutDown(); 109} 110 111//--- This is the end of the VOID LOOP ------------------------------- 112} 113 114
Left_Shield.ino
arduino
Support code, used in the Serial monitor
1void infoLeft () { 2 while (true) { 3 while (Serial.available() == 0); 4 int command = Serial.read() - '0'; 5 6 switch (command) { 7 8 case 1: 9 turnOn(left[command]); 10 Serial.print("Relay1 ON: "); 11 Serial.print(left[command]); 12 Serial.print(" "); 13 Serial.println(leftString[command]); 14 break; 15 16 case 2: 17 turnOn(left[command]); 18 Serial.print("Relay2 ON: "); 19 Serial.print(left[command]); 20 Serial.print(" "); 21 Serial.println(leftString[command]); 22 break; 23 24 case 3: 25 turnOn(left[command]); 26 Serial.print("Relay3 ON: "); 27 Serial.print(left[command]); 28 Serial.print(" "); 29 Serial.println(leftString[command]); 30 break; 31 32 case 4: 33 turnOn(left[command]); 34 Serial.print("Relay4 ON: "); 35 Serial.print(left[command]); 36 Serial.print(" "); 37 Serial.println(leftString[command]); 38 break; 39 40 case 5: 41 turnOn(left[command]); 42 Serial.print("Relay5 ON: "); 43 Serial.print(left[command]); 44 Serial.print(" "); 45 Serial.println(leftString[command]); 46 break; 47 48 case 6: 49 turnOn(left[command]); 50 Serial.print("Relay6 ON: "); 51 Serial.print(left[command]); 52 Serial.print(" "); 53 Serial.println(leftString[command]); 54 break; 55 56 case 7: 57 turnOn(left[command]); 58 Serial.print("Relay7 ON: "); 59 Serial.print(left[command]); 60 Serial.print(" "); 61 Serial.println(leftString[command]); 62 break; 63 64 case 8: 65 turnOn(left[command]); 66 Serial.print("Relay8 ON: "); 67 Serial.print(left[command]); 68 Serial.print(" "); 69 Serial.println(leftString[command]); 70 break; 71 72 case 0: 73 Serial.println("Exiting Left Sheild..."); 74 break; 75 76 default: 77 shutdown(); 78 Serial.println("Shutdown"); 79 break; 80 } 81 if (command == 0) { 82 break; 83 } 84 85 } 86} 87
FJ_Grinder.ino
arduino
Automation for grider
1#define ON HIGH 2#define OFF LOW 3#define delayTime 200 4 5boolean switching = true; 6boolean state = true; 7 8int choice; 9int direction; 10 11const int motionButton = 0; // This is the Lug-Chain E-Stop 12const int frontSensor = 1; 13const int backSensor = 2; 14 15const int forward = 7; 16const int reverse = 8; 17 18int sensor[] = {motionButton, frontSensor, backSensor}; 19char* sensorString[] = {"motion", "front", "back"}; 20 21int relays[] = {0, 0, 0, 0, 0, 0, 0, forward, reverse}; 22char* relaysString[] = {"0", "0", "0", "0", "0", "0", "0", "forward", "reverse"}; 23 24 25void setup() { 26 27 Serial.begin(9600); 28 29 pinMode(motionButton, INPUT); 30 pinMode(frontSensor, INPUT); 31 pinMode(backSensor , INPUT); 32 33 pinMode(forward, OUTPUT); 34 pinMode(reverse, OUTPUT); 35 36} 37 38void loop() { 39 40 Serial.print("Grinding "); 41 Serial.println(relaysString[direction]); 42 while (Serial.available() < 0); 43 int options = Serial.read() - '0'; 44 if (options == 1) { 45 INFO(); 46 } 47 48 if (direction = reverse) { 49 if ( read(frontSensor) < 25) { 50 switching = true; 51 direction = forward; 52 } 53 } 54 if (direction = forward) { 55 if ( read(backSensor) < 25) { 56 switching = true; 57 direction = reverse; 58 } 59 } 60 61 if (motionButtonPressed()) { 62 switch (direction) { 63 64 case forward: 65 if (switching == true) { 66 turnOff(reverse); 67 giveMeSomeTime(); 68 turnOn(forward); 69 switching = false; 70 } 71 break; 72 73 case reverse: 74 if (switching == true) { 75 turnOff(forward); 76 giveMeSomeTime(); 77 turnOn(reverse); 78 switching = false; 79 } 80 break; 81 } 82 } 83 else { 84 shutdown(); 85 } 86} 87 88 89 90 91 92 93 94
Start_UP_Controls.ino
arduino
Functions that run in the main code.
1 2 3bool eStopButtonPressed(){ 4 return (analogRead(startUp) <= 100); 5} 6bool lugChainPressed(){ 7 return (analogRead(motion) <= 100); 8} 9//--- Turn the pin ON ---------------------------------------- 10void turnOn(int pinNumber){ 11 digitalWrite(pinNumber, ON); 12} 13//------------------------------------------------------------ 14//--- Turn the pin OFF --------------------------------------- 15void turnOff(int pinNumber){ 16 digitalWrite(pinNumber, OFF); 17} 18//------------------------------------------------------------ 19//--- Return true if the pin is ON --------------------------- 20bool isOn(int pinNumber){ 21 return (digitalRead(pinNumber) == ON); 22} 23//------------------------------------------------------------ 24//--- Return true if the pin is OFF -------------------------- 25bool isOff(int pinNumber){ 26 return (digitalRead(pinNumber) == OFF); 27} 28//-------------------------------------------------------------------------------- 29// Give some time between actions to check if the e-stop button was pressed------- 30void giveMeSomeTime(){ 31 for (int i = 0; i < 6; i++) 32 { 33 if (eStopButtonPressed()) 34 shutdown(); 35 delay (delayTime); 36 if (eStopButtonPressed()) 37 shutdown(); 38 } 39} 40 41// Shutdown the process ------------------------------------------------------------ 42void shutdown(){ 43 for (int a = 0; a < 2; a++) 44 { 45 turnOff(cutterHeadA); 46 turnOff(cutterHeadB); 47 turnOff(trimSawA); 48 turnOff(trimSawB); 49 turnOff(scoringA); 50 turnOff(scoringB); 51 turnOff(lugChain); 52 turnOff(crossOver); 53 } 54} 55//------------------------------------------------------------------------------------- 56bool systemCheck(){ 57 if (isOn(cutterHeadA) && isOn(cutterHeadB) && isOn(trimSawA) && isOn(trimSawB)) 58 return 1; 59 if (isOff(cutterHeadA) && isOff(cutterHeadB) && isOff(trimSawA) && isOff(trimSawB)) 60 return 0; 61} 62 63void spoolUp(){ 64 turnOn(trimSawB); 65 giveMeSomeTime(); 66 turnOn(trimSawA); 67 giveMeSomeTime(); 68 turnOn(cutterHeadB); 69 giveMeSomeTime(); 70 turnOn(cutterHeadA); 71 giveMeSomeTime(); 72 if (eStopButtonPressed()) 73 shutdown(); 74} 75 76 77void INFO() { 78 Serial.println("Select what you want"); 79 Serial.println("1 = Relays, 2 = Sensors"); 80 81 while (Serial.available() == 0); 82 int sheild = Serial.read() - '0'; 83 switch (sheild) { 84 85 case 1: 86 Serial.println("Relay Sheild"); 87 infoRelays(); 88 break; 89 case 2: 90 Serial.println("Sensor"); 91 sensorInfo(); 92 break; 93 } 94 95} 96
Controls.ino
arduino
Support Code for the Press. Function calls are all here.
1//--- Slapper Button ----------------------------------------------------------------------------------------- 2void slapperMode() 3{ 4 if (digitalRead(21) == ON) 5 turnOff(crowderRollsAirRelay); 6 else 7 turnOn(crowderRollsAirRelay); 8} 9//------------------------------------------------------------ 10//--- Return true if the eStop button is pressed ------------- 11boolean eStopButtonPressed() 12{ 13 return (analogRead(startUpSequenceButton) < 200); 14} 15//------------------------------------------------------------ 16//--- Return true if the run button is pressed --------------- 17boolean runButtonPressed() 18{ 19 return (analogRead(runButton) < 200); 20} 21//------------------------------------------------------------ 22//--- Turn the pin ON ---------------------------------------- 23void turnOn(int pinNumber) 24{ 25 digitalWrite(pinNumber, ON); 26} 27//------------------------------------------------------------ 28//--- Turn the pin OFF --------------------------------------- 29void turnOff(int pinNumber) 30{ 31 digitalWrite(pinNumber, OFF); 32} 33//------------------------------------------------------------ 34//--- Return true if the pin is ON --------------------------- 35boolean isOn(int pinNumber) 36{ 37 return (digitalRead(pinNumber) == ON); 38} 39//------------------------------------------------------------ 40//--- Return true if the pin is OFF -------------------------- 41boolean isOff(int pinNumber) 42{ 43 return (digitalRead(pinNumber) == OFF); 44} 45//-------------------------------------------------------------------------------- 46// Give some time between actions to check if the e-stop button was pressed------- 47 48boolean pln(int pinNumber) 49{ 50 return Serial.println(analogRead(pinNumber)); 51} 52 53void giveMeSomeTime() 54{ 55 for (int i = 0; i < 4; i++) 56 { 57 if (eStopButtonPressed()) 58 shutdown(); 59 delay (delayTime); 60 if (eStopButtonPressed()) 61 shutdown(); 62 } 63} 64//----------------------------------------------------------------------------------------------------------- 65//--- Maintenance mode -------------------------------------------------------------------------------------- 66void maintenance() 67{ 68 while ( runButtonPressed() && !eStopButtonPressed() && analogRead(maintenancePressed) >= 200 ) 69 { 70 if (analogRead(maintenancePressed) >= 75) 71 { 72 Serial.println("Maintenance Mode Active"); 73 74 // This opens the press and keeps everything open to releave any kind of pressure. 75 76 turnOff(assemblyChainRelay ); // Turns the assembly chain off 77 turnOff(crowderRollsFreakDriveRelay ); // Turns the Freq on Crowder Rolls off 78 turnOff(hydraulicCrowderRollsRelay ); // Turns Hydraulic Crowder rolls off 79 turnOff(clearingRollsRelay ); // turn off the clearing rolls 80 turnOn(bigSqueezeRelay ); // Pulls back the squeeze 81 turnOff(spikeHoldDownRelay ); // spike clamp compress on the flying cut off 82 turnOn(pressTopHoldRelay ); // Air hold downs in the press up 83 turnOn(pushoutRelay ); // Press bar retract 84 turnOff(flyingCutOffRetractRelay ); // turns the flying cut off retract off 85 turnOff(flyingCutOffSawGuardClampRelay); // Flying cut off clamp off 86 turnOff(flyingCutOffSawUpRelay ); // Flying cut off saw cut off 87 88 slapperMode(); // This allows me to use the slappers while in this mode 89 90 } 91 else // Once the swithc has been deactivated this else statment allows the code to break 92 // away from the while loop it is nested into. 93 { 94 break; // Gets me out of the while loop. 95 } 96 } 97} 98//----------------------------------------------------------------------------------------------------------------------------------------------------- 99// Shutdown the process ------------------------------------------------------------------------------------------------------------------------------- 100void shutdown() 101{ 102 turnOff(hydraulicTankRelay); 103 turnOff(flyingCutOffSawMotorRelay); 104 turnOff(PET4Relay); 105 turnOff(PET1Relay); 106 turnOff(PET2Relay); 107 turnOff(PET3Relay); 108 turnOff(assemblyChainRelay); 109 turnOff(crowderRollsFreakDriveRelay); 110} 111 112 113void INFO() { 114 Serial.println("Select the Sheild you want"); 115 Serial.println("1 = Left, 2 = Middle, 3 = Right"); 116 117 while (Serial.available() == 0); 118 int sheild = Serial.read() - '0'; 119 switch (sheild) { 120 121 case 1: 122 Serial.println("Left Sheild"); 123 infoLeft(); 124 break; 125 case 2: 126 Serial.println("Middle Sheild"); 127 infoMiddle(); 128 break; 129 case 3: 130 Serial.println("Right Sheild"); 131 infoRight(); 132 break; 133 } 134 135} 136 137
Stacker_functions.ino
arduino
Support code for the stacker and function calls.
1//--- Shut it Down ------------------------------------------ 2void shutDown(){ 3 turnOff(up); 4 turnOff(down); 5 turnOff(forward); 6 turnOff(reverse); 7 turnOff(brake); 8 return; 9} 10 11//--- Turn the pin ON ---------------------------------------- 12void turnOn(int pinNumber){ 13 digitalWrite(pinNumber, ON); 14} 15 16//--- Turn the pin OFF --------------------------------------- 17void turnOff(int pinNumber){ 18 digitalWrite(pinNumber, OFF); 19} 20 21//--- Return true if the pin is ON --------------------------- 22boolean isOn(int pinNumber){ 23 return (digitalRead(pinNumber) == ON); 24} 25 26//--- Return true if the pin is OFF -------------------------- 27boolean isOff(int pinNumber){ 28 return (digitalRead(pinNumber) == OFF); 29} 30//--- Returns the analogRead for the pin --------------------- 31int aRead(int pinNumber) { 32 return analogRead(pinNumber); 33} 34 35
FJ_Cutter_Heads_Start_UP.ino
arduino
This is the main code that runs the start up sequence and automation for a single part of the machine. Since this is the main code, there are several other codes that run in tab to this code that I will also post
1 2//--- Deffenitions ----------------------------------------------------------------------------------------------------------- 3#define ON LOW 4#define OFF HIGH 5#define delayTime 250 6 7bool state = true; 8int choice; 9//----------------------------------------------------------------------------------------------------------------------------- 10const int startUp = 0; // This is the Cutter-Head E-Stop 11const int motion = 1; // This is the Lug-Chain E-Stop 12 13int sensor[] = {startUp, motion}; 14char* sensorString[] = {"startUp", "motion"}; 15//---------------------------------------------------------------------------------------------------------------------------- 16 17//--- This is for the relay shield on the LEFT 18int cutterHeadA = 38; // Cutter Head A 19int cutterHeadB = 40; // Cutter Head B 20int trimSawA = 42; // Trimsaw A 21int trimSawB = 44; // Trimsaw B 22int scoringA = 46; // Scoring Saw A 23int scoringB = 48; // Scoring Saw B 24int crossOver = 50; // Cross Over belts 25int lugChain = 52; // Lug Chain 26 27int relays[] = {0, cutterHeadA, cutterHeadB, trimSawA, trimSawB, scoringA, scoringB, crossOver, lugChain}; 28char* relaysString[] = {"0", "cutterHeadA", "cutterHeadB", "trimSawA", "trimSawB", 29 "scoringA", "davidNorth", "crossOver", "lugChain" 30 }; 31//---------------------------------------------------------------------------------------------------------------------------- 32void setup() { 33 34 Serial.begin(9600); 35 //-------------------------------------------------------------------------------------------------------------------------- 36 for (int y = 0; y <= 1; y++) { 37 Serial.print(sensorString[y]); 38 Serial.print(": "); 39 Serial.println(sensor[y]); 40 pinMode(sensor[y], INPUT); 41 } 42 //-------------------------------------------------------------------------------------------------------------------------- 43 for (int x = 0; x <= 8; x++) { 44 Serial.print(relaysString[x]); 45 Serial.print(": "); 46 Serial.println(relays[x]); 47 pinMode(relays[x], OUTPUT); 48 turnOff(relays[x]); 49 } 50 //---------------------------------------------------------------------------------------------------------------------------- 51}// This is the end of the Setup 52//---------------------------------------------------------------------------------------------------------------------------- 53 54 55void loop() { 56 57 Serial.println("making borads"); 58 while (Serial.available() < 0); 59 int options = Serial.read() - '0'; 60 if (options == 1) { 61 INFO(); 62 } 63 64 //----------------------------------- 65 //--- Start UP ---------------------- 66 if (systemCheck() == 0) 67 { 68 if (!eStopButtonPressed()) { 69 spoolUp(); 70 } 71 } 72 if (eStopButtonPressed()) 73 shutdown(); 74 //---------------------------------- 75 76 //---------------------------------- 77 //--- Operation -------------------- 78 if (systemCheck() == 1) 79 { 80 if (!lugChainPressed()) 81 { 82 turnOn(lugChain ); 83 turnOn(crossOver); 84 } 85 else 86 { 87 turnOff(lugChain ); 88 turnOff(crossOver); 89 if (eStopButtonPressed()) 90 shutdown(); 91 } 92 } 93 94 //-------------------------------------------- 95}// This is the end of the loop! 96//-------------------------------------------- 97 98 99
Sart_UP_Sensors.ino
arduino
For the Serial Monitor so that you can look at values while the machine is running. Creates a sort of menu.
1void sensorInfo() { 2 3 while (state = true) { 4 while (Serial.available() == 0); 5 int selection = Serial.read() - '0'; 6 7 switch (selection) { 8 9 case startUp: 10 while (state == true) { 11 Serial.print(sensorString[selection]); 12 Serial.print(": "); 13 Serial.println(analogRead(sensor[selection])); 14 choice = Serial.read() - '0'; 15 if (choice == 0) { 16 state = false; 17 } 18 } 19 break; 20 21 case motion: 22 while (state == true) { 23 Serial.print(sensorString[selection]); 24 Serial.print(": "); 25 Serial.println(analogRead(sensor[selection])); 26 choice = Serial.read() - '0'; 27 if (choice == 0) { 28 state = false; 29 } 30 } 31 break; 32 33 default: 34 return; 35 break; 36 37 } 38 } 39} 40
Middle_Shield.ino
arduino
Support code for the Press, used in the Serial monitor
1void infoMiddle () { 2 while (true) { 3 while (Serial.available() == 0); 4 int command = Serial.read() - '0'; 5 6 switch (command) { 7 8 case 1: 9 turnOn(middle[command]); 10 Serial.print("Relay1 ON: "); 11 Serial.print(middle[command]); 12 Serial.print(" "); 13 Serial.println(middleString[command]); 14 break; 15 16 case 2: 17 turnOn(middle[command]); 18 Serial.print("Relay2 ON: "); 19 Serial.print(middle[command]); 20 Serial.print(" "); 21 Serial.println(middleString[command]); 22 break; 23 24 case 3: 25 turnOn(middle[command]); 26 Serial.print("Relay3 ON: "); 27 Serial.print(middle[command]); 28 Serial.print(" "); 29 Serial.println(middleString[command]); 30 break; 31 32 case 4: 33 turnOn(middle[command]); 34 Serial.print("Relay4 ON: "); 35 Serial.print(middle[command]); 36 Serial.print(" "); 37 Serial.println(middleString[command]); 38 break; 39 40 case 5: 41 turnOn(middle[command]); 42 Serial.print("Relay5 ON: "); 43 Serial.print(middle[command]); 44 Serial.print(" "); 45 Serial.println(middleString[command]); 46 break; 47 48 case 6: 49 turnOn(middle[command]); 50 Serial.print("Relay6 ON: "); 51 Serial.print(middle[command]); 52 Serial.print(" "); 53 Serial.println(middleString[command]); 54 break; 55 56 case 7: 57 turnOn(middle[command]); 58 Serial.print("Relay7 ON: "); 59 Serial.print(middle[command]); 60 Serial.print(" "); 61 Serial.println(middleString[command]); 62 break; 63 64 case 8: 65 turnOn(middle[command]); 66 Serial.print("Relay8 ON: "); 67 Serial.print(middle[command]); 68 Serial.print(" "); 69 Serial.println(middleString[command]); 70 break; 71 72 case 0: 73 Serial.println("Exiting Left Sheild..."); 74 break; 75 76 default: 77 shutdown(); 78 Serial.println("Shutdown"); 79 break; 80 } 81 if (command == 0) { 82 break; 83 } 84 85 } 86} 87
Press_Code_24VDC_wCommands.ino
arduino
Main Press code. This runs the largest part of the machine that catches and cuts the boards, then compresses the boards together.
1/* 2Written by: Amos Parmenter, Ricardo G, Brad Parmenter, Sam Parmenter. 3Date Revised: March 16, 2015 4 5Purpose: This code was intended to run the press section of the finger-jointer at Paremnter Intl. 6 This code over sees the cycling of the press along with the e-stops and other functions 7 pertaining to this section of the mill. 8*/ 9 10 11//--- Deffenitions ----------------------------------------------------------------------------------------------------------- 12#define ON LOW 13#define OFF HIGH 14#define delayTime 250 15 16bool state = true; 17 18int choice; 19int selection; 20int x; 21 22//-- Declare Buttons --------------------------------------------------------------------------------------------------------- 23const int startUpSequenceButton = 4; // Designates Upper Left E-Stop as start up sequence 24const int runButton = 6; // Designates the Green E-Stop as Run for crowder rolls 25 26//--- Declare Sensors -------------------------------------------------------------------------------------------------------- 27const int speedRollsSensor = 0; // This is for the sensor on the speed up rolls at the begining of the press 28const int pushoutSensor = 1; // This is for the sensor looking at the pushout 29const int endPressSensor = 2; // This is for the sensor on at the end of the press 30const int fullStrokeSensor = 3; // This is for the sensor on the flying cut off relase 31const int assemblySensor = 7; // This is for the sensor in the assembly 32const int flyingCutOffMoveSensor = 10; // This is for the sensor that sees the flying cut off move 33const int drainSensor = 12; // This is for the drain sensor in the press 34const int maintenancePressed = 11; // This is for the maintenance button that opens the press 35 36int sensors[] = { 37 speedRollsSensor, pushoutSensor, endPressSensor, fullStrokeSensor, startUpSequenceButton, 5, 38 runButton, assemblySensor, 8, 9, flyingCutOffMoveSensor, maintenancePressed, drainSensor, 13, 14, 15 39}; 40char* sensorsString[] = { 41 "speedRollsSensor", "pushoutSensor", "endPressSensor", "fullStrokeSensor", "startUpSequenceButton", "5", 42 "runButton", "assemblySensor", "8", "9", "flyingCutOffMoveSensor", "maintenancePressed", "drainSensor", "13", "14", "15" 43}; 44 45//--- Relay Shield #1 on the left --------------------------------------------------------------------------------------------- 46int pushoutRelay = 22; // press pushout in the press 47int hydraulicCrowderRollsRelay = 24; // hydraulic crowder rolls 48int crowderRollsAirRelay = 26; // crowder rolls air 49int flyingCutOffSawUpRelay = 28; // flying cutt off saw blade cuts the board 50int flyingCutOffRetractRelay = 30; // flying cut off retract 51int spikeHoldDownRelay = 32; // spike hold down 52int flyingCutOffSawGuardClampRelay = 34; // flying cut off saw guard clamp 53int pressTopHoldRelay = 36; // Press top hold 54 55//--- Relay Shield #2 in the middle ------------------------------------------------------------------------------------------- 56int flyingCutOffSawMotorRelay = 38; // The flying cut off saw motor 57int PET3Relay = 40; // PET #3 58int PET4Relay = 42; // PET #4 59int PET1Relay = 44; // PET #1 60int PET2Relay = 46; // PET #2 61int hydraulicTankRelay = 48; // Hydraulic Tank 62int bigSqueezeRelay = 50; // the big squeeze 63int limitSwitchRelay = 52; // limit switch 64 65//--- Relay Shield #3 on the right --------------------------------------------------------------------------------------------- 66int crowderRollsFreakDriveRelay = 43; // the crowder rolls on the freak-drive 67int airSolenoidCutterheadRelay = 45; // the air selinod after Cuttterhead A 68int clearingRollsRelay = 51; // Clearing rolls 69int assemblyChainRelay = 53; // Assembly chain 70 71//--- Extra relays ------------------------------------------------------------------------------------------------------------- 72int relay21 = 39; 73int relay22 = 41; 74int relay25 = 47; 75int relay26 = 49; 76 77 78int left[] = { 79 0, pushoutRelay, hydraulicCrowderRollsRelay, crowderRollsAirRelay, flyingCutOffSawUpRelay, 80 flyingCutOffRetractRelay, spikeHoldDownRelay, flyingCutOffSawGuardClampRelay, pressTopHoldRelay 81}; 82char* leftString[] = { 83 "0", "pushoutRelay", "hydraulicCrowderRollsRelay", "crowderRollsAirRelay", "flyingCutOffSawUpRelay", 84 "flyingCutOffRetractRelay", "spikeHoldDownRelay", "flyingCutOffSawGuardClampRelay", "pressTopHoldRelay" 85}; 86 87int middle[] = { 88 0, flyingCutOffSawMotorRelay, PET3Relay, PET4Relay, PET1Relay, 89 PET2Relay, hydraulicTankRelay, bigSqueezeRelay, limitSwitchRelay 90}; 91char* middleString[] = { 92 "0", "flyingCutOffSawMotorRelay", "PET3Relay", "PET4Relay", "PET1Relay", 93 "PET2Relay", "hydraulicTankRelay", "bigSqueezeRelay", "limitSwitchRelay" 94}; 95 96int right[] = { 97 0, crowderRollsFreakDriveRelay, airSolenoidCutterheadRelay, clearingRollsRelay, assemblyChainRelay, 98 relay21, relay22, relay25, relay26 99}; 100char* rightString[] = { 101 "0", "crowderRollsFreakDriveRelay", "airSolenoidCutterheadRelay", "clearingRollsRelay", "assemblyChainRelay", 102 "relay21", "relay22", "relay25", "relay26" 103}; 104 105 106 107//------------------------------------------------------------------------------------------------------------------------------ 108//--- The Setup ---------------------------------------------------------------------------------------------------------------- 109void setup() 110{ 111 Serial.begin(9600); // Serial communication baud-rate 112 113 // The Sensors 114 for (int s = 0; s <= 15; s++) { 115 pinMode(sensors[s], INPUT); 116 Serial.print(sensorsString[s]); 117 Serial.print(": "); 118 Serial.println(sensors[s]); 119 if ( s == 15) { 120 Serial.println(""); 121 } 122 } 123 124 //------------------------------------------------------------------------------------------------------------------------------- 125 for (int x = 0; x <= 8; x++) { 126 pinMode(left[x], OUTPUT); 127 turnOff(left[x]); 128 Serial.print(left[x]); 129 Serial.print(", "); 130 if ( x == 8) { 131 Serial.println(""); 132 } 133 } 134 for (int y = 0; y <= 8; y++) { 135 pinMode(middle[y], OUTPUT); 136 turnOff(middle[y]); 137 Serial.print(middle[y]); 138 Serial.print(", "); 139 if ( y == 8) { 140 Serial.println(""); 141 } 142 } 143 for (int z = 0; z <= 8; z++) { 144 pinMode(right[z], OUTPUT); 145 turnOff(right[z]); 146 Serial.print(right[z]); 147 Serial.print(", "); 148 if ( z == 8) { 149 Serial.println(""); 150 } 151 } 152 //---------------This Completes Programming 3 Relay Shields----------------------------------------------------------------------- 153 154 // This is for the slapper button that is using an interrpt pin. 155 attachInterrupt(2, slapperMode, CHANGE); 156 pinMode(21, INPUT); 157 158 159}// This is the end of the void Setup----------------------------------------------------------------------------------------------- 160 //--------------------------------------------------------------------------------------------------------------------------------- 161 162//---------------------------------------------------------------------------------------------------------------------------------- 163//--- The loop that runs continually as long as the ardunio is on. ---------------------------------------------------------------- 164void loop() 165{ 166 167 Serial.println("making borads"); 168 while(Serial.available() < 0); 169 int options = Serial.read() - '0'; 170 //Serial.println(options); 171 if(options == 1){ 172 INFO(); 173 } 174 175 176 177 // Maintenance 178 if (analogRead(maintenancePressed) >= 200) // Checks 179 { 180 maintenance(); 181 } 182 183 // Emergency stop 184 if (eStopButtonPressed()) 185 { 186 shutdown(); 187 } 188 189 // Turns on the assembly chain 190 // Checks the status of the Start up Sequence 191 if (!eStopButtonPressed() && !runButtonPressed()) 192 { 193 turnOn(assemblyChainRelay); 194 turnOn(hydraulicCrowderRollsRelay); 195 } 196 197 //--- Allows the program to skip delays when running ----------------------------------------------------------------------------- 198 if (isOff(hydraulicTankRelay)) 199 // Checks to make sure the hydra;ic tank is off before entering the nested loop. This makes sure that we are not using 200 // the delays after the machine has started up. Once running this section of code is skipped. 201 { 202 //--- Checks the status of the Press E-Stop ------------------------------------------------------------------------------------ 203 //--- This is the startup sequence for this section of the machine. ------------------------------------------------------------ 204 if (!eStopButtonPressed()) 205 { 206 turnOn(PET4Relay); 207 giveMeSomeTime(); 208 turnOn(PET3Relay); 209 giveMeSomeTime(); 210 turnOn(PET2Relay); 211 giveMeSomeTime(); 212 turnOn(PET1Relay); 213 giveMeSomeTime(); 214 turnOn(flyingCutOffSawMotorRelay); 215 giveMeSomeTime(); 216 turnOn(hydraulicTankRelay); 217 } 218 } 219 //-------------------------------------------------------------------------------------------------------------------------------- 220 221 //--- Turn off run button process ------------------------------------------------------------------------------------------------ 222 if (!eStopButtonPressed() && runButtonPressed()) 223 // This checks to make the run button has been turned off and the the e-stop has not been pressed. 224 { 225 turnOff(assemblyChainRelay); 226 turnOff(crowderRollsFreakDriveRelay); 227 turnOff(hydraulicCrowderRollsRelay); 228 } 229 //--------------------------------------------------------------------------------------------------------------------------------- 230 // Debug - Print which mode or sensor values the code is running 231 232 //Serial.println(analogRead(fullStrokeSensor)); 233 234 235 236 //-------------------------------------------------------------------------------------------------------------------------------- 237 // The next section of code will instruct he cycling of the press. 238 239 //--- End of the Press sensors --------------------------------------------------------------------------------------------------- 240 if (analogRead(endPressSensor) >= 100 && analogRead(drainSensor) <= 100) 241 // This checks both sensors at the end of the press to make sure they are both on. 242 { 243 turnOff(flyingCutOffRetractRelay); 244 turnOn(bigSqueezeRelay); 245 turnOn(pressTopHoldRelay); 246 turnOn(pushoutRelay); 247 248 /* We were having some issues with the spike coming down randomly. 249 This nested if statement makes it only possible if the press bar 250 has been retracted as well as all the other condition from the first if statment are also true. 251 */ 252 if (analogRead(pushoutSensor) <= 100) 253 // This ensures that the press bar has been retracted before it allows the spike to come down. 254 { 255 turnOn(spikeHoldDownRelay); 256 } 257 } 258 //-------------------------------------------------------------------------------------------------------------------------------- 259 260 //--- This is for the flying cut off saw ----------------------------------------------------------------------------------------- 261 if (isOff(flyingCutOffRetractRelay) && analogRead(flyingCutOffMoveSensor) <= 200 && isOn(spikeHoldDownRelay)) 262 // checks all conditions before proceeding 263 { 264 /* 265 This forces the ardunio to focus on the just this small loop for a small amount of time to ensure the 266 flying-cut off saw comes up. The counter is adjustable for the best timing possible, but the value does 267 not represent an actual time count. This also ensures the cut can only happen once and will be reset and 268 availble to happen again once the board that was cut entered the press and the sensor at the front has 269 reset to value for x. 270 */ 271 for (x = 0; x <= 3; x++) 272 { 273 turnOn(flyingCutOffSawGuardClampRelay); 274 turnOn(flyingCutOffSawUpRelay); 275 } 276 } 277 278 //------------------------------------------------------------------------------------------------------------------------------- 279 // This checks to see if the press bar is retracted and that saw is full stroke. 280 if (isOn(pushoutRelay) && analogRead(fullStrokeSensor) >= 200) 281 { 282 for (x = 0; x <= 3; x++) 283 { 284 turnOff(flyingCutOffSawGuardClampRelay); 285 turnOff(flyingCutOffSawUpRelay); 286 287 if ( isOff(flyingCutOffSawUpRelay) && isOff(flyingCutOffSawGuardClampRelay)) 288 { 289 turnOn(clearingRollsRelay); 290 turnOn(flyingCutOffRetractRelay); 291 } 292 // This is looking for any reason to let the spike unclamp. 293 if (isOn(clearingRollsRelay) || isOn(flyingCutOffRetractRelay) ) 294 { 295 turnOff(spikeHoldDownRelay); 296 } 297 } 298 } 299 //------------------------------------------------------------------------------------------------------------------------------ 300 // Front of the Press 301 // Checks the status of the sensor at the front of the press. 302 // This section os looking to reset the cycling process and reseting x 303 if (analogRead(speedRollsSensor) <= 100) 304 { 305 turnOff(spikeHoldDownRelay); 306 turnOff(clearingRollsRelay); 307 turnOff(pushoutRelay); 308 turnOn(flyingCutOffRetractRelay); 309 x = 0; 310 } 311 312 //------------------------------------------------------------------------------------------------------------------------------ 313 // This checks to make sure the press bar is all the way forward. 314 // then it allows the machine to close and pressurize. 315 if (analogRead(pushoutSensor) <= 100) 316 { 317 turnOff(pressTopHoldRelay); 318 turnOff(bigSqueezeRelay); 319 } 320 321 //------------------------------------------------------------------------------------------------------------------------------ 322 //Assembley & Crowd control 323 if (analogRead(runButton) > 100) // This is the run button that will now turn ON the assembly 324 { 325 if (analogRead(assemblySensor) <= 100 || analogRead(drainSensor) <= 100) 326 { 327 turnOn(crowderRollsFreakDriveRelay); 328 } 329 else 330 { 331 turnOff(crowderRollsFreakDriveRelay); 332 } 333 } 334 335 //------------------------------------------------------------------------------------------------------------------------------ 336 }// This is the end of the void Loop 337 //-------------------------------------------------------------------------------------------------------------------------------- 338 339 340 341
Sensors.ino
arduino
Support code for the Press, used in the Serial monitor
1void sensorInfo() { 2 3 while (state = true) { 4 while (Serial.available() == 0); 5 int selection = Serial.read() - '0'; 6 7 switch (selection) { 8 9 case speedRollsSensor: 10 while (state == true) { 11 Serial.print(sensorsString[selection]); 12 Serial.print(": "); 13 Serial.println(analogRead(sensors[selection])); 14 choice = Serial.read() - '0'; 15 if (choice == 0) { 16 state = false; 17 } 18 } 19 break; 20 21 case pushoutSensor: 22 while (state == true) { 23 Serial.print(sensorsString[selection]); 24 Serial.print(": "); 25 Serial.println(analogRead(sensors[selection])); 26 choice = Serial.read() - '0'; 27 if (choice == 0) { 28 state = false; 29 } 30 } 31 break; 32 33 case endPressSensor: 34 while (state == true) { 35 Serial.print(sensorsString[selection]); 36 Serial.print(": "); 37 Serial.println(analogRead(sensors[selection])); 38 choice = Serial.read() - '0'; 39 if (choice == 0) { 40 state = false; 41 } 42 } 43 break; 44 45 case fullStrokeSensor: 46 while (state == true) { 47 Serial.print(sensorsString[selection]); 48 Serial.print(": "); 49 Serial.println(analogRead(sensors[selection])); 50 choice = Serial.read() - '0'; 51 if (choice == 0) { 52 state = false; 53 } 54 } 55 break; 56 57 case startUpSequenceButton: 58 while (state == true) { 59 Serial.print(sensorsString[selection]); 60 Serial.print(": "); 61 Serial.println(analogRead(sensors[selection])); 62 choice = Serial.read() - '0'; 63 if (choice == 0) { 64 state = false; 65 } 66 } 67 break; 68 69 case A5: // Open Pin 70 while (state == true) { 71 Serial.print(sensorsString[selection]); 72 Serial.print(": "); 73 Serial.println(analogRead(sensors[selection])); 74 choice = Serial.read() - '0'; 75 if (choice == 0) { 76 state = false; 77 } 78 } 79 break; 80 81 case runButton: // Open Pin 82 while (state == true) { 83 Serial.print(sensorsString[selection]); 84 Serial.print(": "); 85 Serial.println(analogRead(sensors[selection])); 86 choice = Serial.read() - '0'; 87 if (choice == 0) { 88 state = false; 89 } 90 } 91 break; 92 93 case assemblySensor: // Open Pin 94 while (state == true) { 95 Serial.print(sensorsString[selection]); 96 Serial.print(": "); 97 Serial.println(analogRead(sensors[selection])); 98 choice = Serial.read() - '0'; 99 if (choice == 0) { 100 state = false; 101 } 102 } 103 break; 104 105 case A8: // Open Pin 106 while (state == true) { 107 Serial.print(sensorsString[selection]); 108 Serial.print(": "); 109 Serial.println(analogRead(sensors[selection])); 110 choice = Serial.read() - '0'; 111 if (choice == 0) { 112 state = false; 113 } 114 } 115 break; 116 117 case A9: // Open Pin 118 while (state == true) { 119 Serial.print(sensorsString[selection]); 120 Serial.print(": "); 121 Serial.println(analogRead(sensors[selection])); 122 choice = Serial.read() - '0'; 123 if (choice == 0) { 124 state = false; 125 } 126 } 127 break; 128 129 case flyingCutOffMoveSensor: // Open Pin 130 while (state == true) { 131 Serial.print(sensorsString[selection]); 132 Serial.print(": "); 133 Serial.println(analogRead(sensors[selection])); 134 choice = Serial.read() - '0'; 135 if (choice == 0) { 136 state = false; 137 } 138 } 139 break; 140 141 case maintenancePressed: // Open Pin 142 while (state == true) { 143 Serial.print(sensorsString[selection]); 144 Serial.print(": "); 145 Serial.println(analogRead(sensors[selection])); 146 choice = Serial.read() - '0'; 147 if (choice == 0) { 148 state = false; 149 } 150 } 151 break; 152 153 case drainSensor: // Open Pin 154 while (state == true) { 155 Serial.print(sensorsString[selection]); 156 Serial.print(": "); 157 Serial.println(analogRead(sensors[selection])); 158 choice = Serial.read() - '0'; 159 if (choice == 0) { 160 state = false; 161 } 162 } 163 break; 164 165 case A13: // Open Pin 166 while (state == true) { 167 Serial.print(sensorsString[selection]); 168 Serial.print(": "); 169 Serial.println(analogRead(sensors[selection])); 170 choice = Serial.read() - '0'; 171 if (choice == 0) { 172 state = false; 173 } 174 } 175 break; 176 177 case A14: // Open Pin 178 while (state == true) { 179 Serial.print(sensorsString[selection]); 180 Serial.print(": "); 181 Serial.println(analogRead(sensors[selection])); 182 choice = Serial.read() - '0'; 183 if (choice == 0) { 184 state = false; 185 } 186 } 187 break; 188 189 case A15: // Open Pin 190 while (state == true) { 191 Serial.print(sensorsString[selection]); 192 Serial.print(": "); 193 Serial.println(analogRead(sensors[selection])); 194 choice = Serial.read() - '0'; 195 if (choice == 0) { 196 state = false; 197 } 198 } 199 break; 200 201 default: 202 return; 203 break; 204 205 } 206 } 207} 208
FJ_Grinder_Controls.ino
arduino
Support Code for grinder
1//--- Checks value of analoginput --------------------------- 2int read(int pinNumber) { 3 return analogRead(pinNumber); 4} 5//--- Checks the Motion Button ------------------------------- 6boolean motionButtonPressed() 7{ 8 return (analogRead(motionButton) > 200); 9} 10//--- Turn the pin ON ---------------------------------------- 11void turnOn(int pinNumber) { 12 digitalWrite(pinNumber, ON); 13} 14//------------------------------------------------------------ 15//--- Turn the pin OFF --------------------------------------- 16void turnOff(int pinNumber) { 17 digitalWrite(pinNumber, OFF); 18} 19//------------------------------------------------------------ 20//--- Return true if the pin is ON --------------------------- 21bool isOn(int pinNumber) { 22 return (digitalRead(pinNumber) == ON); 23} 24//------------------------------------------------------------ 25//--- Return true if the pin is OFF -------------------------- 26bool isOff(int pinNumber) { 27 return (digitalRead(pinNumber) == OFF); 28} 29//---------------------------------------------------------------------------- 30// Give some time between actions to check if the e-stop button was pressed--- 31void giveMeSomeTime() { 32 for (int i = 0; i < 1; i++) 33 { 34 delay (delayTime); 35 } 36} 37// Shutdown the process ---------------------------------------------------- 38void shutdown() { 39 for (int a = 0; a < 1; a++) 40 { 41 turnOff(reverse); 42 turnOff(forward); 43 } 44} 45void INFO() { 46 47 Serial.println("Select what you want"); 48 Serial.println("1 = Relays, 2 = Sensors"); 49 50 while (Serial.available() == 0); 51 int selection = Serial.read() - '0'; 52 switch (selection) { 53 54 case 1: 55 Serial.println("Relays"); 56 infoRelays(); 57 break; 58 case 2: 59 Serial.println("Sensors"); 60 sensorInfo(); 61 break; 62 } 63} 64 65void sensorInfo() { 66 67 while (state = true) { 68 while (Serial.available() == 0); 69 int selection = Serial.read() - '0'; 70 71 switch (selection) { 72 case motionButton: 73 while (state == true) { 74 Serial.print(sensorString[selection]); 75 Serial.print(": "); 76 Serial.println(analogRead(sensor[selection])); 77 choice = Serial.read() - '0'; 78 if (choice == 0) { 79 state = false; 80 } 81 } 82 break; 83 case frontSensor: 84 while (state == true) { 85 Serial.print(sensorString[selection]); 86 Serial.print(": "); 87 Serial.println(analogRead(sensor[selection])); 88 choice = Serial.read() - '0'; 89 if (choice == 0) { 90 state = false; 91 } 92 } 93 break; 94 case backSensor: 95 while (state == true) { 96 Serial.print(sensorString[selection]); 97 Serial.print(": "); 98 Serial.println(analogRead(sensor[selection])); 99 choice = Serial.read() - '0'; 100 if (choice == 0) { 101 state = false; 102 } 103 } 104 break; 105 default: 106 return; 107 break; 108 } 109 } 110} 111 112void infoRelays () { 113 while (true) { 114 while (Serial.available() == 0); 115 int command = Serial.read() - '0'; 116 117 switch (command) { 118 119 case forward: 120 turnOn(relays[command]); 121 Serial.print("Relay1 ON: "); 122 Serial.print(relays[command]); 123 Serial.print(" "); 124 Serial.println(relaysString[command]); 125 break; 126 127 case reverse: 128 turnOn(relays[command]); 129 Serial.print("Relay2 ON: "); 130 Serial.print(relays[command]); 131 Serial.print(" "); 132 Serial.println(relaysString[command]); 133 break; 134 135 case 0: 136 Serial.println("Exiting Sheild..."); 137 break; 138 139 default: 140 shutdown(); 141 Serial.println("Shutdown"); 142 break; 143 } 144 if (command == 0) { 145 break; 146 } 147 } 148} 149 150 151
Stacker_functions.ino
arduino
Support code for the stacker and function calls.
1//--- Shut it Down ------------------------------------------ 2void shutDown(){ 3 turnOff(up); 4 turnOff(down); 5 turnOff(forward); 6 turnOff(reverse); 7 turnOff(brake); 8 return; 9} 10 11//--- Turn the pin ON ---------------------------------------- 12void turnOn(int pinNumber){ 13 digitalWrite(pinNumber, ON); 14} 15 16//--- Turn the pin OFF --------------------------------------- 17void turnOff(int pinNumber){ 18 digitalWrite(pinNumber, OFF); 19} 20 21//--- Return true if the pin is ON --------------------------- 22boolean isOn(int pinNumber){ 23 return (digitalRead(pinNumber) == ON); 24} 25 26//--- Return true if the pin is OFF -------------------------- 27boolean isOff(int pinNumber){ 28 return (digitalRead(pinNumber) == OFF); 29} 30//--- Returns the analogRead for the pin --------------------- 31int aRead(int pinNumber) { 32 return analogRead(pinNumber); 33} 34 35
Right_Shield.ino
arduino
Support code for the Press, used in the Serial monitor
1void infoRight () { 2 while (true) { 3 while (Serial.available() == 0); 4 int command = Serial.read() - '0'; 5 6 switch (command) { 7 8 case 1: 9 turnOn(right[command]); 10 Serial.print("Relay1 ON: "); 11 Serial.print(right[command]); 12 Serial.print(" "); 13 Serial.println(rightString[command]); 14 break; 15 16 case 2: 17 turnOn(right[command]); 18 Serial.print("Relay2 ON: "); 19 Serial.print(right[command]); 20 Serial.print(" "); 21 Serial.println(rightString[command]); 22 break; 23 24 case 3: 25 turnOn(right[command]); 26 Serial.print("Relay3 ON: "); 27 Serial.print(right[command]); 28 Serial.print(" "); 29 Serial.println(rightString[command]); 30 break; 31 32 case 4: 33 turnOn(right[command]); 34 Serial.print("Relay4 ON: "); 35 Serial.print(right[command]); 36 Serial.print(" "); 37 Serial.println(rightString[command]); 38 break; 39 40 case 5: 41 turnOn(right[command]); 42 Serial.print("Relay5 ON: "); 43 Serial.print(right[command]); 44 Serial.print(" "); 45 Serial.println(rightString[command]); 46 break; 47 48 case 6: 49 turnOn(right[command]); 50 Serial.print("Relay6 ON: "); 51 Serial.print(right[command]); 52 Serial.print(" "); 53 Serial.println(rightString[command]); 54 break; 55 56 case 7: 57 turnOn(right[command]); 58 Serial.print("Relay7 ON: "); 59 Serial.print(right[command]); 60 Serial.print(" "); 61 Serial.println(rightString[command]); 62 break; 63 64 case 8: 65 turnOn(right[command]); 66 Serial.print("Relay8 ON: "); 67 Serial.print(right[command]); 68 Serial.print(" "); 69 Serial.println(rightString[command]); 70 break; 71 72 case 0: 73 Serial.println("Exiting Left Sheild..."); 74 break; 75 76 default: 77 shutdown(); 78 Serial.println("Shutdown"); 79 break; 80 } 81 if (command == 0) { 82 break; 83 } 84 85 } 86} 87
FJ_Cutter_Heads_Start_UP.ino
arduino
This is the main code that runs the start up sequence and automation for a single part of the machine. Since this is the main code, there are several other codes that run in tab to this code that I will also post
1 2//--- Deffenitions ----------------------------------------------------------------------------------------------------------- 3#define ON LOW 4#define OFF HIGH 5#define delayTime 250 6 7bool state = true; 8int choice; 9//----------------------------------------------------------------------------------------------------------------------------- 10const int startUp = 0; // This is the Cutter-Head E-Stop 11const int motion = 1; // This is the Lug-Chain E-Stop 12 13int sensor[] = {startUp, motion}; 14char* sensorString[] = {"startUp", "motion"}; 15//---------------------------------------------------------------------------------------------------------------------------- 16 17//--- This is for the relay shield on the LEFT 18int cutterHeadA = 38; // Cutter Head A 19int cutterHeadB = 40; // Cutter Head B 20int trimSawA = 42; // Trimsaw A 21int trimSawB = 44; // Trimsaw B 22int scoringA = 46; // Scoring Saw A 23int scoringB = 48; // Scoring Saw B 24int crossOver = 50; // Cross Over belts 25int lugChain = 52; // Lug Chain 26 27int relays[] = {0, cutterHeadA, cutterHeadB, trimSawA, trimSawB, scoringA, scoringB, crossOver, lugChain}; 28char* relaysString[] = {"0", "cutterHeadA", "cutterHeadB", "trimSawA", "trimSawB", 29 "scoringA", "davidNorth", "crossOver", "lugChain" 30 }; 31//---------------------------------------------------------------------------------------------------------------------------- 32void setup() { 33 34 Serial.begin(9600); 35 //-------------------------------------------------------------------------------------------------------------------------- 36 for (int y = 0; y <= 1; y++) { 37 Serial.print(sensorString[y]); 38 Serial.print(": "); 39 Serial.println(sensor[y]); 40 pinMode(sensor[y], INPUT); 41 } 42 //-------------------------------------------------------------------------------------------------------------------------- 43 for (int x = 0; x <= 8; x++) { 44 Serial.print(relaysString[x]); 45 Serial.print(": "); 46 Serial.println(relays[x]); 47 pinMode(relays[x], OUTPUT); 48 turnOff(relays[x]); 49 } 50 //---------------------------------------------------------------------------------------------------------------------------- 51}// This is the end of the Setup 52//---------------------------------------------------------------------------------------------------------------------------- 53 54 55void loop() { 56 57 Serial.println("making borads"); 58 while (Serial.available() < 0); 59 int options = Serial.read() - '0'; 60 if (options == 1) { 61 INFO(); 62 } 63 64 //----------------------------------- 65 //--- Start UP ---------------------- 66 if (systemCheck() == 0) 67 { 68 if (!eStopButtonPressed()) { 69 spoolUp(); 70 } 71 } 72 if (eStopButtonPressed()) 73 shutdown(); 74 //---------------------------------- 75 76 //---------------------------------- 77 //--- Operation -------------------- 78 if (systemCheck() == 1) 79 { 80 if (!lugChainPressed()) 81 { 82 turnOn(lugChain ); 83 turnOn(crossOver); 84 } 85 else 86 { 87 turnOff(lugChain ); 88 turnOff(crossOver); 89 if (eStopButtonPressed()) 90 shutdown(); 91 } 92 } 93 94 //-------------------------------------------- 95}// This is the end of the loop! 96//-------------------------------------------- 97 98 99
Start_UP_Controls.ino
arduino
Functions that run in the main code.
1 2 3bool eStopButtonPressed(){ 4 return (analogRead(startUp) <= 100); 5} 6bool lugChainPressed(){ 7 return (analogRead(motion) <= 100); 8} 9//--- Turn the pin ON ---------------------------------------- 10void turnOn(int pinNumber){ 11 digitalWrite(pinNumber, ON); 12} 13//------------------------------------------------------------ 14//--- Turn the pin OFF --------------------------------------- 15void turnOff(int pinNumber){ 16 digitalWrite(pinNumber, OFF); 17} 18//------------------------------------------------------------ 19//--- Return true if the pin is ON --------------------------- 20bool isOn(int pinNumber){ 21 return (digitalRead(pinNumber) == ON); 22} 23//------------------------------------------------------------ 24//--- Return true if the pin is OFF -------------------------- 25bool isOff(int pinNumber){ 26 return (digitalRead(pinNumber) == OFF); 27} 28//-------------------------------------------------------------------------------- 29// Give some time between actions to check if the e-stop button was pressed------- 30void giveMeSomeTime(){ 31 for (int i = 0; i < 6; i++) 32 { 33 if (eStopButtonPressed()) 34 shutdown(); 35 delay (delayTime); 36 if (eStopButtonPressed()) 37 shutdown(); 38 } 39} 40 41// Shutdown the process ------------------------------------------------------------ 42void shutdown(){ 43 for (int a = 0; a < 2; a++) 44 { 45 turnOff(cutterHeadA); 46 turnOff(cutterHeadB); 47 turnOff(trimSawA); 48 turnOff(trimSawB); 49 turnOff(scoringA); 50 turnOff(scoringB); 51 turnOff(lugChain); 52 turnOff(crossOver); 53 } 54} 55//------------------------------------------------------------------------------------- 56bool systemCheck(){ 57 if (isOn(cutterHeadA) && isOn(cutterHeadB) && isOn(trimSawA) && isOn(trimSawB)) 58 return 1; 59 if (isOff(cutterHeadA) && isOff(cutterHeadB) && isOff(trimSawA) && isOff(trimSawB)) 60 return 0; 61} 62 63void spoolUp(){ 64 turnOn(trimSawB); 65 giveMeSomeTime(); 66 turnOn(trimSawA); 67 giveMeSomeTime(); 68 turnOn(cutterHeadB); 69 giveMeSomeTime(); 70 turnOn(cutterHeadA); 71 giveMeSomeTime(); 72 if (eStopButtonPressed()) 73 shutdown(); 74} 75 76 77void INFO() { 78 Serial.println("Select what you want"); 79 Serial.println("1 = Relays, 2 = Sensors"); 80 81 while (Serial.available() == 0); 82 int sheild = Serial.read() - '0'; 83 switch (sheild) { 84 85 case 1: 86 Serial.println("Relay Sheild"); 87 infoRelays(); 88 break; 89 case 2: 90 Serial.println("Sensor"); 91 sensorInfo(); 92 break; 93 } 94 95} 96
Right_Shield.ino
arduino
Support code for the Press, used in the Serial monitor
1void infoRight () { 2 while (true) { 3 while (Serial.available() 4 == 0); 5 int command = Serial.read() - '0'; 6 7 switch (command) { 8 9 10 case 1: 11 turnOn(right[command]); 12 Serial.print("Relay1 13 ON: "); 14 Serial.print(right[command]); 15 Serial.print(" "); 16 17 Serial.println(rightString[command]); 18 break; 19 20 case 21 2: 22 turnOn(right[command]); 23 Serial.print("Relay2 ON: "); 24 25 Serial.print(right[command]); 26 Serial.print(" "); 27 Serial.println(rightString[command]); 28 29 break; 30 31 case 3: 32 turnOn(right[command]); 33 Serial.print("Relay3 34 ON: "); 35 Serial.print(right[command]); 36 Serial.print(" "); 37 38 Serial.println(rightString[command]); 39 break; 40 41 case 42 4: 43 turnOn(right[command]); 44 Serial.print("Relay4 ON: "); 45 46 Serial.print(right[command]); 47 Serial.print(" "); 48 Serial.println(rightString[command]); 49 50 break; 51 52 case 5: 53 turnOn(right[command]); 54 Serial.print("Relay5 55 ON: "); 56 Serial.print(right[command]); 57 Serial.print(" "); 58 59 Serial.println(rightString[command]); 60 break; 61 62 case 63 6: 64 turnOn(right[command]); 65 Serial.print("Relay6 ON: "); 66 67 Serial.print(right[command]); 68 Serial.print(" "); 69 Serial.println(rightString[command]); 70 71 break; 72 73 case 7: 74 turnOn(right[command]); 75 Serial.print("Relay7 76 ON: "); 77 Serial.print(right[command]); 78 Serial.print(" "); 79 80 Serial.println(rightString[command]); 81 break; 82 83 case 84 8: 85 turnOn(right[command]); 86 Serial.print("Relay8 ON: "); 87 88 Serial.print(right[command]); 89 Serial.print(" "); 90 Serial.println(rightString[command]); 91 92 break; 93 94 case 0: 95 Serial.println("Exiting Left Sheild..."); 96 97 break; 98 99 default: 100 shutdown(); 101 Serial.println("Shutdown"); 102 103 break; 104 } 105 if (command == 0) { 106 break; 107 } 108 109 110 } 111} 112
Start_UP_relayShield.ino
arduino
For the Serial Monitor so that you can look at values while the machine is running. Creates a sort of menu. I used 1-8 for the case number to associate with the relay shields.
1void infoRelays () { 2 while (true) { 3 while (Serial.available() == 0); 4 int command = Serial.read() - '0'; 5 6 switch (command) { 7 8 case 1: 9 turnOn(relays[command]); 10 Serial.print("Relay1 ON: "); 11 Serial.print(relays[command]); 12 Serial.print(" "); 13 Serial.println(relaysString[command]); 14 break; 15 16 case 2: 17 turnOn(relays[command]); 18 Serial.print("Relay2 ON: "); 19 Serial.print(relays[command]); 20 Serial.print(" "); 21 Serial.println(relaysString[command]); 22 break; 23 24 case 3: 25 turnOn(relays[command]); 26 Serial.print("Relay3 ON: "); 27 Serial.print(relays[command]); 28 Serial.print(" "); 29 Serial.println(relaysString[command]); 30 break; 31 32 case 4: 33 turnOn(relays[command]); 34 Serial.print("Relay4 ON: "); 35 Serial.print(relays[command]); 36 Serial.print(" "); 37 Serial.println(relaysString[command]); 38 break; 39 40 case 5: 41 turnOn(relays[command]); 42 Serial.print("Relay5 ON: "); 43 Serial.print(relays[command]); 44 Serial.print(" "); 45 Serial.println(relaysString[command]); 46 break; 47 48 case 6: 49 turnOn(relays[command]); 50 Serial.print("Relay6 ON: "); 51 Serial.print(relays[command]); 52 Serial.print(" "); 53 Serial.println(relaysString[command]); 54 break; 55 56 case 7: 57 turnOn(relays[command]); 58 Serial.print("Relay7 ON: "); 59 Serial.print(relays[command]); 60 Serial.print(" "); 61 Serial.println(relaysString[command]); 62 break; 63 64 case 8: 65 turnOn(relays[command]); 66 Serial.print("Relay8 ON: "); 67 Serial.print(relays[command]); 68 Serial.print(" "); 69 Serial.println(relaysString[command]); 70 break; 71 72 case 0: 73 Serial.println("Exiting Left Sheild..."); 74 break; 75 76 default: 77 shutdown(); 78 Serial.println("Shutdown"); 79 break; 80 } 81 if (command == 0) { 82 break; 83 } 84 85 } 86} 87
Sart_UP_Sensors.ino
arduino
For the Serial Monitor so that you can look at values while the machine is running. Creates a sort of menu.
1void sensorInfo() { 2 3 while (state = true) { 4 while (Serial.available() 5 == 0); 6 int selection = Serial.read() - '0'; 7 8 switch (selection) 9 { 10 11 case startUp: 12 while (state == true) { 13 Serial.print(sensorString[selection]); 14 15 Serial.print(": "); 16 Serial.println(analogRead(sensor[selection])); 17 18 choice = Serial.read() - '0'; 19 if (choice == 0) { 20 state 21 = false; 22 } 23 } 24 break; 25 26 case motion: 27 28 while (state == true) { 29 Serial.print(sensorString[selection]); 30 31 Serial.print(": "); 32 Serial.println(analogRead(sensor[selection])); 33 34 choice = Serial.read() - '0'; 35 if (choice == 0) { 36 state 37 = false; 38 } 39 } 40 break; 41 42 default: 43 44 return; 45 break; 46 47 } 48 } 49} 50
Stacker_Code.ino
arduino
Code for the automatic stacker
1/* Written By: Amos Parmenter 2 Jun 11, 2014 "Revised 3 July 16, 2014" 4 Parmenter INT. 5 6 This is for the small 7 green automatic stacker at the 8 end of the finger jointer after the mulder. 9 The purpouse 10 is to stack one full layer of boards onto the outfeed 11 chain 12 deck in front of the machine. It runs in a cycle 13 motion to acomplish this task 14 and will use an array of 15 sensor to determine postion of the forks the boards 16 lay 17 on to determine where and when the cylce is complete and 18 ready to 19 cycle again. 20 21 * Be sure to read the tab for the function calls. 22 23 I keep all of the function off the main tab to 24 make the code easier to read 25 or find the values 26 I am looking for. It helps the debuging process. 27 28*/ 29#define 30 ON LOW 31#define OFF HIGH 32 33//--- Sensors -------------------------- 34int 35 button = 0; // The switch to start thde cycle 36int allForward = 5; // The 37 sensor that says im forward 38int unit = 1; // This sensor sees the unit 39int 40 allBack = 3; // The sensor that says im all the way back 41int allUp = 42 2; // The sensor that says im all the way up 43// I have three open filters on 44 the shield for more sensors 45//-------------------------------------- 46//--- 47 Relays --------------------------- 48int up = 39; // The relay going up 49int 50 down = 41; // The relay going down 51int forward = 43; // The relay going 52 forward 53int reverse = 45; // The relay going reverse 54int brake = 47; // 55 The relay for the brake 56 57// I have three relays left unused. 58// int relay 59 = 49; 60// int relay = 51; 61// int relay = 53; 62//-------------------------------------- 63 64void 65 setup() { 66 Serial.begin(9600); 67 68 pinMode(unit, INPUT); 69 pinMode(allForward, 70 INPUT); 71 pinMode(allBack, INPUT); 72 pinMode(button, INPUT); 73 pinMode(allUp, 74 INPUT); 75 76 pinMode(forward, OUTPUT); // This sets Relay 1 as an 77 output 78 digitalWrite(forward, OFF); // Turns the relay off 79 pinMode(reverse, 80 OUTPUT); // This sets Relay 2 as an output 81 digitalWrite(reverse, OFF); 82 // Turns the relay off 83 pinMode(up, OUTPUT); // This sets Relay 84 3 as an output 85 digitalWrite(up, OFF); // Turns the relay off 86 pinMode(down, 87 OUTPUT); // This sets Relay 4 as an output 88 digitalWrite(down, OFF); 89 // Turns the relay off 90 pinMode(brake, OUTPUT); // This sets 91 Relay 5 as an output 92 digitalWrite(brake, OFF); // Turns the relay off 93 94} 95 96void 97 loop() { 98 Serial.println(aRead(allForward)); 99 100 if (analogRead(button) 101 >= 200 ) { 102 turnOn(brake); // Disengages the brake of on the F/R Motor 103 104 while (isOn(brake)) { 105 turnOn(brake); 106 turnOn(forward); // 107 Sends the F/R motor FORWARD 108 delay(1000); 109 if (aRead(allForward) 110 >= 200 ){ 111 delay(20); 112 break; 113 } 114 } 115 } 116 117if 118 (aRead(allForward) >= 200) { 119 turnOff(forward); // Turns the F/R motor OFF 120 121 turnOn(down ); // This is the U/D Motor turning going DOWN 122 delay(1000); 123 124 turnOff(brake); // Engages the brake of on the F/R Motor 125} 126 127if (aRead(unit) 128 >= 200) { 129 turnOn(brake); // This Disengages the F/R brake 130 while (isOn(brake)) 131 { 132 turnOn(brake); 133 turnOn(reverse); // This sends the F/R Motor REVERSE 134 135 if (aRead(allBack) >= 150) 136 break; 137 } 138} 139 140if (aRead(allBack) 141 >= 200 && aRead(allUp) <= 200 ) { 142 turnOff(reverse); // This turns the F/R 143 Motor OFF 144 delay(1250); 145 turnOff(brake); // Engages the F/R brake 146 147 turnOff(down); 148 turnOn(up ); // Sends the U/D Motor UP 149} 150 151if (aRead(allBack) 152 >= 200 && aRead(allUp) >= 200) { 153 shutDown(); 154} 155 156//--- This is the 157 end of the VOID LOOP ------------------------------- 158} 159 160
Left_Shield.ino
arduino
Support code, used in the Serial monitor
1void infoLeft () { 2 while (true) { 3 while (Serial.available() 4 == 0); 5 int command = Serial.read() - '0'; 6 7 switch (command) { 8 9 10 case 1: 11 turnOn(left[command]); 12 Serial.print("Relay1 13 ON: "); 14 Serial.print(left[command]); 15 Serial.print(" "); 16 17 Serial.println(leftString[command]); 18 break; 19 20 case 21 2: 22 turnOn(left[command]); 23 Serial.print("Relay2 ON: "); 24 25 Serial.print(left[command]); 26 Serial.print(" "); 27 Serial.println(leftString[command]); 28 29 break; 30 31 case 3: 32 turnOn(left[command]); 33 Serial.print("Relay3 34 ON: "); 35 Serial.print(left[command]); 36 Serial.print(" "); 37 38 Serial.println(leftString[command]); 39 break; 40 41 case 42 4: 43 turnOn(left[command]); 44 Serial.print("Relay4 ON: "); 45 46 Serial.print(left[command]); 47 Serial.print(" "); 48 Serial.println(leftString[command]); 49 50 break; 51 52 case 5: 53 turnOn(left[command]); 54 Serial.print("Relay5 55 ON: "); 56 Serial.print(left[command]); 57 Serial.print(" "); 58 59 Serial.println(leftString[command]); 60 break; 61 62 case 63 6: 64 turnOn(left[command]); 65 Serial.print("Relay6 ON: "); 66 67 Serial.print(left[command]); 68 Serial.print(" "); 69 Serial.println(leftString[command]); 70 71 break; 72 73 case 7: 74 turnOn(left[command]); 75 Serial.print("Relay7 76 ON: "); 77 Serial.print(left[command]); 78 Serial.print(" "); 79 80 Serial.println(leftString[command]); 81 break; 82 83 case 84 8: 85 turnOn(left[command]); 86 Serial.print("Relay8 ON: "); 87 88 Serial.print(left[command]); 89 Serial.print(" "); 90 Serial.println(leftString[command]); 91 92 break; 93 94 case 0: 95 Serial.println("Exiting Left Sheild..."); 96 97 break; 98 99 default: 100 shutdown(); 101 Serial.println("Shutdown"); 102 103 break; 104 } 105 if (command == 0) { 106 break; 107 } 108 109 110 } 111} 112
Press_Code_24VDC_wCommands.ino
arduino
Main Press code. This runs the largest part of the machine that catches and cuts the boards, then compresses the boards together.
1/* 2Written by: Amos Parmenter, Ricardo G, Brad Parmenter, Sam 3 Parmenter. 4Date Revised: March 16, 2015 5 6Purpose: This code was intended 7 to run the press section of the finger-jointer at Paremnter Intl. 8 This 9 code over sees the cycling of the press along with the e-stops and other functions 10 11 pertaining to this section of the mill. 12*/ 13 14 15//--- Deffenitions 16 ----------------------------------------------------------------------------------------------------------- 17#define 18 ON LOW 19#define OFF HIGH 20#define delayTime 250 21 22bool state = true; 23 24int 25 choice; 26int selection; 27int x; 28 29//-- Declare Buttons --------------------------------------------------------------------------------------------------------- 30const 31 int startUpSequenceButton = 4; // Designates Upper Left E-Stop as start up 32 sequence 33const int runButton = 6; // Designates the Green E-Stop 34 as Run for crowder rolls 35 36//--- Declare Sensors -------------------------------------------------------------------------------------------------------- 37const 38 int speedRollsSensor = 0; // This is for the sensor on the speed up rolls 39 at the begining of the press 40const int pushoutSensor = 1; // This 41 is for the sensor looking at the pushout 42const int endPressSensor = 2; 43 // This is for the sensor on at the end of the press 44const int fullStrokeSensor 45 = 3; // This is for the sensor on the flying cut off relase 46const 47 int assemblySensor = 7; // This is for the sensor in the assembly 48const 49 int flyingCutOffMoveSensor = 10; // This is for the sensor that sees the flying 50 cut off move 51const int drainSensor = 12; // This is for the drain 52 sensor in the press 53const int maintenancePressed = 11; // This is for 54 the maintenance button that opens the press 55 56int sensors[] = { 57 speedRollsSensor, 58 pushoutSensor, endPressSensor, fullStrokeSensor, startUpSequenceButton, 5, 59 runButton, 60 assemblySensor, 8, 9, flyingCutOffMoveSensor, maintenancePressed, drainSensor, 13, 61 14, 15 62}; 63char* sensorsString[] = { 64 "speedRollsSensor", "pushoutSensor", 65 "endPressSensor", "fullStrokeSensor", "startUpSequenceButton", "5", 66 67 "runButton", "assemblySensor", "8", "9", "flyingCutOffMoveSensor", "maintenancePressed", 68 "drainSensor", "13", "14", "15" 69}; 70 71//--- Relay Shield #1 on the 72 left --------------------------------------------------------------------------------------------- 73int 74 pushoutRelay = 22; // press pushout in the press 75int hydraulicCrowderRollsRelay 76 = 24; // hydraulic crowder rolls 77int crowderRollsAirRelay = 26; // 78 crowder rolls air 79int flyingCutOffSawUpRelay = 28; // flying cutt off 80 saw blade cuts the board 81int flyingCutOffRetractRelay = 30; // flying 82 cut off retract 83int spikeHoldDownRelay = 32; // spike hold down 84int 85 flyingCutOffSawGuardClampRelay = 34; // flying cut off saw guard clamp 86int pressTopHoldRelay 87 = 36; // Press top hold 88 89//--- Relay Shield #2 in the middle 90 ------------------------------------------------------------------------------------------- 91int 92 flyingCutOffSawMotorRelay = 38; // The flying cut off saw motor 93int PET3Relay 94 = 40; // PET #3 95int PET4Relay = 42; // 96 PET #4 97int PET1Relay = 44; // PET #1 98int PET2Relay = 46; 99 // PET #2 100int hydraulicTankRelay = 48; // Hydraulic Tank 101int 102 bigSqueezeRelay = 50; // the big squeeze 103int limitSwitchRelay 104 = 52; // limit switch 105 106//--- Relay Shield #3 on the right --------------------------------------------------------------------------------------------- 107int 108 crowderRollsFreakDriveRelay = 43; // the crowder rolls on the freak-drive 109int 110 airSolenoidCutterheadRelay = 45; // the air selinod after Cuttterhead A 111int 112 clearingRollsRelay = 51; // Clearing rolls 113int assemblyChainRelay 114 = 53; // Assembly chain 115 116//--- Extra relays ------------------------------------------------------------------------------------------------------------- 117int 118 relay21 = 39; 119int relay22 = 41; 120int relay25 = 47; 121int relay26 = 49; 122 123 124int 125 left[] = { 126 0, pushoutRelay, hydraulicCrowderRollsRelay, crowderRollsAirRelay, 127 flyingCutOffSawUpRelay, 128 flyingCutOffRetractRelay, spikeHoldDownRelay, flyingCutOffSawGuardClampRelay, 129 pressTopHoldRelay 130}; 131char* leftString[] = { 132 "0", "pushoutRelay", 133 "hydraulicCrowderRollsRelay", "crowderRollsAirRelay", "flyingCutOffSawUpRelay", 134 135 "flyingCutOffRetractRelay", "spikeHoldDownRelay", "flyingCutOffSawGuardClampRelay", 136 "pressTopHoldRelay" 137}; 138 139int middle[] = { 140 0, flyingCutOffSawMotorRelay, 141 PET3Relay, PET4Relay, PET1Relay, 142 PET2Relay, hydraulicTankRelay, bigSqueezeRelay, 143 limitSwitchRelay 144}; 145char* middleString[] = { 146 "0", "flyingCutOffSawMotorRelay", 147 "PET3Relay", "PET4Relay", "PET1Relay", 148 "PET2Relay", "hydraulicTankRelay", 149 "bigSqueezeRelay", "limitSwitchRelay" 150}; 151 152int right[] = { 153 0, crowderRollsFreakDriveRelay, 154 airSolenoidCutterheadRelay, clearingRollsRelay, assemblyChainRelay, 155 relay21, 156 relay22, relay25, relay26 157}; 158char* rightString[] = { 159 "0", "crowderRollsFreakDriveRelay", 160 "airSolenoidCutterheadRelay", "clearingRollsRelay", "assemblyChainRelay", 161 162 "relay21", "relay22", "relay25", "relay26" 163}; 164 165 166 167//------------------------------------------------------------------------------------------------------------------------------ 168//--- 169 The Setup ---------------------------------------------------------------------------------------------------------------- 170void 171 setup() 172{ 173 Serial.begin(9600); // Serial communication baud-rate 174 175 176 // The Sensors 177 for (int s = 0; s <= 15; s++) { 178 pinMode(sensors[s], 179 INPUT); 180 Serial.print(sensorsString[s]); 181 Serial.print(": "); 182 183 Serial.println(sensors[s]); 184 if ( s == 15) { 185 Serial.println(""); 186 187 } 188 } 189 190 //------------------------------------------------------------------------------------------------------------------------------- 191 192 for (int x = 0; x <= 8; x++) { 193 pinMode(left[x], OUTPUT); 194 turnOff(left[x]); 195 196 Serial.print(left[x]); 197 Serial.print(", "); 198 if ( x == 8) { 199 200 Serial.println(""); 201 } 202 } 203 for (int y = 0; y <= 8; y++) { 204 205 pinMode(middle[y], OUTPUT); 206 turnOff(middle[y]); 207 Serial.print(middle[y]); 208 209 Serial.print(", "); 210 if ( y == 8) { 211 Serial.println(""); 212 213 } 214 } 215 for (int z = 0; z <= 8; z++) { 216 pinMode(right[z], OUTPUT); 217 218 turnOff(right[z]); 219 Serial.print(right[z]); 220 Serial.print(", "); 221 222 if ( z == 8) { 223 Serial.println(""); 224 } 225 } 226 //---------------This 227 Completes Programming 3 Relay Shields----------------------------------------------------------------------- 228 229 230 // This is for the slapper button that is using an interrpt pin. 231 attachInterrupt(2, 232 slapperMode, CHANGE); 233 pinMode(21, INPUT); 234 235 236}// This is the end 237 of the void Setup----------------------------------------------------------------------------------------------- 238 239 //--------------------------------------------------------------------------------------------------------------------------------- 240 241//---------------------------------------------------------------------------------------------------------------------------------- 242//--- 243 The loop that runs continually as long as the ardunio is on. ---------------------------------------------------------------- 244void 245 loop() 246{ 247 248 Serial.println("making borads"); 249 while(Serial.available() 250 < 0); 251 int options = Serial.read() - '0'; 252 //Serial.println(options); 253 254 if(options == 1){ 255 INFO(); 256 } 257 258 259 260 // Maintenance 261 262 if (analogRead(maintenancePressed) >= 200) // Checks 263 { 264 maintenance(); 265 266 } 267 268 // Emergency stop 269 if (eStopButtonPressed()) 270 { 271 shutdown(); 272 273 } 274 275 // Turns on the assembly chain 276 // Checks the status of the Start 277 up Sequence 278 if (!eStopButtonPressed() && !runButtonPressed()) 279 { 280 turnOn(assemblyChainRelay); 281 282 turnOn(hydraulicCrowderRollsRelay); 283 } 284 285 //--- Allows the program 286 to skip delays when running ----------------------------------------------------------------------------- 287 288 if (isOff(hydraulicTankRelay)) 289 // Checks to make sure the hydra;ic tank 290 is off before entering the nested loop. This makes sure that we are not using 291 292 // the delays after the machine has started up. Once running this section of 293 code is skipped. 294 { 295 //--- Checks the status of the Press E-Stop ------------------------------------------------------------------------------------ 296 297 //--- This is the startup sequence for this section of the machine. ------------------------------------------------------------ 298 299 if (!eStopButtonPressed()) 300 { 301 turnOn(PET4Relay); 302 giveMeSomeTime(); 303 304 turnOn(PET3Relay); 305 giveMeSomeTime(); 306 turnOn(PET2Relay); 307 308 giveMeSomeTime(); 309 turnOn(PET1Relay); 310 giveMeSomeTime(); 311 312 turnOn(flyingCutOffSawMotorRelay); 313 giveMeSomeTime(); 314 turnOn(hydraulicTankRelay); 315 316 } 317 } 318 //-------------------------------------------------------------------------------------------------------------------------------- 319 320 321 //--- Turn off run button process ------------------------------------------------------------------------------------------------ 322 323 if (!eStopButtonPressed() && runButtonPressed()) 324 // This checks to make 325 the run button has been turned off and the the e-stop has not been pressed. 326 327 { 328 turnOff(assemblyChainRelay); 329 turnOff(crowderRollsFreakDriveRelay); 330 331 turnOff(hydraulicCrowderRollsRelay); 332 } 333 //--------------------------------------------------------------------------------------------------------------------------------- 334 335 // Debug - Print which mode or sensor values the code is running 336 337 //Serial.println(analogRead(fullStrokeSensor)); 338 339 340 341 342 //-------------------------------------------------------------------------------------------------------------------------------- 343 344 // The next section of code will instruct he cycling of the press. 345 346 //--- 347 End of the Press sensors --------------------------------------------------------------------------------------------------- 348 349 if (analogRead(endPressSensor) >= 100 && analogRead(drainSensor) <= 100) 350 // 351 This checks both sensors at the end of the press to make sure they are both on. 352 353 { 354 turnOff(flyingCutOffRetractRelay); 355 turnOn(bigSqueezeRelay); 356 357 turnOn(pressTopHoldRelay); 358 turnOn(pushoutRelay); 359 360 /* We were 361 having some issues with the spike coming down randomly. 362 This nested if 363 statement makes it only possible if the press bar 364 has been retracted as 365 well as all the other condition from the first if statment are also true. 366 */ 367 368 if (analogRead(pushoutSensor) <= 100) 369 // This ensures that the press 370 bar has been retracted before it allows the spike to come down. 371 { 372 turnOn(spikeHoldDownRelay); 373 374 } 375 } 376 //-------------------------------------------------------------------------------------------------------------------------------- 377 378 379 //--- This is for the flying cut off saw ----------------------------------------------------------------------------------------- 380 381 if (isOff(flyingCutOffRetractRelay) && analogRead(flyingCutOffMoveSensor) <= 200 382 && isOn(spikeHoldDownRelay)) 383 // checks all conditions before proceeding 384 385 { 386 /* 387 This forces the ardunio to focus on the just this small loop 388 for a small amount of time to ensure the 389 flying-cut off saw comes up. The 390 counter is adjustable for the best timing possible, but the value does 391 not 392 represent an actual time count. This also ensures the cut can only happen once and 393 will be reset and 394 availble to happen again once the board that was cut entered 395 the press and the sensor at the front has 396 reset to value for x. 397 */ 398 399 for (x = 0; x <= 3; x++) 400 { 401 turnOn(flyingCutOffSawGuardClampRelay); 402 403 turnOn(flyingCutOffSawUpRelay); 404 } 405 } 406 407 //------------------------------------------------------------------------------------------------------------------------------- 408 409 // This checks to see if the press bar is retracted and that saw is full stroke. 410 411 if (isOn(pushoutRelay) && analogRead(fullStrokeSensor) >= 200) 412 { 413 for 414 (x = 0; x <= 3; x++) 415 { 416 turnOff(flyingCutOffSawGuardClampRelay); 417 418 turnOff(flyingCutOffSawUpRelay); 419 420 if ( isOff(flyingCutOffSawUpRelay) 421 && isOff(flyingCutOffSawGuardClampRelay)) 422 { 423 turnOn(clearingRollsRelay); 424 425 turnOn(flyingCutOffRetractRelay); 426 } 427 // This is looking 428 for any reason to let the spike unclamp. 429 if (isOn(clearingRollsRelay) || 430 isOn(flyingCutOffRetractRelay) ) 431 { 432 turnOff(spikeHoldDownRelay); 433 434 } 435 } 436 } 437 //------------------------------------------------------------------------------------------------------------------------------ 438 439 // Front of the Press 440 // Checks the status of the sensor at the front 441 of the press. 442 // This section os looking to reset the cycling process and 443 reseting x 444 if (analogRead(speedRollsSensor) <= 100) 445 { 446 turnOff(spikeHoldDownRelay); 447 448 turnOff(clearingRollsRelay); 449 turnOff(pushoutRelay); 450 turnOn(flyingCutOffRetractRelay); 451 452 x = 0; 453 } 454 455 //------------------------------------------------------------------------------------------------------------------------------ 456 457 // This checks to make sure the press bar is all the way forward. 458 // 459 then it allows the machine to close and pressurize. 460 if (analogRead(pushoutSensor) 461 <= 100) 462 { 463 turnOff(pressTopHoldRelay); 464 turnOff(bigSqueezeRelay); 465 466 } 467 468 //------------------------------------------------------------------------------------------------------------------------------ 469 470 //Assembley & Crowd control 471 if (analogRead(runButton) > 100) // 472 This is the run button that will now turn ON the assembly 473 { 474 if (analogRead(assemblySensor) 475 <= 100 || analogRead(drainSensor) <= 100) 476 { 477 turnOn(crowderRollsFreakDriveRelay); 478 479 } 480 else 481 { 482 turnOff(crowderRollsFreakDriveRelay); 483 484 } 485 } 486 487 //------------------------------------------------------------------------------------------------------------------------------ 488 489 }// This is the end of the void Loop 490 //-------------------------------------------------------------------------------------------------------------------------------- 491 492 493 494
Middle_Shield.ino
arduino
Support code for the Press, used in the Serial monitor
1void infoMiddle () { 2 while (true) { 3 while (Serial.available() 4 == 0); 5 int command = Serial.read() - '0'; 6 7 switch (command) { 8 9 10 case 1: 11 turnOn(middle[command]); 12 Serial.print("Relay1 13 ON: "); 14 Serial.print(middle[command]); 15 Serial.print(" "); 16 17 Serial.println(middleString[command]); 18 break; 19 20 case 21 2: 22 turnOn(middle[command]); 23 Serial.print("Relay2 ON: "); 24 25 Serial.print(middle[command]); 26 Serial.print(" "); 27 Serial.println(middleString[command]); 28 29 break; 30 31 case 3: 32 turnOn(middle[command]); 33 Serial.print("Relay3 34 ON: "); 35 Serial.print(middle[command]); 36 Serial.print(" "); 37 38 Serial.println(middleString[command]); 39 break; 40 41 case 42 4: 43 turnOn(middle[command]); 44 Serial.print("Relay4 ON: "); 45 46 Serial.print(middle[command]); 47 Serial.print(" "); 48 Serial.println(middleString[command]); 49 50 break; 51 52 case 5: 53 turnOn(middle[command]); 54 Serial.print("Relay5 55 ON: "); 56 Serial.print(middle[command]); 57 Serial.print(" "); 58 59 Serial.println(middleString[command]); 60 break; 61 62 case 63 6: 64 turnOn(middle[command]); 65 Serial.print("Relay6 ON: "); 66 67 Serial.print(middle[command]); 68 Serial.print(" "); 69 Serial.println(middleString[command]); 70 71 break; 72 73 case 7: 74 turnOn(middle[command]); 75 Serial.print("Relay7 76 ON: "); 77 Serial.print(middle[command]); 78 Serial.print(" "); 79 80 Serial.println(middleString[command]); 81 break; 82 83 case 84 8: 85 turnOn(middle[command]); 86 Serial.print("Relay8 ON: "); 87 88 Serial.print(middle[command]); 89 Serial.print(" "); 90 Serial.println(middleString[command]); 91 92 break; 93 94 case 0: 95 Serial.println("Exiting Left Sheild..."); 96 97 break; 98 99 default: 100 shutdown(); 101 Serial.println("Shutdown"); 102 103 break; 104 } 105 if (command == 0) { 106 break; 107 } 108 109 110 } 111} 112
Sensors.ino
arduino
Support code for the Press, used in the Serial monitor
1void sensorInfo() { 2 3 while (state = true) { 4 while (Serial.available() 5 == 0); 6 int selection = Serial.read() - '0'; 7 8 switch (selection) 9 { 10 11 case speedRollsSensor: 12 while (state == true) { 13 Serial.print(sensorsString[selection]); 14 15 Serial.print(": "); 16 Serial.println(analogRead(sensors[selection])); 17 18 choice = Serial.read() - '0'; 19 if (choice == 0) { 20 state 21 = false; 22 } 23 } 24 break; 25 26 case pushoutSensor: 27 28 while (state == true) { 29 Serial.print(sensorsString[selection]); 30 31 Serial.print(": "); 32 Serial.println(analogRead(sensors[selection])); 33 34 choice = Serial.read() - '0'; 35 if (choice == 0) { 36 state 37 = false; 38 } 39 } 40 break; 41 42 case endPressSensor: 43 44 while (state == true) { 45 Serial.print(sensorsString[selection]); 46 47 Serial.print(": "); 48 Serial.println(analogRead(sensors[selection])); 49 50 choice = Serial.read() - '0'; 51 if (choice == 0) { 52 state 53 = false; 54 } 55 } 56 break; 57 58 case fullStrokeSensor: 59 60 while (state == true) { 61 Serial.print(sensorsString[selection]); 62 63 Serial.print(": "); 64 Serial.println(analogRead(sensors[selection])); 65 66 choice = Serial.read() - '0'; 67 if (choice == 0) { 68 state 69 = false; 70 } 71 } 72 break; 73 74 case startUpSequenceButton: 75 76 while (state == true) { 77 Serial.print(sensorsString[selection]); 78 79 Serial.print(": "); 80 Serial.println(analogRead(sensors[selection])); 81 82 choice = Serial.read() - '0'; 83 if (choice == 0) { 84 state 85 = false; 86 } 87 } 88 break; 89 90 case A5: // 91 Open Pin 92 while (state == true) { 93 Serial.print(sensorsString[selection]); 94 95 Serial.print(": "); 96 Serial.println(analogRead(sensors[selection])); 97 98 choice = Serial.read() - '0'; 99 if (choice == 0) { 100 state 101 = false; 102 } 103 } 104 break; 105 106 case runButton: 107 // Open Pin 108 while (state == true) { 109 Serial.print(sensorsString[selection]); 110 111 Serial.print(": "); 112 Serial.println(analogRead(sensors[selection])); 113 114 choice = Serial.read() - '0'; 115 if (choice == 0) { 116 state 117 = false; 118 } 119 } 120 break; 121 122 case assemblySensor: 123 // Open Pin 124 while (state == true) { 125 Serial.print(sensorsString[selection]); 126 127 Serial.print(": "); 128 Serial.println(analogRead(sensors[selection])); 129 130 choice = Serial.read() - '0'; 131 if (choice == 0) { 132 state 133 = false; 134 } 135 } 136 break; 137 138 case A8: // 139 Open Pin 140 while (state == true) { 141 Serial.print(sensorsString[selection]); 142 143 Serial.print(": "); 144 Serial.println(analogRead(sensors[selection])); 145 146 choice = Serial.read() - '0'; 147 if (choice == 0) { 148 state 149 = false; 150 } 151 } 152 break; 153 154 case A9: // 155 Open Pin 156 while (state == true) { 157 Serial.print(sensorsString[selection]); 158 159 Serial.print(": "); 160 Serial.println(analogRead(sensors[selection])); 161 162 choice = Serial.read() - '0'; 163 if (choice == 0) { 164 state 165 = false; 166 } 167 } 168 break; 169 170 case flyingCutOffMoveSensor: 171 // Open Pin 172 while (state == true) { 173 Serial.print(sensorsString[selection]); 174 175 Serial.print(": "); 176 Serial.println(analogRead(sensors[selection])); 177 178 choice = Serial.read() - '0'; 179 if (choice == 0) { 180 state 181 = false; 182 } 183 } 184 break; 185 186 case maintenancePressed: 187 // Open Pin 188 while (state == true) { 189 Serial.print(sensorsString[selection]); 190 191 Serial.print(": "); 192 Serial.println(analogRead(sensors[selection])); 193 194 choice = Serial.read() - '0'; 195 if (choice == 0) { 196 state 197 = false; 198 } 199 } 200 break; 201 202 case drainSensor: 203 // Open Pin 204 while (state == true) { 205 Serial.print(sensorsString[selection]); 206 207 Serial.print(": "); 208 Serial.println(analogRead(sensors[selection])); 209 210 choice = Serial.read() - '0'; 211 if (choice == 0) { 212 state 213 = false; 214 } 215 } 216 break; 217 218 case A13: // 219 Open Pin 220 while (state == true) { 221 Serial.print(sensorsString[selection]); 222 223 Serial.print(": "); 224 Serial.println(analogRead(sensors[selection])); 225 226 choice = Serial.read() - '0'; 227 if (choice == 0) { 228 state 229 = false; 230 } 231 } 232 break; 233 234 case A14: // 235 Open Pin 236 while (state == true) { 237 Serial.print(sensorsString[selection]); 238 239 Serial.print(": "); 240 Serial.println(analogRead(sensors[selection])); 241 242 choice = Serial.read() - '0'; 243 if (choice == 0) { 244 state 245 = false; 246 } 247 } 248 break; 249 250 case A15: // 251 Open Pin 252 while (state == true) { 253 Serial.print(sensorsString[selection]); 254 255 Serial.print(": "); 256 Serial.println(analogRead(sensors[selection])); 257 258 choice = Serial.read() - '0'; 259 if (choice == 0) { 260 state 261 = false; 262 } 263 } 264 break; 265 266 default: 267 268 return; 269 break; 270 271 } 272 } 273} 274
FJ_Grinder.ino
arduino
Automation for grider
1#define ON HIGH 2#define OFF LOW 3#define delayTime 200 4 5boolean 6 switching = true; 7boolean state = true; 8 9int choice; 10int direction; 11 12const 13 int motionButton = 0; // This is the Lug-Chain E-Stop 14const int frontSensor 15 = 1; 16const int backSensor = 2; 17 18const int forward = 7; 19const int 20 reverse = 8; 21 22int sensor[] = {motionButton, frontSensor, backSensor}; 23char* 24 sensorString[] = {"motion", "front", "back"}; 25 26int relays[] = {0, 0, 27 0, 0, 0, 0, 0, forward, reverse}; 28char* relaysString[] = {"0", "0", "0", 29 "0", "0", "0", "0", "forward", "reverse"}; 30 31 32void setup() { 33 34 35 Serial.begin(9600); 36 37 pinMode(motionButton, INPUT); 38 pinMode(frontSensor, 39 INPUT); 40 pinMode(backSensor , INPUT); 41 42 pinMode(forward, OUTPUT); 43 44 pinMode(reverse, OUTPUT); 45 46} 47 48void loop() { 49 50 Serial.print("Grinding 51 "); 52 Serial.println(relaysString[direction]); 53 while (Serial.available() 54 < 0); 55 int options = Serial.read() - '0'; 56 if (options == 1) { 57 INFO(); 58 59 } 60 61 if (direction = reverse) { 62 if ( read(frontSensor) < 25) { 63 64 switching = true; 65 direction = forward; 66 } 67 } 68 if (direction 69 = forward) { 70 if ( read(backSensor) < 25) { 71 switching = true; 72 73 direction = reverse; 74 } 75 } 76 77 if (motionButtonPressed()) { 78 79 switch (direction) { 80 81 case forward: 82 if (switching == 83 true) { 84 turnOff(reverse); 85 giveMeSomeTime(); 86 turnOn(forward); 87 88 switching = false; 89 } 90 break; 91 92 case reverse: 93 94 if (switching == true) { 95 turnOff(forward); 96 giveMeSomeTime(); 97 98 turnOn(reverse); 99 switching = false; 100 } 101 break; 102 103 } 104 } 105 else { 106 shutdown(); 107 } 108} 109 110 111 112 113 114 115 116
Controls.ino
arduino
Support Code for the Press. Function calls are all here.
1//--- Slapper Button ----------------------------------------------------------------------------------------- 2void 3 slapperMode() 4{ 5 if (digitalRead(21) == ON) 6 turnOff(crowderRollsAirRelay); 7 8 else 9 turnOn(crowderRollsAirRelay); 10} 11//------------------------------------------------------------ 12//--- 13 Return true if the eStop button is pressed ------------- 14boolean eStopButtonPressed() 15{ 16 17 return (analogRead(startUpSequenceButton) < 200); 18} 19//------------------------------------------------------------ 20//--- 21 Return true if the run button is pressed --------------- 22boolean runButtonPressed() 23{ 24 25 return (analogRead(runButton) < 200); 26} 27//------------------------------------------------------------ 28//--- 29 Turn the pin ON ---------------------------------------- 30void turnOn(int pinNumber) 31{ 32 33 digitalWrite(pinNumber, ON); 34} 35//------------------------------------------------------------ 36//--- 37 Turn the pin OFF --------------------------------------- 38void turnOff(int pinNumber) 39{ 40 41 digitalWrite(pinNumber, OFF); 42} 43//------------------------------------------------------------ 44//--- 45 Return true if the pin is ON --------------------------- 46boolean isOn(int pinNumber) 47{ 48 49 return (digitalRead(pinNumber) == ON); 50} 51//------------------------------------------------------------ 52//--- 53 Return true if the pin is OFF -------------------------- 54boolean isOff(int pinNumber) 55{ 56 57 return (digitalRead(pinNumber) == OFF); 58} 59//-------------------------------------------------------------------------------- 60// 61 Give some time between actions to check if the e-stop button was pressed------- 62 63boolean 64 pln(int pinNumber) 65{ 66 return Serial.println(analogRead(pinNumber)); 67} 68 69void 70 giveMeSomeTime() 71{ 72 for (int i = 0; i < 4; i++) 73 { 74 if (eStopButtonPressed()) 75 76 shutdown(); 77 delay (delayTime); 78 if (eStopButtonPressed()) 79 80 shutdown(); 81 } 82} 83//----------------------------------------------------------------------------------------------------------- 84//--- 85 Maintenance mode -------------------------------------------------------------------------------------- 86void 87 maintenance() 88{ 89 while ( runButtonPressed() && !eStopButtonPressed() && analogRead(maintenancePressed) 90 >= 200 ) 91 { 92 if (analogRead(maintenancePressed) >= 75) 93 { 94 Serial.println("Maintenance 95 Mode Active"); 96 97 // This opens the press and keeps everything open to 98 releave any kind of pressure. 99 100 turnOff(assemblyChainRelay ); 101 // Turns the assembly chain off 102 turnOff(crowderRollsFreakDriveRelay ); 103 // Turns the Freq on Crowder Rolls off 104 turnOff(hydraulicCrowderRollsRelay 105 ); // Turns Hydraulic Crowder rolls off 106 turnOff(clearingRollsRelay 107 ); // turn off the clearing rolls 108 turnOn(bigSqueezeRelay ); 109 // Pulls back the squeeze 110 turnOff(spikeHoldDownRelay ); // 111 spike clamp compress on the flying cut off 112 turnOn(pressTopHoldRelay ); 113 // Air hold downs in the press up 114 turnOn(pushoutRelay ); 115 // Press bar retract 116 turnOff(flyingCutOffRetractRelay ); // turns 117 the flying cut off retract off 118 turnOff(flyingCutOffSawGuardClampRelay); 119 // Flying cut off clamp off 120 turnOff(flyingCutOffSawUpRelay ); 121 // Flying cut off saw cut off 122 123 slapperMode(); // This allows me to 124 use the slappers while in this mode 125 126 } 127 else // Once the swithc 128 has been deactivated this else statment allows the code to break 129 // away 130 from the while loop it is nested into. 131 { 132 break; // Gets me out 133 of the while loop. 134 } 135 } 136} 137//----------------------------------------------------------------------------------------------------------------------------------------------------- 138// 139 Shutdown the process ------------------------------------------------------------------------------------------------------------------------------- 140void 141 shutdown() 142{ 143 turnOff(hydraulicTankRelay); 144 turnOff(flyingCutOffSawMotorRelay); 145 146 turnOff(PET4Relay); 147 turnOff(PET1Relay); 148 turnOff(PET2Relay); 149 turnOff(PET3Relay); 150 151 turnOff(assemblyChainRelay); 152 turnOff(crowderRollsFreakDriveRelay); 153} 154 155 156void 157 INFO() { 158 Serial.println("Select the Sheild you want"); 159 Serial.println("1 160 = Left, 2 = Middle, 3 = Right"); 161 162 while (Serial.available() == 0); 163 164 int sheild = Serial.read() - '0'; 165 switch (sheild) { 166 167 case 1: 168 169 Serial.println("Left Sheild"); 170 infoLeft(); 171 break; 172 173 case 2: 174 Serial.println("Middle Sheild"); 175 infoMiddle(); 176 177 break; 178 case 3: 179 Serial.println("Right Sheild"); 180 infoRight(); 181 182 break; 183 } 184 185} 186 187
Downloadable files
untitled
untitled
untitled
untitled
Comments
Only logged in users can leave comments
amosp33
0 Followers
•0 Projects
+2
Work attribution
Table of contents
Intro
4
0