منتديات الهندسة الكهربية والإلكترونية والميكاترونكس والكومبيوتر
هل تريد التفاعل مع هذه المساهمة؟ كل ما عليك هو إنشاء حساب جديد ببضع خطوات أو تسجيل الدخول للمتابعة.

مشروع أضواء متلاحقة 8 مخارج متعدد النماذج والسرعات ، بسيط وذهيد ياستخدام الميكروكونترولر PIC16F628A

اذهب الى الأسفل

مشروع أضواء متلاحقة 8 مخارج متعدد النماذج والسرعات ، بسيط وذهيد ياستخدام الميكروكونترولر PIC16F628A  Empty مشروع أضواء متلاحقة 8 مخارج متعدد النماذج والسرعات ، بسيط وذهيد ياستخدام الميكروكونترولر PIC16F628A

مُساهمة من طرف Admin الأربعاء مارس 09, 2016 11:15 pm

مشروع أضواء متلاحقة 8 مخارج متعدد النماذج والسرعات ، بسيط وذهيد الثمن ياستخدام الميكروكونترولر PIC16F628A
الدائرة الكهربية :


مشروع أضواء متلاحقة 8 مخارج متعدد النماذج والسرعات ، بسيط وذهيد ياستخدام الميكروكونترولر PIC16F628A  Fig10

الوصف :
المشروع مزود بمفتاح ON-OFF ومقاومة متغيرة (يمن استخدام مفتاح ON-OFF وفوليوم المعروف)
فى حالة فصل المفتاح :
يتم عرض نموذج ثابت لا يتغير .
فى حالة توصيل المفتاح :
يتم عرض إضاءة متحركة بعدد من النماذج الشائعة مع التحكم فى سرعة العرض .
التحكم فى السرعة :
يتم عن طريق استخدام ساعة RCخارجية مع مقاومة متغيرة للتحكم فى تردد الساعة وبالتالى سرعة تنفيذ التعليمات .
نماذج الإضاءة :
يوجد 8 مخارج متصلة بالمنفذ PORTB ولذلك تكون نماذج الإضاءة فى شكل نماذج لبايتات ذات8 بت وكل بت تقابل ليد ، تعيين البت بواحد يعنى إضاءة الليد ، فى حين تعيين البت بصفر يعنى إطفاء الليد . وحتى نتمكن من تنفيذ أكبر عدد من النماذج ينبغى حفظها فى ذاكرة البرنامج لأنها الأكبر .
البرنامج :


الكود:

// LED Light Sequencer
// PIC16F628 RC CLOCK
// Change for different length patterns.
 #define PATTERNLENGTH 221
// Declare functions
 unsigned short int getPattern(unsigned short int index);
////////////////////////////////////
unsigned short int count; // Declare loop counter
/////////////////////////////////////
 // Main program loop
 void main()
 {
 CMCON = 0x07; // To turn off comparators
 TRISB=0; // Set all Port B to outputs
 TRISA.F0=1;
 PORTB=0;
 while(1) // Loop forever
 {
   if(Button(&PORTA,0,20,1)){
      PORTB=0b11111111;
      delay_ms(250);
      PORTB=0b00000000;
      delay_ms(250);
   }
 else{
   
   // Loop from 0 to PATTERNLENGTH-1
   for(count = 0; count < PATTERNLENGTH; count++){
   // Get the next pattern and output to LEDs
      PORTB = getPattern(count);
 // Pause for the specified number of ms (up to 65535)
      delay_ms(250);
      }
   }
  }
 }
