Pic 12f629 taster

Rasprava o PIC mikrokontrolerima, PIC projekti i drugo vezano za PIC-eve...

Moderators: pedja089, stojke369, [eDo], trax

Post Reply
gagi011bg
Penjem se :)
Penjem se :)
Posts: 89
Joined: 18-03-2012, 02:04

Pic 12f629 taster

Post by gagi011bg »

Pozdrav svima! :D
Napravio sam jedam program sa picom 12f629,da dimuje led diodu i jednim tasterom za prebacivanje u drugi program:

Code: Select all

steps	VAR	 word	
brzina con 02
start:
'-----------Dimovanje od 100 - 0% ---------
For steps=255 TO 200 step -1 
PWM gpio.0,STEPS,brzina
Next
gosub  taster
For steps=200 TO 150 step -1 
PWM gpio.0,STEPS,brzina
Next
gosub taster
For steps=150 TO 100 step -1 
PWM gpio.0,STEPS,brzina
Next
gosub taster
For steps=100 TO 50 step -1 
PWM gpio.0,STEPS,brzina
Next
gosub taster
For steps=50 TO 0 step -1 
PWM gpio.0,STEPS,brzina
Next

'------------------------------------- 
high gpio.0
pause 2500
'------------------------------------- 

'-----------Dimovanje od 0 - 100% ---------
For steps=0 TO 50  
PWM gpio.0,STEPS,brzina     
Next
gosub  taster
For steps=50 TO 100  
PWM gpio.0,STEPS,brzina     
Next
gosub  taster
For steps=100 TO 150  
PWM gpio.0,STEPS,brzina     
Next
gosub  taster
For steps=150 TO 200  
PWM gpio.0,STEPS,brzina     
Next
gosub  taster
For steps=200 TO 255  
PWM gpio.0,STEPS,brzina     
Next

'------------------------------------- 
low gpio.0
pause 2500
'------------------------------------- 
goto start

program_dva:
high gpio.2
pause 1000
low gpio.2
pause 1000
goto start


taster:
if gpio.1=0 then
goto program_dva
endif
return
e sad da li ima neku ideju,kada dioda dimuje od 0-100%,da li može da se kada se pritisne taster na pinu GPIO.1,
odmah prebaci u mom primeru: na program_dva.
tj.,da ne moram da čekam da dioda tek kada dodje do 0% dimovanja,
ili dalje kada krene od 100%-0% prebaci u program_dva,
nego da taster ODMAH odreaguje.

Jednostavno,kada je dioda u stanju dimovanja,pritiskom na taster,odmah prebaci na drugu labelu.

Ja sam sam probao sa naredbom GOSUB gde sam u labeli:
taster:
if gpio.1=0 then
goto program_dva
endif
return


U principu radi i ovako,napravio taster za proveru,sa razmacima od oko 50 stepova,ali ipak moram da cekam da se odradi oko 50 koraka,da se izvrši provera,imali neku ideju kako bi ovo moglo da se bolje odradi,da kada pritisnem taster odmah dodje do promene.
User avatar
Kukinjos
Pravi forumaš
Pravi forumaš
Posts: 1724
Joined: 28-03-2012, 18:01
Location: Split

Re: Pic 12f629 taster

Post by Kukinjos »

Pa moglo bi i ovako:

Code: Select all

steps   VAR    word   
brzina con 02
start:
'-----------Dimovanje od 100 - 0% ---------
For steps=255 TO 0 step -1 
if gpio.1=0 then goto program_dva
PWM gpio.0,STEPS,brzina
Next

'------------------------------------- 
high gpio.0
pause 2500
'------------------------------------- 

'-----------Dimovanje od 0 - 100% ---------
For steps=0 TO 255  
if gpio.1=0 then goto program_dva
PWM gpio.0,STEPS,brzina
Next

'------------------------------------- 
low gpio.0
pause 2500
'------------------------------------- 
goto start

program_dva:
high gpio.2
pause 1000
low gpio.2
pause 1000
goto start
Cezare, star sam i nemoćan, ali poslušaj moj savjet ....
gagi011bg
Penjem se :)
Penjem se :)
Posts: 89
Joined: 18-03-2012, 02:04

Re: Pic 12f629 taster

Post by gagi011bg »

Hvala,Kukinjos,na predlogu,nisam još stigao da probam,ali mislim da će to biti ovako ok :wink:
Post Reply