Shop OBEX P1 Docs P2 Docs Learn Events
Encoder question...clock count overflow? — Parallax Forums

Encoder question...clock count overflow?

FlyingFishFingerFlyingFishFinger Posts: 461
edited 2009-12-23 01:59 in Propeller 1
Hi-
I'm trying to set up a small program that counts the number of clock ticks that elapse between passes of a tab between an encoder. This is my first own attempt at Spin, so still learning the language. Here's what I've got:

VAR
Word ClockDiff
Word ClockInit
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
Inpin = 1
OBJ
Serial: "FullDuplexSerial"
PUB Main
Serial.start(31,30,0,9600)
DIRA[noparse][[/noparse]Inpin]~
REPEAT
if INA[noparse][[/noparse]Inpin]
ClockInit := CNT
WAITPEQ(0,|<Inpin,0)
ClockDiff := CNT - ClockInit
Serial.tx(%00000000)
Serial.dec(ClockDiff)

The problem is that I never get digits printed that are longer than 5 digits...
I'm probably missing something important here, but I'm not quite sure what.

Raf

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
UC Berkeley '12 EECS
CalSol: Berkeley Solar Car team
www.calsol.berkeley.edu
KJ6AWU

Comments

Sign In or Register to comment.