QTR-8RC Reflectance Sensor Array

Discussion in 'Embedded Systems and Microcontrollers' started by kaiser444, Mar 18, 2013.

  1. kaiser444

    Thread Starter New Member

    Mar 18, 2013
    9
    0
    If i use a PIC 16F877A for QTR-8RC Reflectance Sensor Array how do i program it?
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    That's a weird little sensor. It does not directly sense light in either a digital or analog sense. Here's it's detector:

    [​IMG]

    What is strange is it does not work by itself, it needs the OUT line connected to a PIC to first charge the cap (ie, the OUT is driven by the PIC), then change the PIC to an input to measure how long it takes the OUT line to discharge.

    I would not try to get all this to work in one shot: the sensors also work as go/no go so do that first. Charge the caps, but just insert some delay (50us or so) then read the OUT pins, that tells you if something is there or not (but not "how close").
     
    • QTR.GIF
      QTR.GIF
      File size:
      2.7 KB
      Views:
      101
    kaiser444 likes this.
  3. kaiser444

    Thread Starter New Member

    Mar 18, 2013
    9
    0
    Thanks, do you know how i can control the speed of motors using a motor driver L293D using PWM in Mikrobasic pro?
     
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    No I do not.
     
  5. kaiser444

    Thread Starter New Member

    Mar 18, 2013
    9
    0
    Is it possible to measure the discharge time with a digital I/O pin?
     
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    Yep.

    First set up a counter with a fast clock.

    Next drive the I/O line as output high. This charges the cap to make a high signal.

    Then reset the counter.

    Then change the I/O to input.

    Loop till the I/O pin discharges and reads low. Then stop counter and read count.
     
    kaiser444 likes this.
  7. kaiser444

    Thread Starter New Member

    Mar 18, 2013
    9
    0
    So if i understood well, i fuzzify the number of count to know the degree of whiteness. Is that it?
     
  8. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    Yep. Somehow you need to calibrate that value. Either a limit above is nothing there below is something, or perhaps the number may lead to a distance.

    But with 8 parallel sensors just go/no go should let you know the story.
     
  9. kaiser444

    Thread Starter New Member

    Mar 18, 2013
    9
    0
    Do you think i should connect the LEDON pin?
    I dont want to use the option of switching on and off the LED but i am thinking if i dont connect it, the LED wont be on
     
  10. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    Yes, connect it. That turns the led ON, useful to make a detection <grin>.

    Flashing the LEDON pin allows you to detect false positives.
     
  11. kaiser444

    Thread Starter New Member

    Mar 18, 2013
    9
    0
    Do you know an email where i can ask questions about PIC16F877A?
     
  12. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
  13. kaiser444

    Thread Starter New Member

    Mar 18, 2013
    9
    0
    I posted my problem there. They told me that the PIC16F877A does not have enough timer to measure the discharge time of each capacitor. Is there no way i can read the readings of the sensor array?
     
  14. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,394
    1,606
    Huh?

    How long does it take to discharge a 10nF cap?
     
  15. kaiser444

    Thread Starter New Member

    Mar 18, 2013
    9
    0
    A maximum of 10ms. I mean it does not have enough timer to measure the 8 discharge times at the same time
     
Loading...