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

أدوات الموضوع

الصورة الرمزية F.Abdelaziz
F.Abdelaziz
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,894
نشاط [ F.Abdelaziz ]
قوة السمعة:328
قديم 20-07-2013, 11:25 AM المشاركة 1   
افتراضي تقنيات الأقفال الإلكترونية مع حفظ المفتاح فى أى من الذاكرات Flash أو RAM أو EEPROM : Twitter FaceBook Google+



تقنيات الأقفال الإلكترونية مع حفظ المفتاح فى أى من الذاكرات Flash أو RAM أو EEPROM :
أولا : قفل إلكترونى بمفتاح فى ذاكرة البرنامج (الفلاش) مع تأثير صوتى ومرئى لبيان الضغط على لوحة المفاتيح :
هذا المشروع قابل للتطبيق في مجال الأمن ، فهو قفل إلكترونى ، عندما يتم إدخال 4 أرقام بشكل صحيح من لوحة المفاتيح ، فإن الميكروكونترولر PICيقوم بتشغيل ريلاى الباب ، ولكن إذا كانت الأرقام غير صحيجة فإن الميكروكونترولر يعمل على انبعاث 3 صفارة beepمشيرا إلى أن إدخال كلمة مرور خاطئة وبالطبع لا يعمل ريلاى الباب .
لجعل المشروع أكثر إثارة يتم إضافة صوت عند الضغط على المفتاح وهو ما يتيح للمستخدم معرفة أن الميكروكونترولر قد تعرف على الضغط .
أيضا يحتوى البرنامج على علاج الارتدادات ولضمان إدخال رقم واحد فى نفس الوقت .
لكن العيب الوحيد هو أن لا يمكن تغيير الأرقام ، لأن مجموعة الأرقام (1,2,3,4) يتم تسجيلها (حفظها) فى ذاكرة البرنامج .
فى المشروع القادم سوف يمكن تغيير الأرقام لتتناسب مع المستخدم ، وفى هذه الحالة فإن المشروع يعمل على تحديد وتمييز أنواع الذاكرة الثلاثة المتاحة فى الميكروكونترولر PIC .
المكونات :
· لوحة مفاتيح 4X4 .
· 6 مقاومة 4K7 .
· مقاومة 330 أوم .
· 2 ترانزستور 2N3904 .
· بزر 12 فولت .
· ريلاى 12 فولت .
· ليد أحمر 5مم .
· دايود 1N4007 .

الدائرة الكهربية :













ملحوظة :
لمنع العمل الغير صحيح نتيجة تشغيل الريلاى ، ينصح بتوصيل مكثف 0.1 uF على التوازى مع طرفى تغذية الميكروكونترولر مع وضعه فى أقرب مكان لهذه الأطراف .



البرنامج :


كود:
Device = 16F628A
Xtal=4
All_Digital=true ; switch to digital mode all port A
PortB_Pullups true
Dim num As Byte ; num :variable to store the pressed keys 
Dim r As Byte ; r : variable for repetitions
Dim buzzer As PORTA.0 ; buzzer : PORTA.1 (buzzer pin)
Dim led As PORTA.1 ; led : PORTA.2 (led pin)
Dim door As PORTA.2 ;door : portA.3 ( lock relay pin) 
Dim A As PORTB.0 ; A: row1 pin name 
Dim B As PORTB.1 ; B: row2 pin name 
Dim C As PORTB.2 ; C: row3 pin name
Dim D As PORTB.3 ; D : row4 pin name 
Dim col1 As PORTB.4 ;col1-col4 : columns pins names 
Dim col2 As PORTB.5
Dim col3 As PORTB.6
Dim col4 As PORTB.7
starting: ; led and buzzer on for 0.5sec to know it is working
High led : High buzzer ; both on 
DelayMS 500 ; wiat 0.5sec
Low led : Low buzzer ; then both off
GoTo first_key ; go to compare 1st keys
scan:
Low A ; row A low 
If col1 = 0 Then num =1 :Return ; key returns loaded with 1
If col2 = 0 Then num =2 :Return ; key returns loaded with 2
If col3 = 0 Then num =3 : Return ; key returns loaded with 3
If col4 = 0 Then num =10: Return ; key returns loaded with 10
High A ; row A high 
Low B ; row B low 
If col1 = 0 Then num =4 : Return
If col2 = 0 Then num =5 : Return
If col3 = 0 Then num =6 : Return
If col4 = 0 Then num =11: Return
High B ; row B high 
Low C ; row C Low
If col1 = 0 Then num =7 : Return
If col2 = 0 Then num =8 : Return
If col3 = 0 Then num =9 : Return
If col4 = 0 Then num =12: Return
High C ; row C high 
Low D ; row D low 
If col1= 0 Then num =14: Return
If col2 = 0 Then num =0 : Return
If col3 = 0 Then num =15: Return
If col4 = 0 Then num =13: Return
High D ; row D high 
DelayMS 10
GoTo scan
;********** program For key press effect And key debounce ****
key_press:
High led : High buzzer ; led and sound on each key press
DelayMS 100 ; 100 milliseconds duration
Low led : Low buzzer ; sound and led off
spacing: ; program key debounce
If col1 = 0 Then spacing ; if the button is pressed go to spacing
If col2 = 0 Then spacing ; if the button is pressed go to spacing
If col3 = 0 Then spacing ; if the button is pressed go to spacing
If col4 = 0 Then spacing ; if the button is pressed go to spacing
DelayMS 25
Return ; returns if you release the keys
; ***************** key comparison ************************
first_key:
GoSub scan ; go to scan and return with a key value
GoSub key_press ; sound and light effect on key pressed 
If num = 1 Then second_key ; if the number is equal to 1 go keyboards to get second_key
GoTo untrue ; Otherwise go to untrue 
second_key:
GoSub scan: GoSub key_press ; go to scan and return with a key value
If num = 2 Then third_key ; If the number is equal To 1 go keyboards To get third_key
GoTo untrue1 ; Otherwise go to untrue1
third_key:
GoSub scan :GoSub key_press ; go to scan and return with a key value
If num = 3 Then forth_key ; If the number is equal To 1 go keyboards To get forth_key
GoTo untrue2 ; Otherwise go to untrue2
forth_key:
GoSub scan :GoSub key_press ; go to scan and return with a key value
If num = 4 Then open ; if the number is equal to 4 connect relay
GoTo untrue3 ; Otherwise go to untrue3
open:
For r = 1 To 2 ; Two beeps indicates correct key
DelayMS 100
High led : High buzzer
DelayMS 100
Low led : Low buzzer
Next
High door ; connects the relay (open door)
DelayMS 5000 ; Wait 1 second
Low door ; disconnect relay
GoTo first_key ; go back to compare keys
; ***************** loops For error keys *****************
untrue:
GoSub scan :GoSub key_press ; these keys do not equate 
untrue1: ; any expected pressed key
GoSub scan :GoSub key_press ; To the End 4 keys And does nothing
untrue2:
GoSub scan :GoSub key_press
untrue3:
For r = 1 To 3 ;led and 3 beeps indicates incorrect password
DelayMS 100
High led : High buzzer
DelayMS 100
Low led : Low buzzer
Next
GoTo first_key ; go back to compare keys
End

اعلانات

الصورة الرمزية mohatvnet
mohatvnet
:: مهندس متميز ::
تاريخ التسجيل: Mar 2009
الدولة: https://t.me/pump_upp
المشاركات: 961
نشاط [ mohatvnet ]
قوة السمعة:0
قديم 20-07-2013, 11:59 AM المشاركة 2   
افتراضي


اسلام عليكم

استاد الفاضل عبد العزيز استفدت كتيرا من دروسيك بالغة الاسمبلي جزاك الله خيرا

لي سؤال ان كان ممكن

كيف يمكن ربط pic مع usb عن طريق الاسمبلي هل يوجد روابط تشرح دالك

هل ستتطرق لدالك في موضوع ما على كيفية ربط pic مع usb عن طريق الاسمبلي

اسف على طرحي لسؤال هنا نضرا لامتلاء مخزون رسائلك الخاصة لدالك لا يمكن ان ارسل رسالة خاصة لك


التعديل الأخير تم بواسطة : mohatvnet بتاريخ 20-07-2013 الساعة 12:05 PM
اعلانات اضافية ( قم بتسجيل الدخول لاخفائها )
  

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


اسلام عليكم

استاد الفاضل عبد العزيز استفدت كتيرا من دروسيك بالغة الاسمبلي جزاك الله خيرا

لي سؤال ان كان ممكن

كيف يمكن ربط pic مع usb عن طريق الاسمبلي هل يوجد روابط تشرح دالك

