Baby-O analog input voltage values

Hello,

I would like to ask a question about Baby Orangutan B-328.
i want to know, if i can change input referance voltages of Babys analog inputs. (in my project, i am reading analog sensors (QTR-1A) and, some of ambient ligt places of black color, my QTR-1A output voltage is 2.1 between 2.5V.) So Baby-O accepting that voltage value like white. But i want to change that referance value like under 1 V is white. Can i do that ?

In the code you are using, there is a threshold value where the white/black decision is made. Change that value to something more suitable.

Thanks for answer Jim. I want to know, what input value (voltage) is 1 for anolog inputs and what input value is 0.

Hello.

The analog reference (AREF) pin is not broken out on the Baby Orangutan and is tied directly to 5V on the board, so it is not possible to use an external reference voltage for the analog inputs. The built-in internal reference voltage is available, but it is 1.1V and might not work with our analog QTR sensors since they can output higher voltages. If the built-in internal reference is used, it might short 1.1V to 5V and damage the microcontroller.

You should not need to change the reference value to use the sensors. The QTR library includes functions for calibration which allow you to use the sensor in various lighting conditions. The qtr_read_calibrated() function returns a scaled reading between the minimum and maximum values read during the calibration process. You can read more about the functions in the Pololu AVR Library Command Reference.

It sounds like you are just trying to distinguish between a black or white surface. To do this, you can read your sensor and compare it to some set threshold in your code. If you continue to have problems reading your sensor, could you upload your code?

- Jeremy

thank you for your answer.
here is how i calibrate my qtr 8a

unsigned char analogPin[] = {D3, D2, D1, D0, I0, I1, I2, I3};
	qtr_analog_init(analogPin, 8, 4, 255);
	startmotors();
	reset();
	red_led(0);
	
		
	
	for (i = 0; i < 9; i++){
	
		if ( i  < 2 || i >5 )
		 {
			 M1_forward(40);
			 M2_reverse(40);
		 }
		 
		 else {
		 M1_reverse(40);
		 M2_forward(40);
		  }
		
		qtr_calibrate(QTR_EMITTERS_ON);
		
		delay_ms(80);
	}

and if i understand, i need to modify “qtr_analog_init(analogPin, 8, 4, 255);”

It is not clear where this code is from. Could you provide a link or post the full code? How many sensors are you using? Why do you think you need to modify qtr_analog_init()? That function initializes the sensor array and is not affected by the calibration. I suggest you read the “QTR Reflectance Sensors” section of the Pololu AVR Library Command Reference to understand how all the QTR sensor functions work.

- Jeremy

you are right. Thank you, i am using QTR-8A. And i will check QTR sensors functions first.

Since the Baby Orangutan only has 6 analog inputs, you will not be able to directly read all 8 sensors on the QTR-8A. If you do not need all the sensors, you might find it convenient to break the sensor apart into two pieces, yielding a 6 sensor array board and a 2 sensor array board. If you do want to use all 8 sensors with the Baby Orangutan, you will probably have to add additional circuitry, like a multiplexer, to read them.

- Jeremy

Jeremy I know on many other arduino variants you can change to the internal reference even though Aref is externally tied to high. I don’t know how they tie it though, perhaps through a resistor.

Do you know why the baby orangutan would be any different?

Well, darn, this reference says arduino.cc/en/Reference/Anal … rence.AREF you can’t just connect Aref to the internal reference, or if you do that you must have a current limiting resistor.

pjrc.com/teensy/adc.html gives more information. In that uno (or is it leonardo? I forget) variant the conditions are 3-state. You can access 5V and switch from 5V to 1.1V if you leave Aref disconnected. If you want you can tie Aref to Vcc in which case you cannot switch to 1.1V.

So are you suggesting that for some reason the baby-O connects Aref to 5V even though there’s no particular reason to do that since Aref of Vcc can be accessed internally to the chip while leaving the Aref pin floating?

Sorry for this slight derailing of the topic.

Hello, Tomek.

The Baby Orangutan is an old product (released in 2008), and we do not recall what led to that decision; it might be a holdover from earlier Orangutans based on the ATmega8. That is not something we would do now, and the Orangutan controllers we have released since then do not have AREF tied to VCC.

If you want to disconnect AREF from VCC, you might be able to cut the trace on the board. I have marked a spot in the picture below:


- Jeremy

Thank you.

Hi Jeremy, thanks for the information. That is good to keep as personal reference. I didn’t realize the Baby-O was made that way, but it’s not too bad with the knowledge of the quirk.

To OP: I think you are concerned about developing some sort of threshold. Usually that is done in the code, not with a value of 0 or 1, but rather with a value of 0 to 1023. That is directly proportional to Vcc, which is about 5V. So if you want a value of 1.9 to trigger a “0” or code needs something like

