Control System

The Control system

Control system

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

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

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

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

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

Code

 


//Include the Arduino Stepper Library
#include <Stepper.h>
 
// 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 < 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 < 5000; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(1000);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(1000);
  }
  delay(2000);
 return(0);
}
}