PENGATURAN KECEPATAN MOTOR DC Berbasis Atmega8535
Skema dengan proteus:
Hasil simulasi dengan proteus:
Program Pengaturan Kecepatan Motor DC dengan Bascom AVR
semoga bermanfaat untuk semua kalangan ,,,..$regfile = “m8535.dat” ‘menggunakan Atmega8535 sebagai preprosesor$crystal = 12000000 ‘menggunakan crystal clock 12 MHz$eeprom ‘menggunakan fasilitas eeprom Atmega8535‘—————————inisialisasi lcd————————————Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.2 , Rs = Portc.0Config Lcd = 16 * 2 : Cursor Off‘—————————inisialisasi pwm———————————–Config Timer1 = Pwm , Pwm = 10 , Prescale = 64 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up ‘pwm dengan settingan fast pwm 10 bit‘—————————inisialisasi port——————————–‘inisialisasi tombolConfig Portb = Input‘—————————pull up internal——————————–Portb.0 = 1Portb.1 = 1Portb.2 = 1Portb.3 = 1Config Portd = Output‘alias logika motorM1a Alias Portd.0M1b Alias Portd.1M2a Alias Portd.2M2b Alias Portd.3‘——————————alias——————————————–‘alias tombolSw_ok Alias Pinb.3Sw_cancel Alias Pinb.2Sw_down Alias Pinb.1Sw_up Alias Pinb.0‘——————————————————————————-Dim Pwm As IntegerDim Pwm_eprom As Eram IntegerHomeLcd “Fahmizal_dte2006″LowerlineLcd “Cek fungsi PWM”Wait 1DoPwm = Pwm_epromIf Sw_up = 0 Then : Incr Pwm : Waitms 10End IfIf Sw_down = 0 Then : Decr Pwm : Waitms 10End IfIf Pwm > 1023 Then : Pwm = 0 : Waitms 10End IfIf Pwm < 0 Then : Pwm = 1023 : Waitms 10End IfPwm_eprom = PwmClsHomeLcd “tes uji pwm”LowerlineReset M1aReset M2aSet M1bSet M2bPwm1a = PwmPwm1b = PwmLcd “nilai pwm:” ; Pwm1a : Waitms 100LoopEnd
Tidak ada komentar:
Posting Komentar