//////////////////////////////////////////////
// getPattern function: returns the index-th output pattern
 // in the desired sequence
 unsigned short int getPattern(unsigned short int index)
 {
 const unsigned short int patternArray[PATTERNLENGTH] = {
 ///////1A-moving from right to left ////////////////////
0b00000001,// For each pattern in the sequence,
0b00000010,// 1 = light on, 0 = off
0b00000100,// Any combination of lights can be on or off
0b00001000,
0b00010000,
0b00100000,
0b01000000,
0b10000000,
///////1B-moving from right to left ///////
0b00000001,
0b00000010,
0b00000100,
0b00001000,
0b00010000,
0b00100000,
0b01000000,
0b10000000,
///////////2A-moving from left to right ////////
0b10000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000001,
///////////2B-moving from left to right ////////
0b10000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000001,
////////////3A-moving from left to right then moving from left to right  ////////
0b00000001,
0b00000010,
0b00000100,
0b00001000,
0b00010000,
0b00100000,
0b01000000,
0b10000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000001,
0b00000000,
//3B-moving from left to right then moving from left to right//
0b00000001,
0b00000010,
0b00000100,
0b00001000,
0b00010000,
0b00100000,
0b01000000,
0b10000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000000,
////////4-moving from center to edges//////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b00000000,
/////////5-moving from edges to center ////////
0b10000001,
0b01000010,
0b00100100,
0b00011000,
0b00000000,
//////////6A///////////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b01000010,
0b00100100,
0b00011000,
0b00000000,
/////////////6B/////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b01000010,
0b00100100,
////////7/////////////////////
0b00000000,
0b10000000,
0b11000000,
0b11100000,
0b11110000,
0b01111000,
0b00111100,
0b00011110,
0b00001111,
0b00000111,
0b00000011,
0b00000001,
0b00000000,
//////////8///////////
0b00000000,
0b00000001,
0b00000011,
0b00000111,
0b00001111,
0b00011110,
0b00111100,
0b01111000,
0b11110000,
0b11100000,
0b11000000,
0b10000000,
0b00000000,
///////////9////////////////
0b00000001,
0b00000100,
0b00000010,
0b00001000,
0b00000100,
0b00010000,
0b00001000,
0b00100000,
0b00010000,
0b01000000,
0b00100000,
0b10000000,
0b01000000,
0b00000000,
///////////10///////////////
0b00000000,
0b01000000,
0b10000000,
0b00100000,
0b01000000,
0b00010000,
0b00100000,
0b00001000,
0b00010000,
0b00000100,
0b00001000,
0b00000010,
0b00000100,
0b00000001,
0b00000000,
///////11A////////////////////
0b11000000,
0b00110000,
0b00001100,
0b00000011,
0b00001100,
0b00110000,
0b11000000,
0b00000000,
//////////////11B////////////
0b00110000,
0b00001100,
0b00000011,
0b00001100,
0b00110000,
/////////////12///////////////////
0b00000000,
0b11000000,
0b00110000,
0b00001100,
0b00000011,
0b00000000,
/////////////13//////////////
0b00000000,
0b00000011,
0b00001100,
0b00110000,
0b11000000,
0b00000000,
//////////////14A////////////
0b00000000,
0b00001111,
0b11110000,
0b00001111,
0b11110000,
0b00000000,
///////////14B////////////////////////
0b00001111,
0b11110000,
//////////////15A////////////////////
0b00000000,
0b01010101,
0b10101010,
0b01010101,
0b10101010,
0b00000000,
////////////15B////////////////////
0b01010101,
0b10101010,
//////////////16////////////////
 0b00000001, // For each pattern in the sequence,
 0b00000011, // 1 = light on, 0 = off
 0b00000111, // Any combination of lights can be on or off
 0b00001111,
 0b00011111,
 0b00111111,
 0b01111111,
 0b11111111,
 ///////////////
 0b01111111,
 0b00111111,
 0b00011111,
 0b00001111,
 0b00000111,
 0b00000011,
 0b00000001,
 0b00000000,
 ///////////17//////////
 0b00000001, // For each pattern in the sequence,
 0b00000011, // 1 = light on, 0 = off
 0b00000111, // Any combination of lights can be on or off
 0b00001111,
 0b00011111,
 0b00111111,
 0b01111111,
 0b11111111,
 /////////////////////
 0b11111110,
 0b11111100,
 0b11111000,
 0b11110000,
 0b11100000,
 0b11000000,
 0b10000000,
 0b00000000,
 ///////////18///////////
 0b11111111, // For each pattern in the sequence,
 0b00000000, // 1 = light on, 0 = off
 0b11111111, // Any combination of lights can be on or off
 0b00000000,
 0b11111111, // NB: Length of this list must be
 0b00000000, // the same as PATTERNLENGTH
 //////////////////
};
 return patternArray[index];
 }

