วันจันทร์ที่ 4 ธันวาคม พ.ศ. 2560

SOURCE CODEดัดแปลงกล่องหยอดเหรียญเครื่องซํกผ้า ทำงาน100เปอร์เซ็นท์ Adapt Vending Machine 100 percent work










SOURCE CODEดัดแปลงกล่องหยอดเหรียญเครื่องซํกผ้า ทำงาน100เปอร์เซ็นท์ Adapt Vending Machine 100 percent work
4/12/2560 SONGCHAI PRAPATRUNGSEE
SOURCE CODEดัดแปลงกล่องหยอดเหรียญเครื่องซํกผ้า ทำงาน100เปอร์เซ็นท์ Adapt Vending Machine 100 percent work

ซื้อโปรแกรมเมอร์ที่นี่


แนวความคิด สร้างกล่องหยอดเหรียญ ทำงาน100เปอร์เซ็นท์
SOURCE CODE , การต่อสายไฟประหยัดสาย1คู่ ,
เทคนิคชั่งผ้าระดับน้ำสูงสุด,
ทำให้สำหรับ บุคคลทั่วไป เป็นสาธารณะ ทุกคนนำไปใช้ได้

ห้ามผู้หนึ่งผู้ใด นำไปจดลิขสิทธิ์ เป็นของตัวเอง

////////////////////////////////////////////////////////////////
#include <REGX51.H>

/*SET PRICE BLINK END(RESET)===*/

#define END 1/*SET0=LOW END,SET1=HIGH END AT P3^4 =RESET*/

//sbit =COMMAND, COIN_B=VARIABLE NAME, P3^5=PIN 3.5
sbit MODE_B=P3^7;
sbit COIN_B=P1^0;
 
sbit POWER=P2^5;
sbit START=P2^6;
sbit GROUND_COIN=P2^4;
sbit RESET=P2^3;//RESET=P2^3=PIN24
sbit WORK_SURE=P2^2;//P2^2=PIN23
sbit DG1=P1^4;
sbit DG2=P1^3;

/*BTT VALUE FOR NUMBER COIN*/
sbit COL0=P1^5;
sbit COL1=P1^6;
sbit COL2=P1^7;
sbit COL3=P3^0;

/*ARRAY 0-9 ====================*/
char DATA[]={0X11>>1,0XB7>>1,0X29>>1,0X23>>1,
0X87>>1,0X43>>1,0X41>>1,0X37>>1,0X01>>1,0X03>>1};

/*DECLARATION GLOBAL VARIABLE===*/
bit BLINK_W,MATCHINE_W,CHECK_W;
bit COIN_L,NUMBER_L,CHECK_L,CX_L;
bit PON_L=1,POFF_L,STON_L,STOFF_L;
bit WORKSURE_W;

unsigned char CX;
unsigned char DG,NUMBER,CN,BLINK_T;
unsigned int TIME,WORKSURE_T;
unsigned char DIGIT1,DIGIT2,i,MUL;
unsigned char DIGIT1,DIGIT2,i,MUL,WORK_N;

/*FUNCTION=====================*/
void CONVERT_DEC_TO_UNIT(unsigned char NUMBER)
{
   unsigned char NUM;

   NUM=((NUMBER%100)/10);//SIB
   DIGIT1=DATA[NUM];

   NUM=NUMBER%10;//NAUY
   DIGIT2=DATA[NUM];
}
void CUT_ZERO()
{
        if(DIGIT1==DATA[0])
                DIGIT1=0XFF;       
}

void DELAY_MS(unsigned int TIME)
{
  unsigned int i,j;
  for(i=TIME;i>0;i--)
  {
    for(j=120;j>0;j--);
  }
}

