این مدار که خودم تست کردم و ساختنش بسیار ساده است با یک کنترل دستگاه های FM پلیر ماشین تنظیمش کردم
خروجی این مدار رو بصورت سریال تنظیم کردم تا به هر وسیله ای خیلی ساده بشه وصلش کرد
شما میتونید به جای ارسال سریال چند تا خروجی از پایه های میکرو رو بهش تعریف کنید و بجای ارسال سریال با خروجی یا I/O استفاده کنید یا هردو رو هم زمان استفاده کنید
کلید ها کاملا توی برنامه و توی خروجی مشخص هستند شما هر کلیدی رو که بزنید استم نوشته شده روی همون کلید ظاهر میشه
از نقشه ها و عکس هایی که از همین مدار هست کمک بگیرید.
http://s5.picofile.com/file/8143940418/21052013127.jpg
http://s5.picofile.com/file/8143940426/21052013128.jpg
http://s5.picofile.com/file/8143940476/21052013129.jpg
متن برنامه:
خروجی این مدار رو بصورت سریال تنظیم کردم تا به هر وسیله ای خیلی ساده بشه وصلش کرد
شما میتونید به جای ارسال سریال چند تا خروجی از پایه های میکرو رو بهش تعریف کنید و بجای ارسال سریال با خروجی یا I/O استفاده کنید یا هردو رو هم زمان استفاده کنید
کلید ها کاملا توی برنامه و توی خروجی مشخص هستند شما هر کلیدی رو که بزنید استم نوشته شده روی همون کلید ظاهر میشه
از نقشه ها و عکس هایی که از همین مدار هست کمک بگیرید.
http://s5.picofile.com/file/8143940418/21052013127.jpg
http://s5.picofile.com/file/8143940426/21052013128.jpg
http://s5.picofile.com/file/8143940476/21052013129.jpg
متن برنامه:
کد:
$regfile = "m8def.dat" $crystal = 8000000 $hwstack = 36 $baud = 9600 $swstack = 36 $framesize = 40 Config Portb.1 = Output Led Alias Portb.1 Led = 1 Config Timer0 = Timer , Prescale = 256 '8000000/256=31250 Hz Config Int1 = Falling 'Interruption on Falling Stop Timer0 Enable Timer0 Enable Int1 Enable Interrupts On Timer0 Tikers 'work on timer On Int1 Infrared 'work on interruption Dim Got As Bit Dim Tik As Word Dim Send As Byte 'counter of teaks of timer Dim Byt As Byte 'counter accepted bit Dim Repeat_flag As Bit 'flag of repetition Dim Start_flag As Bit 'flag of start condition Dim Address_1 As Byte 'direct byte of address Dim Command_1 As Byte 'direct byte of command Dim Address_0 As Byte 'indirect byte of address Dim Command_0 As Byte 'indirect byte of command Dim Summa As Word Dim Address_nec As Byte , Command_nec As Byte 'Switch Off cursor '################################################################################################################ Do 'Main cycle If Got = 1 Then '----------- If Command_nec = 162 Then Print "CH-" If Command_nec = 98 Then Print "CH" If Command_nec = 226 Then Print "CH+" If Command_nec = 34 Then Print "BACK" If Command_nec = 2 Then Print "NEXT" If Command_nec = 194 Then Print "PLAY-STOP" If Command_nec = 224 Then Print "-" If Command_nec = 168 Then Print "+" If Command_nec = 144 Then Print "EQ" If Command_nec = 104 Then Print "0" If Command_nec = 152 Then Print "FOL-" If Command_nec = 176 Then Print "FOL+" If Command_nec = 48 Then Print "1" If Command_nec = 24 Then Print "2" If Command_nec = 122 Then Print "3" If Command_nec = 16 Then Print "4" If Command_nec = 56 Then Print "5" If Command_nec = 90 Then Print "6" If Command_nec = 66 Then Print "7" If Command_nec = 74 Then Print "8" If Command_nec = 82 Then Print "9" If Command_nec = 162 Then Print "CH-" If Command_nec = 98 Then Print "CH" If Command_nec = 226 Then Print "CH+" If Command_nec = 34 Then Print "BACK" If Command_nec = 2 Then Print "NEXT" If Command_nec = 194 Then Print "PLAY-STOP" If Command_nec = 224 Then Print "-" If Command_nec = 168 Then Print "+" If Command_nec = 144 Then Print "EQ" ' If Command_nec = 104 Then ' Send = 0 ' Print Send ' End If If Command_nec = 152 Then Print "FOL-" If Command_nec = 176 Then Print "FOL+" If Command_nec = 48 Then Send = 1 End If ' Print Send 'If Command_nec = 24 Then 'Send = 2 'Print Send 'End If 'If Command_nec = 122 Then 'Send = 3 'Print Send 'End If 'If Command_nec = 16 Then 'Send = 4 'Print Send 'End If 'If Command_nec = 56 Then ' Send = 5 ' Print Send 'End If 'If Command_nec = 90 Then ' Send = 6 ' Print Send ' End If If Command_nec = 66 Then Send = 7 Print Send End If If Command_nec = 74 Then Send = 8 Print Send End If If Command_nec = 82 Then Send = 9 Print Send End If Led = 0 Waitms 50 Led = 1 Waitms 50 Reset Got End If Waitms 10 Loop End 'End of main cycle '################################################################################################################ Tikers: 'work on timer Timer0 = 253 '31250/(256-253)=10416,66 Hz (96 een) Incr Tik If Tik >= 1200 Then 'if 1200 teaks, have thrown all in source condition Tik = 0 Repeat_flag = 0 Start_flag = 0 Address_1 = 255 Command_1 = 255 Address_0 = 0 Command_0 = 0 Address_nec = 255 Command_nec = 255 Stop Timer0 End If Return '################################################################################################################ Infrared: 'work on interruption Start Timer0 If Tik >= 139 And Tik < 150 Then 'if has happenned from 139 before 150 teaks - "START" Address_nec = 1 Repeat_flag = 0 Start_flag = 1 Address_1 = 255 Command_1 = 255 Address_0 = 0 Command_0 = 0 End If If Tik >= 116 And Tik < 139 Then 'if has happenned from 116 before 138 teaks - "REPETITION" Address_nec = 0 Repeat_flag = 1 Start_flag = 0 End If If Tik >= 22 And Tik < 116 And Start_flag = 1 Then 'if has happenned from 22 before 115 teaks - have taken "1" Incr Byt If Byt < 9 Then Shift Address_1 , Left Address_1 = Address_1 + 1 End If If Byt >= 9 And Byt < 17 Then Shift Address_0 , Left Address_0 = Address_0 + 1 End If If Byt >= 17 And Byt < 25 Then Shift Command_1 , Left Command_1 = Command_1 + 1 End If If Byt >= 25 Then Shift Command_0 , Left Command_0 = Command_0 + 1 End If End If If Tik >= 10 And Tik < 22 And Start_flag = 1 Then 'if has happenned from 10 before 21 teaks - have taken "0" Incr Byt If Byt < 9 Then Shift Address_1 , Left End If If Byt >= 9 And Byt < 17 Then Shift Address_0 , Left End If If Byt >= 17 And Byt < 25 Then Shift Command_1 , Left End If If Byt >= 25 Then Shift Command_0 , Left End If End If Tik = 0 If Byt = 32 Then Address_nec = Address_1 Command_nec = Command_1 Set Got Address_1 = 255 Command_1 = 255 Byt = 0 Repeat_flag = 0 Start_flag = 0 Stop Timer0 End If Return
دیدگاه