السبب في كتابة الكود ...
ارفع الكود من فضلك
|
اولا مشكور جدااا على اهتمامك اخى الكريم
وهذا الكود ..
على المحكاة يعمل بطريقة صحيحة وفى الواقع يقوم النظام بتشغيل الاوامر بطريقة عشوائية ... وتتحقق شروط مكتوبة فى البرنامج بطريقة ذاتية ....
بمعنى انا واضع فى البرنامج أمر شرط لا يتحقق الا عند تفعيل واحد منطقى على احدى رجول الميكرو .... وبلاقى ان الشرط دة بيتحقق لوحدة .. مع انى مركب مقومات فول داون لمنع النويس على الدائرة ..
كود:
/*HYGAZY FOR Microsystem*/
// LCD module connections //
sbit LCD_RS at RB5_bit;
sbit LCD_EN at RB4_bit;
sbit LCD_D4 at RB3_bit;
sbit LCD_D5 at RB2_bit;
sbit LCD_D6 at RB1_bit;
sbit LCD_D7 at RB0_bit;
sbit LCD_RS_Direction at TRISB5_bit;
sbit LCD_EN_Direction at TRISB4_bit;
sbit LCD_D4_Direction at TRISB3_bit;
sbit LCD_D5_Direction at TRISB2_bit;
sbit LCD_D6_Direction at TRISB1_bit;
sbit LCD_D7_Direction at TRISB0_bit;
// End LCD module connections//
//*************//**********************//
#define EZR_KIY portc.f5=1;delay_ms(120);portc.f5=0;delay_ms(60);portc.f5=1;delay_ms(120);portc.f5=0;delay_ms(60);
#define EZR_TEST portc.f5=1;delay_ms(150);portc.f5=0; delay_ms(60);portc.f5=1;delay_ms(150);portc.f5=0;delay_ms(60);portc.f5=1;delay_ms(150);portc.f5=0;
#define EZR_eror portc.f5=1;delay_ms(6100); EZR_TEST
#define CLEAR Lcd_Cmd(_LCD_CLEAR);
//*************************************//
/*void interrupt(){
cut1:
if(portd.f7==1&& Z==1){while(1)if(portd.f7==0){goto cut2;}cut2: portc=0;EZR_TEST portc.f0=1;delay_ms(300);while(1){if(porta.f1==1){portc=0; EZR_TEST delay_ms(400);portc=20;goto cut1; } }}
INTCON=0b01100000;
TMR0=0;
}*/
//--------------**************-------------//
void main(){
int x=0;
int A=0;
int Z=0;
/*OPTION_REG=0b10000101;
INTCON=0b10100000;
TMR0=217;*/
//-------**********--------//
adcon1=0x06;
trisb=0; portb=0; trisd=1; portd=0;
trisc=128; portc=0; trisa=1; porta=0;
trise=1; porte=0;
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF); // cursor off
START:
CLEAR
A=0;
Z=0;
Lcd_Cmd(_LCD_CLEAR); // clear LCD
lcd_out(1,1," <<< Welcome >>>>");
lcd_out(2,2,"Loading System");
EZR_KIY
delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);
lcd_out(1,4,"HYGAZY FOR");
lcd_out(2,4,"Microsystem");
EZR_TEST EZR_TEST EZR_TEST
delay_ms(3000);
CLEAR
lcd_out(1,2,"Chose Cutting");
lcd_out(2,1,"Program Press UP");
//********************************************************//
while(1){
if(porte.f2==1){ A++;EZR_KIY CLEAR delay_ms(100);}
if(A==3){A=1; }
if(porta.f0==1&&A==1){delay_ms(400);EZR_KIY goto loop;}
if(porta.f0==1&&A==2){delay_ms(400); goto loop20sm;}
if(A==1){ lcd_out(2,3,"PlEASE START");lcd_out(1,4,"CUT 10 SM");}
if(A==2){ lcd_out(2,3,"PlEASE START");lcd_out(1,4,"CUT 20 SM");}
}
//*********************************************************//
//----------------- CUT 10 SM -----------------//
loop:
while(1){
//--------------********** MOTOR 1 LEFT && RIGHT **********---------------//
if(porta.f1==1){ portc.f4=1; EZR_KIY while(1){if(porta.f1==0){portc.f4=0;goto loop;}}}
if(porta.f2==1){ portc.f6=1; EZR_KIY while(1){if(porta.f2==0){portc.f6=0;goto loop;}}}
//-------***********************************************************--------//
//-------------************ MOTOR 2 LEFT && RIGHT **********---------------// //--------********** MOTOR 1 LEFT && RIGHT **********-------//
if(porta.f4==1){ portc.f1=1; EZR_KIY while(1){if(porta.f4==0){portc.f1=0;goto loop;}}}
if(porta.f5==1){ portc.f2=1; EZR_KIY while(1){if(porta.f5==0){portc.f2=0;goto loop;}}}
//-------***********************************************************-------//
//-------------*************** CUT 1 MANWAL ****************--------------//
if(porte.f0==1){portc.f3=1; EZR_TEST delay_ms(300);while(1){if(portc.f7==1){portc=0;goto loop;}}}
//------***********************************************************-------//
//-------------*************** CUT 2 MANWAL ****************--------------//
if(porte.f1==1){portc.f0=1; EZR_TEST delay_ms(300); while(1){if(portd.f4==1){portc=0;goto loop;}}}
//------***********************************************************-------//
//------------------************* RESTART ******************--------------//
if(portd.f0==1){ EZR_KIY delay_ms(600);portc=0; goto start;}
//----************************************************************-------//
//---------------*********** MOTOR START **************-----------------//
if(porta.f0==1){EZR_KIY Z++; delay_ms(400);}
if(Z==1){ portc=20;}
if(Z==2){ portc=0;}
if(Z==3){Z=1;}
//----------**************************************************--------//
//-------------********** TEST CUT 1 && 2 ************---------------//
if(portd.f2==1){portc=8;delay_ms(300);while(1){if(portc.f7==1){ portc=4;delay_ms(480);portc=8; goto loop;}}}
if(portd.f7==1){portc=1;delay_ms(300);while(1){if(portd.f4==1){ portc=20;delay_ms(250);portc=20; EZR_KIY goto loop;}}}
//-------*************************************************----------//
//--------------****** TESE EREROR 1 && 2*********-----------------//
if(portd.f5==1){CLEAR lcd_out(1,4,"TESE EREROR"); portc=0; EZR_eror goto START;}
//-------***************************************************-----//
}
loop20sm:
while(1){
//--------------********** MOTOR 1 LEFT && RIGHT **********---------------//
if(porta.f1==1){ portc.f4=1; EZR_KIY while(1){if(porta.f1==0){portc.f4=0;goto loop;}}}
if(porta.f2==1){ portc.f6=1; EZR_KIY while(1){if(porta.f2==0){portc.f6=0;goto loop;}}}
//-------***********************************************************--------//
//-------------************ MOTOR 2 LEFT && RIGHT **********---------------// //--------********** MOTOR 1 LEFT && RIGHT **********-------//
if(porta.f4==1){ portc.f1=1; EZR_KIY while(1){if(porta.f4==0){portc.f1=0;goto loop;}}}
if(porta.f5==1){ portc.f2=1; EZR_KIY while(1){if(porta.f5==0){portc.f2=0;goto loop;}}}
//-------***********************************************************-------//
//-------------*************** CUT 1 MANWAL ****************--------------//
if(porte.f0==1){portc.f3=1; EZR_TEST delay_ms(300);while(1){if(portc.f7==1){portc=0;goto loop;}}}
//------***********************************************************-------//
//-------------*************** CUT 2 MANWAL ****************--------------//
if(porte.f1==1){portc.f0=1; EZR_TEST delay_ms(300); while(1){if(portd.f4==1){portc=0;goto loop;}}}
//------***********************************************************-------//
//------------------************* RESTART ******************--------------//
if(portd.f0==1){ EZR_KIY delay_ms(600);portc=0; goto start;}
//----************************************************************-------//
//---------------*********** MOTOR START **************-----------------//
if(porta.f0==1){EZR_KIY Z++; delay_ms(400);}
if(Z==1){ portc=20;}
if(Z==2){ portc=0;}
if(Z==3){Z=1;}
//----------**************************************************--------//
//-------------********** TEST CUT 1 && 2 ************---------------//
if(portd.f3==1){portc=8;delay_ms(300);while(1){if(portc.f7==1){ portc=4;delay_ms(480);portc=8; goto loop;}}}
if(portd.f7==1){portc=1;delay_ms(300);while(1){if(portd.f4==1){ portc=20;delay_ms(250);portc=20; EZR_KIY goto loop;}}}
//-------*************************************************----------//
//--------------****** TESE EREROR 1 && 2*********-----------------//
if(portd.f5==1){ portc=0; EZR_eror goto START;}
//-------***************************************************-----//
//-----********** END **********------//
}
}
صورة المحكاة