I have trying to use the above with an Arduino Due but only get wild results using the standard example.
When using the polulu example sketch on my Arduino, it appears I am getting faulty readings from 2 of the sensors (1&2). I re-soldered it and got the same issue. The calibration for the sensors is also odd 3-6 shows values of around 500 whereas 1 & 2 are both under 20. Can these be damaged? Is there something I can do or does it mean buying a new one?
Thanks in advance
Could you tell me more about your setup? The Arduino Due operates at 3.3 V; do you have the QTR-8A reflectance sensor array configured for 3.3V operation? If you are not sure how to do this, you can find more information on this in the “Module Connections” section of the QTR-8 user’s guide. Could you post pictures that show how you have things connected? Could you post a video showing how you are testing the sensor array?
Thank you for your response. I answer to your question, the sensor is powered from the Arduino output which I am fairly certain is ‘a regulated 5V’ (according to their website) so I don;t think that is an issue, but I will measure it to be sure.
In terms of connections, I isolated it (ie, nothing plugged into the Arduino other than the sensor) where the sensor outputs 1-6 are going into the Arduino analogue inputs 0-5. The emitter pin is from 4 (the one thing I changed int he Sketch code) as 2 will be used as an interrupt. Other than that, the only connections are the 5V and Gnd, all from the Arduino.
I am using the standard Sketch supplied (tried both calibrated and un-calibrated) and am monitoring it using the Serial monitor built into the Sketch software.
Hope this helps
You should be using the 3.3 V supply on the Arduino Due. When the sensor is supplied 5 V, the analog output could be as high as 5V, but since the Arduino Due’s logic voltage is 3.3 V, applying more than 3.3 V to the analog input pins can damage it.
You will also want to reconfigure your QTR-8A for 3.3 V operation like I mentioned in my previous post.
Ah ok. Was using the 5v. I will switch to the 3.3v output and it looks like a simple fix of shorting the 2 points to convert the sensors to 3.3v. I do believe the sensors are not working so I have ordered another. I will report back if any further issues with a screen grab of calibration results and initial readings.
Based on what you have told me so far, I would not expect the sensor to be broken. You might try swapping the outputs of the sensors and reading them with pins you know to be working. You might also test the analog inputs on your Arduino Due by reading something with known voltage.
Firstly, thanks for all your help so far! So, first wires I used weren’t solid core and I think a bit got stuck in the analogue input of the arduino input 1 which messed up 0 & 1 ! Anyway, that’s now solved and it seems to work pretty well.
It has now highlighted the next issue (sorry) - ambient light messing up the readings. If I use the ‘without calibration’ I get no useful results. If I calibrate and put my hand over the sensors during calibration, it works well, even if I take my hand away once calibration has completed.
So, my questions are:
- Is this normal?
- Should I add some sort of cover to protect the sensors from ambient light or use some sort of LED setup to mask background light interference?
- Can I manually input calibration readings to avoid the constant calibration period?
Thanks in advance.
When calibrating, you should try calibrating under the conditions in which the sensor will be used (i.e. expose it to the most and least reflective conditions he wants it to be able to detect). You should also check to make sure the sensor array is positioned as close to the recommended sensing distance (0.125") as possible. The sensors can be affected by ambient light, so you might try adding shielding if you suspect the sensor is being affected by it. We have seen people use electrical tape for shielding.
Alternatively, you could try setting calibration values manually. You can access the calibration values through the public member pointers allocated during calibrate(). You can read more about this in the “QTRSensors Methods & Usage Notes” section of the guide for the Arduino library for the Pololu QTR reflectance sensors.
Thank you. I read through the guide but couldn’t see anywhere to set the calibration settings manually?
The description for the calibrate() command in the guide states:
[quote]void calibrate(unsigned char readMode = QTR_EMITTERS_ON)
Reads the sensors for calibration. The sensor values are not returned; instead, the maximum and minimum values found over time are stored internally and used for the readCalibrated() method. You can access the calibration (i.e raw max and min sensor readings) through the public member pointers calibratedMinimumOn, calibratedMaximumOn, calibratedMinimumOff, and calibratedMaximumOff. Note that these pointers will point to arrays of length numSensors, as specified in the constructor, and they will only be allocated after calibrate() has been called. If you only calibrate with the emitters on, the calibration arrays that hold the off values will not be allocated.[/quote]
So to store values manually you will need to put the values into the arrays pointed to by the calibratedMinimumOn, calibratedMaximumOn, calibratedMinimumOff, and calibratedMaximumOff pointers.
You might find this forum thread about recalling stored calibration value from EEPROM helpful. Other members of our forum have posted code they used to store calibration values there.
You might also find this code posted by one of our engineers helpful. The highlighted lines (Lines 146-155) belong to the function he used to set the line calibration values.