Shop OBEX P1 Docs P2 Docs Learn Events
Pic & qti — Parallax Forums

Pic & qti

crashercrasher Posts: 1
edited 2010-11-21 12:49 in Accessories
Does any one knows how to use QTI sensor with a PIC?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-11-21 12:49
    We can't help you with the actual PIC programming. That you'll have to do yourself.

    There's a simple example of the use of a QTI sensor with a Stamp in the QTI sensor documentation. It uses two I/O pins and the Stamp Basic statements HIGH, LOW, and RCTIME. HIGH and LOW are straightforward to do with any microprocessor including the PICs. They simply set the selected I/O pin to a one or a zero respectively when the I/O pin is set for output mode. The RCTIME statement simply measures the time that the specified I/O pin remains in the state specified (high or low). The 2nd parameter is the state to be measured. The BS2 measures this in units of 2us, but any unit will do as long as it fits what you're trying to do with your program.

    Typically, with a microprocessor like the PIC, to do the RCTIME, you'd wait for the I/O pin to have the "on" state, then drop into a loop that does a 2us delay, checks the I/O pin, increments a 16-bit counter, and jumps back in the loop if the I/O pin is still in the "on" state. It's pretty simple.
Sign In or Register to comment.