PDA

View Full Version : Newbie question!!!



mel4853
- 3rd July 2007, 03:43
I have a program that I'm trying to make work but am having problems. This program is supposed to count how many times pin 0 goes low. I'm using a 4026 chip and here's the code. . . . . . I'm trying to see how many times a wheel goes around. I'm using a QRB1134 sensor. Any help would be greatly appreciated!!!!!

'************************************************* ***************
'* Name : WHEEL COUNTER *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2007 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 6/16/2007 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
symbol sensor=pin0
symbol counter=5
symbol reset=4
symbol CMCON=$19
symbol ANSEL=$9F
symbol TRISIO=$85

Main:
poke CMCON,$07 'shut off comparators
poke ANSEL,$00 'set to all digital
poke TRISIO,$01 'set GPIO 0 as input & GPIO 1,2,3,4,5 as output
pulsout 4,10 'reset display
B1=0 'reset counter
B3=0
Loop:
if sensor=0 then Count1
goto Loop

Count1:
B3=B3+1
if B3=2 then Clock
goto Loop

Clock:
pulsout 4,10 'reset display to 0
B1=B1+1
if B1>1 then Count 'counter
pulsout 5,10 'ditto
B3=0
return
Count:
B1=B1+1 'increment count by 1
for B2=1 to B1 'count to display
pulsout 5,10 'ditto
next B2 'ditto
B3=0
goto Loop 'return to main program

paul borgmeier
- 3rd July 2007, 05:58
maybe part of the problem - you have a "return" in your code but no "gosub"