please dont rip this site

PIC JAL IO Routine

Counter

by M. Yalin Duyur

With help from Rob Curtis

it is a good way to count pin_b7s but when you forget your finger on it 8)) it counts by it self I don't want it (when you count a wheels spin it is slow. ok decreasing debounce_delay works but when wheel stops on the button you couldn't see the spins count ) for my job my code is better than yours 8))

-- name    : counter.jal
-- authors : M.YALIN DUYUR & ROB CURTIS
-- date    : August 2000

include 16f84_4
include jlib
include jseven

port_b_direction = all_output
port_a_direction = all_output

var byte a, b, c, d, x
var byte pincount
var byte debounce_delay
pincount = 0
debounce_delay = 5
a = 0
b = 0
c = 0
d = 0

procedure display (byte in d4, byte in d3, byte in d2, byte in d1) is
port_a = 0b_0111
port_b = seven_from_digit (d4)
delay_1ms (5)
port_a = 0b_1011
port_b = seven_from_digit (d3)
delay_1ms (5)
port_a = 0b_1101
port_b = seven_from_digit (d2)
delay_1ms (5)
port_a = 0b_1110
port_b = seven_from_digit (d1)
delay_1ms (5)
end procedure

procedure count is
a = a + 1
if a == 10 then
a = 0
b = b + 1
end if
if b == 10 then
b = 0
c = c + 1
end if
if c == 10 then
c = 0
d = d + 1
end if
if d == 10 then
d = 0
end if
end procedure

-- Thanks ROB
procedure TestPort is
   pin_b7_direction = input
  if pin_b7 & pincount < debounce_delay  then 
    pincount = pincount + 1
    if pincount == debounce_delay  then Count end if
  else
  pincount = 0
end if

end procedure

forever loop
TestPort
display (d, c, b, a)
end loop

Questions:


file: /Techref/piclist/jal/counter-mydrb.htm, 2KB, , updated: 2005/3/15 04:02, local time: 2024/11/24 01:01,
TOP NEW HELP FIND: 
3.144.244.244:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/TECHREF/piclist/jal/counter-mydrb.htm"> PIC JAL IO Routine Counter</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .