Automatic X Y Table with ARDUINO UNO ( simulation )

| Sabtu, 06 Juni 2015


Automatic X Y Table with ARDUINO UNO ( simulation )



     Alat simulasi ini kami buaat dengan bahan dasar karton, kemudian menggunakan 2 buah motor DC 12v dan masing - masing menggunakan gear dan belt untuk mengurangi kecepatan motor dan menambah kekuatan motor agar mampu berputar lebih pelan tapi tetap kuat menggerakan benda kerja.
      Didalam alat yang kami buat ini terdapat sebuah microcontroller yaitu sebuah ARDUINO UNO yang digunakan sebagai pengganti PLC.

Kelebihan menggunakan ARDUINO UNO :
-biaya lebih murah.
- pemrogramannya lebih simpel karena menggunaan pemrograman dasar.
- input dan output bisa kita sesuaikan dengan kebutuhan I/O kita.
- bisa menggunakan sumber antara 3 - 20v DC

Kekurangan menggunakan ARDUINO UNO :
- ketahanan terhadap faktor lingkungan sangat rendah.
- tegangan I/O yang rendah ( max. 5v).

Dibawah ini adalah program arduino yang kami gunakan :
========================================================================
#include <plcLib.h>
#include <LedControl.h>

const int X01=14;
const int X02=15;
const int X03=16;
const int X04=17;
const int X05=18;
const int X06=19;
const int X07=2;
const int X08=4;
const int X09=7;
const int Y02=3;
const int Y04=5;
const int Y05=6;
const int Y08=9;
const int Y09=10;
const int Y010=11;
unsigned int R1=0,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,R13,R14,R15,RX,RX1=1,RX2,RX3=1,RX4,RX5=1,RX6,RX7=1,RX8,RX9=1,RX10,RX11=1,RX12;
unsigned int RY1,RY2,RY3,RY4,RY5,RY6;
unsigned long T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T12,T13,T14,T15,T11;
Counter C1a(10);
Counter C1b(12);
Counter C2a(10);
Counter C2b(12);
Counter C3(9);
Counter C4(9);
Counter CX(2);
Counter CY(9);
LedControl asik=LedControl(13,12,8,1);
Shift SF1(0x8000);
//sensor go
const int analogInPin = A4;  // Analog input pin that the potentiometer is attached to
const int analogInPin2 = A5;
int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)
int sensorValue2 = 0;        // value read from the pot
int outputValue2 = 0;

unsigned int RP1;
unsigned int RP2;
//sensor end
void setup() {
  pinMode (14,INPUT); //mode
  pinMode (15,INPUT); //sift
  pinMode (16,INPUT); //up
  pinMode (17,INPUT); //down
  pinMode (18,INPUT); //count x
  pinMode (19,INPUT); //count y
  pinMode (2,INPUT);
  pinMode (4,INPUT);
  pinMode (7,INPUT);
  pinMode (3,OUTPUT);
  pinMode (5,OUTPUT);
  pinMode (6,OUTPUT);
  pinMode (9,OUTPUT);
  pinMode (10,OUTPUT);
  pinMode (11,OUTPUT);
   asik.shutdown(0,false);
 asik.setIntensity(0,8);
 asik.clearDisplay(0);
  Serial.begin(9600);
}

