قسم الميكروكنترولر والروبوت ودوائر الاتصال بالحاسب الالي قسم المتحكمات الـ microcontroller و المعالجات microprocessor و التحكم الرقمي بالكمبيوتر CNC والانظمة الآلية والروبوت Robots

أدوات الموضوع

heshamali
:: مهندس ::
تاريخ التسجيل: Aug 2009
المشاركات: 15
نشاط [ heshamali ]
قوة السمعة:0
قديم 12-01-2012, 04:09 PM المشاركة 1   
ha مساعدة في كود ميكروبيسك Twitter FaceBook Google+



مشكلة في ملف الميكروبيسك عايز تصحيح الكود ووضعه كملف ميكروبيسك وملف هكس نوع البيك 18f452
program hejriandmeladi
dim kp, cnt, oldstate as byte
txt as char[6]
num as byte[10]
mon,ayam ,yaom,shahr,sana as word
alf,ba,aen,waw,zay,yer ,lam,mem,non,sen,sad,fa,qaf,ra,shen,tha,qen,tta,ge n,gem,dal,kaf as longint
ta,ya ,ha,daal as float
dim rxr,rxr1,rxr2 as char[10]
dim keypadPort as byte at PORTD
dim LCD_RS as sbit at RC4_bit
LCD_EN as sbit at RC5_bit
LCD_D4 as sbit at RC0_bit
LCD_D5 as sbit at RC1_bit
LCD_D6 as sbit at RC2_bit
LCD_D7 as sbit at RC3_bit
LCD_RS_Direction as sbit at TRISC4_bit
LCD_EN_Direction as sbit at TRISC5_bit
LCD_D4_Direction as sbit at TRISC0_bit
LCD_D5_Direction as sbit at TRISC1_bit
LCD_D6_Direction as sbit at TRISC2_bit
LCD_D7_Direction as sbit at TRISC3_bit
sub procedure hejri()
if mon<=2 then
mon=mon+12
yer=yer-1
end if
gem=yer / 100
dal=yer / 400
aen=2-gem+dal
waw=floor((yer+4716)*365.25 )
zay=floor((mon+1)*30.6001 )
ha=yaom+zay+waw+aen-1524
ta=floor(ha-1937806.5)
kaf=(ta-1)/10631
lam=floor((ta+354)-10631*kaf )
mem=floor((10985-lam)/5316 )
non=floor((50*lam)/17719)
sen=floor(lam/5670)
fa=floor((43*lam)/15238)
qaf=mem*non+sen*fa
sad=floor((30-qaf)/15)
ra=floor((17719*qaf)/50)
shen=floor(qaf/16)
tta=floor((15238*qaf)/ 43)
tha=lam-(sad*ra)-(shen*tta)+29
shahr=floor((24*tha)/709)
gen=floor((709*shahr)/24)
ayam=tha-gen
sana=30*kaf+qaf-30
wordToStr(ayam,rxr)'
delay_ms(10)
wordToStr(shahr,rxr1)
delay_ms(10)
WordToStr(sana,rxr2)
ltrim(rxr)
ltrim(rxr1)
ltrim(rxr2)
Lcd_Out(2,1,"HJRI:")
delay_ms(10)
Lcd_Out(2,6,rxr)
Lcd_Out(2,8,":")
delay_ms(10)
Lcd_Out(2,9,rxr1)
Lcd_Out(2,12,":")
Lcd_Out(2,13,rxr2)

end sub
sub procedure meladi()
alf=ceil((yer-1)*354.3667)
ba=ceil((mon-1)*29.5)
gem=yaom+alf+ba+1948438
daal=(gem -1867216.25)/36524.25
aen=daal /4
if gem < 2299161 then
waw=gem
else
waw=1+gem+daal-aen
end if
zay=waw+1524
ha=floor((zay-122.1)/ 365.25)
ta=floor(ha*365.25)
ya=floor((zay-ta) / 30.6001 )
kaf=floor(ya*30.6001 )
ayam=zay-ta-kaf
if ya<14 then
shahr=ya-1
else
shahr=ya-13
end if
if shahr > 2 then
sana=ha-4716
else
sana=ha-4715
end if
wordToStr(ayam,rxr)'
delay_ms(10)
wordToStr(shahr,rxr1)
delay_ms(10)
WordToStr(sana,rxr2)
ltrim(rxr)
ltrim(rxr1)
ltrim(rxr2)
Lcd_Out(2,1,"MLDI:")
Lcd_Out(2,6,rxr)
Lcd_Out(2,8,":")
delay_ms(10)
Lcd_Out(2,9,rxr1)
Lcd_Out(2,12,":")
delay_ms(10)
Lcd_Out(2,13,rxr2)
delay_ms(10)
end sub

sub procedure con_hejri()
aa:
if cnt=2 then
yaom=num[2]+num[1]*10
if yaom >0 then
if yaom <=31 then
byteToStr(yaom, txt)
ltrim(txt)
Lcd_Cmd(_LCD_CLEAR)
Lcd_Out(1,1,"MLDI:")
Lcd_Out(1,6,txt)
Lcd_Out_cp(":")
else
Lcd_Cmd(_LCD_CLEAR)
Lcd_Out(1,1," DAY is invalid")
cnt=0
goto aa
end if
else
Lcd_Cmd(_LCD_CLEAR)
Lcd_Out(1,1," DAY is invalid")
cnt=0
goto aa
end if
end if
if cnt=4 then
mon=num[4]+num[3]*10
if mon>0 then
if mon <=12 then
if mon=2 then
if yaom>29 then
Lcd_Out(1,1," DAY is invalid")
cnt=0
goto aa
end if
end if
if mon<=7 then
if mon mod 2 = 0 then
if yaom >30 then
Lcd_Cmd(_LCD_CLEAR)
delay_ms(10)
Lcd_Out(1,1," DAY is invalid")
cnt=0
goto aa
end if
end if
end if
if mon>=8 then
if mon mod 2 <> 0 then
if yaom >30 then
Lcd_Cmd(_LCD_CLEAR)
delay_ms(10)
Lcd_Out(1,1," DAY is valid")
cnt=0
goto aa
end if
end if
end if
byteToStr(mon, txt)
ltrim(txt)
Lcd_Out(1,1,"MLDI:")
Lcd_Out(1,10,txt)
Lcd_Out_cp(":")
else
Lcd_Cmd(_LCD_CLEAR)
Lcd_Out(1,1,"MONTH is invalid")
cnt=0
goto aa
end if
else
Lcd_Cmd(_LCD_CLEAR)
Lcd_Out(1,1,"MONTH is invalid")
cnt=0
goto aa
end if
end if
if cnt<4 then
if cnt mod 2 <>0 then
byteToStr(num[cnt], txt)
Lcd_Out_cp(txt)
end if
end if
if cnt >4 then
if kp=13 then
cnt=cnt-1
if cnt=7 then
yer=num[5]*100+num[6]*10+num[7]
if (yer>621) and (yer>0) then
hejri()
else
Lcd_Cmd(_LCD_CLEAR)
Lcd_Out(1,1,"YEAR is invalid")
cnt=0
goto aa
end if
end if
else
byteToStr(num[cnt], txt)
ltrim(txt)
Lcd_Out_cp(txt)
end if
end if
if cnt=8 then
yer=1000*num[5]+100*num[6]+10*num[7]+num[8]
hejri()
end if
end sub

sub procedure con_meladi()
aa:
if cnt=2 then
yaom=num[2]+num[1]*10
if yaom >0 then
if yaom <=30 then
byteToStr(yaom, txt)
ltrim(txt)
Lcd_Cmd(_LCD_CLEAR)
Lcd_Out(1,1,"HJRI:")
Lcd_Out(1,6,txt)
Lcd_Out_cp(":")
else
Lcd_Cmd(_LCD_CLEAR)
Lcd_Out(1,1," DAY is invalid")
cnt=0
goto aa
end if
else
Lcd_Cmd(_LCD_CLEAR)
Lcd_Out(1,1," DAY is invalid")
cnt=0
goto aa
end if
end if
if cnt=4 then
mon=num[4]+num[3]*10
if mon>0 then
if mon <=12 then
byteToStr(mon, txt)
ltrim(txt)
Lcd_Out(1,10,txt)
Lcd_Out_cp(":")
else
Lcd_Cmd(_LCD_CLEAR)
Lcd_Out(1,1,"MONTH is invalid")
cnt=0
goto aa
end if
else
Lcd_Cmd(_LCD_CLEAR)
Lcd_Out(1,1,"MONTH is invalid")
cnt=0
goto aa
end if
end if
if cnt<4 then
if cnt mod 2 <>0 then
byteToStr(num[cnt], txt)
Lcd_Out_cp(txt)
end if
end if
if cnt >4 then
if kp=13 then
cnt=cnt-1
select case cnt
case 5
yer=num[5]
meladi()
case 6
yer=num[5]*10+num[6]
meladi()
case 7
yer=num[5]*100+num[6]*10+num[7]
meladi()
end select
else
byteToStr(num[cnt], txt)
ltrim(txt)
Lcd_Out_cp(txt)
end if
end if
if cnt=8 then
yer=1000*num[5]+100*num[6]+10*num[7]+num[8]
meladi()
end if
end sub
main:
oldstate = 0
cnt = 0
Keypad_Init()
Lcd_Init()
Lcd_Cmd(_LCD_CLEAR)
Lcd_Cmd(_LCD_CURSOR_OFF)
trisb.0=1
'Lcd_Out(1,1,"MLDI:")
if portb.0=1 then
Lcd_Out(1,1,"MLDI:")
end if
if portb.0=0 then
Lcd_Out(1,1,"HJRI:")
end if
while TRUE
kp = 0
while ( kp = 0 )
kp = Keypad_Key_Click()
wend
select case kp
case 5
kp = 4
case 6
kp = 5
case 7
kp = 6
case 9
kp = 7
case 10
kp = 8
case 11
kp =9
case 13
kp=13
case 14
kp = 0
case 15
kp = 35
case 16
kp = 68
end select
inc(cnt)
num[cnt]=kp
if kp=35 then
Lcd_Cmd(_LCD_CLEAR)
cnt=0
goto main
end if
if portb.0=1 then
con_hejri()
end if
if portb.0=0 then
con_meladi()
end if
wend
end.


التعديل الأخير تم بواسطة : heshamali بتاريخ 12-01-2012 الساعة 04:56 PM
اعلانات
إضافة رد

العلامات المرجعية

«     الموضوع السابق       الموضوع التالي    »
أدوات الموضوع

الانتقال السريع إلى


الساعة معتمدة بتوقيت جرينتش +3 الساعة الآن: 06:52 AM
موقع القرية الالكترونية غير مسؤول عن أي اتفاق تجاري أو تعاوني بين الأعضاء
فعلى كل شخص تحمل مسئولية نفسه إتجاه مايقوم به من بيع وشراء وإتفاق وأعطاء معلومات موقعه
التعليقات المنشورة لا تعبر عن رأي موقع القرية الالكترونية ولايتحمل الموقع أي مسؤولية قانونية حيال ذلك (ويتحمل كاتبها مسؤولية النشر)

Powered by vBulletin® Version 3.8.6, Copyright ©2000 - 2025