ايران ويج

نسخه‌ی کامل: كمك در مورد برنامه روبات تعقيب خط
شما در حال مشاهده‌ی نسخه‌ی متنی این صفحه می‌باشید. مشاهده‌ی نسخه‌ی کامل با قالب بندی مناسب.
دوستان توروخدا كمك كنين مشكلم خيلي اضطراريه
برنامه روباتو نوشتيم (فكر كنم درست نباشه)و پروگرام كرديم ولي وقتي ميكرو رو به روبات وصل ميكنيم هيچ عملي اتفاق نميفته. برنامه رو توي بسكام با زبان بيسيك نوشتيم. البته اينم بگم كه اين اولين باره كه برنامه نويسي ميكنيمWhistle
به هر حال ممنون ميشم كمك كنين
اينم خود برنامه:
$prog &HFF , &HC4 , &H99 , &H00
$regfile = M32def.det
$crystal = 8000000
'******************************
Config Porta = Input
Config Portd = Output
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 1
'*****************************
N Alias Pina.0
H Alias Pina.1
B Alias Pina.2
Y Alias Pina.3
G Alias Pina.4
V Alias Pina.5
S Alias Pina.6
Lmj Alias Pind.1
Lma Alias Pind.6
Rmj Alias Pind.3
Rma Alias Pind.2
'*****************************
Declare Sub Jelo
Declare Sub Chap
Declare Sub Rast
Declare Sub Jelo2
Declare Sub Chap2
Declare Sub Rast2
'*****************************
Do

If Y = 1 And B = 1 And G = 1 And V = 1 And H = 1 And N = 1 Then Call Jelo
If Y = 0 And B = 0 And G = 1 And V = 1 And H = 1 And N = 1 Then Call Jelo
If Y = 0 And B = 1 And G = 1 And V = 1 And H = 1 And N = 1 Then Call Jelo2
If B = 0 And Y = 1 And G = 1 And V = 1 And H = 1 And N = 1 Then Call Jelo2
If B = 0 And H = 0 And G = 1 And V = 1 And Y = 1 And N = 1 Then Call Rast2
If B = 0 And G = 0 And Y = 1 And V = 1 And H = 1 And N = 1 Then Call Chap2
If B = 0 And N = 0 And G = 1 And V = 1 And H = 1 And Y = 1 Then Call Rast
If B = 0 And V = 0 And G = 1 And Y = 1 And H = 1 And N = 1 Then Call Chap
If B = 1 And V = 1 And G = 0 And Y = 1 And H = 1 And N = 1 Then Call Chap2
If B = 1 And V = 0 And G = 1 And Y = 1 And H = 1 And N = 1 Then Call Chap2
If B = 1 And V = 1 And G = 1 And Y = 1 And H = 0 And N = 1 Then Call Rast2
If B = 1 And V = 1 And G = 1 And Y = 1 And H = 1 And N = 0 Then Call Rast2
If B = 1 And V = 0 And G = 0 And Y = 1 And H = 1 And N = 1 Then Call Chap2
If B = 1 And V = 1 And G = 1 And Y = 1 And H = 0 And N = 0 Then Call Rast2
If Y = 0 And B = 1 And G = 0 And V = 0 And H = 1 And N = 1 Then Call Chap2
If Y = 0 And B = 1 And G = 1 And V = 1 And H = 0 And N = 0 Then Call Rast2
If Y = 1 And B = 0 And G = 1 And V = 0 And H = 0 And N = 1 Then Call Chap2
If Y = 1 And B = 0 And G = 0 And V = 1 And H = 1 And N = 0 Then Call Rast2
If Y = 0 And B = 1 And G = 0 And V = 1 And H = 1 And N = 1 Then Call Chap2
If Y = 0 And B = 1 And G = 1 And V = 1 And H = 0 And N = 1 Then Call Rast2

