Show Posts
Pages: [1]
1  Using Arduino / Sensors / Re: Problem with Aref on: February 26, 2013, 11:46:56 pm
I guess that is my mistake.  I was relying on the Arduino reference guides and documentation.  I guess maybe they should consider changes there documentation from:

Quote

As indicated:
Quote
EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference.

to something more like (1-5V)
2  Using Arduino / Sensors / Re: Problem with Aref on: February 26, 2013, 11:27:19 pm
Quote
The voltage you applied to aref becomes the new reference... it's normal that you cannot read anything but 1023.

I am sorry, that doesn't make any sense.  I am applying ~2.19mV at AREF, and grounding the analog input pin, I should get zero.  When I apply 3.3V at AREF and ground the analog input pin, I get 0. Similarly, when I repeat this for 5V, I get 0.  It is only when I apply the 2.2mV that I get 1023.

I forgot to mention in my first post, I tested all of this with a DVM, and I am infact getting the voltages as they should be at each pin and reference.
3  Using Arduino / Sensors / Problem with Aref on: February 26, 2013, 11:07:39 pm
I am trying to get the Aref pin to work so I can scale down analog input references for better resolution.  I cannot figure out what I am doing wrong here.

I am using the 3.3V supply from the Uno board through a voltage divider of 1.5M and 1K resistors.  This provides around 2.19mV.  I connect that to the Aref, and the GND below the Aref to the bottom of the divider.  No matter what I do, I cannot read anything but 1023.  I am understand the floating pin, but it doesn't go to 0 when grounded.  I have tried just connecting it to the 3.3V supply directly (to AREF), and that works.  I have tried INTERNAL and DEFAULT analog references, and they seem to work fine.  It is only when I try and scale it down that it won't read.  Also, I have tried multiple analog pins in case one was bad or something.

Divider:


Below is the code, however, I suspect there is something else going on as it work fine on a direct connection to board voltages...

Any help would be appreciated

Code:
float test;
float coeff[] = {0 , 1.978425E+2 , -2.001204E-7 , 1.036969E-11 , -2.549687E-16 ,   
    3.585153E-21 , -5.344285E-26 , 5.099890E-31};    //Type J coefficients

float temp;
float temp_comp;

long time_ref;        //time to act as start time reference (milliseconds)
long time_current;

int analogpin = A1;  //analog pin to use
int analoginput = 0;  //integer value 0-1023 input from pin



void setup(){
  Serial.begin(9600);
  analogReference(EXTERNAL);  //use AREF as voltage reference
 
  Serial.println("Anolog input testing");
 
}
 
void loop(){
  delay(2000);
  time_current = millis();  //timestamp
 // analoginput = 0;
  analoginput = analogRead(analogpin); // reads analong input pin and stores to variable
 
  test = 0;
  temp = 0;
  temp_comp = 0;
 
  test = map(analoginput, 0 , 1023 , 0 , 2150); // maps 0-1023 to 0-2150 microvolts
  test = test/1000; // converts microvolts to millivolts
 
  temp = tc_calc(test);
  temp_comp = temp + 21.222;
 
  Serial.print(time_current);
  Serial.print("\t");
  Serial.print(analoginput);
  Serial.print("\t");
  Serial.print(test);
  Serial.print("\t");
  Serial.print(temp);
  Serial.print("\t");
  Serial.print(temp_comp);
  Serial.println("");
}



// Thermocouple Calculations
float tc_calc(float tc_mv){
  int i = 0;
     while(i <=7) {
       temp = temp + coeff[i]*pow(tc_mv,i);
       i++;
      }
  return temp;
}
4  Using Arduino / Programming Questions / Re: Serial Monitor for Program Configuration data on: May 31, 2012, 04:20:20 pm
An excellent idea.  I looked at that, but will investigate it further...

I suspect I will still have some issues, as the answer to the first question (how many break points?) determines how many states and questions there are... and I will be parsing the data into an array...

5  Using Arduino / Programming Questions / Serial Monitor for Program Configuration data on: May 31, 2012, 03:14:32 pm
First, thanks to all you guys that post to the forum regularly, as I have spent days reading that stuff, and it is so helpful.

I am just getting back into programming, so I am a little rusty and need some help with serial communications.  I have got the bulk of my code working for the operation, but am having a devil of a time getting the user interface portion to function the way I want.

Objective:

Use the setup() section to ask the user questions (via serial monitor) and take those responses in as variables.  I have successfully been able to enter data on the serial monitor, move it from the serial buffer to a character buffer and convert to my desired data and store.  Where I am having trouble, is doing this for different variables, only once, and not continually looping.

Example: (as viewed from the monitor)

How many break points do you want?
6 (user entered 6 and pressed enter)
Enter break point time 0:
0 (user entered 0 and pressed enter)
Enter break point time 1:
115 (user entered 115 and pressed enter)
.
.
.
Enter break point time 5:
10000 (user entered 10000 and pressed enter)

Would you like to run the operation now? (Y/N)
Y (user entered Y and pressed enter)

**program now runs contents in void loop()


I toyed with putting empty while looks after each question until the answer has been entered, but can't get that to work either.

Surely I am not the first person to try this, and I am hoping someone can save me some dev time and point me towards an example?

Code below is highly truncated, and does not even come close to what I am looking for, but every time I read a noob post, they get yelled at for not posting their code, so here it is.

Quote
/*  Reflow Controller User Interface
    wdenny
    2012.05.31_r1
*/

int b_points = 0;
String readString;
float test;
boolean stringComplete = false;

void setup() {
  Serial.begin(9600);
  Serial.println("Reflow Controller User Interface"); // identify begining of programing and help with debugging
  Serial.println("2012.05.31_r1");
  Serial.println(" ");
  Serial.println("How many break points? (integer values)");
        
}

void loop(){
  // print the string when a newline arrives:
  if (stringComplete) {
    Serial.println(readString);
    // clear the string:
    readString = "";
    stringComplete = false;
  }
}

void serialEvent(){
    while (Serial.available()) {
      delay(10);
      if (Serial.available() >0) {
        char c = Serial.read();
   readString += c;
        }

      }
       
//   char buf[readString.length()+1];
//   readString.toCharArray(buf,readString.length()+1);
//   test = atof(buf);
   stringComplete = true;

}

Pages: [1]