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.

MSP430 - Measure a simple resistor with ENERGIA

Other Parts Discussed in Thread: ENERGIA

Hey,

I was wondering if you could help me with an actually really simple project.

I am trying to measure a resistor with the slope A/D technique using Energia (http://www.ti.com/lit/an/slaa129b/slaa129b.pdf) - I added as attachment my very! basic code in order to make my point.

Basically, a capacitor (470uF) builds with a resistor (DC voltage) a classic circuit. The capacitor charges and discharges. The discharge time is once taken with a precise 100 Ohm resistor and afterwards with a random resistor I want to measure with the MSP430. 

Although I measure different discharge times, I only get a time factor of around 7 and it should be one around 9.2 since my "random" resistor is 918 Ohm.

I also considered the charging time with 2500ms since 5 tau for 918 Ohm and 470uF are 2.16s. The high capacity affects a considerable measuring time, but I only try to proof the concept and it does not work. Measuring with the factor of 7 and a 100 Ohm resistor -> a 700 Ohm resistor, although I do have a 918 Ohm resistor is not satisfying and does not fulfill my specifications of +-5 Ohm. 

Do you have any idea what I missed to consider or might influenced my circuit? I just want to measure accurate a resistor using Energia - a high language. I also tried a resistor bridge.

Best regards

Markus

  • 1. What type of capacitor are you using? 470 micro Farads is quite a big capacity, many cheap aluminium electrolytics have +80%/-20% precision in this capacity range, so it could affect your measurements and calculations considerably.

    2. Did you account for internal switch resistance during charge/discharge time? Check data sheet for your device,  VOL/H output voltage specs. It well may be something around +0.6 Volts of voltage drop on your output's internal switch when you charge or discharge the capacitor, which is about 20% of 3.3Volts power supply.

    3. If you charge or discharge your 470uF capacitor via just 100 Ohm serial resistor connected straight to the I/O pin of your MSP430 device it may be a way too much for its driving capability. You can have peak current of up to 30mA. Is your output strong enough to survive this sort of current? Is it able to provide it?

    4. Make sure internal pull-up/pull-down are disabled for this pin.

  • Serge A said:
    2. Did you account for internal switch resistance during charge/discharge time?

    Right. It can affect results:

  • Thanks for the answers so far.

    1) The capacitor accuracy cannot influence my result since: 

    Rref/tref = Rsensor/tsensor for V(t)=Vo*e^(-t/R*C) - the capacitor is as bad or good for both measurements and gets unimportant for the calculation of the resistor. 

    Anyway: I changed the capacitor to a more accurate and smaller one. 2.2uF. Still - the measurement of several resistors do not provide any better result. The factor is even not close in order to calculate the true resistor value.

    3) Yeah the MSP430 is capable to have a maximum current of 48mA for all 8 channels. Since I only use one channel I still meet the maximum values. (see attachment)

    2) I really do not know what to think about that. I mean I am measuring besides my uC the voltage with a multimeter. A test drive with an oscilloscope turned out to be a mess. I guess my charge and discharge time is too short in order to get an analyzable picture. Anyway.

    The comparator gives an output between 0 and 1023. Where:

    0 -> 0V and 1023 -> Vcc

    since I did not program a smaller comparator voltage.

    I measure the capacitor voltage directly with the MSP430 thus 0 means 0V at the capacitor and 1023 - Vcc at the capacitor, accordingly. My timer stops when the certain voltage decreases 0.25*Vcc what is 1024/4-1=255. Why would the switch resistance influence my measurements? It is certainly true that an unknown resistance increased my discharge time (tau=R*C), but my factor is all the time to small instead of to big.

    Here some figures: 

    C=470uF

    Rref=100 Ohm tref=24ms

    Rsens=918 Ohm tsens=134ms

    ---

    How it actually is:

    Rsens=Rref*tsens/tref=(100*134/24)Ohm=558 Ohm

    -------------------------------

    C=2.2uF

    Rref=100 Ohm tref=512us

    Rsens=918 Ohm tsens=3200us

    ---

    How it actually is:

    Rsens=Rref*tsens/tref=(100*3200/512)Ohm=625 Ohm

    I feel like I am just missing something simple...

  • Markus,

    I see your point now. So what you do:

    1. Charge the capacitor C fully via some resistor (which value is irrelevant) for at least 5*tau time;

    2. Discharge the capacitor via reference precision 100 Ohm resistor R1 counting discharge time. Let's say it is T1;

    3. Charge the capacitor C fully again;

    4. Discharge the capacitor C via resistor R2 which value you want to measure counting discharge time. Let's say it is T2.

    Now you expect that

    T2/T1 = R2/R1 = 918/100 = 9.18;

    But in reality what you've got taking into account internal switch resistance RS

    T2/T1 = (RS+R2)/(RS+R1) = (RS+918)/(RS+100) = 7.

    You can calculate RS now:

    RS = (R2-7*R1)/(7-1) = (918-700)/6 = 36 Ohm

    This is the value which affects you measurements.

    Regards,

    Serge

  • Hi Serge,

    you are totally right! That is a great hint! Thank you very much!

    Could it be that the internal switch resistor is depending on the current, thus the size of the resistor? I feel like I get a current depending internal switch rather than a single switch resistance. 

    If that is the case - I guess it could be useful to determine R=f(I(R))

    Best

    Markus

  • Hi Markus,

    Yes it is indeed current-dependent as it is semiconductor resistance. Look at the picture posted by Ilmars above. But as you can see on it, if you limit the current to around 0-20mA band (output is in Full Drive Strength configuration), the A/V curve is almost linear within it, so you can almost ignore non-linearity error for it. This will limit your range of measurable resistance though, you will not be able to measure R < ~200..300Ohm; your reference 100 Ohm resistor also has to be replaced with the one with a larger value.

    To be able to measure the full range resistance - yes, you'll have to create some sort of R=f(I(R)) adjustment in your firmware.

    The bad thing - as you can see on the graph as well - the internal switch resistance is also very temperature-dependant. So in general it is hard to get high-precision resistance measurement from this setup without proper adjustment for temperature variation using integrated temperature sensor.

    Best regards,

    Serge

**Attention** This is a public forum