var= analogRead(pin); threshold = 389; // produced by multiplying (desiredVoltage[1.9]/Vcc[5v])*(1023) = 389; if (var>threshold){ //action dependent on '1' } else{ //action dependent on '0' }

I apologize if I’m off-base. I have only skimmed your question and I did notice you had some non-arduino style code, so you might be perfectly aware of what I’m saying and are actually asking some other sort of question. Also, probably you want your threshold set at more like “2.5V” not 1.9v, since sometimes 1.9V would not trigger if your threshold is so low. You have to test out your system.

Thank you Tomek and Jeremy. Now i decided to do this with QTR-8RC.

Now i am a little bit confused with QTR-8RC, because i could not understand how i must exactly use this sensor board.
i want to share my code (i took this code from spanish robot group, and this project from Pololu’s Community Projects page.)

So, i did not understand how can i do this with code : (From QTR - 8RC on your web site)

The typical sequence for reading a sensor is:

Turn on IR LEDs (optional).
Set the I/O line to an output and drive it high.
Allow at least 10 μs for the sensor output to rise.
Make the I/O line an input (high impedance).
Measure the time for the voltage to decay by waiting for the I/O line to go low.

Turn off IR LEDs (optional).

how can i do this with my code.

Best. Reaven.

In your code, it looks like you are still declaring your array of sensors as analog sensors. You should make adjustments to your code to use the functions that apply to the RC version of the QTR sensor. If you have not gone through the QTR Reflectance Sensors section of the Pololu AVR library command reference, I strongly recommend you read through it. If there are specific parts from the command reference you do not understand, please let me know.

- Jeremy

Hello,

i want to ask a question about reading the QTR_8RC sensor board,
on QTR-8RC reflactance sensor board page this is writing :

The typical sequence for reading a sensor is:

Turn on IR LEDs (optional).
Set the I/O line to an output and drive it high.
Allow at least 10 μs for the sensor output to rise.
Make the I/O line an input (high impedance).
Measure the time for the voltage to decay by waiting for the I/O line to go low.
Turn off IR LEDs (optional).

i am reading sensor values in arduino ide. everything is normal, i am reading values. with baby o-328 P (Pord D4 and D7 and PC0 to PC5)
and i want to know, in the code below where i am setting i/o line an output, where i am waiting 10us, and where i am making i/o line an input and high impedance. ?


#include <QTRSensors.h>

#define NUM_SENSORS   8     // number of sensors used
#define TIMEOUT       2500  // waits for 2500 microseconds for sensor outputs to go low
#define EMITTER_PIN   2     // emitter is controlled by digital pin 2

// sensors 0 through 7 are connected to digital pins 3 through 10, respectively
QTRSensorsRC qtrrc((unsigned char[]) {4,14,15,16,17,18,19,7},
  NUM_SENSORS, TIMEOUT, EMITTER_PIN); 
unsigned int sensorValues[NUM_SENSORS];


void setup()
{
  delay(500);
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);    // turn on Arduino's LED to indicate we are in calibration mode
  for (int i = 0; i < 400; i++)  // make the calibration take about 10 seconds
  {
    qtrrc.calibrate();       // reads all sensors 10 times at 2500 us per read (i.e. ~25 ms per call)
  }
  digitalWrite(13, LOW);     // turn off Arduino's LED to indicate we are through with calibration

  // print the calibration minimum values measured when emitters were on
  Serial.begin(9600);
  for (int i = 0; i < NUM_SENSORS; i++)
  {
    Serial.print(qtrrc.calibratedMinimumOn[i]);
    Serial.print(' ');
  }
  Serial.println();
  
  // print the calibration maximum values measured when emitters were on
  for (int i = 0; i < NUM_SENSORS; i++)
  {
    Serial.print(qtrrc.calibratedMaximumOn[i]);
    Serial.print(' ');
  }
  Serial.println();
  Serial.println();
  delay(1000);
}


void loop()
{
  // read calibrated sensor values and obtain a measure of the line position from 0 to 5000
  // To get raw sensor values, call:
  //  qtrrc.read(sensorValues); instead of unsigned int position = qtrrc.readLine(sensorValues);
  unsigned int position = qtrrc.readLine(sensorValues);

  // print the sensor values as numbers from 0 to 1000, where 0 means maximum reflectance and
  // 1000 means minimum reflectance, followed by the line position
  for (unsigned char i = 0; i < NUM_SENSORS; i++)
  {
    Serial.print(sensorValues[i]);
    Serial.print('\t');
  }
  //Serial.println(); // uncomment this line if you are using raw values
  Serial.println(position); // comment this line out if you are using raw values
  
  delay(250);
}

The read() function automatically switches the IO line between an output and input. You can find the exact lines of code that change the pin between an output and input starting (and do all of the other steps listed on the product page) from line 545 in the source code for the QTR library.

- Jeremy

Thank you.