If Y = 0 And B = 0 And G = 0 And V = 0 And H = 0 And N = 0 Then Call Jelo
If Y = 1 And B = 1 And G = 0 And V = 0 And H = 0 And N = 0 Then Call Jelo
If Y = 1 And B = 0 And G = 0 And V = 0 And H = 0 And N = 0 Then Call Jelo2
If B = 1 And Y = 0 And G = 0 And V = 0 And H = 0 And N = 0 Then Call Jelo2
If B = 1 And H = 1 And G = 0 And V = 0 And Y = 0 And N = 0 Then Call Rast2
If B = 1 And G = 1 And Y = 0 And V = 0 And H = 0 And N = 0 Then Call Chap2
If B = 1 And N = 1 And G = 0 And V = 0 And H = 0 And Y = 0 Then Call Rast
If B = 1 And V = 1 And G = 0 And Y = 0 And H = 0 And N = 0 Then Call Chap [/php][/code]
If B = 0 And V = 0 And G = 1 And Y = 0 And H = 0 And N = 0 Then Call Chap2
If B = 0 And V = 1 And G = 0 And Y = 0 And H = 0 And N = 0 Then Call Chap2
If B = 0 And V = 0 And G = 0 And Y = 0 And H = 1 And N = 0 Then Call Rast2
If B = 0 And V = 0 And G = 0 And Y = 0 And H = 0 And N = 1 Then Call Rast2
If B = 0 And V = 1 And G = 1 And Y = 0 And H = 0 And N = 0 Then Call Chap2
If B = 0 And V = 0 And G = 0 And Y = 0 And H = 1 And N = 1 Then Call Rast2
If Y = 1 And B = 0 And G = 1 And V = 1 And H = 0 And N = 0 Then Call Chap2
If Y = 1 And B = 0 And G = 0 And V = 0 And H = 1 And N = 1 Then Call Rast2
If Y = 0 And B = 1 And G = 0 And V = 1 And H = 1 And N = 0 Then Call Chap2
If Y = 0 And B = 1 And G = 1 And V = 0 And H = 0 And N = 1 Then Call Rast2
If Y = 1 And B = 0 And G = 1 And V = 0 And H = 0 And N = 0 Then Call Chap2
If Y = 1 And B = 0 And G = 0 And V = 0 And H = 1 And N = 0 Then Call Rast2

