Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
mhdkevinalghozali
Published

Mini AGV as a Gas Decomposer using Fan with PID Control

This robot walks along the trajectory that has been provided and acts as a building security guard from gas leaks.

BeginnerShowcase (no instructions)1,095
Mini AGV as a Gas Decomposer using Fan with PID Control

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
IR Range Sensor
Digilent IR Range Sensor
×2
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Rocker Switch, SPST
Rocker Switch, SPST
×1
Battery Holder, 18650 x 2
Battery Holder, 18650 x 2
×1
DC Motor, 12 V
DC Motor, 12 V
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
Grove - Gas Sensor(MQ2)
Seeed Studio Grove - Gas Sensor(MQ2)
×1
Axial Fan, 5 V
Axial Fan, 5 V
You can use Fan Module L9110 also
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Solder Wire, Lead Free
Solder Wire, Lead Free
Multitool, Screwdriver
Multitool, Screwdriver

Story

Read more

Custom parts and enclosures

Mechanical Design of Automated Guided Vehicle (AGV) as a Gas Decomposer using P Controlled Fan

I use Solidworks software

Schematics

Wiring Diagram

We use in Proteus Software

Code

Automated Guided Vehicle (AGV) as a Gas Decomposer using P Controlled Fan

Arduino
#define MQ2pin (0)

int kanan1 = 4;
int kanan2 = 6;
int kiri1 = 7;
int kiri2 = 8;
int enA= 11;
int enB= 3;
int setpoint = 300;
int INA = 5;
int INB = 12;
float kp = 0.2;
float error, p, pid;
int sensorValue;

int IR1=9;   //kanan
int IR2=10;   //kiri

int speed = 70;
int speed2 = 150;

void setup(){
  Serial.begin(9600);
  pinMode(kanan1,OUTPUT);
  pinMode(kanan2,OUTPUT);
  pinMode(kiri1,OUTPUT);
  pinMode(kiri2,OUTPUT);
  pinMode(enA,OUTPUT);
  pinMode(enB,OUTPUT);
  pinMode(IR1,INPUT);
  pinMode(IR2,INPUT);
  pinMode(INA, OUTPUT);
  pinMode(INB, OUTPUT);
  Serial.begin(9600);
}

void loop(){
  int s1=digitalRead(9);
  int s2=digitalRead(10);
  sensorValue = analogRead(MQ2pin);
  Serial.print("GAS : ");
  Serial.print(sensorValue);
  Serial.println(" ppm");
  delay(10);
  error = setpoint - sensorValue ;
  p = error * kp;
//  pid = setpoint - p;
  if(p<=0){
    p = 0;
  }

  if (sensorValue > 300) {
    berhenti();
    for(int p = 0; p < 255; p++){
      analogWrite(INA, p);
      digitalWrite(INB, LOW);
      delay(10);
    }
  } else if (sensorValue < 300) {
    for(int p = 255; p > 0; p--){
      digitalWrite(INA, LOW);
      digitalWrite(INB, LOW);
    }
    //LURUS
    if(s1==LOW && s2==LOW)
    {
      maju();
    }
    //KANAN
    else if(s1==LOW&&s2==HIGH)
    {
      kanan();
    }
    //KIRI
    else if(s1==HIGH&&s2==LOW)
    {
      kiri();
    }
    //BERHENTI
    else
    {
      berhenti();
    }
  }
}

void maju() {
  Serial.println("maju");
  digitalWrite(kanan1, HIGH);
  digitalWrite(kanan2, LOW);
  analogWrite (enA, speed);
  digitalWrite(kiri1, HIGH);
  digitalWrite(kiri2, LOW);
  analogWrite (enB, speed);
  digitalWrite(INA, LOW);
  digitalWrite(INB, LOW);
}

void kanan() {
  digitalWrite(kanan1, HIGH);
  digitalWrite(kanan2, LOW);
  analogWrite (enA, speed2);
  digitalWrite(kiri1, LOW);
  digitalWrite(kiri2, LOW);
}

void kiri() {
  digitalWrite(kanan1, LOW);
  digitalWrite(kanan2, LOW);
  digitalWrite(kiri1, HIGH);
  digitalWrite(kiri2, LOW);
  analogWrite (enB, speed2);
}


void berhenti() {
  digitalWrite(kanan1, LOW);
  digitalWrite(kanan2, LOW);
  digitalWrite(kiri1, LOW);
  digitalWrite(kiri2, LOW);
}

Credits

mhdkevinalghozali
0 projects • 0 followers

Comments