سلام دوستان .
من یه روبات مسیریاب ساختم که وقتی می خوام برامه pwm رو روش اعمال کنم قاطی میکنه و یکی از موتورا آروم می چرخه و یکی تند . یا یه سنسور که وارد برنامه می کنم همین مشکل پیش می یاد .
اینم نمونه ساده برنامه با بسکام :
Loop
End 'end program
من یه روبات مسیریاب ساختم که وقتی می خوام برامه pwm رو روش اعمال کنم قاطی میکنه و یکی از موتورا آروم می چرخه و یکی تند . یا یه سنسور که وارد برنامه می کنم همین مشکل پیش می یاد .
اینم نمونه ساده برنامه با بسکام :
$regfile = "m16def.dat"
$crystal = 8000000
Config Lcdpin = Pin Db4 = Pinb.4 , Db5 = Pinb.5 , Db6 = Pinb.6 , Db7 = Pinb.7 , Rs = Pinb.2 , E = Pinb.3 : Config Lcdpin = 16 * 2
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 1
Config Porta = Input : Config Portd = Output
Cursor Off
Locate 1 , 2 : Lcd "In The Name Of" : Locate 2 , 7 : Lcd "God"
Wait 2
Do
If Pina.7 = 1 Then
Set Portd.0
Reset Portd.1
Set Portd.2
Reset Portd.3
Pwm1a = 1000
Else
Reset Portd.0
Reset Portd.1
Reset Portd.2
Reset Portd.3
Pwm1b = 1000
End If
If Pina.5 = 1 And Pina.7 = 0 Then
Set Portd.0
Reset Portd.1
Reset Portd.2
Set Portd.3
Pwm1a = 1000
Else
Reset Portd.0
Reset Portd.1
Reset Portd.2
Reset Portd.3
Pwm1b = 1000
End If
If Pina.6 = 1 And Pina.7 = 0 Then
Reset Portd.0
Set Portd.1
Set Portd.2
Reset Portd.3
Pwm1a = 1000
Else
Reset Portd.0
Reset Portd.1
Reset Portd.2
Reset Portd.3
Pwm1b = 1000
[/right]End If$crystal = 8000000
Config Lcdpin = Pin Db4 = Pinb.4 , Db5 = Pinb.5 , Db6 = Pinb.6 , Db7 = Pinb.7 , Rs = Pinb.2 , E = Pinb.3 : Config Lcdpin = 16 * 2
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 1
Config Porta = Input : Config Portd = Output
Cursor Off
Locate 1 , 2 : Lcd "In The Name Of" : Locate 2 , 7 : Lcd "God"
Wait 2
Do
If Pina.7 = 1 Then
Set Portd.0
Reset Portd.1
Set Portd.2
Reset Portd.3
Pwm1a = 1000
Else
Reset Portd.0
Reset Portd.1
Reset Portd.2
Reset Portd.3
Pwm1b = 1000
End If
If Pina.5 = 1 And Pina.7 = 0 Then
Set Portd.0
Reset Portd.1
Reset Portd.2
Set Portd.3
Pwm1a = 1000
Else
Reset Portd.0
Reset Portd.1
Reset Portd.2
Reset Portd.3
Pwm1b = 1000
End If
If Pina.6 = 1 And Pina.7 = 0 Then
Reset Portd.0
Set Portd.1
Set Portd.2
Reset Portd.3
Pwm1a = 1000
Else
Reset Portd.0
Reset Portd.1
Reset Portd.2
Reset Portd.3
Pwm1b = 1000
Loop
End 'end program
دیدگاه