Can Not Read Proper Voltage?

Status
Not open for further replies.

SDTricker

Member
Hello,

So I have a project that is using a simple voltage divider. Two 10K resistors from a 5V. When I try and read it with the Teensy, I am getting around 4.0 voltage, but I even verified it with my fluke that it is at 2.5V!!! Why would my teensy not read the proper voltage.
Here is the Code I am using. Could the ADC be screwed up? It does change when I change the voltage divider, but it kinda seems it is always 1V above the true voltage. :/

void setup()
{
Serial.begin(9600);
}

void loop()
{
int sensorValue = analogRead(A9);
float voltage = sensorValue * (5.0 / 1023.0);
Serial.println(voltage);
}
 
vref = 3.3V is likely the case.

(4/5) * 3.3 = 2.64; much nearer the expectation.

Code:
float voltage = sensorValue * (3.3 / 1024.0);
Any good?
 
Thanks guys. Idk why but I was thinking the analog ref was 5V. So.....crap. I have my PCB supplying 5V to the voltage divider instead of 3.3V. Is it safe to attatch 5V to the ARef pin?
 
If this is Teensy 3.1 (you didn't say exactly which board you're using), then NO, do not connect 5V to the AREF pin. You'll likely damage the chip. The analog-only pins, A10-A14 and AREF are NOT 5V tolerant. You MUST NOT connect 5V to any of those pins!

On Teensy-LC, none of the pins are 5V tolerant. 5V connected to any pin except VIN or VUSB will damage the chip.

On Teensy 2.0 and Teensy++ 2.0, you can connect 5V.
 
Thanks Paul. Yeah, I'm realizing a logic error I was making on my circuit. This is outside of the Teensy hardware, but I do have a technical question. Why are some boards tolerant of 5V and others only up to 3.3V? It seems like higher end micro controllers are using 3.3V for their Ref? What is the reason for this?
 
I make no attempt to answer the question you have posted for Paul; I post FYI:

You do not need to change VREF from 3.3V

It is possible to measure voltages many (many) times larger than VREF by using resistors as voltage dividers (I had the impression you knew that because you were dividing 5V appropriately to measure using 3.3V ref but your subsequent post indicates maybe not, so...), to measure up to 33 volts you only need to divide the voltage by something close to (but prefer larger than) 10 (for sake of error and fluctuation etc), a 10K resistor from the ADC/analog node to GND and a 100K resistor from that node to Vsrc will divide Vsrc at a ratio very near 11:1
 
my post makes no attempt to answer the question "why do higher end MCUs use lower voltages?", that is why I said/wrote that.

It is academic and, whether or not my understanding of why is right, wrong, worth anything or completely worthless; I don't have the time to do it justice, sorry.
 
my post makes no attempt to answer the question "why do higher end MCUs use lower voltages?", that is why I said/wrote that.

It is academic and, whether or not my understanding of why is right, wrong, worth anything or completely worthless; I don't have the time to do it justice, sorry.

Then just don't answer. You didn't have to say you weren't going to answer. haha never got a response on a forum like this before. o_O
 
Thanks Paul. Yeah, I'm realizing a logic error I was making on my circuit. This is outside of the Teensy hardware, but I do have a technical question. Why are some boards tolerant of 5V and others only up to 3.3V? It seems like higher end micro controllers are using 3.3V for their Ref? What is the reason for this?

On page 11, of the manual the designers of the chip mention the following:
Code:
All 5 V tolerant digital I/O pins are internally clamped to VSS through a ESD protection diode. There is no diode connection to VDD. If VIN greater than VDIO_MIN (=VSS-0.3V) is observed, then there is no need to provide current limiting resistors at the pads. If this limit cannot be observed then a current limiting resistor is required. The negative DC injection current limiting resistor is calculated as R=(VDIO_MIN-VIN)/|IIC|.
2. Analog pins are defined as pins that do not have an associated general purpose I/O port function.
3. All analog pins are internally clamped to VSS and VDD through ESD protection diodes. If VIN is greater than VAIO_MIN (=VSS-0.3V) and VIN is less than VAIO_MAX(=VDD+0.3V) is observed, then there is no need to provide current limiting
resistors at the pads. If these limits cannot be observed then a current limiting resistor is required. The negative DC injection current limiting resistor is calculated as R=(VAIO_MIN-VIN)/|IIC|. The positive injection current limiting resistor is calculated as R=(VIN-VAIO_MAX)/|IIC|. Select the larger of these two calculated resistances.

On the following pages, they also go over power consumption, etc. Note how the chip consumes the same number of milli-amps at 1.8V vs. 3.3V. Your answer may very well be there, i.e. in order to keep the power consumption in check despite high clock rates, the designers keep lowering the core voltages of chips. The Edison from Intel runs at 1.8V, for example.

Folks in the overclocker community have been playing with core CPU voltage for years, balancing the stability of the rig at high speeds vs. the thermal output. Lower voltages = lower heat production but the chip may not be stable.

However, also have a look at the technical data sheet and the rather more in-depth reference manual for the MK20 series.
 
Last edited:
Status
Not open for further replies.
Back
Top