Shop OBEX P1 Docs P2 Docs Learn Events
Quadrature_Encoder object - can't seem to get things working... — Parallax Forums

Quadrature_Encoder object - can't seem to get things working...

Chris_DChris_D Posts: 305
edited 2009-02-22 20:08 in Propeller 1
I have spent the day exploring some of the objects and the Quadrature Encoder object is something I need to use on my first real project.· I wrote up the following program.....


****************************************************************************
CON
· _clkmode = xtal1 + pll16x
· _xinfreq = 5_000_000
·
VAR
······· Long Pos[noparse][[/noparse]1]··········· 'Encoder position
······· long stack[noparse][[/noparse]40]
OBJ
· SerIO: "FullDuplexSerial"
· Encoder: "Quadrature_Encoder"

PUB StartThingsUp
······ Encoder.Start(0, 1, 0, @Pos)·········· 'Start continuous two-encoder reader
······ coginit(6, MpuMcuInterface, @stack[noparse][[/noparse]20])
PUB MpuMcuInterface
''Send test messages and to Parallax Serial Terminal.
· SerIO.start(31, 30, 0, 115200)
· 'Rx pin is 31
· 'Tx pin is 30
· repeat
···
··· SerIO.str(string("Encoder Count",9))
··· SerIO.dec(Pos[noparse][[/noparse]1])
···
··· SerIO.str(string(" ", 13))
··· SerIO.str(string(" ", 13))
······· waitcnt(50000000 + cnt)

****************************************************************************
I have tried a bunch of different things to get it to work but can't seem to find the magic combination.· I have a panel mount rotary encoder connected up to the demo board on P0·& P1.· This type of encoder is also called a rotary encoder switch (volumn controls etc.).· Anyway, I have tried pull up resistors, pull down resistors, pulling to ground, pulling things up etc.· No matter what I do, the counter does not rise up.· I have checked with a VOM to make sure the signals are going from 0V to 3.3V at the various stages of rotation and that seems to be correct.

I am a newbie so keep that in mind.

Any ideas on what I am doing wrong?

Chris
···

Comments

  • Chris_DChris_D Posts: 305
    edited 2009-02-22 20:08
    Never mind...

    As is usually the case - my program was wrong.· I forgot that the array is base zero and so encoder 1 was being written to POS[noparse][[/noparse]0] and I was looking at POS[noparse][[/noparse]1].· Changed that and it appears to work now!



    Chris
Sign In or Register to comment.