Admin
Admin

عدد المساهمات : 1194
تاريخ التسجيل : 28/01/2014

https://fathallaabdelaziz.forumarabia.com

الرجوع الى أعلى الصفحة اذهب الى الأسفل

مشروع أضواء متلاحقة 8 مخارج متعدد النماذج والسرعات ، بسيط وذهيد ياستخدام الميكروكونترولر PIC16F628A  Empty رد: مشروع أضواء متلاحقة 8 مخارج متعدد النماذج والسرعات ، بسيط وذهيد ياستخدام الميكروكونترولر PIC16F628A

مُساهمة من طرف Admin الخميس مارس 10, 2016 10:58 am

تعديل المشروع للاستخدام مع الميكروكونترولر PIC12F675 :

مشروع أضواء متلاحقة 8 مخارج متعدد النماذج والسرعات ، بسيط وذهيد ياستخدام الميكروكونترولر PIC16F628A  Fig11

البرنامج :
مع تعديل جزء منه وترك باقى التعديل ليتم بمعرفة المستخدم :



الكود:

// LED Light Sequencer
// PIC16F628 RC CLOCK
// Change for different length patterns.
 #define PATTERNLENGTH 221
// Declare functions
 unsigned short int getPattern(unsigned short int index);
////////////////////////////////////
unsigned short int count; // Declare loop counter
/////////////////////////////////////
 // Main program loop
 void main()
 {
 CMCON = 0x07; // To turn off comparators
 ANSEL=0;//ALL PINS DIGITAL I/O
 TRISIO=0b00001000; // only GP3 as input
  while(1) // Loop forever
 {
   if(Button(&GPIO,3,20,0)){
      GPIO=0b110111;// For PIC12F675 0bxx000000
      delay_ms(250);
      GPIO=0b000000;
      delay_ms(250);
   }
 else{
   
   // Loop from 0 to PATTERNLENGTH-1
   for(count = 0; count < PATTERNLENGTH; count++){
   // Get the next pattern and output to LEDs
      GPIO = getPattern(count);
 // Pause for the specified number of ms (up to 65535)
      delay_ms(250);
      }
   }
  }
 }
