قسم الميكروكنترولر والروبوت ودوائر الاتصال بالحاسب الالي قسم المتحكمات الـ microcontroller و المعالجات microprocessor و التحكم الرقمي بالكمبيوتر CNC والانظمة الآلية والروبوت Robots

   

الصورة الرمزية F.Abdelaziz
F.Abdelaziz
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,832
نشاط [ F.Abdelaziz ]
قوة السمعة:
قديم 07-02-2013, 02:41 AM المشاركة 33   
افتراضي



السلام عليكم

شكرا جزيلا للمشاركين

أعتذر لخطأ وع سهوا بالدوائر السابقة فى توصيل الإعادة والساعة للعداد 4017 .

الدائرة الصحيحة


اعلانات

الصورة الرمزية F.Abdelaziz
F.Abdelaziz
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,832
نشاط [ F.Abdelaziz ]
قوة السمعة:
قديم 07-02-2013, 03:32 AM المشاركة 34   
افتراضي


التجربة رقم 6 :










الغرض :
استخدام العداد 4017 لمسح الأعمدة , حيث يتم إجراء "خمس إزاحات" "5-shift" وبعد ذلك تتم "الإعادة" reset .
لغة الأسمبلى :





لغة السى :


كود:
//PIC16F628A
//A single illumination LED 
//across the bottom row off LEDs

void RESET_4017(viod){
PORTA.F1=1;                                   //Reset 4017 : Line HIGH
PORTA.F1=0;                                   //then LOW
}

void CLOCK_4017(void){
PORTA.F0=1;                                   // Clock 4017 : Line HIGH
PORTA.F0=0;                                   //then LOW
}

void main( ){
TRISA=0;
TRISB=0;

while (1){

RESET_4017();                     //Reset 4017 , column 1 only active
PORTB=1;                             //Turn on bottom LED 1 , fixed for every column 
delay_ms(500);                      //Illuminate LED 1

CLOCK_4017();                    //Call clock 4017 , column 2 only active
delay_ms(500);                      //Illuminate LED 2

CLOCK_4017();                    //Call clock 4017 , column 3 only active
delay_ms(500);                      //Illuminate LED 3

CLOCK_4017();                    //Call clock 4017 , column 4 only active
delay_ms(500);                      //Illuminate LED 4

CLOCK_4017();                    //Call clock 4017 , column 5only active
delay_ms(500);                      //Illuminate LED 5
}
}



ملحوظة 1 :

لعلك لاحظت أنه قد تم إنشاء دالة لإعادة reset ودالة لتوقيت العداد 4017 , بغرض تسهيل كتابة وفهم البرنامج , وصيغها كالتالى :

كود:
void RESET_4017(viod){
PORTA.F1=1;                       //Reset 4017 : Line HIGH
PORTA.F1=0;                       //then LOW
}

void CLOCK_4017(void){
PORTA.F0=1;                       // Clock 4017 : Line HIGH
PORTA.F0=0;                       //then LOW
}

ملحوظة 2 :

جزء الكود التالى :
كود:
CLOCK_4017();                    //Call clock 4017 , column 2 only active
delay_ms(500);                      //Illuminate LED 2

CLOCK_4017();                    //Call clock 4017 , column 3 only active
delay_ms(500);                      //Illuminate LED 3

CLOCK_4017();                    //Call clock 4017 , column 4 only active
delay_ms(500);                      //Illuminate LED 4

CLOCK_4017();                    //Call clock 4017 , column 5only active
delay_ms(500);                      //Illuminate LED 5


هو تكرار أربع مرات للعبارة :

كود:
CLOCK_4017();                    
delay_ms(500);

لذلك يمكن استخدام حلقة تكرار عدد المرات for كما يلى :


كود:
for(count=0;count<4;count++){
CLOCK_4017();                    
delay_ms(500);
}



ويجب إعلان متغير عداد الحلقة count مسبقا .
ويصبح البرنامج :


