Presentation about IR reading

Hi team

I have to do a presentation in my university about IR sensor and accurate reading. I have red few articles in which I did not got good sense, few friends of students poi tout about pololu but I could not

Can you please help me about some article in this website to read me and follow
Thanks in advanced
Pasindu

Hi Pasindu,
That’s a big topic. Are you interested in IR sensors used for obstacle detection, or IR communication or the effects that the environment has on accurate distance measurement, or …?

You might start with the data sheets for the Vishay TSSP58038 and TSSP58P38 IR receivers. Vishay also has an application note on using a IR sensor for fast proximity sensing that you might find interesting: https://www.vishay.com/docs/82741/tssp4056sensor.pdf

The write ups on the Adafruit site are usually a good place to start. Check out: Overview | IR Sensor | Adafruit Learning System

Tom

Hi Tom

I am locking for line following and accurate distance measurement using Ir Sensor

Accidently I found following link but I can not understand the code which is more complicated

Thanks

Hi Pasindu,

That looks like a great resource. Thanks for pointing it out. I noticed that there is a section on sensor calibration that might give you some ideas about accurate distance measurment.

Tom

Hi Tom,
Step one
I need to understand above code that I pointed out in my post 3rd. How it read the sensor values, I know that the corresponding pin should be input , Do you know the library that article is point out

pasindu

Hello.

The documentation you are linking to is about 2 different versions of our older QTR sensors, which each work very differently from each other. So, it is not entirely clear to me which one you are referring to, but in either case, I suggest reading through our “QTR Reflectance Sensor Application Note” instead. You can also find information in the documentation for our QTR Reflectance Sensor Arduino library.

Brandon

1 Like

Hello Brandon,

Wow it is super documentation , I never believe this kind of information’s
Now my life is easy

I found following link about Arduino library from the link given by Brandon thank you
https://github.com/pololu/qtr-sensors-arduino/blob/master/QTRSensors.h

It is not easy to undusted for me base on my knowledge
Can I post some questions about this code until I understand the code fully

Thanks

Hi!

You can use these documents or articles for your presentation on IR reading:

I am glad you found the documentation useful. If you have any specific questions about the library, we would be happy to help.

Brandon

Thanks Brandon

Actually I when trough all the articles in the pololu website related to QTR sensor and it operation. All the hardware related explain is very clear for me as well as articles are explaining very well . Thanks to pololu

The hard part is to understand cording part that actual behavior in side the hardware ( in my case Microcontroller ) That what I have to present each every code that relation ship with hardware

So I will Start hare

in the QTRSensors.h file

#pragma once

#include <stdint.h>

#pragma once
this code is very clear it is preprocessor directives in c

header declare
#include <stdint.h>

enum class QTRReadMode : uint8_t {
  /// Each reading is made without turning on the infrared (IR) emitters. The
  /// reading represents ambient light levels near the sensor.
  Off,

  /// Each reading is made with the emitters on. The reading is a measure of
  /// reflectance.
  On,

  /// For each sensor, a reading is made in both the on and off states. The
  /// value returned is **on + max &minus; off**, where **on** and **off** are
  /// the reading with the emitters on and off, respectively, and **max** is
  /// the maximum possible sensor reading. This mode can reduce the amount of
  /// interference from uneven ambient lighting.
  OnAndOff,

  /// The odd-numbered sensors are read with the odd-numbered emitters on, then
  /// the even-numbered sensors are read with the even-numbered emitters on.
  /// This mode can reduce interference between adjacent sensors, especially on
  /// QTRX sensor boards. It is only usable with second-generation QTR and QTRX
  /// sensor arrays that have two emitter control pins.
  OddEven,

  /// The odd and even sensors are read separately with the respective emitters
  /// on, then all sensors are read with emitters off and **on + max &minus;
  /// off** is returned. (In other words, this mode combines OddEven and
  /// OnAndOff.)
  OddEvenAndOff,

  /// Calling read() with this mode prevents it from automatically controlling
  /// the emitters: they are left in their existing states, which allows manual
  /// control of the emitters for testing and advanced use. Calibrating and
  /// obtaining calibrated readings are not supported with this mode.
  Manual
};

As per what I can understood the class QTRReadMode is for two type of sensor which is QTR old and QTRX. So I not need complicate my presentation much and I only have old pololu red color QTRC type sensor. Hence can I remove the "OddEven"and OddEvenAndOff from the code otherwise I have to explain them during the presentation

Actually I don’t know usage of this this enum

Any advice please

Dear Keonte45
Yes those articles are very informative. The doubt what I have is how code works in side the hardware

The QTR sensor has an IR emitter and an IR detector. QTRReadMode controls whether or not the emitter is on during the readings. The purpose of this is described in the comments of the code you posted. With the emitter off, you can get readings using the ambient light levels near the sensor. With the emitter on, it measures the reflectance (this is the most common measurement method). OnAndOff takes a reading with and without the emitter and considers both to help account for uneven ambient lighting. As you mentioned OddEven and OddEvenAndOff do not apply to all of the QTR reflectance sensors like the older QTR-8A and QTR-8RC arrays.

Brandon

Yes Brandon , Now I am very clear usage of constant enum class of QTRReadMode but I don’t know where it applies in the code , I mean enum constant. Can you please help me where this enum constants are using in the code

Thanks

I searched again and again and found following links

QTR .cpp file

Example file ino

In the example it calls qtr.setTypeRC();



void setup()
{
  // configure the sensors
  qtr.setTypeRC();

Then it set to RC …It is clear

It has another enum in the QTRSensors.h file . it also very clear for me

/// Sensor types.
enum class QTRType : uint8_t {
  Undefined,
  RC,
  Analog
};
void QTRSensors::setTypeRC()
{
  _type = QTRType::RC;
  _maxValue = _timeout;
}

No idea about the reason variables _maxValue = _timeout;

It is not entirely clear to me what you are asking, but the calibration and reading methods all use the QTRReadMode setting to decide how to take the readings. You can find the code for that in QTRSensors.cpp. They also take an optional argument to set the QTRReadMode for that particular reading.

As far as the max timeout value, if no timeout value is otherwise specified, the library will use 2500. This can be found on line 67 of QTRSensors.h.

If that does not answer your questions, could you try rephrasing them to be more specific?

Brandon