هل ستتطرق لدالك في موضوع ما على كيفية ربط pic مع usb عن طريق الاسمبلي

اسف على طرحي لسؤال هنا نضرا لامتلاء مخزون رسائلك الخاصة لدالك لا يمكن ان ارسل رسالة خاصة لك
أخى الكريم

شكرا جزيلا لك

بارك الله فيك وكل عام وأنت بخير

أعتذر لك لإنشغالى فى الوقت الراهن بلغة Basic والمترجم Proton .
مع تمنياتى بدوام التوفيق


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


قفل إلكترونى بمفتاح قابل للتغيير بذاكرة RAM :
هذا المشروع مشابهة جدا للمشروع السابق إلا أنه يمكنك تغيير الأرقام المحددة مسبقا للمفتاح (1,2,3,4) بأى توليفة أرقام أخرى من المفاتيح ، سوف يتم تحميل أرقام المفتاح الأصلية فى أربعة متغيرات ، وسوف تكون هناك وسيلة لتغيير قيم هذه المتغيرات مما يجعلها على النحو التالى :
بعد وضع أرقام المفتاح الأصلية (1,2,3,4) ، يجب ان نحافظ على الضغط على المفتاح D لمدة 2 ثانية ، وعلى وجه الدقة عند توصيل الريلاى بعد ثانية يوجد سؤال عن ما إذا تم الضغط على المفتاح D للذهاب إلى التسجيل ، إن لم يكن المفتاح D مضغوط ، ، فسوف تفقد الفرصة لتغيير المفتاح ويجب علينا تكرار العملية ، عندما تقوم بإدخال تغيير المفتاح يضىء الليد ويبقى مضاء فى انتظار أن تدخل الأربعة أرقام الجديدة .
من المهم أن تعرف أنه يتم تخزين المفتاح الجديد فى المتغيرات :
set_first , set_second, set_third , set_fourth، وهذه المتغيرات تأخذ مساحة فى ذاكرة RAM والتى تكون فعالة فقط عند توصيل القدرة , وبمجرد قطع القدرة يتم مسح هذه الذاكرة ، وبالتالى عند إعادة التشغيل يتم فقد المفتاح الجديد ويوجد مكانه المفتاح الأصلى (1,2,3,4)، لأن هذا المفتاح فى ذاكرة البرنامج وعند بداية التشغيل يتم تحميله على ذاكرة RAM مرة أخرى حيث يتم تغيير المفتاح منها .


الصورة الرمزية F.Abdelaziz
F.Abdelaziz
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,894
نشاط [ F.Abdelaziz ]
قوة السمعة:328
قديم 20-07-2013, 12:38 PM المشاركة 5   
افتراضي


البرنامج :


