Haberler:

Forum kuralları güncellendi LÜTFEN  okuyunuz:  https://bit.ly/2IjR3ME

Ana Menü

Pulsin Komutu Hakkında

Başlatan ugurbayoglu, 05 Ekim 2014, 01:31:30

ugurbayoglu

Arkadaşlar merhaba.Öncelikle bayramınız mübarek olsun diyerek sorunumu belirteyim.
Pbp da pulsin komutu ile puls darbesinin genişliğini ölçmeye çalışıyorum fakat sonuç tam olarak ölçemiyorum. Sonuç hareketli oluyor 123-124 gibi bunu çözmenin bir yolu var mıdır ? Vakit kaybı olmadan 10 kere okutup ortalamasını almadan ?

PORTA=0
PORTB=0
TrisA=%00000000

TrisB=%00000001


@ DEVICE pic16F628 ''islemci  16F628

@ DEVICE pic16F628, WDT_on  ''Watch Dog timer açık

@ DEVICE pic16F628, PWRT_ON  ''Power on timer açık

@ DEVICE pic16F628, PROTECT_OFF ''Kod Koruma kapalı

@ DEVICE pic16F628, MCLR_OFF  ''MCLR pini kullanılmıyor.



DEFINE OSC 16
DEFINE LCD_DREG		PORTb	
DEFINE LCD_DBIT		4		
DEFINE LCD_EREG		PORTb	
DEFINE LCD_EBIT		3		
define LCD RWREG    PORTb   
define LCD_RWBIT    2       
DEFINE LCD_RSREG	PORTb	
DEFINE LCD_RSBIT	1		
DEFINE LCD_BITS		4		
DEFINE LCD_LINES	2		

CMCON=7 


SYMBOL PULS=PORTB.0
DEGER VAR WORD

clear

Low PORTB.2		
LCDOut $FE,1	
pause 200      

BASLA: 

PULSIN PULS,1,DEGER

LCDOUT $FE,2,"Puls=" ,#DEGER


goto BASLA

END

Maxim

ete ustanın forumunda da yazmıştım
puls in komutunun hassas olabilmesi için 20mhz osc kullanmalısın.

ama işin doğrusu en hassas hali ile bile puls in komutu çok amatör kalacaktır.
doğrusu interrupt kullanmaktır.

bu verdiğim hex dosyasını bir denermisin?
16F628A ve 20mhz olacak!

:100000001F2AA101A117B400FE30DE203408DE282B
:10001000C600B71F0D282D30DE20B90F1428B80FE9
:100020001428B70A0319B70ABE01BF01C001C101F4
:10003000B7176A30B6070310B70CB80CB90CC10C6F
:10004000C00CBF0CBE0CB60F1B2839083602B9070E
:10005000B60238083702B807B702A40167202E306D
:10006000DE20C70103103E0DB9003F0DB800400D62
:10007000B700410DB600C70D0310B90DB80DB70D8F
:10008000B60DC70D3E08B9073F0803183F0FB80764
:1000900040080318400FB70741080318410FB6077F
:1000A0000318C70F0310B90DB80DB70DB60DC70D66
:1000B0004708303EDE203908BE003808BF00370848
:1000C000C0003608C100C60B312803105829A01102
:1000D0002408031D6E28A0150A30A4003908A800C2
:1000E0003808A7003708A6003608A500A301B0010C
:1000F000AF01AE010A30AD002221A30A2308240279
:10010000031D77282D08031DA011A01D8928240B8D
:100110008C282D08303EDE20A40B6E285829B20012
:10012000861186108316861186100F30860583127D
:100130003208A018B9283E30A60080301321333091
:10014000B100CD201330A60088301321CD206430BB
:100150001221CD20643012212230B100CD20283070
:10016000B8200C30B8200630B820A0143208B928C6
:100170002014B100201CC7288610033C031CCC2887
:10018000CC200730A600D03013210314080020141F
:10019000FE3C0319DC288614201C201086150F3025
:1001A00086053108F039860400008611B10E000082
:1001B0002018CD283230122132085829A11B8F284F
:1001C0000800A200841780048413A901251CA9003B
:1001D000EF2003195829EF2003195829EF28220886
:1001E000A9060130A500A601000822052906031D65
:1001F0000800A50A0319A60FF42808008317800138
:10020000840AFF3E031DFF285829AA01A900FF30D8
:10021000A907031CAA07031C58290330A600E630CF
:1002200013210729A601FC3EA500A609031C1E29CF
:10023000FF300000A50703181929A5070000A60F25
:1002400018290800BA01BB01BC01BD012130AB0077
:100250004929BA0DBB0DBC0DBD0D2D083A022E0863
:10026000031C2E0F3B022F08031C2F0F3C023008EB
:10027000031C300F3D02031C4929BD002D08BA02A2
:100280002E08031C2E0FBB022F08031C2F0FBC02CD
:100290000314A50DA60DA70DA80DAB0B29293D082C
:1002A000B0003C08AF003B08AE003A08AD0058294A
:1002B00083138312031308003F08BC004306CA00DF
:1002C000C2080319C429BE080319C7294208BE027F
:1002D0007F3003186F29BE07031CC6297229BE0789
:1002E0000318C9294108BA004008BB00BC17C3174E
:1002F0001830C900C101C001BF01802903188C2931
:1003000045083A024408031C440F3B024308031CFF
:10031000430F3C02031C97294508BA024408031CFA
:10032000440FBB024308031C430FBC020314C10D5E
:10033000C00DBF0DBA0DBB0DBC0DC90B7E29BF1B77
:10034000A929BE080319C629CA0CBE03C90ACA0DC9
:100350007E290318B7294508BA024408031C440F34
:10036000BB024308031C430FBC02031CC329C10F7B
:10037000C329C00FC329BF0FC329BF0CC00CC10CB8
:10038000BE0A0319C929D029C815CA294815BE01B2
:10039000CC29C814FF30BE00C101C0018030BF00AD
:1003A000CA1BD329BF135829C001C101CA13E729A9
:1003B000CA13C11FE729C109C009BF09BE09BE0F81
:1003C000E629BF0FE629C00A0319C10ACA179630E9
:1003D000C900C1080319F5290830C9073F08BE0044
:1003E0004008BF004108C0000A2AC008031D0A2AAD
:1003F0000830C9023F08031D062A0830C9023E081A
:10040000031D052A4108C900142ABE01C0003E0888
:10041000BF00BE01C01B122A0310BE0DBF0DC00DD0
:10042000C9030A2ACA1FC0133E08C1004908BE00FA
:100430004008C9003F08C0004908BF00582983018F
:100440004030C800A0018501860183168501013076
:100450008600073083129F000130AA00F430062185
:10046000203084006030FF20A03084005030FF2016
:10047000203084003030FE200130A500063084009A
:100480000130E1202608BF002508BE00D421410824
:10049000CE004008CD003F08CC003E08CB00C5018F
:1004A000C4017A30C3008730C2004E08C1004D0835
:1004B000C0004C08BF004B08BE005C214108CE00C4
:1004C0004008CD003F08CC003E08CB008030A100A2
:1004D000012050308F2075308F206C308F2073308A
:1004E0008F203D308F204E08B9004D08B8004C08D1
:1004F000B7004B08B600023008206D308F20533013
:0E0500008F2020308F208F208F203C2A862ACB
:02400E00423F2F
:00000001FF