void loop()
{
    // read the analog in value:
  sensorValue = analogRead(analogInPin);
  sensorValue2 = analogRead(analogInPin2);
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, 255);
  outputValue2 = map(sensorValue2, 0, 1023, 0, 255);
  // change the analog out value:
  if(sensorValue2<1){
    RP2=1;}
    else{RP2=0;}
  if(sensorValue<1){
    RP1=1;}
    else{RP1=0;}

  //X1 = MODE
  //X2 = RIGHT
  //X3 = UP
  //X4 = DOWN
  //X5 = STOP
  //X6 = COUNTER MOTOR X
  //X7 = COUNTER MOTOR Y
  //Y2 & Y8 = CW
  //Y5 & Y9 = EMERGENCY STOP
  //Y4 & Y10 = CCW

  //sistem input
  inNot(X01); orBit(R6); CX.countUp();



  //sumbu X
  if(CX.count()==0)
 {

         //program x / y
            SF1.bitValue(14);  SF1.inputBit();
            in(X02); timerOn(T1,10); SF1.shiftRight();
            SF1.bitValue(15); out(RY2);
            SF1.bitValue(14); out(RY1);
         
            //tampilan X=
      asik.setRow(0,7,B00110111);
      asik.setRow(0,6,B01001000);
           //tampilan Y=
      asik.setRow(0,3,B00111011);
      asik.setRow(0,2,B01001000);
   
           //program counter X & Y
   if(RY1==1)    //Y
       {
      inNot(X03); timerOn(T2,10); C1a.countUp();
      inNot(X04); timerOn(T3,10); C1a.countDown();
       }
     
   if(RY2==1)    //X
       {
     inNot(X03); timerOn(T4,10); C1b.countUp();
      inNot(X04); timerOn(T5,10); C1b.countDown();
       }
      asik.setDigit(0,4,C1b.count(),RY2);
      asik.setDigit(0,5,C1b.count(),false);
      asik.setDigit(0,0,C1a.count(),RY1);
      asik.setDigit(0,1,C1a.count(),false);
  }

                            //program sistem
     if(CX.count()==1)
 {
      asik.setRow(0,7,B01000110);
      asik.setRow(0,6,B00111110);
      asik.setRow(0,5,B01110110);
      asik.setRow(0,4,B01110110);
      asik.setRow(0,3,B00110000);
      asik.setRow(0,2,B01110110);
      asik.setRow(0,1,B11111011);
      asik.setRow(0,0,B10000000);

             //sensor
  in(RP2); C2a.countUp();
  in(RP1); C2b.countUp();
  //sensor
      inNot(X07); out(R8);
      inNot(X08); out(R2);
      inNot(X09); out(R5);
   
   if(C1a.count()>C2a.count()) {R1=1;} else(R1=0);
    in(R1); andNotBit(R8); outNot(Y08);
    in(R2); andNotBit(R8); outNot(Y010);
    in(R8); outNot(Y09);
 
       if(C1b.count()>C2b.count()) {R4=1;} else(R4=0);
    in(R4); andNotBit(R8); outNot(Y02);
    in(R5); andNotBit(R8); outNot(Y04);
    in(R8); outNot(Y05);

 }


  if(CX.count()==2)
 {
      asik.setRow(0,7,B00000000);
      asik.setRow(0,6,B01000111);
      asik.setRow(0,5,B00110000);
      asik.setRow(0,4,B00010101);
      asik.setRow(0,3,B00110000);
      asik.setRow(0,2,B01011011);
      asik.setRow(0,1,B00110111);
      asik.setRow(0,0,B00000000);

             //sensor
  in(RP2); C2a.countDown();
  in(RP1); C2b.countDown();

      inNot(X07); out(R8);
if(C2a.count()>0){R2=1;R1=0;} else(R2=0);
    in(R1); andNotBit(R8); outNot(Y08);
    in(R2); andNotBit(R8); outNot(Y010);
    in(R8); outNot(Y09);
if(C2b.count()>0){R5=1;R4=0;} else(R5=0);
    in(R4); andNotBit(R8); outNot(Y02);
    in(R5); andNotBit(R8); outNot(Y04);
    in(R8); outNot(Y05);
 
if(C2a.count()<1) {R9=1;} else(R9=0);
if(C2b.count()<1) {R10=1;} else(R10=0);
in(R9); andBit(R10); out(R11);

if(R11) {C1a.clear(); C1b.clear(); C2a.clear(); C2b.clear(); CX.clear();}

 }}

int satuan(int a){ int X; X=a%10; return X;}
int puluhan(int a){ int X; X=(a/10)%10; return X;}
========================================================================

sekian pembahasan dari kami..
terimakasih atas kunjungan anda hari ini.
---{TERIMA KASIH DAN SELAMAT MENCOBA }---

0 komentar:

Next Prev
▲Top▲