كود:
Device = 16F628A Xtal=4 All_Digital=true ; all port A switch to digital mode PortB_Pullups true
Dim num As Byte ; num :variable to store the pressed keys Dim r As Byte ; r : variable for repetitions Dim buzzer As PORTA.0 ; buzzer : PORTA.1 (buzzer pin) Dim led As PORTA.1 ; led : PORTA.2 (led pin) Dim door As PORTA.2 ;door : portA.3 ( lock relay pin)
Dim A As PORTB.0 ; A: row1 pin Dim B As PORTB.1 ; B: row2 pin Dim C As PORTB.2 ; C: row3 pin Dim D As PORTB.3 ; D : row4 pin Dim col1 As PORTB.4 ;col1-col4 the pin names of the columns Dim col2 As PORTB.5 Dim col3 As PORTB.6 Dim col4 As PORTB.7
Dim set_first As Byte ;Variable to store key 1st number Dim set_second As Byte ;Variable To store key 2nd number Dim set_third As Byte ;Variable To store key 3rd number Dim set_fourth As Byte ;Variable To store key 4th number set_first =1 set_second =2 set_third =3 set_fourth =4
Starting: ;led and buzzer to know it is working High led : High buzzer DelayMS 500 Low led : Low buzzer
GoTo first_key ; go to compare 1st key
storing: ;to change the key GoSub press_effect : High led ; GoSub scan : GoSub press_effect ;go to scan and return with a key "num" value High led ;keep LED lit set_first = num ;save the value of number to set_first store2: GoSub scan : GoSub press_effect ;go to scan and return with a key "num" value High led ;keep led lit set_second = num ;save the value of number to set_second store3: GoSub scan : GoSub press_effect ;go to scan and return with a key "num" value High led ;keep led lit set_third = num ;Save the value of number to set_third store4: GoSub scan : GoSub press_effect ;go to scan and return with a key "num" value High led ;keep LED lit set_fourth = num ;Save the value of number to set_fourth GoTo Starting ; go to beginning
scan: Low A ;rowA sensing If col1 = 0 Then num =1 :Return ;if rowA and col1 key pressed return with num = 1 If col2 = 0 Then num =2 :Return ;If rowA And col2 key pressedreturn with num = 2 If col3 = 0 Then num =3 :Return ;If rowA And col3 key pressedreturn with num = 3 If col4 = 0 Then num =10:Return ;If rowA And col4 key pressedreturn with num = 10 High A Low B ;rowB sensing If col1 = 0 Then num =4 : Return If col2 = 0 Then num =5 : Return If col3 = 0 Then num =6 : Return If col4 = 0 Then num =11: Return High B Low C ;rowC sensing If col1 = 0 Then num =7 : Return If col2 = 0 Then num =8 : Return If col3 = 0 Then num =9 : Return If col4 = 0 Then num =12: Return High C Low D ;srowD sensing If col1 = 0 Then num =14: Return If col2 = 0 Then num =0 :Return If col3 = 0 Then num =15: Return If col4 = 0 Then num =13: Return High D DelayMS 10 GoTo scan
; ***************** loops for key press effect and key debounce *************
press_effect: High led : High buzzer ;generates led lit and sound each key is pressed DelayMS 100 ;100 milliseconds duration Low led : Low buzzer ;sound and led off
spacing: ;loop For key debounce If col1 = 0 Then spacing ;If the key is pressed go spacing (wait for release) If col2 = 0 Then spacing ;If the key is pressed go spacing (Wait For release) If col3 = 0 Then spacing ;If the key is pressed go spacing (Wait For release) If col4 = 0 Then spacing ;If the key is pressed go spacing (Wait For release) DelayMS 25 ;debounce Return ;returns if you release the keys
; ***************** key comparison************************
first_key: GoSub scan ;go to scan and return with a value GoSub press_effect ;Sound and light effect On key pressed If num = set_first Then second_key ;if the number is equal to set_first GoTo untrue ;Otherwise go to loop untrue second_key: GoSub scan :GoSub press_effect ;go to scan and return with a value If num = set_second Then third_key ;If the number is equal To set_second GoTo untrue1 ;Otherwise go To loop untrue1 third_key: GoSub scan :GoSub press_effect ;go To scan And Return with A value If num = set_third Then fourth_key ;if the number is equal To set_third GoTo untrue2 ;Otherwise go To loop untrue2 fourth_key: GoSub scan :GoSub press_effect ;go To scan And Return with A value If num = set_fourth Then OPEN ;If the number is equal To set_fourth GoTo untrue3 ;Otherwise go To loop untrue3
OPEN: For r = 1 To 2 ;Two beeps indicates correct key DelayMS 100 High led : High buzzer DelayMS 100 Low led : Low buzzer Next High door ;connects the relay (open door) DelayMS 1000 ;wait 1 second Low door ;disconnect relay High A: High B :High C :Low D ;sensing only the row D If col4 = 0 Then storing ;corresponding to "D" key GoTo first_key ;go back to compare keys
; ***************** loops for error keys ***************** untrue: GoSub scan :GoSub press_effect ;these keys do not equate untrue1: ;any expected pressed key GoSub scan :GoSub press_effect ;to the End 4 keys And does nothing untrue2: GoSub scan :GoSub press_effect untrue3: For r = 1 To 3 ;3 beeps indicates incorrect password DelayMS 100 High led : High buzzer DelayMS 100 Low led : Low buzzer Next GoTo first_key ;go back to compare keys
End


عبدالله نعمان
:: مهندس متواجد ::
تاريخ التسجيل: May 2006
المشاركات: 176
نشاط [ عبدالله نعمان ]
قوة السمعة:0
قديم 10-12-2013, 12:12 PM المشاركة 6   
افتراضي


ممتاز جدااااااااااااا

إضافة رد

العلامات المرجعية

«     الموضوع السابق       الموضوع التالي    »
أدوات الموضوع

الانتقال السريع إلى


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

Powered by vBulletin® Version 3.8.6, Copyright ©2000 - 2024