siyah12

proteusta deniyosan seni yanıltabilir.
bu işin en güvenlisi portb0 kesmesi olur kanaatindeyim.



on interrupt goto kesme

disable
kesme:
a=a+1
if portb.0=x then kesme
resume
enable



kristal değerine göre a'yı hesaplarsın
bizler insanız yanılabiliriz.
iyi çalışmalar

ugurbayoglu

Evet 20 mhz de denedim daha hareketli değerler ama 16 da bi nebze daha iyi. Interput olayını da çözemedim bir türlü

siyah12

INTCON=%10010000'  RB0 Kesmesi açık
OPTION_REG.6=0 '  RB0 da düsen kenarda kesme oluşur.
'OPTION_REG.6=1 '  RB0 da yükselen kenarda kesme oluşur.

CMCON=7
PORTA=0
PORTB=0
TrisA=%00000000
TrisB=%00000001
@ DEVICE pic16F628 ''islemci  16F628
@ DEVICE pic16F628, WDT_on  ''Watch Dog timer açık
@ DEVICE pic16F628, PWRT_ON  ''Power on timer açık
@ DEVICE pic16F628, PROTECT_OFF ''Kod Koruma kapalı
@ DEVICE pic16F628, MCLR_OFF  ''MCLR pini kullanılmıyor.
DEFINE OSC 16
DEFINE LCD_DREG      PORTb   
DEFINE LCD_DBIT      4      
DEFINE LCD_EREG      PORTb   
DEFINE LCD_EBIT      3      
define LCD RWREG    PORTb   
define LCD_RWBIT    2       
DEFINE LCD_RSREG   PORTb   
DEFINE LCD_RSBIT   1      
DEFINE LCD_BITS      4      
DEFINE LCD_LINES   2      


SYMBOL PULS=PORTB.0
DEGER VAR WORD
a     var WORD
b     VAR WORD

clear
ON INTERRUPT GOTO KESME

Low PORTB.2      
LCDOut $FE,1   
pause 200     

BASLA:
'PULSIN PULS,1,DEGER
B=A*4            '4MHZ KRİSTAL İÇİN(YADA BUNU DENEYEREK BUL)
DEGER=B

LCDOUT $FE,2,"Puls=" ,#DEGER
goto BASLA


disable            '
kesme:            '
a=a+1            'PORTB.0=1 OLDUĞUNDA a YA 1 EKLE VE
if PULS=1 then kesme   'PORTB.0=1 OLDUĞU SÜRE BOYUNCA AYA 1 ARTTIRIR
INTCON.1=0         '
resume            '
enable            '
end