//////////////////////////////////////////////
// getPattern function: returns the index-th output pattern
 // in the desired sequence
 unsigned short int getPattern(unsigned short int index)
 {
 const unsigned short int patternArray[PATTERNLENGTH] = {
 ///////1A-moving from right to left ////////////////////
0b000001,// For each pattern in the sequence,
0b000010,// 1 = light on, 0 = off
0b000100,// Any combination of lights can be on or off
0b010000,
0b100000,
///////1B-moving from right to left ///////
0b000001,
0b000010,
0b000100,
0b010000,
0b100000,
///////////2A-moving from left to right ////////
0b100000,
0b10000,
0b000100,
0b000010,
0b000001,
///////////2B-moving from left to right ////////
0b100000,
0b010000,
0b000100,
0b000010,
0b000001,
////////////3A-moving from left to right then moving from left to right  ////////
0b000001,
0b000010,
0b000100,
0b010000,
0b100000,
0b010000,
0b000100,
0b000010,
0b000001,
//3B-moving from left to right then moving from left to right//
0b000010,
0b000100,
0b010000,
0b100000,
0b100000,
0b010000,
0b000100,
0b000010,
/*
////////4-moving from center to edges//////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b00000000,
/////////5-moving from edges to center ////////
0b10000001,
0b01000010,
0b00100100,
0b00011000,
0b00000000,
//////////6A///////////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b01000010,
0b00100100,
0b00011000,
0b00000000,
/////////////6B/////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b01000010,
0b00100100,
////////7/////////////////////
0b00000000,
0b10000000,
0b11000000,
0b11100000,
0b11110000,
0b01111000,
0b00111100,
0b00011110,
0b00001111,
0b00000111,
0b00000011,
0b00000001,
0b00000000,
//////////8///////////
0b00000000,
0b00000001,
0b00000011,
0b00000111,
0b00001111,
0b00011110,
0b00111100,
0b01111000,
0b11110000,
0b11100000,
0b11000000,
0b10000000,
0b00000000,
///////////9////////////////
0b00000001,
0b00000100,
0b00000010,
0b00001000,
0b00000100,
0b00010000,
0b00001000,
0b00100000,
0b00010000,
0b01000000,
0b00100000,
0b10000000,
0b01000000,
0b00000000,
///////////10///////////////
0b00000000,
0b01000000,
0b10000000,
0b00100000,
0b01000000,
0b00010000,
0b00100000,
0b00001000,
0b00010000,
0b00000100,
0b00001000,
0b00000010,
0b00000100,
0b00000001,
0b00000000,
///////11A////////////////////
0b11000000,
0b00110000,
0b00001100,
0b00000011,
0b00001100,
0b00110000,
0b11000000,
0b00000000,
//////////////11B////////////
0b00110000,
0b00001100,
0b00000011,
0b00001100,
0b00110000,
/////////////12///////////////////
0b00000000,
0b11000000,
0b00110000,
0b00001100,
0b00000011,
0b00000000,
/////////////13//////////////
0b00000000,
0b00000011,
0b00001100,
0b00110000,
0b11000000,
0b00000000,
//////////////14A////////////
0b00000000,
0b00001111,
0b11110000,
0b00001111,
0b11110000,
0b00000000,
///////////14B////////////////////////
0b00001111,
0b11110000,
//////////////15A////////////////////
0b00000000,
0b01010101,
0b10101010,
0b01010101,
0b10101010,
0b00000000,
////////////15B////////////////////
0b01010101,
0b10101010,
//////////////16////////////////
 0b00000001, // For each pattern in the sequence,
 0b00000011, // 1 = light on, 0 = off
 0b00000111, // Any combination of lights can be on or off
 0b00001111,
 0b00011111,
 0b00111111,
 0b01111111,
 0b11111111,
 ///////////////
 0b01111111,
 0b00111111,
 0b00011111,
 0b00001111,
 0b00000111,
 0b00000011,
 0b00000001,
 0b00000000,
 ///////////17//////////
 0b00000001, // For each pattern in the sequence,
 0b00000011, // 1 = light on, 0 = off
 0b00000111, // Any combination of lights can be on or off
 0b00001111,
 0b00011111,
 0b00111111,
 0b01111111,
 0b11111111,
 /////////////////////
 0b11111110,
 0b11111100,
 0b11111000,
 0b11110000,
 0b11100000,
 0b11000000,
 0b10000000,
 0b00000000,
 ///////////18///////////
 0b11111111, // For each pattern in the sequence,
 0b00000000, // 1 = light on, 0 = off
 0b11111111, // Any combination of lights can be on or off
 0b00000000,
 0b11111111, // NB: Length of this list must be
 0b00000000, // the same as PATTERNLENGTH
 //////////////////
 */
};
 return patternArray[index];
 }

Admin
Admin

عدد المساهمات : 1194
تاريخ التسجيل : 28/01/2014

https://fathallaabdelaziz.forumarabia.com

الرجوع الى أعلى الصفحة اذهب الى الأسفل

الرجوع الى أعلى الصفحة

- مواضيع مماثلة
» مشروع أضواء مبرمجة متحركة بعدة نماذج والميكروكونترولر PIC12F675
» المشروعات الصغيرة القابلة للتنفيذ : مشروع إنذار متعدد الأغراض بمواصفات قياسية عالمية
» مشروع قفل إلكترونى بسيط باستخدام ذاكرة EEPROM بالميكروكونترولر ولوحة مفاتيح وشاشة LCD :
» المشاريع المتوسطة : 1- مشروع عداد السرعة "التاكوميتر" Tachometer باستخدام الميكروكونترولر PIC
» مراجعة برمجة الميكروكونترولر PIC من خلال مشاريع الميكروكونترولر PIC16F877A مع الدايودات المشعة للضوء والمترجم ميكروسى برو :

 
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى