go_away

Author Topic: QTR-1RC Reflectance Sensor  (Read 2306 times)

0 Members and 1 Guest are viewing this topic.

Offline ccdjr106Topic starter

  • Full Member
  • ***
  • Posts: 62
  • Helpful? 0
QTR-1RC Reflectance Sensor
« on: February 14, 2010, 12:49:48 PM »
http://www.pololu.com/catalog/product/959 i bought this sensor because i thought i would be able to use it for edge detection.  is this possible ??
if soo can somebody give me some sample code. im using a arduino.

Offline Razor Concepts

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
Re: QTR-1RC Reflectance Sensor
« Reply #1 on: February 14, 2010, 01:21:15 PM »
What kind of "edge" are you detecting? Edge of an object? Edge of some tape? etc etc

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: QTR-1RC Reflectance Sensor
« Reply #2 on: February 14, 2010, 01:35:08 PM »
Hi,

[...] i thought i would be able to use it for edge detection.  is this possible ??
Possible yes, but a little tedious to work with IMO.


if soo can somebody give me some sample code. im using a arduino.
First off, their description on how it is used with the schematic on the page is wrong.

Quote
Interfacing the QTR-1RC Output to a Digital I/O Line
Like the Parallax QTI, the QTR-1RC module has sensor outputs that require a digital I/O line capable of first charging the output capacitor (by driving the line high) and then measuring the time for the capacitor to discharge through the phototransistor. This measurement approach has several advantages, especially when multiple units are used:
It's the exact contrary.
You set the I/O port to output and set it high to discharge the capacitor and then set it to input and measure the time taken until the port reads low, by charging the capacitor through the phototransistor (with a current that will depend on amount of incoming light and hence the speed).
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline ccdjr106Topic starter

  • Full Member
  • ***
  • Posts: 62
  • Helpful? 0
Re: QTR-1RC Reflectance Sensor
« Reply #3 on: February 14, 2010, 06:59:28 PM »
how do i measure the time it takes to discharge the capacitor

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,942
  • Helpful? 98
Re: QTR-1RC Reflectance Sensor
« Reply #4 on: February 14, 2010, 07:59:31 PM »
how do i measure the time it takes to discharge the capacitor
A software loop with a counter.

Code: [Select]
loop:
   if input is high
       increment counter
       goto loop
   else
       return counter

Offline ccdjr106Topic starter

  • Full Member
  • ***
  • Posts: 62
  • Helpful? 0
Re: QTR-1RC Reflectance Sensor
« Reply #5 on: February 14, 2010, 08:21:15 PM »
can you plz give me some real code

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,942
  • Helpful? 98
Re: QTR-1RC Reflectance Sensor
« Reply #6 on: February 15, 2010, 08:29:17 AM »
can you plz give me some real code

Like this:
Code: [Select]
cblock 0x100
counter
endb

#define sensor PORTB, 1

; function to measure the sensor value
; value is stored in the variable counter
Get_sensor_value:  
  clrf counter
loop:
  btfss sensor     ; if sensor is high the increment counter
  goto exit         ; else have count so exit
  incf counter, f
  goto loop
exit:
  return
  

Or do you want code in another language and for a different processor?
I gave you pseudo code to show the logic so you can write it for your processor.
« Last Edit: February 15, 2010, 08:50:41 AM by waltr »

Offline ccdjr106Topic starter

  • Full Member
  • ***
  • Posts: 62
  • Helpful? 0
Re: QTR-1RC Reflectance Sensor
« Reply #7 on: February 15, 2010, 09:23:35 AM »
ummm i dont really know what language it is  but im using a arduino duemilanove

 


Get Your Ad Here