Embedded Systems and Power Electronics

Total Pageviews

About Me

My photo
I am currently a PhD student at UC Berkeley, following a 6-year journey working at Apple after my undergrad years at Cornell University. I grew up in Dhaka, Bangladesh where my interest in electronics was cultivated, resulting in the creation of this blog.

BTemplates.com

Powered by Blogger.

Jun 17, 2014

Simple AC voltmeter


I had long been thinking of designing a simple AC voltmeter but had somehow never gotten to it. However, with school just ending, and me going back to electronics, this was a neat simple yet useful circuit that I felt I could just get done with in a day or two.

The concept is fairly straight forward. Since I needed this only to measure the mains AC voltage and the output voltage of the sine wave inverter I was working on (based on the PIC32MX250F128B - more on this later), I didn't need to do any "true RMS" measurement. All I had to do was to convert the mains AC to DC, filter it and measure the peak voltage. Of course this had to be scaled down to a safe range for the microcontroller. The RMS voltage for a sine wave is equal to 0.707 (to 3 decimal places) the peak voltage.

The design was based on the Microchip PIC16F676. However I realized that I didn't have any in stock with me. So, I just used the pin-compatible PIC16F684. On the software side of things, the difference between the code for PIC16F676 and PIC16F684 is just one line. (See source file attached below.)

The variable resistor is adjusted so that the reading of my AC voltmeter matches that of a commercial voltmeter (Extech MA640 DMM). This is a sort of calibration.

CAUTION: THIS CIRCUIT IS NOT ISOLATED FROM THE MAINS AC AND HAS THE POTENTIAL TO BE LETHAL. YOU MUST BE VERY CAREFUL IF YOU ARE GOING TO USE THIS DESIGN. DO NOT ATTEMPT IF INEXPERIENCED. I CANNOT AND WILL NOT BE HELD RESPONSIBLE FOR ANY DAMAGE DONE WHILE USING THIS CIRCUIT.

Here's the schematic:

 Fig. 1 - Voltmeter

Here are some pictures:

 Fig. 2 - The PCB without (above) and with (below) the transformer


Fig. 3 - The test setup


Fig. 4 - Measuring voltage set with the variac


 Fig. 5 - Measuring voltage set with the variac


 Fig. 6 - Measuring voltage set with the variac

Fig. 7 - Measuring voltage set with the variac


C source file:
https://drive.google.com/file/d/0B4SoPFPRNziHdDB6cDdzNGZPdXc/edit?usp=sharing

http://www.4shared.com/file/Cz56s9Zlba/ACvoltmeter.html

mikroC project file:
https://drive.google.com/file/d/0B4SoPFPRNziHN2MydDRDalRWS1k/edit?usp=sharing
http://www.4shared.com/file/JwW3bpJNce/ACvoltmeter.html

Parts list (Excel XLSX file):
https://drive.google.com/file/d/0B4SoPFPRNziHb2ZCcnFNVnNpc2s/edit?usp=sharing
http://www.4shared.com/file/b_NcW4vdce/parts_list.html

Schematic (ARES DSN file):
https://drive.google.com/file/d/0B4SoPFPRNziHb1NFWDdwcWpJV2M/edit?usp=sharing
http://www.4shared.com/file/U6kPQH_rce/schematic.html

PCB (ARES LYT file):
https://drive.google.com/file/d/0B4SoPFPRNziHNDhhMDBkNFlnWW8/edit?usp=sharing
http://www.4shared.com/file/ZVczMJ7Wba/schematic.html

PCB (PDF files):
https://drive.google.com/file/d/0B4SoPFPRNziHMV9LdTBab1BXeDg/edit?usp=sharing
Mirrored:  https://drive.google.com/file/d/0B4SoPFPRNziHSmxvT1pSbXBWOTA/edit?usp=sharing

It's a fun simple yet useful project that you can build pretty easily if you want. Let me know what you think in the comments section below!

