Wednesday, March 2, 2011

Arduino Volt-Ammeter - Final Part - Printed circuit board

After all job of building the prototype and making the sketch work, it's the time to build the circuit. It's not the objective to explain in detail how to make printed circuit boards, but only a superficial explanation about it, besides, of course, to present the project changes to make it works out of Arduino board.


It's a continuation of article: Arduino Volt-Ammeter - Part 1 - Breadboard

Schematic and board layout

Board designs are made with specialized softwares. There are several available, including for free. In this project I prefered to use the CadSoft Eagle given it's components library size available on the web, an interesting tip is also download the SparkFun components library that appear to have all components that they sell, a wide variety, and can save a big drawing time. The schematic is a circuit logical view that is a prerequisite for drawing the tracks and validate it later.

Basically the requirements to run an Arduino project on an independent printed circuit board is a 5v power supply, a 16Mhz crystal oscillator, and, of course, link the microcontroller pins with all digital and analog ports of Arduino board. The diagram bellow is popular on web and explain how we need to draw the schematic to work as the prototype.


The new components that are needed to be added to prototype to work in a printed circuit board are:

  • 1 28 pin solder tail dip sockets (for Atmega microcontroller);
  • 1 power Jack connector for PCB;
  • 1 LM78L05 regulator;
  • 1 1uf capacitor;
  • 1 10uf capacitor;
  • 1 16MHz crystal oscillator;

With the new components and microcontroller pinout, we've got the following schematic:


Through schematic design it's possible to validate the tracks to build from circuit layout. After putting all devices on board layout, in order to facilitate their connections, it's necessary to manually write the tracks layout, because auto-routing functions usually do not do a good job. See how the layout was designed for this project:

Layout em PDF.


Building the printed circuit board

It's not the objective of this article to teach anyone to etch copper boards, for that there are several articles out there. But I'd like to make some important considerations.

The method used for this project was the heat transfer with clothes iron. I tried before to transfer the printer toner directly as explained in some articles out there. But as each printer has it's own characteristics is almost impossible determine a procedure that works in most cases, not to mention the various irons types and board sizes to be transferred. It's also notable the copper deterioration of the printed parts, which suggests that the transferred toner does not properly protect the copper during corrosion.

The solution found that worked better in this method was through Press-n-Peel paper. The blue polyester film is transferred together with the toner creating an optimal etching protection, as well as it's is removed much more easily when compared to using only toner in couche paper (or magazine paper). But make no mistake, it's not a trivial process and may also cause some waste with unsuccessful attempts. It's even recommended very careful handling with it because the blue pellicle is very delicated and any bend or scratching can remove it easily (I learned the hard way) and destroy the paper (that is not cheap).

After some damage trying to use the paper, I got a first good transfer (note that some adjustments were still needed, even minimal, with a pen):


Then, after etching:


And finally, cut and drilled:

Layout em PDF.

To cut and drill the board was used a Dremel 300 rotary tool attached to Workstation. We used a 1mm drill for all holes, but note that it was not very suitable for all components and opened so much some islands eliminating almost all their contact, which complicates a lot the soldering process. In such cases it's important to use an appropriate bundle of CNC drills.

Component soldering

The component positioning at board can be properly viewed in Eagle sources. The soldered parts were arranged as following:


In order to save the board from rust it was all tinned. This procedure makes the placement of components a little complicate, because it pulls the tin, but it is important to keep the board if it has no solder mask. As you can see, the tinned visual is not the best:


Finally I arranged some cables with special connectors to help in the new device usage:


Conclusion

In closing, a short demonstration of the device working:

