Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Arduino powered voltage display

  1. #1
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Arduino powered voltage display

    Ok, I'm trying to make my Arduino display voltages for 12v, 5v and 3v lines. I've got a 16x2 LCD.

    First, is it possible to get all 3 displayed at once? As in the top line being "3.3V 5V 12V" spaced evenly, then the bottom line being the 3 readings. I know they won't update all at the same time, but that's no big deal.

    Second, if it's not possible, how do I need to set it up so when the unit is turned on it displays a welcome message, then with each button press it switches between 3v, 5v and 12v?

    Here's my code so far for the second setup (with only 3v and 5v for now, still have to figure out how to read 12v without frying something):

    Code:
    /*Arduino Controlled Voltage Monitor
    Code by Will Lyon 12/5/2010
    Code for project Power House on TBCS
    http://www.thebestcasescenario.com*/
    
    #include <LiquidCrystal.h>
    #include <math.h>
    int counter = 0;              //Add counter
    int buttonPin = 2;            //Attach button to pin 2
    
    // initialize the library with the numbers of the interface pins
    LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
    
    void setup() {
      pinMode(buttonPin, INPUT);   //Set button pin to input
      lcd.begin(16, 2);            //Set up the LCD's number of columns and rows
      lcd.print("  POWER  HOUSE");
      lcd.setCursor(0, 1);
      lcd.print("Desktop Pwr Unit");
    }
    
    void loop()
    {
      digitalRead(buttonPin);      //Read the button pin
      if (buttonPin = HIGH)        //If the button is pressed
      {
        counter + 1;               //Advance to next mode
        if(counter == 2)           //Reset count if over max mode number
        {
          counter = 1;
        }
      }
      if(counter == 1)
      {
        lcd.print("3.3 Volt Line");
        lcd.setCursor(0, 1);
        lcd.print(analogRead(2));
      }
      else if(counter == 2)
      {
        lcd.print("5 Volt Line");
        lcd.setCursor(0, 1);
        lcd.print(analogRead(0));
      }
    }
    It displays the opening message, but when the button is pressed nothing happens.

    Here is how it's wired up:



    any ideas? Thanks!

  2. #2
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Arduino powered voltage display

    ok with some help of the Arduino forums and references, this is the current code which works almost 100%

    Code:
    /*Arduino Controlled Voltage Monitor
    Code by Will Lyon 12/5/2010
    Code for project Power House on TBCS
    http://www.thebestcasescenario.com*/
    
    #include <LiquidCrystal.h>
    
    //Initialize the library with the numbers of the interface pins
    LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
    
    void setup()
    {
      lcd.begin(16, 2);                      //Set up the LCD's number of columns and rows
      lcd.print("  POWER  HOUSE");           //First line opening message
      lcd.setCursor(0, 1);
      lcd.print("Desktop Pwr Unit");         //Second line opening message
      delay(5000);
      lcd.setCursor(0, 1);                   //Clear bottom line
      lcd.print("                ");
      lcd.setCursor(0,0);
      lcd.print(" 3v    5v   12v");          //Update top line readout
    }
    
    void loop()
    {
      lcd.setCursor(0, 1);
      float f = analogRead(0) * 4.9 / 1023;     // 3.3 => 9.9
      lcd.print(f, 2);  // print float with one decimal
    
      lcd.setCursor(6, 1);
      f = analogRead(1) * 5.0 / 1023;         // 5.0 => 9.9
      lcd.print(f, 2);
      
      
      lcd.setCursor(11, 1);
      f = analogRead(2) * 12.0 / 1023;         // 12.0 => 25.0
      lcd.print(f, 2);
    
      delay(1000);
    }
    I need to find out why the 5v and 12v aren't reading properly. they're just sitting at 5.00 and 12.00 and don't change. if I change the coding (in the analogRead() ) sections for those two inputs, the value on the screen changes to whatever the multiplier is

    the 3v line I had to set the multiplier to 4.9 so the display readout was the same as what my multimeter said the line has. as for the other two, my meter says 4.85b and 12.4v respectively., and the lcd says 5.00 and 12.00

    I'm also using a voltage divider on the 12v line so as to not fry the Arduino. Here's how that is set up:

    12v---|51K|---+---|68K|---GND

    The Arduino's analog pin is connected to the "+"

    With this the sense pin is seeing 5.40v. Should I put a 10K to ground off the two analog pins for 5v and 12v?

  3. #3
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Arduino powered voltage display

    Alright well I got it sorted.

    here's the setup:


    and the code:
    Code:
    /*Arduino Controlled Voltage Monitor
    Code by Will Lyon 12/5/2010
    Code for project Power House on TBCS
    http://www.thebestcasescenario.com*/
    
    #include <LiquidCrystal.h>
    
    //Initialize the library with the numbers of the interface pins
    LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
    
    void setup()
    {
      lcd.begin(16, 2);                      //Set up the LCD's number of columns and rows
      lcd.print("  POWER  HOUSE");           //First line opening message
      lcd.setCursor(0, 1);
      lcd.print("Desktop Pwr Unit");         //Second line opening message
      delay(5000);
      lcd.setCursor(0, 1);                   //Clear bottom line
      lcd.print("                ");
      lcd.setCursor(0,0);
      lcd.print(" 3v    5v   12v");          //Update top line readout
    }
    
    void loop()
    {
      lcd.setCursor(0, 1);
      float f = analogRead(0) * 4.88 / 1023;   // 3.3 => 9.9
      lcd.print(f, 2);                        // print float with two decimals
    
    
      lcd.setCursor(6, 1);
      float g = analogRead(1) * 8.5 / 1023;	  // 5.0 => 9.9
      lcd.print(g, 2);
    
      
      lcd.setCursor(11, 1);
      float h = analogRead(2) * 17.25 / 1023;  // 12.0 => 25.0
      lcd.print(h, 2);
    
      delay(1000);
    }

  4. #4
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Arduino powered voltage display




  5. #5
    If you can't hack it, you don't own it! Oneslowz28's Avatar
    Join Date
    Mar 2007
    Location
    Aiken, Sc
    Posts
    5,084

    Default Re: Arduino powered voltage display

    How did I miss this? Nice work man! I will have to board this up one night!

  6. #6
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Arduino powered voltage display

    here ya go CJ

    :EDIT: had to fix the schematic for the LCD meter, will upload shortly

    oh and don't forget Louverduino! (have one of these on the way already)

    http://batchpcb.com/index.php/Products/47020

  7. #7
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Arduino powered voltage display

    alright fixed it and its up

    http://batchpcb.com/index.php/Products/48401


  8. #8
    Anodized. Again. Konrad's Avatar
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,060

    Default Re: Arduino powered voltage display

    Curious - what's the actual accuracy on this readout? Do you calibrate it with another meter? Or is extreme accuracy not really required for this application?

    Also - why the arbitrary 1000(ms?) delay? What's the fastest update rate your part can support? (I don't think the Arduino board will be sucking big power or overheating, much, lol ...)

    (I can see the x.xx digital resolution, and I suppose I can work out the fractional math, but higher precision does not in itself equal higher accuracy ... it all boils down to the limits for the Arduino/ADC and comparator/sensor parts ...)
    My mind says Technic, but my body says Duplo.

  9. #9
    Resident 100HP water-cannon operator SXRguyinMA's Avatar
    Join Date
    Jun 2008
    Location
    MA
    Posts
    5,865

    Default Re: Arduino powered voltage display

    I set the calibration in the coding according the my digital multimeter. it's within .01v of the multimeter's reading. The reason for the 1000ms delay is that it was originally set at 100ms, but the update on the LCD screen was way too fast, so the only reason I set it to 1000ms (1 second) was just for aesthetics mostly.

  10. #10
    Fresh Paint
    Join Date
    Jan 2011
    Posts
    3

    Default Re: Arduino powered voltage display

    Quote Originally Posted by SXRguyinMA View Post
    Alright well I got it sorted.

    here's the setup:
    (fritzing breadboard view)
    Small request: could you post the schematic view from fritzing or other tools when posting circuit designs? The breadboard view is cool, but it's easier to see what's connected to what in the schematic than tracing connections on the breadboard or PCB. Took me a while to reverse-engineer the voltage dividers :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •