Saturday, February 4, 2012

MSP430 BASED 30V VOLT METER


       This is a simple application of internal 10-bit ADC(analog to digital  converter) of MSP430G2231 microcontroller.you can use this  circuit  to measure  up to 30 v dc. the possible  applications are on bench top power supply or as a panel meter in various system.

Circuit description
            TEXAS INSTRUMENTS  MSP430G2231  is the heart and brain of this circuit .the internal adc of the mcu with a resistor network voltage  divider is used to measure the input voltage . then 3 digest of comm anode 7 segment display is used to display final converted voltage. as you can see in the schematic the displays are multiplexed with each other . means we switch on one display and put the corresponding digit on this while other two displays are off this cycle go for each of the display.

   the only problem with MSP430 mcu is there is very less I/O lines are available to use so we need 7 +3 lines to drive the display and maybe one more pin for adc input (if adc input is not multiplexed with other pin) total 10to11 lines are required but we don't have that much lines from mcu so we have to use 74LS47 bcd to 7segment decoder  ic which enable us to display any digit with only 4 i/o lines instead of 7 lines so now we require only 4+3+1 lines total 8 lines.

you can find more about driving multiplexed 7 segment led display from a mcu in application note from My previous post click here
in my circuit the refresh rate is about 50hz.




 Voltage Divider Front End



as you can seen in the schematic the 82k resistor and 10 k trim pot is connected ias a voltage divider configuration  .we all know very well that by default MSP430 microcontroller ADC reference voltage can be  set to 2.5 volts internal reference . so what we have to do is make such voltage divider that can divide out maximum range 30 volts to 2.5 volts . so we need is Vin/12 ==> 30/12 =2.5v   voltage divider . and to keep as less as possible attenuation on the under test voltage we have to keep the voltage divider resistor value in few thousand ohms because it takes very little current from the target but as much to drive adc of MSP430.


calculation
10bit adc resolution we get 1023 maximum count
with 2.5 v reference  we get  2.5/1023 = 0.0024437 V/Count
means if the adc count is 188 then input voltage is 188 * 0.0024437== 0.459 volts


but now with the voltage divider  the maximum  voltage  is 30v so the calculations
will be  30/1023= 0.02932 volts/count
if now we get 188 then 188*0.02932==5.5 Volts

you can also increase  or decrease  the range by changing resistor network and the calculations a little bit.

the capacitor 0.1uf makes the adc input a bit stable because 10bit adc is really sensitive .
the 2.7v zener will provide over votage protection to the internal adc because it wont allow voltage more than 2.7v.
Accuracy and calibration 
overall  accuracy of this circuit is great but it totally depends on the values of 82K resistor and 10k trim pot . as fine as you can go by adjustment of the trim pot your accuracy goes fine.


calibration of this circuit is done by adjustment of the 10k trimpot around value of 7.45k or so .
all you have to do is take any standard power like 5v or 12v and apply that to the input of the resistor network and adjust the trimpot until you get correct value on the display


Software  Sorce code and Firmware
the sotware is written in c and complied ti ccs 5.1 studio
click here download firmware  and source code 


any question  please  make comment

you may also like  30 volts Panel Volt Meter Using Pic mcu

25 comments:

  1. I would be very grateful if you change the code scheme to measure the voltage to 50.0 volts or if you can measure up to 50.00 volts - and therefore the scheme

    ReplyDelete
  2. Hello!
    When i want to programm chip it says, that #pragma vector = TIMERA0_VECTOR is undefined.
    What can i do?

    ReplyDelete
  3. Great project!Is there by any chance a PCB available?

    ReplyDelete
  4. Hello ,
    why do we have a 4,7kohms from vdd to rst pin?

    ReplyDelete
    Replies
    1. Actually if you try any other value of resistor it will work also, even if you just put a jumper wire between them.

      Delete
  5. I do not know exactly what to do to set?
    10k potentiometer resistance at what level do you need?

    by Tom

    ReplyDelete
  6. Replies
    1. the source download link is there in the post please take a look there

      Delete
  7. sir what is # include in your code

    ReplyDelete
  8. Replies
    1. you do't have to comment twice.

      #include is to include header files that contains register and other definitions.

      Delete
  9. Seems like the input impedance is low (<100K), so user need to be aware of the output impedance of the Circuit they are measuring on.

    ReplyDelete
    Replies
    1. if you like to increase impedance then use higher values of the registers with same ratio , or use a opamp buffer. do what you like

      Delete
  10. Hi could you help me please?
    There's a part of the code thai I didn't understand:
    unsigned char i;
    /* Configure ADC Temp Sensor Channel */
    ADC10CTL1 = INCH_7 + ADC10DIV_3; // Temp Sensor ADC10CLK/4
    ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + REF2_5V;
    __delay_cycles(1000); // Wait for ADC Ref to settle
    ADC10AE0 |= BIT7;
    ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start

    adcCalibrated = ADC10MEM;
    for (i=0; i < 8; i++)
    adcMeasured[i] = adcCalibrated;
    adcAverage = adcCalibrated;

    When you write : ADC10CTL1 = INCH_7 + ADC10DIV_3; INCH_7 means what?
    And why the the part : adcAverage = adcCalibrated. I thought that for adcAverage only meant the Measure value...
    And why do i have to put in p1.7 the value that i want to show on displays?
    What is SREF_1 + ADC10SHT_3 + REFON + ADC10ON + REF2_5V?
    I know that I asking too much , but i really wanna do this! :D

    Also.. I'm using the MSP430G2533, it's the only available that I found...do i have to change something in the project?

    Thanks ! Great Job! Waiting for your answer!

    ReplyDelete
  11. The same circuit connections for MSP430G2553 or it is different ?
    Can the same components be used for measuring a maximum of 5 V ?

    ReplyDelete
  12. Can you help me
    how did you burn the software in the IC
    how to use this CCS software its a big puzzle

    ReplyDelete
    Replies
    1. I used msp430 launchpad, and just open the project in ccs

      Delete
    2. --diag_warning=225 --display_error_number --printf_support=minimal --preproc_with_compile --preproc_dependency="main.pp" "../main.c"
      "../main.c", line 24: error #20: identifier "TIMER_A0_VECTOR" is undefined
      1 error detected in the compilation of "../main.c".

      >> Compilation failure
      gmake: *** [main.obj] Error 1
      gmake: Target `all' not remade because of errors.

      **** Build Finished ****



      This error occurs when I tried compiling the code.TIMER_A0_VECTOR IS UNDEFINED.Can you help me with that? Itll be of great help

      Delete
    3. okey , just try to create a new project , select the correct Part number of mcu. copy paste content of the C file into main.c . try to compile

      if still get error then please let me know

      Delete
  13. how to interface keypad for above experiment

    ReplyDelete
  14. what is the input that we have to give??

    ReplyDelete