'LCD'ler
DEFINE OSC 4
DEFINE LCD_LINES 2
Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTb
Define LCD_RSBIT 1
Define LCD_EREG PORTb
Define LCD_EBIT 0
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
'Motor Hiz
DEFINE CCP1_REG PORTC 'Hpwm 1 pin port
DEFINE CCP1_BIT 2 'Hpwm 1 pin bit
DEFINE CCP2_REG PORTC 'Hpwm 2 pin port
DEFINE CCP2_BIT 1 'Hpwm 2 pin bit
DEFINE HPWM2_TIMER 1 'Hpwm 2 timer select
DEFINE HPWM3_TIMER 1 'Hpwm 3 timer select
'********************************
'Butonlar
input porte.0
input porte.1
input porte.2
input portb.5
'Motor1
output portd.0
output portd.1
output portd.2
output portc.0
'********************************
ADCON1=4
TRISA = %00001011
CMCON=7
a var byte
b var byte
x var byte
y var byte
Yon var byte
x=0
y=0
'********************************
low portd.0
low portd.1
low portd.2
low portc.0
pause 500 'LCD Ekranin acilmasi icin gereken sure
baslama:
low portd.0
low portd.1
low portd.2
low portc.0
Lcdout $fe, 1, "Hiz Kontrol"
LCDOut 254,192
LCDOut "Cift Yon PWM"
pause 750
Hiz:
HPWM 1,x,2000
HPWM 2,y, 2000
if porte.0=0 then
x = x +1
Y = y +1
Lcdout $fe, 1, "Hiz Degeri"
LCDOut 254,192
LCDOut "Hiz:", #x, "/255"
pause 200
endif
if porte.1=0 then
x = x - 1
Y = y - 1
Lcdout $fe, 1, "Hiz Degeri"
LCDOut 254,192
LCDOut "Hiz:", #x, "/255"
pause 200
endif
if portb.5=0 then
low portd.0
low portd.1
low portd.2
low portc.0
Lcdout $fe, 1, "Duruyor"
LCDOut 254,192
LCDOut "10 SN Durma"
pause 10000
endif
if Porte.2=0 then
Lcdout $fe, 1, "Ileri Donus"
LCDOut 254,192
LCDOut "Hiz:", #x, "/255"
pause 200
low portd.0
high portd.1
low portd.2
high portc.0
else
Lcdout $fe, 1, "Geri Donus"
LCDOut 254,192
LCDOut "Hiz:", #x, "/255"
high portd.0
low portd.1
high portd.2
low portc.0
pause 1
endif
goto hiz