#  Control System 

 



 ##  

  expand\_more  

 
  

 

####  **The Control system**

   ![Control system](/sites/g/files/omnuum4601/files/styles/hwp_1_1__360x360_scale/public/srtsandbox/files/screen_shot_2018-06-15_at_9.17.13_pm.png?itok=Jog4gyIB) 

 

 Shown above is the control system without the wiring and stepper motors that are involved. The system includes 2 red A4988 stepper motor driver, 1 ULN2003 stepper motor driver, a voltage converter, and a 12 V NiMh battery.

####  **Ardunio**

   ![Arduino](/sites/g/files/omnuum4601/files/styles/hwp_1_1__360x360_scale/public/srtsandbox/files/screen_shot_2018-06-15_at_9.09.36_pm.png?itok=VWTmmWt8) 

 

 Ardunio is the microcontroller of the whole SeaHawk. It runs a test code that proples the SeaHawk forward with the propulsion system, and then perform a descent and ascent through the buoyancy Engine. The code for the test is attached in the subpage.

####  Circuit Diagram

 The circuit diagram shown below is for the yaw control nema 17 stepper motor, and the buoyancy engine threaded rod driver.

   ![Yaw and Buoyancy Engine](/sites/g/files/omnuum4601/files/styles/hwp_1_1__720x720_scale/public/srtsandbox/files/throttle_assembly_bb.png?itok=RqBq4EH3) 

 

 The power source however, would not be a 9V battery but instead a 12 V NiMh battery instead. The last motor to be controlled by the arduino is the propulsion control motor that is the only 28BYJ-48 type stepper motor within the system. The circuit diagram can be seen from the image below\[6\].

   ![28BYJ Stepper motor](/sites/g/files/omnuum4601/files/styles/hwp_1_1__960x960_scale/public/srtsandbox/files/98a6y.jpg?itok=jAQTUVug) 

 

 The power source of the motor however is also supposed to be a 12 V NiMh battery for our case instead of the plug for a ac-dc adapter as shown in the diagram above. Each of these motor correspods to their own individual driver that connects to specific pins in the arduino uno. The details of these pins can be seen in the code attached below.

####  **Control Bracket**

   ![Board](/sites/g/files/omnuum4601/files/styles/hwp_1_1__360x360_scale/public/srtsandbox/files/screen_shot_2018-06-15_at_9.18.04_pm.png?itok=ga9GTWqW) 

 

 The control Bracket contains the entire circuit of the control system together in a compact manner.

####  Code

   
//Include the Arduino Stepper Library  
\#include &lt;Stepper.h&gt;  
   
// Define Constants  
   
// Number of steps per internal motor revolution   
const float STEPS\_PER\_REV = 32;   
   
// Amount of Gear Reduction  
const float GEAR\_RED = 16;  
   
// Number of steps per geared output rotation  
const float STEPS\_PER\_OUT\_REV = STEPS\_PER\_REV \* GEAR\_RED;  
   
// Define Variables  
   
// Number of Steps Required  
int StepsRequired;

 // defines pins numbers

 const int stepPin = 3;

 const int dirPin = 4;   
 // set direction and step pin  
// Create Instance of Stepper Class  
// Specify Pins used for motor coils  
// The pins used are 8,9,10,11   
// Connected to ULN2003 Motor Driver In1, In2, In3, In4   
// Pins entered in sequence 1-3-2-4 for proper step sequencing  
   
Stepper steppermotor(STEPS\_PER\_REV, 8, 10, 9, 11);  
   
void setup()  
{  
// Sets the two pins as Outputs  
 pinMode(stepPin,OUTPUT);  
 pinMode(dirPin,OUTPUT);  
   
 //digitalWrite(dirPin,LOW); //Enables the motor to move in a particular direction  
}  
   
void loop()  
{  
 delay(60000);  
 // Rotate CCW 1/2 turn quickly  
 StepsRequired = - STEPS\_PER\_OUT\_REV / 2;   
 steppermotor.setSpeed(700);   
 steppermotor.step(StepsRequired);  
 delay(0.1);  
 // Rotate CCW 1/2 turn quickly  
 StepsRequired = - STEPS\_PER\_OUT\_REV / 2;   
 steppermotor.setSpeed(700);   
 steppermotor.step(StepsRequired);  
 delay(0.1);  
 // Rotate CCW 1/2 turn quickly  
 StepsRequired = - STEPS\_PER\_OUT\_REV / 2;   
 steppermotor.setSpeed(700);   
 steppermotor.step(StepsRequired);  
 delay(0.1);  
 // Rotate CCW 1/2 turn quickly  
 StepsRequired = - STEPS\_PER\_OUT\_REV / 2;   
 steppermotor.setSpeed(700);   
 steppermotor.step(StepsRequired);  
 delay(0.1);  
 // Rotate CCW 1/2 turn quickly  
 StepsRequired = - STEPS\_PER\_OUT\_REV / 2;   
 steppermotor.setSpeed(700);   
 steppermotor.step(StepsRequired);  
 delay(0.1);  
 // Rotate CCW 1/2 turn quickly  
 StepsRequired = - STEPS\_PER\_OUT\_REV / 2;   
 steppermotor.setSpeed(700);   
 steppermotor.step(StepsRequired);  
 delay(0.1);  
 // Rotate CCW 1/2 turn quickly  
 StepsRequired = - STEPS\_PER\_OUT\_REV / 2;   
 steppermotor.setSpeed(700);   
 steppermotor.step(StepsRequired);  
 delay(0.1);  
 // Rotate CCW 1/2 turn quickly  
 StepsRequired = - STEPS\_PER\_OUT\_REV / 2;   
 steppermotor.setSpeed(700);   
 steppermotor.step(StepsRequired);  
 delay(0.1);  
 StepsRequired = - STEPS\_PER\_OUT\_REV / 2;   
 steppermotor.setSpeed(700);   
 steppermotor.step(StepsRequired);  
 delay(0.1);  
 // Rotate CCW 1/2 turn quickly  
 StepsRequired = - STEPS\_PER\_OUT\_REV / 2;   
 steppermotor.setSpeed(700);   
 steppermotor.step(StepsRequired);  
 delay(0.1);  
 // Rotate CCW 1/2 turn quickly  
 StepsRequired = - STEPS\_PER\_OUT\_REV / 2;   
 steppermotor.setSpeed(700);   
 steppermotor.step(StepsRequired);  
 delay(0.1);  
 {  
 digitalWrite(dirPin,LOW); // Enables the motor to move in a particular direction  
 // Makes 200 pulses for making one full cycle rotation  
 for(int x = 0; x &lt; 5000; x++) {  
 digitalWrite(stepPin,HIGH);   
 delayMicroseconds(1000);   
 digitalWrite(stepPin,LOW);   
 delayMicroseconds(1000);   
 }  
   
 delay(10000); // One second delay  
   
 digitalWrite(dirPin,HIGH); //Changes the rotations direction  
 for(int x = 0; x &lt; 5000; x++) {  
 digitalWrite(stepPin,HIGH);  
 delayMicroseconds(1000);  
 digitalWrite(stepPin,LOW);  
 delayMicroseconds(1000);  
 }  
 delay(2000);  
 return(0);  
}  
}

####