/*TIMER0 MODE1 16BIT============*/
void T0M1_16BIT()interrupt 1//INTERRUPT VECTOR1
{
  /*SET TIMER============*/
  //TR0=0;//STOP TIMER0
  //TF0=0;//TIMER OVERFLOW FLAG=CLEAR
  TH0=0XEC;//HI BYTE TIMER0
  TL0=0X8C;//LOW BYTE TIMER0
  //TR0=1;//START TIMER0
       
if(WORKSURE_W==1)
{
TIME=0;
if(++WORKSURE_T>1000)//200=1SEC
{//IF LOWER 700 SOME TIME NOT WORK FOR 11KG WA13R3
                WORKSURE_T=0;
                WORKSURE_W=0;
                WORK_N=0;
                MATCHINE_W=1;
}      
if(WORK_SURE==0)//LEVEL LED FOR WEIGHT
{
if(++WORK_N==10)
{
        WORKSURE_T=0;
        WORKSURE_W=0;
        WORK_N=0;
}
}
}

/* SET COIN */
if(COL3==0&&COL2==0&&COL1==0&&COL0==0)
{
                MUL=1;
}else if(COL3==0&&COL2==0&&COL1==0&&COL0==1)
{
                MUL=1;
}else if(COL3==0&&COL2==0&&COL1==1&&COL0==0)
{
                MUL=2;
}else if(COL3==0&&COL2==0&&COL1==1&&COL0==1)
{
                MUL=3;
}else if(COL3==0&&COL2==1&&COL1==0&&COL0==0)
{
                MUL=4;
}else if(COL3==0&&COL2==1&&COL1==0&&COL0==1)
{
                MUL=5;
}else if(COL3==0&&COL2==1&&COL1==1&&COL0==0)
{
                MUL=6;
}else if(COL3==0&&COL2==1&&COL1==1&&COL0==1)
{
                MUL=7;
}else if(COL3==1&&COL2==0&&COL1==0&&COL0==0)
{
                MUL=8;
}else if(COL3==1&&COL2==0&&COL1==0&&COL0==1)
{
                MUL=9;
}else MUL=1;

if(MODE_B==1)//MODE1=5BATH
{
         CX=MUL*5;
}else CX=MUL*10;

                                               
/*CHECK FOR END PROCESS*/
if(CHECK_W==1)
{
if(RESET==END)//***
{
TIME++;//37
if(TIME==1000)//200=1SEC
{
        TIME=0;
        CX_L=0;
        CHECK_W=0;
        BLINK_W=0;
        NUMBER_L=0;
        CN=0;
        GROUND_COIN=1;
}  
}else TIME=0;//PULSE
}

/*COIN RECEIVE FOR WORK=========*/
if(COIN_B==0&&COIN_L==0&&CX_L==0)
{
PON_L=1;
POFF_L=0;

if(TIME++==4)//DELAY 20MS
{
TIME=0;
COIN_L=1;
CHECK_L=0;
BLINK_W=1;

/*MODE 5,10,15...95BAHT
ELSE MODE 10,20...90BAHT=======*/  
if(MODE_B==1)
{
        NUMBER=++CN*5;
        //CX=MUL*5;//***
}else //MODE_B=0
{
                NUMBER=++CN*10;
}
}
}else if(COIN_B==1)COIN_L=0;

/*BLINK_W=0 =BLINK FOR WAIT COIN
ELSE NO BLINK WHEN COIN RECEIVE*/
if(BLINK_W==0)
{
CONVERT_DEC_TO_UNIT(CX);
if(MODE_B==1)//MODE1=5BATH
{
BLINK_T++;
if(BLINK_T<=100&&PON_L==1)//500MS
{
if(BLINK_T==100)
{
        BLINK_T=0;
        PON_L=0;
        POFF_L=1;
}
/*DISPLAY SEGMENT 2DIGIT==*/
switch (DG)
{
        case 0:
                        CUT_ZERO();
                        DG1=DG2=1;//DG1 DG2 OFF  
                        DG1=0;//DG1 ON
               
                        //P0=D1M0;//DIGIT1***
                        P0=DIGIT1;//DIGIT1***
                        DG=1;//DG=1 =case 1:
        break;
        case 1:
                        DG1=DG2=1;//DG2 DG1 OFF  
                        DG2=0;//DG2 ON

                        P0=DIGIT2;//DIGIT2
                        DG=0;
        break;    
}                                           
}else
if(BLINK_T<=100&&POFF_L==1)//500MS
{
if(BLINK_T==100)
{
        BLINK_T=0;
        PON_L=1;
        POFF_L=0;
}
DG1=DG2=1;//OFF
}                          
}else //MODE_B==0=10BATH
{
BLINK_T++;
if(BLINK_T<=100&&PON_L==1)//500MS
{
if(BLINK_T==100)
{
        BLINK_T=0;
        PON_L=0;
        POFF_L=1;
}
        /*DISPLAY BLINK SEGMENT 2DIGIT===*/
switch (DG)
{
        case 0:
                        DG1=DG2=1;//DG2 DG1 OFF  
                        DG1=0;//DG1 ON
       
                        P0=DIGIT1;//DIGIT1***

                        DG=1;
        break;
        case 1:
                        DG1=DG2=1;//DG1 DG2 OFF  
                        DG2=0;//DG2 ON

                        P0=DIGIT2;//DIGIT2
                        DG=0;
        break;   
}                                           
}else
if(BLINK_T<=100&&POFF_L==1)//500MS
{
if(BLINK_T==100)
{
        BLINK_T=0;
        PON_L=1;
        POFF_L=0;
}
DG1=DG2=1;//OFF
}    
}
}else//BLINK_W==1=STOP BLINK
{
if(NUMBER==CX&&NUMBER_L==0)//COIN EXCACTLY
{
CX_L=1;
NUMBER_L=1;
MATCHINE_W=1;

}
CONVERT_DEC_TO_UNIT(NUMBER);
CUT_ZERO();
                                                                         
/*DISPLAY NO BLINK 2DIGIT======*/
switch (DG)
{
        case 0:
                DG1=DG2=1;//DG2 DG1 OFF  
                DG2=0;//DG2 ON

                P0=DIGIT2;

                DG=1;
                break;
        case 1:
                DG2=DG1=1;//DG1 DG2 OFF  
                DG1=0;//DG1 ON

                P0=DIGIT1;
                DG=0;
                break;
}
}
}

/*FUNCTION MAIN===============*/
void main()
{
  TMOD=0X1;//SET TIMER0 MODE1
  TCON=0X0;//TIMER CONTROLL
  IE=0X82;//INTERRUPT ENABLE
  IP=0X0;//INTERRUPT PRIORITY
  TH0=0X0;//HI BYTE TIMER0
  TL0=0X0;//LOW BYTE TIMER0
  TR0=1;//START TIMER0
  //POWER=1;
  //START=1;
while(1)
{
/*MATCHINE WORK WHEN RECEIVE COIN MAX*/
if(MATCHINE_W==1)
{
        GROUND_COIN=0;
        POWER=0;
        DELAY_MS(500);
       
        POWER=1;
        DELAY_MS(500);

        START=0;
        DELAY_MS(500);
                                                                                               
        START=1;
        WORKSURE_W=1;

        MATCHINE_W=0;
        CHECK_W=1;
}
}

}

ไม่มีความคิดเห็น: