ACTUATOR Arduino ConTrolled Uber Automated Task co-Ordinator Robot

Posted on 27/10/2014 by lavaguava
Modified on: 13/09/2018
Project
Press to mark as completed
Introduction
This is an automatic import from our previous community platform. Some things can look imperfect.

If you are the original author, please access your User Control Panel and update it.

You can see a side view here and a view of the casters here  I worked really hard on that acronym title. Chassis This uses a bit of impro for the chassis and a lot of luck along the way, I found some chassis online but they were either expensive or not the correct shape to both protect the circuitry and hold the circuitry. I decided to make the chassis out of meccano, it was easy to edit, it's made out of steel and I can make it however I want. I only just had enough meccano. Here are three ...


ACTUATOR Arduino ConTrolled Uber Automated Task co-Ordinator Robot

You can see a side view here and a view of the casters here 

I worked really hard on that acronym title.

Chassis

This uses a bit of impro for the chassis and a lot of luck along the way, I found some chassis online but they were either expensive or not the correct shape to both protect the circuitry and hold the circuitry. I decided to make the chassis out of meccano, it was easy to edit, it's made out of steel and I can make it however I want. I only just had enough meccano. Here are three pieces of luck I encountered when building:

1. The mounting holes on the stepper motors available from 4tronix are the same diameter as the meccano holes and are correctly spaced apart if you use the pieces I have used

2. The Arduino Mega in the case that I have fits perfectly with the frame I have built it.

3. The mounting holes of the casters are the correct diameter and using the same parts I have used, are spaced nicely to fit with the meccano

I could have given the robot more plating if I had more flanged panels but what I have given it should be sufficient. I originally used meccano wheels at the back, however I decided to change to casters to provide more freedom of movement. The robot (around the 20th of november 2014) recieved the front wheels, they worked well however the robot was tilted forwards, on the 13th of december 2014 motor mounting modifications were made giving the robot extremely little tilt (>2 degrees), this also increased overal ground clearance. The robot when fully constructed will weigh around 1.5 kg.

Motors and control

The robot uses 2 stepper motors for movement and steering, darlington array PCB's are mounted on the flanged panels at the sides of the robot.

Aims and abilities

This robot is going to have several functions, I was planning  on adding a line following system first but have added an ultrasonic distance sensor.

 

Below is the code for the Arduino MEGA

//declare variables for the motor pins

 

const byte starboardmotorPin1 = 38;

const byte starboardmotorPin2 = 40;

const byte starboardmotorPin3 = 42;

const byte starboardmotorPin4 = 44;

 

const byte portmotorPin1 = 46;

const byte portmotorPin2 = 48;

const byte portmotorPin3 = 50;

const byte portmotorPin4 = 52;

 

//Do some research on phototransistors, ensure you

//search for "phototransistor" not "photodiode"

 

const byte hardstarboardphototransistor = 27;

const byte hardstarboardledpin = 29;

const byte hardportphototransistor = 31;

const byte hardportledpin = 33;

 

const int trig = 7;

const int echo = 8;

const int xpin = A3;

const int ypin = A4;

const int zpin = A5;

const int leftactivate = 26;

const int rightactivate = 28;

 

in&t motorSpeed = 1500;  //variable to set stepper speed

int lookup[8] = 

{

  B01000, B01100, B00100, B00110, B00010, B00011, B00001, B01001

};

int xcoordinate[10] =

{

  0, 0, 0, 0, 0, 0, 0, 0, 0, 0

};

int ycoordinate[10] =

{

  0, 0, 0, 0, 0, 0, 0, 0, 0, 0

};

byte countl = 0;

byte countr = 0;

byte stage = 0;

byte select = 0; ////////////////////////////////review

int environmentcheck = 0;

byte rlselect = 0;

 

long duration, inches, cm;

long outsidecm;

int xg;

int yg;

int zg;

/////////////////////////////////////////////////////////

void setup()

{

  //declare the motor pins as outputs

  pinMode(portmotorPin1, OUTPUT);

  pinMode(portmotorPin2, OUTPUT);

  pinMode(portmotorPin3, OUTPUT);

  pinMode(portmotorPin4, OUTPUT);

 

  pinMode(starboardmotorPin1, OUTPUT);

  pinMode(starboardmotorPin2, OUTPUT);

  pinMode(starboardmotorPin3, OUTPUT);

  pinMode(starboardmotorPin4, OUTPUT);

 

 

  pinMode(hardportledpin, OUTPUT);

  pinMode(hardportphototransistor, INPUT);

  pinMode(hardstarboardledpin, OUTPUT);

  pinMode(hardstarboardphototransistor, INPUT);

 

  pinMode(13, OUTPUT);

  digitalWrite(13, LOW);

 

  pinMode(leftactivate, INPUT);

  pinMode(rightactivate, INPUT);

}

 

//////////////////////////////////////////////////////////////////////////////////////

//Below is the main loop that will carry out the actions, variables and functions are used in here

//to instruct the robot.

void loop()

{

  //linefollowselect();

 

 

  environmentcheck = environmentcheck + 1;

 

 

  if(environmentcheck == 1024)

  {

    rightleftselect();

    environmentcheck = 0;

  }

 

  if(rlselect == 1)

  {

    rightforward();

  }

 

  if(rlselect == 0)

  {

    leftforward();

  }

  /*

  if(0 == 0 && cm > 10)

   {

   forward();

   }

 

   if(cm < 10)

   {

   mapmode();

   }

 

   */

  if(select == 1)

  {

    lightlinefollow();

  }

 

  if(select == 2)

  {

 

  }

 

}

 

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

// code to follow a drawn line, dark line on light background

void darklinefollow()

{

 

  digitalWrite(hardportledpin, HIGH);

 

  if((digitalRead(hardportphototransistor) == HIGH) && (digitalRead(hardstarboardphototransistor) == LOW))

  {

    leftforward();

  }

 

  if((digitalRead(hardportphototransistor) == HIGH) && (digitalRead(hardstarboardphototransistor) == HIGH))

  {

    forward();

  }

 

  digitalWrite(hardportledpin, LOW);

  digitalWrite(hardstarboardledpin, HIGH);

 

  if((digitalRead(hardstarboardphototransistor) == HIGH) && (digitalRead(hardportphototransistor) == LOW))

  {

    rightforward();

  }

 

  digitalWrite(hardstarboardledpin, LOW);

}

 

void lightlinefollow()

{

 

  digitalWrite(hardportledpin, HIGH);

  if(digitalRead(hardportphototransistor) == LOW)

  {

    leftforward();

  }

 

  if((digitalRead(hardportphototransistor) == LOW) && (digitalRead(hardstarboardphototransistor) == LOW))

  {

    forward();

  }

  digitalWrite(hardportledpin, LOW);

 

  digitalWrite(hardstarboardledpin, HIGH);

  if(digitalRead(hardstarboardphototransistor) == HIGH)

  {

    rightforward();

  }

 

  digitalWrite(hardstarboardledpin, LOW);

}

 

 

//////////////////////////below are the functions for human interface through the adafruit

//capacitive touch pad

 

 

void linefollowselect()

{

 

  byte pushswitchState = 0; 

  byte pushswitchPin = 4;

  byte moveselect = 0;

 

  pushswitchState = digitalRead(pushswitchPin);

 

  if (pushswitchState == LOW)

  {  

    delay(10);

    moveselect = (select + 1);

  }

 

 

  if((pushswitchState == HIGH) && (moveselect == (select + 1)))

  {

 

    if(select < 3)

    {

      select = select + 1;

    } 

 

    if(select == 3)

    {

      select = 0;

    }

  }

}

 

void rightleftselect()

{

  if(digitalRead(rightactivate) == HIGH)

  {

    rlselect = 1;

  } 

 

  if(digitalRead(leftactivate) == HIGH)

  {

    rlselect = 0;

  }

}

 

//////////////////////////////////////////////////////////////////////

 

 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////// below: functions for movement of individual stepper motors

 

void leftforward()

{

  for(int i = 0; i < 8; i++)

  {

    lsetOutput(i);

    delayMicroseconds(motorSpeed);

  }

}

 

void rightforward()

{

  for(int n = 7; n >= 0; n--)

  {

    rsetOutput(n);

    delayMicroseconds(motorSpeed);

  }

}

 

void leftbackward()

{

  for(int i = 7; i >= 0; i--)

  {

    lsetOutput(i);

    delayMicroseconds(motorSpeed);

  }

}

 

void rightbackward()

{

  for(int n = 0; n < 8; n++)

  {

    rsetOutput(n);

    delayMicroseconds(motorSpeed);

  }

}

 

 

 

 

void backward()

{

  for (int i = 7; i >= 0; i--)

  {

    lsetOutput(i);

    delayMicroseconds(motorSpeed);

  }

  for (int n = 0; n < 8; n++)

  {

    rsetOutput(n);

    delayMicroseconds(motorSpeed);

  }

}

 

void forward()

{

  for (int n = 7; n >= 0; n--)

  {

    rsetOutput(n);

    delayMicroseconds(motorSpeed);

  }

  for (int i = 0; i < 8; i++)

  {

    lsetOutput(i);

    delayMicroseconds(motorSpeed);

  }

}

 

void randavoidancesequence()

 

{

  int rlchoose = analogRead(A0) % 1;

 

  for (int i = 0; i<2048; i++)

  {

    void backward(); 

  }

 

  if(rlchoose == 0){

    for(int i = 0; i<2048; i++)

    {

      void leftbackwards();

    }

  }

 

  if(rlchoose == 0){

    for (int i = 0; i<2048; i++)

    {

      void rightbackwards();

    }

  }

}

 

void distance()

{

 

  const int trig = 7;

  const int echo = 8;

 

 

  pinMode(trig, OUTPUT);

  digitalWrite(trig, LOW);

  delayMicroseconds(2);

  digitalWrite(trig, HIGH);

  delayMicroseconds(5);

  digitalWrite(trig, LOW);

 

 

  pinMode(echo, INPUT);

  duration = pulseIn(echo, HIGH);

 

  inches = microsecondsToInches(duration);

  cm = microsecondsToCentimeters(duration);

 

}

 

long microsecondsToInches(long microseconds)

{

  return microseconds / 74 / 2;

}

 

long microsecondsToCentimeters(long microseconds)

{

  // The speed of sound is 340 m/s or 29 microseconds per centimeter.

  // The ping travels out and back, so to find the distance of the

  // object we take half of the distance travelled.

  return microseconds / 29 / 2;

}

 

void tilt()

{

  xg = ((analogRead(A3)- 1.65)*(5 / 1023.0)) ;

  yg = ((analogRead(A4)- 1.65)*(5 / 1023.0)) ;

  zg = ((analogRead(A5)- 1.65)*(5 / 1023.0)) ;  

 

}

 

void warmbodymovement()

{

 

}

 

void mapmode()

{

 

}

//////////////////////// function to cycle through left stepper motor solenoids

void rsetOutput(int out)

{

  digitalWrite(portmotorPin1, bitRead(lookup[out], 0));

  digitalWrite(portmotorPin2, bitRead(lookup[out], 1));

  digitalWrite(portmotorPin3, bitRead(lookup[out], 2));

  digitalWrite(portmotorPin4, bitRead(lookup[out], 3));

}

 

//////////////////////// function to cycle through right stepper motor solenoids

void lsetOutput(int out)

{

  digitalWrite(starboardmotorPin1, bitRead(lookup[out], 0));

  digitalWrite(starboardmotorPin2, bitRead(lookup[out], 1));

  digitalWrite(starboardmotorPin3, bitRead(lookup[out], 2));

  digitalWrite(starboardmotorPin4, bitRead(lookup[out], 3));

}

 

 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I plan to add an ultrasonic distance sensor at the front, pointing down to avoid drops and an ultrasonic distance sensor at the front, pointing forward to avoid obstacles. I am recieving some PIR sensors soon, enabling the detection of warm body movement.

After that implentation I may add a remote control system, I have located some interseting multiple IO reciever/transmitter chipsets, I will investigate these.

 

General comment updates:

16 December: I have not updated this robot in a while.

Multiple functions - aims to be an easy to edit robot with lots of accessable variables and functions within the software, these can be implemented in a meaningful in the main loop to make the robot function as desired.

LikedLike this to see more

Spread the word

Flag this post

Thanks for helping to keep our community civil!


Notify staff privately
It's Spam
This post is an advertisement, or vandalism. It is not useful or relevant to the current topic.

You flagged this as spam. Undo flag.Flag Post