كود:
unsigned short count; //Loop count variable
void RESET_4017(viod){ PORTA.F1=1; //Reset 4017 : Line HIGH PORTA.F1=0; //then LOW } void CLOCK_4017(void){ PORTA.F0=1; // Clock 4017 : Line HIGH PORTA.F0=0; //then LOW } void main( ){ TRISA=0; TRISB=0; while (1){ RESET_4017(); //Reset 4017 , column 1 only active PORTB=1; //Turn on bottom LED 1 , for every column delay_ms(500); //Illuminate LED 1 for(count=0;count<4;count++){ CLOCK_4017();//Illumination LED 2 to LED 5 delay_ms(500); } } }




اعلانات اضافية ( قم بتسجيل الدخول لاخفائها )

الصورة الرمزية F.Abdelaziz
F.Abdelaziz
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,832
نشاط [ F.Abdelaziz ]
قوة السمعة:
قديم 07-02-2013, 01:45 PM المشاركة 35   
افتراضي


التجربة رقم 7 : تحريك إضاءة عامود جهة اليمين :
الغرض :
تحريك عامود ليدات من جهة اليسار إلى جهة اليمين .



الدائرة الكهربائية :
الفكرة :
يقوم البرنامج بتوصيل جميع خطوط المنفذ PORTB وإخراجها إلى شاشة الليدات أثناء تنفيذ التأخير . يتم فصل المنفذ ( لمنع ظهور نسخ أو ظلال ) ويتم توقيت العداد 4017 إلى الخرج التالى . تتكرر الدورة للخمس أعمدة ويتكرر البرنامج .
لغة الأسمبلى :


كود:
 ;PIC16F84 and only F84 chip         
                   ;Column shift right

  Start   ORG 0x00
             BSF 03,5             ;Go to page1 to set the ports
             MOVLW 00h       ;Put 00 into W             
             MOVWF 05h       ;Make all RA lines output        
             MOVWF 06h       ;Make all RB lines output
             BCF 03,5             ;Go to Page0 for programming             

 Shift    MOVLW 05
            MOVWF 19h        ;Put 5 in the Count file for 5 columns
            BSF 05h,1            ;Reset 4017
            BCF 05h,1            ;allow 4017 to clock via clock line

 Shift1  MOVLW 7F
            MOVWF 06h        ;Turn on 7 outputs for LEDs
            CALL Delay
            MOVLW 00          ;Turn off LEDs to prevent mirroring
            MOVWF 06h
            CALL Clock          ;Clock the 4017
            DECFSZ 19h,1      ;Decrement the count file
            GOTO Shift1
            GOTO Shift 

 Clock   BCF 05,0              ;Clock the 4017
            NOP
            BSF 05,0
            RETURN

 Delay   MOVLW 03
             MOVWF 1Ah
 Delay1 DECFSZ 1Bh,1
             GOTO Delay1
             DECFSZ 1Ch,1
             GOTO Delay1
             DECFSZ 1Ah,1
             GOTO Delay1
             RETURN

             END
لغة السى والمترجم ميكروسى برو :

كود:
//PIC16F628A // Column shift right. unsigned short count;
void RESET_4017(viod){ PORTA.F1=1; //Reset 4017 : Line HIGH PORTA.F1=0; //then LOW
}
void CLOCK_4017(void){ PORTA.F0=1; // Clock 4017 : Line HIGH PORTA.F0=0; //then LOW
} void main (){ //Start TRISA=0; // Make all RA lines output TRISB=0; //Make all RB lines output PORTB=0; // Off all LEDs while(1){ //Endless loop RESET_4017(); // Reset the 4017, allow 4017 to clock via clock line for(count=0 ; count<5 ; count++){ PORTB=0x7F; // Turn on 7 outputs for LEDs Delay_ms(500); // Call Delay 500 ms PORTB=0; // Turn off LEDs to prevent mirroring CLOCK_4017(); // Clock the 4017 } } }



مخطط المسار


الصورة الرمزية F.Abdelaziz
F.Abdelaziz
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,832
نشاط [ F.Abdelaziz ]
قوة السمعة:
قديم 07-02-2013, 09:26 PM المشاركة 36   
افتراضي


التجربة رقم 8 تحريك إضاءة عامود جهة اليمين ثم جهة اليسار :


الغرض :

تحريك عامود ليدات عبر الشاشة والعودة مرة أخرى .
الدائرة الكهربائية :



الفكرة :
تحريك العامود عند العودة ليس سهلا مثل الحركة للأمام لأن العداد 4017 يتم توقيته فقط من اليسار إلى اليمين . لتحريك العامود جهة اليسار , يجب إعادة reset العداد 4017 ( لذلك فأنت تعرف أن الخرج الأول يكون مرتفعا HIGH ) , بعد ذلك يتم توقيته ثلاثة مرات بحيث يكون الخرج "الرابع" يكون مرتفعا HIGH . عندئذ يمكن توصيل الليدات . يتم تكرار ذلك عن طريق توقيت العداد 4017 مرتين لإنتاج العامود الثالث وآخر مرة يتم توقيته لمرة واحدة لإنتاج العامود الثانى . ثم تكرار العملية .
لغة الأسمبلى :



كود:
 ;PIC16F84 and only F84 chip         
                   ;Column of LEDs moves across and back 

  Start   ORG 0x00
             BSF 03,5             ;Go to page1 for setting-up the ports
             MOVLW 00h       ;Put 00 into W             
             MOVWF 05h       ;Make all RA lines output        
             MOVWF 06h       ;Make all RB lines output
             BCF 03,5             ;Go to Page0 for programming
             
 Shift    MOVLW 05
            MOVWF 19h        ;Put 5 in the Count file for 5 columns
            BSF 05h,1            ;Reset 4017
            BCF 05h,1            ;allow 4017 to clock via clock line

 Shift1  MOVLW 7F
            MOVWF 06h         ;Turn on 7 outputs for LEDs
            CALL Delay
            MOVLW 00           ;Turn off LEDs to prevent mirroring
            MOVWF 06h
            CALL Clock           ;Clock the 4017
            DECFSZ 19h,1      ;Decrement the count file
            GOTO Shift1

            MOVLW 03h
            MOVWF 19h         ;3 shifts - yes 3 shifts!
 AAA   CALL Back
            DECFSZ 19h,1
            GOTO AAA
            GOTO Shift 



 Back   BSF 05h,1
            BCF 05h,1            ;Reset 4017 and allow 4017 to clock 
            MOVLW 00h
            MOVWF 06h         ;Turn off LEDs to prevent "streaking"
            MOVF 19h,0         ;Copy 19h into W
            MOVWF 18h         ;Copy W into file 18h
 BBB    CALL Clock
            DECFSZ 18h,1
            GOTO BBB

            MOVLW 7Fh
            MOVWF 06h         ;Turn on all 7 LEDs
            CALL Delay
            RETURN 

 Clock  BCF 05,0                 ;Clock the 4017
            NOP
            BSF 05,0
            RETURN

 Delay   MOVLW 03
             MOVWF 1Ah
 Delay1 DECFSZ 1Bh,1
             GOTO Delay1
             DECFSZ 1Ch,1
             GOTO Delay1
             DECFSZ 1Ah,1
             GOTO Delay1
             RETURN

             END
كود:


لغة السى والمترجم ميكروسى برو :

كود:
//PIC16F84 and only F84 chip //Column of LEDs moves across and back unsigned short count; //Variable declaration
void RESET_4017(viod){ PORTA.F1=1; //Reset 4017 : Line HIGH, column 1 on PORTA.F1=0; //then LOW, allow 4017 to clock via clock line
}
void CLOCK_4017(void){ PORTA.F0=1; // Clock 4017 : Line HIGH PORTA.F0=0; //then LOW
} void main (){ //Start main TRISA=0; // Make all RA lines output TRISB=0; //Make all RB lines output while(1){ //Endless loop PORTB=0;//Initial condition : All LEDs off // Forward direction RESET_4017( );// Reset the 4017 for(count=0 ; count<5; count++){ PORTB=0x7F; // Turn on 7 outputs for LEDs Delay_ms(500); // Call Delay 500 ms PORTB=0; // Turn off LEDs to prevent mirroring CLOCK_4017( ); //Clock the 4017 }//for loop end //Backward direction //back from column 4 RESET_4017( );// Reset the 4017 CLOCK_4017( ); CLOCK_4017( ); CLOCK_4017( ); //3 Clock the 4017 PORTB=0x7F; // Turn on 7 outputs for LEDs Delay_ms(500); // Call Delay 500 ms PORTB=0; // Turn off LEDs to prevent mirroring //column 3 RESET_4017( );// Reset the 4017 CLOCK_4017( ); CLOCK_4017( ); //2 Clock the 4017 PORTB=0x7F; // Turn on 7 outputs for LEDs Delay_ms(500); // Call Delay 500 ms PORTB=0; // Turn off LEDs to prevent mirroring // coulun 2 RESET_4017( );// Reset the 4017 CLOCK_4017( ); //1 Clock the 4017 PORTB=0x7F; // Turn on 7 outputs for LEDs Delay_ms(500); // Call Delay 500 ms PORTB=0; // Turn off LEDs to prevent mirroring } }






الصورة الرمزية F.Abdelaziz
F.Abdelaziz
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,832
نشاط [ F.Abdelaziz ]
قوة السمعة:
قديم 07-02-2013, 09:32 PM المشاركة 37   
افتراضي


ملاحظة :
جزء الكود التالى :


كود:
//Backward direction //back from column 4
RESET_4017( );// Reset the 4017 CLOCK_4017( ); CLOCK_4017( ); CLOCK_4017( ); //3 Clock the 4017 PORTB=0x7F; // Turn on 7 outputs for LEDs Delay_ms(500); // Call Delay 500 ms PORTB=0; // Turn off LEDs to prevent mirroring //column 3
RESET_4017( );// Reset the 4017 CLOCK_4017( ); CLOCK_4017( ); //2 Clock the 4017 PORTB=0x7F; // Turn on 7 outputs for LEDs Delay_ms(500); // Call Delay 500 ms PORTB=0; // Turn off LEDs to prevent mirroring // coulun 2
RESET_4017( );// Reset the 4017 CLOCK_4017( ); //1 Clock the 4017
PORTB=0x7F; // Turn on 7 outputs for LEDs Delay_ms(500); // Call Delay 500 ms PORTB=0; // Turn off LEDs to prevent mirroring





يتضمن تكرار ثلاثة مرات لمجموعة عبارات , لكن فى كل مرة توجد عبارة مختلفة لذلك فهى لا تصلح لاستخدام التكرار بحلقة for إلا بشروط . وشروط تعنى استخدام جمل الشرط , وهنا من الأفضل أن نستخدم "switch…case" لاستعراض فائدة استخدامها كما يلى :


كود:
for(count=0;count<3;count++){ RESET_4017( );// Reset the 4017 switch(count){ case 0 :// count=0 CLOCK_4017( ); CLOCK_4017( ); CLOCK_4017( );break; case 1: : //count=1 CLOCK_4017( ); CLOCK_4017( );break; case 2 : : //count=2 CLOCK_4017( );break; } //switch end PORTB=0x7F; // Turn on 7 outputs for LEDs Delay_ms(500); // Call Delay 500 ms PORTB=0; // Turn off LEDs to prevent mirroring }
ويصبح البرنامج :
//PIC16F84 and only F84 chip //Column of LEDs moves across and back unsigned short count; //Variable declaration void RESET_4017(viod){ PORTA.F1=1; //Reset 4017 : Line HIGH, column 1 on PORTA.F1=0; //then LOW, allow 4017 to clock via clock line } void CLOCK_4017(void){ PORTA.F0=1; // Clock 4017 : Line HIGH PORTA.F0=0; //then LOW }
void main (){ //Start main TRISA=0; // Make all RA lines output TRISB=0; //Make all RB lines output
while(1){ //Endless loop PORTB=0;//Initial condition : All LEDs off // Forward direction RESET_4017( );// Reset the 4017 for(count=0 ; count<5; count++){ PORTB=0x7F; // Turn on 7 outputs for LEDs Delay_ms(500); // Call Delay 500 ms PORTB=0; // Turn off LEDs to prevent mirroring CLOCK_4017( ); //Clock the 4017 }//for end
//Backward direction //back from column 4 for(count=0;count<3;count++){ RESET_4017( );// Reset the 4017 switch(count){ case 0 : CLOCK_4017( ); CLOCK_4017( ); CLOCK_4017( ); break; case 1: CLOCK_4017( ); CLOCK_4017( ); break; case 2 : CLOCK_4017( ); break; } //switch end
PORTB=0x7F; // Turn on 7 outputs for LEDs Delay_ms(500); // Call Delay 500 ms PORTB=0; // Turn off LEDs to prevent mirroring }
} }






fawzy73
:: مهندس متواجد ::
تاريخ التسجيل: Dec 2008
المشاركات: 92
نشاط [ fawzy73 ]
قوة السمعة:
قديم 09-02-2013, 12:32 AM المشاركة 38   
افتراضي


بارك الله فيك
زادك من علمه
وجعله الله في ميزان حسناتك

امين


maher_guizeni
:: مهندس متواجد ::
تاريخ التسجيل: Dec 2010
الدولة: Tunis
المشاركات: 116
نشاط [ maher_guizeni ]
قوة السمعة:
قديم 10-02-2013, 12:50 AM المشاركة 39   
افتراضي


بارك الله فيك
و ننتظر المزيد


الصورة الرمزية F.Abdelaziz
F.Abdelaziz
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,832
نشاط [ F.Abdelaziz ]
قوة السمعة:
قديم 10-02-2013, 02:42 AM المشاركة 40   
افتراضي


السلام عليكم

شكرا لجميع الأخوة المشاركين

مع تمنياتى بدوام التوفيق



الساعة معتمدة بتوقيت جرينتش +3 الساعة الآن: 07:26 AM
موقع القرية الالكترونية غير مسؤول عن أي اتفاق تجاري أو تعاوني بين الأعضاء
فعلى كل شخص تحمل مسئولية نفسه إتجاه مايقوم به من بيع وشراء وإتفاق وأعطاء معلومات موقعه
التعليقات المنشورة لا تعبر عن رأي موقع القرية الالكترونية ولايتحمل الموقع أي مسؤولية قانونية حيال ذلك (ويتحمل كاتبها مسؤولية النشر)