This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

About the ADC workshop tutorial (Lab4).

Other Parts Discussed in Thread: MSP430G2231

Hi sir,

I've just finished the workshop on the ADC in Lab4 and I have a few question to ask.

Is it the ADC for MSP430 is for measure temperature only?

In step 8, why is it that we use INCH_10 to select the temperature sensor? Is it INCH_10 for temperature sensor only?

As for the measurement value it produce (tempraw), what is 734 means? How do we convert it to a standard temperature value like 26 degree Celcius for room temperature?

 

 

  • I have no idea, what Lab4 or Step 8 are, but I'll try to answer.

    Steven Gan Teck Yik said:
    Is it the ADC for MSP430 is for measure temperature only?

    No. It's a general-purpose ADC. The temperature sensor is just an optional internal sensor that is connected to the ADC.

    The ADC10 and ADC12 have an internal analog multiplexer for selecting the input signal form a number of different sources. 8 to 12 multiplexer inputs are connected to I/O pins, four are connected e.g. to an internal VCC/2 divider or to the internal temperature sensor.
    So yes, INCH_10 is selecting the multiplexer input that is connected to the temperature sensor. See the device datasheet or the family users guide for details about the other inputs.

    Steven Gan Teck Yik said:
    As for the measurement value it produce (tempraw), what is 734 means?

    It means 734/(2^x-1) of the selected reference voltage. Where x is the bit width of the ADC.

    So on ADC12 with 12 bit resolution (can be selected to be 10 or 8 bit, but 12 is the default), 734 means 734/4095 * reference. For a reference of 1.5V, it means 0.269V

    The device datasheet, the users guide and perhaps a device-specifi calibration value tells you the offset of the sensor for 0°C or 0°F, as well as the gain for 1°C or 1°F.
    Subtract this offset from the measured voltage and divide it by the gain and you'll get the temperature.

    The temperature sensor has a large tolerance. Very large. So you'll need calibraiton values. Datasheet or users guide only give the rough range ad you're easily some 10 degrees off.
    Some MSPs have calibration values stored in a speacial memory are. Usually teh reading for 30 and 80°C on 1.5 or 2.5V reference. You can calculate the offset and gain from these values.
    On some MSPs, you need to find these values by yourself.

    Keep in mind that the sensor is measuring the internal temperature, which might be some degrees above ambient if the cpu  is doing some work.

  • Jens-Michael Gross said:
    No. It's a general-purpose ADC. The temperature sensor is just an optional internal sensor that is connected to the ADC.

    The ADC10 and ADC12 have an internal analog multiplexer for selecting the input signal form a number of different sources. 8 to 12 multiplexer inputs are connected to I/O pins, four are connected e.g. to an internal VCC/2 divider or to the internal temperature sensor.
    So yes, INCH_10 is selecting the multiplexer input that is connected to the temperature sensor. See the device datasheet or the family users guide for details about the other inputs.

    I'm currently using MSP430G2231 which is from the MSP430 LaunchPad Development Tool. From the data sheet, it is a ADC10 which is a 10 bit ADC and 8 channel. Does 8 channel means we can have 8 inputs connected to the I/O pins (measuring 8 items)?

    From the header file (MSP430G2231.h), why is it there is INCH_0 to INCH_15 which is Channel 0 to Channel 15? I thought MSP430G2231 only has 8 channel?

    Jens-Michael Gross said:
    It means 734/(2^x-1) of the selected reference voltage. Where x is the bit width of the ADC.

    So on ADC12 with 12 bit resolution (can be selected to be 10 or 8 bit, but 12 is the default), 734 means 734/4095 * reference. For a reference of 1.5V, it means 0.269V

    The device datasheet, the users guide and perhaps a device-specifi calibration value tells you the offset of the sensor for 0°C or 0°F, as well as the gain for 1°C or 1°F.
    Subtract this offset from the measured voltage and divide it by the gain and you'll get the temperature.

    The temperature sensor has a large tolerance. Very large. So you'll need calibraiton values. Datasheet or users guide only give the rough range ad you're easily some 10 degrees off.
    Some MSPs have calibration values stored in a speacial memory are. Usually teh reading for 30 and 80°C on 1.5 or 2.5V reference. You can calculate the offset and gain from these values.
    On some MSPs, you need to find these values by yourself.

    Keep in mind that the sensor is measuring the internal temperature, which might be some degrees above ambient if the cpu  is doing some work.

    What is the reference voltage 1.5V or 2.5V for? Hoe do we know which to choose?

    How to calculate the offset and gain for the reading for 30 and 80°C on 1.5 or 2.5V reference?

    If I use the ADC to measure other values other than the temperature, do I need to consider the offset and gain too?

     

  • Steven Gan Teck Yik said:
    Does 8 channel means we can have 8 inputs connected to the I/O pins (measuring 8 items)?

    It actually has 16 channels, and yes, 8 of them are externally availably (A0..A7 on the device pinout list, multiplexed with P1.0..P1.7 and some other module functions) The other 8 are internal. INCH_8 is connected to the external reference (which is on this chip also on P1.4 and therefore a duplicate of INCH_4), INCH_9 measures Veref- (again, on this chip a duplicate, this time of INCH_3), INCH_10 is the temperature sensor 8as you already know), and INCH_11 to INCH_15 are connected to VCC/2. They will return ~0x200 if you use VCC as reference, but when using the internal 1.5V or 2.5V reference, you can test VCC here (and detect voltage failure, e.g. by battery depletion) without external circuitry.

    Steven Gan Teck Yik said:
    What is the reference voltage 1.5V or 2.5V for? Hoe do we know which to choose?

    To do an analog to digital conversion, you need a reference. The digital values tells you which fraction of the reference the analog value has. Since you only have a resolution of 10 bit, the reference follows three requirements:

    • it must be higher than the highest signal. Signals higher as the reference will always give maximum result, no matter how much higher. Also the signal must not be above VCC.
    • it must be stable, or else your values will change caused by reference changes, even if the signal is constant.
    • it should be as small as possible, since your resolution is 1/1023 of the reference.

    You can use VCC as reference, But VCC is not really stable and subject to influences caused by current ripples etc. And for small signals, the resolution of VCC/1023 might be not fine enough. And drifts in VCC will change your results too (on VCC=3.00V you'll get different results as with VCC=3.3V)

    The MSP offers two internal band-gap references (on some 5x devices even three): 1.5V and 2.5V. You enable them by setting the REFON bit and can switch between the two with the REF2_5V bit.
    Band-gap references are stable and precise. But they consume more current than using VCC. There are two, so you can chose the one that is closest but still larger than your maximum signal, for highest resolution.

    With the SREFx bits, you can select the reference to use: VCC, itnernal reference (if enabled) or external reference (if externally provided and within the allowed range of 1.4V..Vcc)

    Steven Gan Teck Yik said:
    How to calculate the offset and gain for the reading for 30 and 80°C on 1.5 or 2.5V reference?

    Simple: bring the chip on 30° and take a sample. Then bring it on 80° and take another sample from INCH_10. Divide the difference of the two samples by the temperature difference and you have the gain (counts per °). Subtract 30*gain from the 30° sample and you have the offset.
    You can use any two temperatures for calibration, but 30/80°C is usually used because 30° is the expected operating temperature later, and 80° is far from it, but still below 85° operating range limit. So by the large difference, the gain is calculated with more precision. Of course assuming a linear behavior of the sensor, which it pretty much has for the operatign range.

    Steven Gan Teck Yik said:
    If I use the ADC to measure other values other than the temperature, do I need to consider the offset and gain too?

    In theory, yes. The ADC is not ideal. Even if you apply exactly 0.000V, it might measure something (offset) but this is rather negligible. Same for the gain. However, your external circuitry is not ideal too. So if you apply a resistor divider, the resistors will ahve a tolerance and therefore a gain error. And if you use an OpAmp, it might have an output offset voltage. So depending on your applicaiton, it could be necessary to calculate offset and gain too. Not to correct the voltage on the MSP pin itself, but for any error introduced by the circuitry attached to it, including a gain error caused by the MSPs input impedance which adds a load to the signal source and can pull the signal down if the signal source has a high output impedance.

**Attention** This is a public forum