Count Command skips counting intervals.
OK guys, I'm missing something easy here.·
I'm using a QTI sensor as an encoder input, counting·white sections on a black servo wheel.· The servo wheel is mounted to an RC electric motor shaft.· The motor is controlled separately via a servo exerciser and a separate power supply.·THERE IS NO connection from the motor to the the·STAMP.· ·I have a 10K resistor across the the red and white QTI leads and the QTI senses the white and black areas very wheel.
Here is the problem:· Using the COUNT command the STAMP and QTI will read several time intervals with amazing precsion.· There are 4 black and 4 white sections on the wheel and I was measuring over 1000 COUNTS in 1000 ms.··The trouble is every so often I get a COUNT value of 0 for the entire period.· NOT 1 COUNT.· Then all works fine for a few more periods (seconds) and I get another 0?· What am I missing?·
Here is meat of the "code",·all 4 lines....
DO
· INPUT 0
· QTI=IN0·············· 'Bit VAR QTI=Input into pin 0
··COUNT QTI,1000, Pulses········ 'Count QTI inputs over 1 sec and store as Pulses
· DEBUG DEC Pulses, CR
LOOP
Here is a "sample" of the out put in COUNTS per 1000 ms:
200
201
200
0
200
0
200
201
200
200
200
0
200
200
0
200
I get the same "random" type result at 50 COUNTS per second all the way up to past 1000 COUNTS per second.· Works great then 0 data, etc.
Thanks...
Steve Woodrough
·
I'm using a QTI sensor as an encoder input, counting·white sections on a black servo wheel.· The servo wheel is mounted to an RC electric motor shaft.· The motor is controlled separately via a servo exerciser and a separate power supply.·THERE IS NO connection from the motor to the the·STAMP.· ·I have a 10K resistor across the the red and white QTI leads and the QTI senses the white and black areas very wheel.
Here is the problem:· Using the COUNT command the STAMP and QTI will read several time intervals with amazing precsion.· There are 4 black and 4 white sections on the wheel and I was measuring over 1000 COUNTS in 1000 ms.··The trouble is every so often I get a COUNT value of 0 for the entire period.· NOT 1 COUNT.· Then all works fine for a few more periods (seconds) and I get another 0?· What am I missing?·
Here is meat of the "code",·all 4 lines....
DO
· INPUT 0
· QTI=IN0·············· 'Bit VAR QTI=Input into pin 0
··COUNT QTI,1000, Pulses········ 'Count QTI inputs over 1 sec and store as Pulses
· DEBUG DEC Pulses, CR
LOOP
Here is a "sample" of the out put in COUNTS per 1000 ms:
200
201
200
0
200
0
200
201
200
200
200
0
200
200
0
200
I get the same "random" type result at 50 COUNTS per second all the way up to past 1000 COUNTS per second.· Works great then 0 data, etc.
Thanks...
Steve Woodrough
·
Comments
COUNT QTI,(1000 */ $100), Pulses
Same result as before.....
QTI = IN0
This reads the STATE of input pin 0. This will be either 0 or 1 as pin 0 is low or high.
When you execute this statement at the start of your loop, and pin 0 happens to be low, then QTI is set to 0 and your COUNT statement counts pin 0 as you intend.
When you execute this statement at the start of your loop, and pin 0 happens to be high, then QTI is set to 1 and your COUNT statement counts pin 1, which is not what you intend. Then you get a zero count.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i@arrl.net
QTI PIN 0
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
So your program could be thus, and run more efficiently·-- and incidentally you'd save the byte of variable space you now use for QTI.
QTI··· PIN·· · 0
········ INPUT 0·· ' Actually this is superfluous in any case, unless you earlier used pin 0 for output
········ DO
············ COUNT QTI,1000, Pulses········ 'Count QTI inputs over 1 sec and store as Pulses
············ DEBUG DEC Pulses, CR
········ LOOP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i@arrl.net
COUNT is an amazing command. I had the motor at FULL boogie, 30,000 RPM, and got a 2005 COUNTS per second for as long as I dared. The "encoder" is a servo wheel with a drilled out RC airplane wheel collar pressed into the spline. The QTI is reading 4 white painted sections on a black wheel. Way cool. Thanks again guys!