Code Monkey home page Code Monkey logo

qtr-sensors-arduino's People

Contributors

davidegrayson avatar kevin-pololu avatar ryantm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qtr-sensors-arduino's Issues

problem withe the "=" operator

Hello,
when i using this code

unsigned char pins[] = {A8,A9,A10,A11,A12,A13,A14,A15};
QTRSensorsAnalog sensors;
void setup() {
 QTRSensorsAnalog sensors = QTRSensorsAnalog(pins, 8);
 sensors.calibrate();
}

the calibraition of the Sensors wont work because the Sensor lost the value of the pins in the QTRSensor implementation.

QTRSensors::calibrateOnOrOff Min/Max Value Storage

Hi,

I was looking through your library, and I can't seem to figure out why you store the maximum value found during calibration into calibratedMinimum, and the minimum value into calibratedMaximum:

for(i=0;i<_numSensors;i++)
{
    if(min_sensor_values[i] > (*calibratedMaximum)[i])
        (*calibratedMaximum)[i] = min_sensor_values[i];
    if(max_sensor_values[i] < (*calibratedMinimum)[i])
        (*calibratedMinimum)[i] = max_sensor_values[i];
}

I keep trying to go through a step by step of how this would work, but I always end up with calibratedMinimum being larger than calibratedMaximum. Should it be:

for(i=0;i<_numSensors;i++)
{
    if(max_sensor_values[i] > (*calibratedMaximum)[i])
        (*calibratedMaximum)[i] = max_sensor_values[i];
    if(min_sensor_values[i] < (*calibratedMinimum)[i])
        (*calibratedMinimum)[i] = min_sensor_values[i];
}

This is contained in line 230 to 236 of QTRSensors.cpp.

Thanks,
Farzad

Should be using virtual methods?

While looking over the code, I found this peculiar piece of code:

if (_type == QTR_RC)
{
    ((QTRSensorsRC*)this)->readPrivate(sensor_values);
    emittersOff();
    if(readMode == QTR_EMITTERS_ON_AND_OFF)
        ((QTRSensorsRC*)this)->readPrivate(off_values);
}
else
{
    ((QTRSensorsAnalog*)this)->readPrivate(sensor_values);
    emittersOff();
    if(readMode == QTR_EMITTERS_ON_AND_OFF)
        ((QTRSensorsAnalog*)this)->readPrivate(off_values);
}

It seems that the QTRSensors object keeps a _type variable to tell the code
which subclass it is, and then based on that calls either the
QTRSensorsAnalog or QTRSensorsRC version of the readPrivate method.

This kind of thing is what C++ has virtual methods for. By declaring
readPrivate as a (pure) virtual method in QTRSensors and then implementing
it in the subclasses, you can just call this->readPrivate() and the compiler
will (generate code to) find out which subclass is being used at runtime.

Or is there some reason that using virtual methods is not an option here?

Gr.

Matthijs

Bug in QTRSensors::readLinePrivate()?

I think there might be a bug in the QTRSensors::readLinePrivate() method. The weighted average is calculated in this method by the following code:

  for (uint8_t i = 0; i < _sensorCount; i++)
  {
...
    // only average in values that are above a noise threshold
    if (value > 50)
    {
      avg += (uint32_t)value * (i * 1000);
      sum += value;
    }
  }
...
  _lastPosition = avg / sum;

The i variable starts at 0 and that 0th element will always contribute a value of 0 to avg.

Maybe something like this would work better?

  for (uint8_t i = 0; i < _sensorCount; i++)
  {
...
    // only average in values that are above a noise threshold
    if (value > 50)
    {
      avg += (uint32_t)value * ((i+1) * 1000);
      sum += value;
    }
  }
...
  _lastPosition = avg / sum - 1000;

It should still result in the same final range I think but the 0th element will always contribute to avg.

Thoughts?

Suggestion for all Pololu arduino libraries

Hi @kevin-pololu,
I have a suggestion to improve your arduino library.
The new arduino IDE includes a auto update of the libraries but for that it need’s a file called “library.properties” inside the library folder. I think that it would be good to add that file to all your libraries so that users can get always the newer versions automatically. I will attach a file the I made for the QTRSensors library base on an Adafruit library, I’m not sure if it works….

name=QTRSensors
version=2.1.2
author=Pololu
maintainer= Pololu <www.pololu.com>
sentence=Driver for Pololu QTR-XX line Sensors
paragraph=Driver for Pololu QTR-XX line Sensors
category=Sensors
url=hhttps://github.com/pololu/qtr-sensors-arduino
architectures=*

Invalid library

Hello, I use Arduino 1.6.7 after adding the library QTR, this message appears : Invalid library found in Arduino \ libraries \ QT

Issue reading white line on black background

I am having a issue where the readLineWhite() is not working properly. It keeps giving me values between 5000-6000 on a QTRX-13MD-RC, even though on a black line with readLineBlack() the readings are perfectly fine and gives me 0-12000.

readLineWhite() on a white line is causing issues.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.