74 comments:

  1. Replies
    1. I want arduino script(programme)
      Plz help me....

      Delete
  2. It is a great work. Hats Off to you Sir.
    I have a Lab Power Supply which have three different Voltages i.e. 5V, 12V and Variable
    Voltage 0 to 18V. How I can interface this to my Power supply? It will be great help to complete my college projects.
    What is IN and OUT terminals ?

    ReplyDelete
  3. Thanks, Harnam!! :D

    To use this device just connect the output of your power suply to the input of ammeter and then use the output of ammeter to supply power in your tests. Look at first complete PCB picture, that one with all components, in this article showing the correct position of input and output poles in screw terminals.

    Don't forget the calibration!!! :P

    ReplyDelete
  4. Thanks Renato Sir !
    I will build this device as soon as I get my components.
    1. Will it display the current simultaneously with the voltage.
    2. Can I use it for checking my Power Supply Input Voltage and Current which is 220 Volts, 50Hz. If yes, what changes I have to make.
    3. Another Question I use this power supply to do my college projects. Is it possible to display the current which is normally in milliAmps?

    ReplyDelete
  5. Harman,
    1. It Will show simultaenously. Check it on demonstration video.
    2. NOOO!! IT'S ONLY FOR DC!!!
    3. The display show the current in ampere with two decimal digits.
    Hope that it helps you.
    Thanks! :P

    ReplyDelete
  6. Thanks Renato Sir!
    I do not have words to thanks you. I am very glad that now my Lab Power Supply has its own VA meter.
    How to integrate the Digital Multiple Voltage Power Supply (http://www.electronics-lab.com/projects/power/020/index.html) with this Arduino unused pins pin 2 & 7(Switches (INPUTS) S1 and S2) and Analog pins 2,3,4,& 5 as a digital pins for Output.

    The source code written is for ATtiny 2313 and it is diffrent from the Arduino codes.

    Regards

    ReplyDelete
  7. GOOD!!! \o/

    Herman, if I properly understood, youre trying to add the voltage regulation at same board. It's a very good idea. The project of this article is good, but I would prefer to use a digital potentiometer (ex.: http://www.sparkfun.com/products/10613) to select the voltage instead of using a fixed options with resistors. It's because when you need to test a battery level sensor or a low/high voltage voltage cutoff, for example, It's better when you can to choose the voltage more precisely. And remember that analog regulators gets hot faster than we can think and they have low efficiency.

    []s :P

    ReplyDelete
  8. Hi! This is extremely useful project!! I have assembled it with LM317 voltage regulator to power a Gunn oscillator (1.25-6VDC @1A). However, I it seems to have some callibration issue. It looks like follows: If I have 2.2 Ohm resistor as a load, arduino VA meter shows 1.52/1.48V and 1.52 V on calibrating voltmeter. Now, if I disconnect the load, arduinos reading goes down to 1.37V, but calibrating voltmeters readings goes up to 2.07 V (as it should be). I guess arduino's has additional voltage drop on the shunt resistor, which in my case is 0.68 Ohm. By how much does the shunt resistor affects readings? Is it possible to have consistent readings with load and without the load?
    Again, Thank You very much!!!

    ReplyDelete
  9. Andris, it's pretty strange. Tell me more about how you built it.
    Many thanks! :P

    ReplyDelete
  10. Here is how I've modified the circuit (removed buzzer and conected LM's output in the input).
    http://shareimage.org/images/ijsaxpt8tlwh50t1hxxd.png. There is something wrong with the voltage division and I can't understand why. It doesn't give proper measurement on the point between R8 and R9. It is divided by factor of around 10 (but not exactly), however voltage here increases if I connect the load in the output...

    ReplyDelete
  11. Andris, we can't predict all circuit resistence and the real R8/R9 precision, it's the reason for calibration exists. I noted that the calibration may vary with the LM78L05's input voltage, but I never seen before the measurement going down when the real input went up on input bornes. Are you ensuring a stable at least 7v for LM78L05?

    ReplyDelete
  12. OK, after some mumbo-jumbo with the bunch of wires on the breadboard I've got it to work as it is supposed! :D However, I do see the role of the shunt resistor. Either I need to calibrate meter for specific load, or voltage drop on shunt should be taken into account and summed internally to the voltage readings. I am also considering to use small resistance shunt and an opamp. But that's for later. This is my first arduino project, but it tends to be very educational. Many Thanks!!! :)

    ReplyDelete
  13. Did you improve the equation that calculate the values? Share it with us, plz! :D

    ReplyDelete
  14. Renato Sir,
    Your idea about using digital potentiometer is great. I was looking for the part but it was not available in the market. It will take couple of days when it will be available with our vendor.

    In the mean time, Can you guide to convert this code into Arduino sketch? How we can integrate this with this Voltage Ammeter?

    ReplyDelete
  15. Hi, Harnam. I think that you will need to capture more two buttons for UP/DOWN voltage control and send the right signal to potentiometer. It's not a big ammount of code, but you need to read the potentiometer datasheet to understand how to use it. The real problem is the amount of ports left available by ammeter. I think that all the five buttons could be handled by only one analog port.

    ReplyDelete
  16. Ronelto Sir,

    It will take some time to get the digital potentiometer from the Vendor. In the mean time, Can we try to play around with the given circuit of http://www.electronics-lab.com/projects/power/020/index.html without integrating to the Arduino Voltmeter-Ammeter Ckt.? Switch S1 and S2 can be connected to Arduino Pin7 & Pin 2(By removing the connection of backlight of LCD from pin7 and connecting the backlight directly to the +5V of LCD through resistance, pin 7 will be free to use and Pin2 is already spare to use).
    4 Analog pins (2,3,4&5)can be used as a digital
    pins for 3.3V, 5V,9V and 12v outputs.
    I am begineer, I don't know much about the coding. Please help in coding


    //pins
    Const int PIN_UP = 7;
    Const int PIN_DN = 2;
    Const int PIN_OUTPUT1 = 16; //Analog pin 2
    Const int PIN_OUTPUT2 = 17; //Analog pin 3
    Const int PIN_OUTPUT3 = 18; //Analog pin 4
    Const int PIN_OUTPUT4 = 19; //Analog pin 5

    void setup () {
    //configure pins
    pinMode (PIN_UP,INPUT);
    pinMode (PIN_DN,INPUT);
    pinMode (PIN_OUTPUT1, OUTPUT);
    pinMode (PIN_OUTPUT2, OUTPUT);
    pinMode (PIN_OUTPUT3, OUTPUT);
    pinMode (PIN_OUTPUT4, OUTPUT);

    How to proceed further

    ReplyDelete
  17. Harnam, hello...

    Look, my name is Renato! OK? :D just kidding.. :P

    To handle many buttons with only one analog port you need to assemble a set of buttons in series with resistors and then use the analogRead() to get the value. You will note that, due to the series of resistors and buttons, you will have diferent readings for each one that you push. These values are what you will need to map.

    This post at Arduino forum is very explanatory: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1226896251

    Try it and come back to say us if it worked.

    ReplyDelete
  18. Hi,

    I need a little clarification:

    the voltmeter, reads from 0 to ?
    the ampere meter, reads from 0 to ?

    ---------

    I also noticed that the ampere meter is not very precise, if instead of a resistance of 0.47 ohms, they put a smaller one, I could fix this?

    thank you ;)

    ReplyDelete
  19. Voltmeter reads from 0 to 50v and the amperemeter from 0 to 10a, but may vary a bit after calibration.

    If I properly undestood the issue, the problem with precision is due to it's wide measurement range. If you look at common voltmeters, they usually have their scales divided in small ranges that you need to choose before to use and usually with only one decimal number.

    ReplyDelete
  20. thank you,
    have a good work ;)

    ReplyDelete
  21. Renato Excellent work, and thank you for posting.

    How much current can this meter handle?

    ReplyDelete
  22. It will measure until 10A, but I never tested before from wich point it will start to burn.

    ReplyDelete
  23. Hello Renato Sir !'
    Our semester is Over and I have time to play around with Arduino and improve my Lab Power Supply. I experimented with one analog pin by connecting the 5 push buttons Btn1 (220 Ohms), Btn2 (390 Ohms), Btn3 (680 Ohms), Btn4 (2.2K), Btn2 (4.7K). One end of the button is tied to +5V and other end to ground through 1K. The output is tested by connected 5 leds. I got the following readings in the serial monitor
    button 1= 838
    button 2= 735
    button 3= 608
    button 4= 319
    button 5= 177

    Code:
    Int led1 =3;
    Int led1 =4;
    Int led1 =5;
    Int led1 =6;
    Int led1 =7;

    int sensor = A0;

    Void setup() {
    Serial.begin(9600);
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
    pinMode(led3, OUTPUT);
    pinMode(led4, OUTPUT);
    pinMode(led5, OUTPUT);

    // read the state of the analog value

    void loop () {
    sensorValue=analogRead(sensor);
    sensorValue /=1024;

    Serial.print ("\nVal#");
    Serial.println (sensorValue);

    if(sensorValue >=838)

    {
    digitalWrite(led1,HIGH);
    delay (50);
    } else
    {
    digitalWrite(led1,LOW);
    delay (50);
    }
    if(sensorValue >=735)

    {
    digitalWrite(led2,HIGH);
    delay (50);
    } else
    {
    digitalWrite(led2,LOW);
    delay (50);
    }

    if(sensorValue >=608)

    {
    digitalWrite(led3,HIGH);
    delay (50);
    } else
    {
    digitalWrite(led3,LOW);
    delay (50);
    }
    if(sensorValue >=319)

    {
    digitalWrite(led4,HIGH);
    delay (50);
    } else
    {
    digitalWrite(led4,LOW);
    delay (50);
    }
    if(sensorValue >=177)

    {
    digitalWrite(led5,HIGH);
    delay (50);
    } else
    {
    digitalWrite(led5,LOW);
    delay (50);
    }
    }


    PROBLEM:- . When the push button is pressed, led comes ON but when released it goes OFF. I failed to toggle it. Please help to resolve this issue pertaining to latch the button.
    (One push ON second push to OFF)

    ReplyDelete
  24. Hmmm.. Look, LEDs will turn off at first loop after you release the button because youre using "else" without any condition inside the main loop(). To do what you want, it will need a bit more controls to handle unique clicks and LED on/off event. Remember that one simple click may affect many loop() executions.

    If you wait a bit, maybe until tomorrow, I can add this support to ebl-arduino button handler. It will permit to handle single clicks, double clicks and hold time; as it's already possible with digital ports.

    ReplyDelete
  25. Renato Sir,

    How to proceed to integrate the digital power supply as per http://www.electronics-lab.com/projects/power/020/index.html) in the same board.

    By using one analog pin for controlling 5 digital
    buttons ?

    ReplyDelete
  26. Is there someone who did the calculation if its possible to get 3 decimal digits with different voltage divider for 30v-3A? (http://www.electronics-lab.com/projects/power/001/index.html, upgraded version)

    Nice project btw, will be build =)

    ReplyDelete
  27. Very helpful post for my PCB "Printed circuit Board" Designer where they can get some ideas also.

    ReplyDelete
  28. That's a superb post.. Thanks for step by step guide to design this type of circuit board. Like this video tutorial also.

    ReplyDelete
  29. Hello
    Good job.
    Can you give an example of the program only on current measurements.
    I need to measure the current 4-20mA

    ReplyDelete
  30. A very well done Renato, this is literally EXACTLY what I have been looking for! So thank you for taking the time to document it on your blog :D

    One quick question; I'm new to the Arduino - did you just pull the Atmega chip from the Arduino for the independent board?

    Thanks again! :D

    ReplyDelete
    Replies
    1. Yeah! I use Arduino only to debug the software and write the micro controller. I bought a couple of chips to work this way.

      Delete
  31. Hi. Really very nice work!!. But when i tried to download the Eagle files, some FBI anti-piracy warning prevented me from doing so. Is there any other way to get these files???
    Thank you for your time and effort

    ReplyDelete
    Replies
    1. Sorry, but all the blog's download content was hosted at megaupload and I'm not having enough time to fix it in these days. I will find another place to host everything again soon.

      Delete
  32. Great work !!! But I was a bit disappointed when I found that your files had been removed... how does it look with your time ? Can you make them available ? Looking forward to it ... :-)

    ReplyDelete
  33. Hi Renato,
    Good job. I have something to ask, how can we create a instruction code to control the amount of the current flow. Example, i want to set my current limit until 1A, then if the the circuit detect the current over the limit, it will send one output instruction to energize a relay. Can you help me for the code? Urgent..

    ReplyDelete
  34. Hmm.. Sounds like good. Can you please post more details about this circuit board.

    Have any of youse had any experience with any pcb assembly companies that do this?

    ReplyDelete
  35. Thank you for posting the great content…I was looking for something like this…I found it quiet interesting, hopefully you will keep posting such blogs….Keep sharing. Love your blog.
    printed circuit board fabrication

    ReplyDelete
  36. I see the files still aren't available. Can I suggest using google code to host it? http://code.google.com

    ReplyDelete
  37. Hi, great project! I want to make it, but the files are uploaded on Megaupload, which is closed. Can you upload them again?

    Thanks,

    ReplyDelete
  38. Hello,

    Congratulations on your creation.
    Could you put new link to download the schematic and board?
    Thank you.

    Mathis

    ReplyDelete
  39. In the assembled picture I notice a transistor that is not listed in the parts list? What is the part number? NPN or PNP

    ReplyDelete
  40. great article. The way you explained it is really awesome and makes every one to read till the end. keep posting.. pcb assembly services

    ReplyDelete
  41. Dear Sir,

    Could I connect the input of a variable power supply to your circuit and take the voltage from the output, for 0-10 V and 0-10 A do I understand this correctly ?

    ReplyDelete
  42. Dear Sir,

    Could I connect the output of a variable power supply to the input of your circuit and take the voltage from the output of your circuit, for 0-10 V and 0-10 A, do I understand this correctly ? Also, aren't the 22pf capacitors normally going with crystals necessary ? Sorry for the double post, I made a mistake the first time.

    ReplyDelete
  43. Ted, you're right... It's useful be used together with an adjustable power supply. And you're right about the crystal capacitors as well. When I was building this project I did not have them available, but it's not really critical for this application.

    ReplyDelete
  44. Dear Sir,

    Thanks for the answer. I made the circuit from the Eagle file provided, using your schematic without changes but with changes to PCB (added the capacitors, changed the position of components to fit a box I have).
    The indication for voltage and amperage are changing continuously. For example, using 9 v from a battery on input, it goes like 12.3 , 14.8 , 18.1 when I believe (as shown in youtube video above) it should show something close to 9 volts, where I should adjust it with setup to be saved to eprom. Any idea what I might did wrong? I didn't made any changes to the program. I used an Atmega 168 with Duemillanove boot from 0.22 IDE.
    Thanks again,
    Ted

    ReplyDelete
    Replies
    1. Ted, check your PCB for shorts that can easily occurs during etching or soldering.

      Delete
  45. Dear Sir,
    After some checking, I don't see any short. Do you have an email address in which I could send you my version of the circuit ?
    Thanks, Ted.

    ReplyDelete
  46. Dear Renato,

    Nevermind my previous post. I saw a difference between your PCB and my version. I didn't connect the input voltage ground to the rest grounding of my PCB, as I saw was the case with your PCB. Problem solved with a piece of wire (though I don't understand really what changed with that. I am a beginner, you know...).
    Thanks again for your answers, and for the Arduino Ammeter.
    Ted.

    ReplyDelete
  47. Really, you provided some great information in this post. I highly acknowledge your proficient approach. I can say that you made an authentic effort. Keep sharing such great posts.

    ReplyDelete
  48. Awesome project, could you please update the download link? It gets a weird infinite redirect

    ReplyDelete
    Replies
    1. Double check it again, please! Beacause it is working for me.

      Delete
  49. Hi, great project. I'm going to use it and make 2 V-A meters for my DIY PSU. My PSU is double 0-30V 3A. How much is the maximum voltage input for your Arduino Project? And also, if I put two V-A meters and I connect my PSU in dual mode +-30V will it work with the Arduino V-A meter?

    ReplyDelete
    Replies
    1. The input is regulated by a LM78L05 regulator, but when I tried to apply a 24v input it started to overheat and then to turn on and off continuously. When I say "input", it is the power that makes the circuit work, and not the power source being measured.

      It will work without problems with measuring a maximum rate of 30V and 3A, but It will not work with negative voltages due to limitations in analog to digital converter.

      Delete
    2. I see, I will power the Arduino itself on a separate 12V power supply. So the voltage divider can handle 30V for measuring? What is the limit for measuring voltage? I don't care that Arduino can't indicatge the negative voltage, but will something burn if I connect my secont PSU positive to the first PSU GND?

      Delete
  50. Hello renato,
    Magnificent project, very interesting, thank you for sharing it.
    Could you say to me where you got yourself the resistances that you used? In particular the one that you used for the shunt (https://lh4.googleusercontent.com/_SlXk_jAXNLY/TdBMKbeKl7I/AAAAAAAAAM0/1GcSCY1521Q/placa5-legenda_en.jpg). Is it also a resistance of 1 % ? Because I do not manage to find a 0.47 ohm resistance 5W identical to your project, the one that I find are ceramic resistance (http://i.ebayimg.com/17/!By5cvU!EWk~$(KGrHqYOKjYEwtVE2y,OBMTqd,zRN!~~_35.JPG).
    Thank you for the interest which you will carry in my question.

    P.s: Please bear with me, I begin in electronics and also in English. Thank you.

    ReplyDelete
    Replies
    1. Its not a 1% and its not critical, this one that you found looks suitable. It's possible to calibrate using another ammeter as shown in the video.

      Delete
    2. OK, but the resistance which you uses for the shunt is not one 5W?

      Delete
    3. Yes, it is. The big green one.

      Delete
    4. Is it a metal film resistor(the big green one)?

      Delete
  51. This comment has been removed by the author.

    ReplyDelete
  52. This comment has been removed by the author.

    ReplyDelete
  53. Hello, I realized a prototype of your project and it works well, thank you again.
    Otherwise why do not to answer my last question?
    Does not my question have any interest?
    I would have wanted to know exactly which type of resistance you used in your project(1/4W, 1/8W, 1%, 5%, Metal Film, Metal Oxide, Carbon Composition...etc) that's all.
    P.s: There is that the voltage which calibrates? In fact the amperage calibrates automatically according to the voltage.I am wrong?

    ReplyDelete
    Replies
    1. Forget me, please. Answering here is not my main role. Moreover I have no idea about the shunt resistor chemistry, but only that it is a 5W 0.47R with 5% precision. The other ones are, if I properly remember, metal film with 1/4W and 1%.

      For calibrations you need a reliable input/output to fix the number shown in the display. The movie demonstrates how it is done. Note that if you calibrate with a 3V input, you will note a small deviation trying to measure 30V, this is why ordinary voltmeters has different scales.

      Delete
    2. A last question and I leave you,
      On my prototype during the calibration of amperes, I press on the buttons of calibration (up and down) but Nothing takes place, is it normal?(Sorry of you annoy)

      Delete
    3. Sorry for my misspelling, but my intention was to say "forgive me" instead of "forget me".

      Amperes calibration takes at least five more clicks than the voltage one. The reason is that the maximum value used to map the analog port input to the real number is 10 for amperes and 50 for voltage.

      Delete
    4. No problem, those are things which arrive.

      OK, everything is understandable, of the blow my prototype works well.
      Thank you for having taken time to answer me.

      Delete
  54. Hello Renato,

    First of all I thank you for sharing such a genuine work.
    And I understand how much time you might have spent to build this, I truly appreciate your job.

    Now my question:
    I'll build this PCB again with 22pF caps along with crystal using a bit more clearance between the tracks and pads using IRON press method of making PCBs. I'm unable to understand what changes do I need to make to set the WIDE range to a bit NARROW one, since I need to measure the voltage and current from a 30V,5A(max) solar panel.
    I'm trying to attach it to my solar charge controller.
    Please spare some time to answer my question.
    Thanks a lot again... :-)

    ReplyDelete
  55. hai sir, i need to know , to build up this VA arduino, we have to combine both part ? means part 1 and final part together ? o it is just 2 different options either we use breadboard o printer circuit board ? i have difficulty to understand .. thank in advance sir :)

    ReplyDelete
  56. hello sir i am test this circuit is running but volt and amp reding in fluxchation pleas help

    ReplyDelete
  57. hello sir i am test this circuit is running but volt and amp reding in fluxchation pleas help

    ReplyDelete