Loop
End
'*****************************
Sub Jelo
Lmj = 1
Rmj = 1
Lma = 0
Rma = 0
Pwm1a = 1000
Pwm1b = 1000
Return
End Sub
'*****************************
Sub Jelo2
Lmj = 1
Rmj = 1
Lma = 0
Rma = 0
Pwm1a = 500
Pwm1b = 500
Return
End Sub
'*****************************
Sub Chap
Lmj = 0
Rmj = 1
Lma = 0
Rma = 0
Pwm1a = 1000
Pwm1b = 1000
Waitms 500
Return
End Sub
'*****************************
Sub Chap2
Lmj = 1
Rmj = 1
Lma = 0
Rma = 0
Pwm1a = 250
Pwm1b = 500
Waitms 500
Return
End Sub
'*****************************
Sub Rast
Lmj = 1
Rmj = 0
Lma = 0
Rma = 0
Pwm1a = 1000
Pwm1b = 1000
Waitms 500
Return
End Sub
'*****************************
Sub Rast2
Lmj = 1
Rmj = 1
Lma = 0
Rma = 0
Pwm1a = 500
Pwm1b = 250
Waitms 500
Return
End Sub
'*****************************
End
سلام دوسته گلم.
من برنامه ی شمارو نگاه کردم.
یک سری ایراد ها داشت که اونارو برطرف کردم.
اما چون مدارتو ندیدم نمیتونم در مورد دستورا if و pwm ها نظری بدم ولی درکل دیگه مشکلی نداره.
بعدشم خیلی کار خودتو سخت کردی نیازی به این همه And نیس برنامه میتونه خیلی ساده تر از این هم نوشته شه ولی حتما صلاح دونستی که این برنامه رو اینطوری نوشتی.ولی بیشتر رو دور موتور ها کار کن.
اینم برنامه اصلاح شده:
کد:
$regfile = "m32def.dat"
$crystal = 8000000
'******************************
Config Porta = Input
Config Portd = Output
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 1
'*****************************
N Alias Pina.0
H Alias Pina.1
B Alias Pina.2
Y Alias Pina.3
G Alias Pina.4
V Alias Pina.5
S Alias Pina.6
Lmj Alias Pind.1
Lma Alias Pind.6
Rmj Alias Pind.3
Rma Alias Pind.2
'*****************************
Declare Sub Jelo
Declare Sub Chap
Declare Sub Rast
Declare Sub Jelo2
Declare Sub Chap2
Declare Sub Rast2
'*****************************
Do
If Y = 1 And B = 1 And G = 1 And V = 1 And H = 1 And N = 1 Then Call Jelo
If Y = 0 And B = 0 And G = 1 And V = 1 And H = 1 And N = 1 Then Call Jelo
If Y = 0 And B = 1 And G = 1 And V = 1 And H = 1 And N = 1 Then Call Jelo2
If B = 0 And Y = 1 And G = 1 And V = 1 And H = 1 And N = 1 Then Call Jelo2
If B = 0 And H = 0 And G = 1 And V = 1 And Y = 1 And N = 1 Then Call Rast2
If B = 0 And G = 0 And Y = 1 And V = 1 And H = 1 And N = 1 Then Call Chap2
If B = 0 And N = 0 And G = 1 And V = 1 And H = 1 And Y = 1 Then Call Rast
If B = 0 And V = 0 And G = 1 And Y = 1 And H = 1 And N = 1 Then Call Chap
If B = 1 And V = 1 And G = 0 And Y = 1 And H = 1 And N = 1 Then Call Chap2
If B = 1 And V = 0 And G = 1 And Y = 1 And H = 1 And N = 1 Then Call Chap2
If B = 1 And V = 1 And G = 1 And Y = 1 And H = 0 And N = 1 Then Call Rast2
If B = 1 And V = 1 And G = 1 And Y = 1 And H = 1 And N = 0 Then Call Rast2
If B = 1 And V = 0 And G = 0 And Y = 1 And H = 1 And N = 1 Then Call Chap2
If B = 1 And V = 1 And G = 1 And Y = 1 And H = 0 And N = 0 Then Call Rast2
If Y = 0 And B = 1 And G = 0 And V = 0 And H = 1 And N = 1 Then Call Chap2
If Y = 0 And B = 1 And G = 1 And V = 1 And H = 0 And N = 0 Then Call Rast2
If Y = 1 And B = 0 And G = 1 And V = 0 And H = 0 And N = 1 Then Call Chap2
If Y = 1 And B = 0 And G = 0 And V = 1 And H = 1 And N = 0 Then Call Rast2
If Y = 0 And B = 1 And G = 0 And V = 1 And H = 1 And N = 1 Then Call Chap2
If Y = 0 And B = 1 And G = 1 And V = 1 And H = 0 And N = 1 Then Call Rast2

If Y = 0 And B = 0 And G = 0 And V = 0 And H = 0 And N = 0 Then Call Jelo
If Y = 1 And B = 1 And G = 0 And V = 0 And H = 0 And N = 0 Then Call Jelo
If Y = 1 And B = 0 And G = 0 And V = 0 And H = 0 And N = 0 Then Call Jelo2
If B = 1 And Y = 0 And G = 0 And V = 0 And H = 0 And N = 0 Then Call Jelo2
If B = 1 And H = 1 And G = 0 And V = 0 And Y = 0 And N = 0 Then Call Rast2
If B = 1 And G = 1 And Y = 0 And V = 0 And H = 0 And N = 0 Then Call Chap2
If B = 1 And N = 1 And G = 0 And V = 0 And H = 0 And Y = 0 Then Call Rast
If B = 1 And V = 1 And G = 0 And Y = 0 And H = 0 And N = 0 Then Call Chap
If B = 0 And V = 0 And G = 1 And Y = 0 And H = 0 And N = 0 Then Call Chap2
If B = 0 And V = 1 And G = 0 And Y = 0 And H = 0 And N = 0 Then Call Chap2
If B = 0 And V = 0 And G = 0 And Y = 0 And H = 1 And N = 0 Then Call Rast2
If B = 0 And V = 0 And G = 0 And Y = 0 And H = 0 And N = 1 Then Call Rast2
If B = 0 And V = 1 And G = 1 And Y = 0 And H = 0 And N = 0 Then Call Chap2
If B = 0 And V = 0 And G = 0 And Y = 0 And H = 1 And N = 1 Then Call Rast2
If Y = 1 And B = 0 And G = 1 And V = 1 And H = 0 And N = 0 Then Call Chap2
If Y = 1 And B = 0 And G = 0 And V = 0 And H = 1 And N = 1 Then Call Rast2
If Y = 0 And B = 1 And G = 0 And V = 1 And H = 1 And N = 0 Then Call Chap2
If Y = 0 And B = 1 And G = 1 And V = 0 And H = 0 And N = 1 Then Call Rast2
If Y = 1 And B = 0 And G = 1 And V = 0 And H = 0 And N = 0 Then Call Chap2
If Y = 1 And B = 0 And G = 0 And V = 0 And H = 1 And N = 0 Then Call Rast2