35 comments:

  1. Hi boss, Which software can I use to open lyt file?

    ReplyDelete
    Replies
    1. Proteus ARES. I've now posted PDF versions of the PDF so you can view it easily.

      Delete
    2. Did you Components list,Schematic Diagram and code

      Delete
  2. When you put the smoothing capacitor C2 directly after the diode you have to use a bulky (and relatively expensive) capacitor with a voltage rating of about 400V, so why not put it after the voltage divider network and use a capacitor with a much lower voltage rating (smaller).

    ReplyDelete
    Replies
    1. The main reason I decided to go with the larger capacitor instead of one at the voltage divider output is due to the 'response time of the circuit'. The 400V capacitor gives me very quick response with changing voltage.

      I have worked on a second voltmeter which does not require this cap at all since the voltage is calculated by figuring out the peak voltage in software. I've just had some issues with balancing the timing of the voltage conversions to make sure that the timing of the seven segment display isn't interrupted (as of now, you can see the display 'blink' periodically). I'll have the issue resolved soon once I get back to that.

      If you want to suggest some other form of voltage conversion and detection, I would appreciate that.

      Delete
    2. it would be great tahmid. Even for dc measurement i do not have always pure dc line. I am looking for your new tutorial

      Delete
  3. Yes it is a great work coming out from u but ur work. When I compiled the source code using mikro C and I simulated it using proteus and foud out that the third switch pin of the 7-segment is not working there by display is not working normal. Pls post the HEX file with the working proteus design it will help us to make use of ur circuit indeed.

    ReplyDelete
    Replies
    1. For proteus simulation, it may be necessary to provide pull-up resistors to the common cathode pins. Try that and let me know how that goes.

      Delete
  4. please can you help me
    i cannt find irf2110 on proteuse

    ReplyDelete
    Replies
    1. I have not used IR2110 on proteus. I just had the block for drawing schematics - no simulation. IR has spice models for the IR2110, if I am not mistaken, on their website. Have you looked at those?

      Delete
  5. pl post some details with 74595 +16f676 vm interphase

    ReplyDelete
  6. Hi Tahmid,

    Could you please suggest me any cost effective and reliable circuit to monitor AC INPUT and AC OUT Voltages and Load Current of an Inverter. I have seen in few schematics with Input and Output are directly connected to microcontroller ANALOG PINS WITH 220K * 3 Resistors. Is that safe but in most of the inverters it is done such way and Netural is directly connected to gnd pin(neutral and Gnd pins are same)

    Thanking You,
    Ravi Kumar

    ReplyDelete
  7. NOT WORKING... WHERE THE HEX... !!!!

    ReplyDelete
  8. please do it for ATMEGA16

    ReplyDelete
  9. Dear Tahmid
    We had written to you in Forum Edaboard about "using of ADC,PID and PWM in 16F877A.(user name cuneyt tasci) We coudnt find any example about this theme or any comprehensive explanning .If you help us about it we would be very appriciated for your guide.Regards

    ReplyDelete
  10. i want to change the c file into hex file..how can i do that.suggest me some softwares to do so or else could you please give me the hex file..

    ReplyDelete
  11. hi is the circuit safe? for high voltage like 550V. If correct capacitor and diode is used

    ReplyDelete
  12. i have download .c file but not compile in mplab ide 8.56 with icd3 so please help me which complier use and how to do

    ReplyDelete
  13. how to connect the ac input pin to the transformer primary, can ask the diagram image, because the image above is less clear of the pack


    This my email indrarummanzah27@gmail.com

    ReplyDelete
  14. Unable to compile code hex not generated please provide hex file and circuit diagram my email add. "Tariqpvz@Gmail.com"

    ReplyDelete
  15. I am Kishore Bhadra from kolkata . can you send me hex file and schematic diagram of pdf.
    my email is bhadra_5@hotmail.com

    ReplyDelete
  16. Dear sir,
    I want to from you .in the edaboard mr.sahu's post automatic voltage stabiliser circuit & hex code.Is it right or wrong ?
    Kishore Bhadra
    India

    ReplyDelete
  17. Really nice design. Kudos to you guy. One quick question, Please whats the function of diodes D6 and D7? I would love to know. Thanks.

    ReplyDelete
  18. please give the hex file ..thanks

    ReplyDelete
  19. Dear Sir,
    i am new this side , so ,if I get hex file
    how can I get it .

    ReplyDelete
  20. Hello yonder,
    I do appreciate your work. Please, I'm compiling the code in mikro C but error like "file 'trueRMSvoltmeter.c' not found" and "main function is not defined"
    Please can you share more light on it. I really wanted to build this project.

    ReplyDelete
  21. excellent result thank you very much

    ReplyDelete
  22. Yes it is a great work coming out from you. When I compiled the source code using mikro C pro v 7.2.0 it doesn't compil. It shows the error related to ADC. Please suggest me how i can compile. My email is mpc_electronics@yahoo.com.
    Regards
    Surinder Kapoor
    India

    ReplyDelete
  23. Please Tahmid, the "AC Input", is it direct mains or secondary of the Step-Down transformer?

    ReplyDelete
  24. Good day,I like this code, how can i get this code, Am using Pic16f886
    Micro C Compile, Thanks.

    ReplyDelete
  25. hi sir ,did u work for ur volt meter to improve it voltage is calculated by figuring out the peak voltage in software.

    ReplyDelete
  26. please help me for creating hex file i am not able to create hex file i think some error of your code
    please make a video for c code to create hex file step by step full tutorial

    ReplyDelete