Loop
End
'*****************************
Sub Jelo
Lmj = 1
Rmj = 1
Lma = 0
Rma = 0
Pwm1a = 1000
Pwm1b = 1000
Return
End Sub
'*****************************
Sub Jelo2
Lmj = 1
Rmj = 1
Lma = 0
Rma = 0
Pwm1a = 500
Pwm1b = 500
Return
End Sub
'*****************************
Sub Chap
Lmj = 0
Rmj = 1
Lma = 0
Rma = 0
Pwm1a = 1000
Pwm1b = 1000
Waitms 500
Return
End Sub
'*****************************
Sub Chap2
Lmj = 1
Rmj = 1
Lma = 0
Rma = 0
Pwm1a = 250
Pwm1b = 500
Waitms 500
Return
End Sub
'*****************************
Sub Rast
Lmj = 1
Rmj = 0
Lma = 0
Rma = 0
Pwm1a = 1000
Pwm1b = 1000
Waitms 500
Return
End Sub
'*****************************
Sub Rast2
Lmj = 1
Rmj = 1
Lma = 0
Rma = 0
Pwm1a = 500
Pwm1b = 250
Waitms 500
Return
End Sub
موفق باشی....
داداش ممنون از كمكت ولي مشل اينجاس كه وقتي ميكرو رو به روبات وصل ميكنم پايه هاي اينپوت درايور رو (lmj-rmj-lma-rma)رو وصل نميكنه به عبارتي موتور هارو راه نميندازه ولي پايه هاي اينيبل درست كار ميكنن (rme-lme) در ضمن به نظرتون اون pwm رو درست نوشتم؟‌موتور هام 600 RPM اند!
در ضمن اون AND هارو هم كه گفتم تازه كام ;)
بازم ممنون از كمكتون Rolleyes
خواهش میکنم دادش.
از چه درایوری استفاده میکنی؟
اگه pcb و شماتیک مدارتو بدی راحت تر به نتیجه میرسیما
(۱۳-شهریور-۱۳۹۱, ۱۵:۵۱:۱۱)h.unique نوشته است: [ -> ]خواهش میکنم دادش.
از چه درایوری استفاده میکنی؟
اگه pcb و شماتیک مدارتو بدی راحت تر به نتیجه میرسیما

از درايور L293 و نقشه شماتيك كه شرمنده ندارم Whistle
ولي ميتونم اينو بگم كه (lmj-left motor jelo,,rmj=right motor jeloWhistle)
ولي نقشه پي سي بي حتماً‌، بفرماييد تو پيوست ميزارم براتون :
عزیز دلم به نظر خودت من چطور پایه هارو تشخیص بدم؟
(۱۳-شهریور-۱۳۹۱, ۱۷:۳۳:۲۹)h.unique نوشته است: [ -> ]عزیز دلم به نظر خودت من چطور پایه هارو تشخیص بدم؟

آقا واقعاً‌ممنون از كمكت عكسارو هم درست كردم Rolleyes
داشی اصلا منظورمنو متوجه نشیدی.من میگم این پایه هارو چطور از هم تشخیص بدم.
تا شماتیک نزاری نمیتونم کاری واست انجام بدم.(نه من و نه هیچ کسه دیگه ای)
موفق باشی...