Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

DIY: Retro Style Analog Volt Meter using Servo Motor

By Ganesh Selvaraj

 

Digital equipments have rapidly replaced Analog equipments in the long run. Well that is because the former has lot of advantages over the latter. But do you miss those retro style analog measuring instruments? Those pointy indicators and graduated scales? Well I do and so have decided to build one with the “modern” parts. This article will show you how to make a Retro Style D.C. Voltmeter which can measure in range of 0-30V. It is assumed that the reader has gone through the project How to get started with AVR and Interface Servo with AVR.

 

Image showing display panel of DIY Analog Voltmeter

Fig. 1: Image showing display panel of DIY Analog Voltmeter

Components Required

1.     ATMega16 development board

2.     Servo motor with servo horn

3.     Resistors

4.     Cardboard / Plastic box

5.     Cardboard sheet

6.     A Needle/ Old pen

 Concept & Voltage Divider Design

Concept of Voltmeter and Voltage divider Design Equation

We all know that ATMega16 (in fact any) microcontroller cannot bear more than 5volts and you would end up damaging its pins if you try to apply more than 5volts to it. But we need to make the instrument capable of measuring at least up to 30 volts to call it as a voltmeter! And that’s where the concept of voltage divider circuit comes into play. Once you understand this concept, you can build voltmeter of any range.

Basically, voltage divider is a circuit used to get a fixed fraction of input voltage as an output voltage. Take a look at the diagram below

Circuit Diagram of Voltage Divider Network

Fig. 2: Circuit Diagram of Voltage Divider Network

Here R1 and R2 are the resistors and Vin is the input voltage. The output voltage Vout is given as:

Vout =  Vin X R2/(R1 + R2) .  .  .  .  .  .  .  .  .  .  .  .  .  .  . (1)

We choose the resistor values based on our requirements. Like say now our maximum voltage to be measured is 30V but we can only give up to 5V to our controller.

So here maximum Vin = 30V and maximum Vout = 5V

Substituting in equation (1) and on solving, we get

R1:R2 = 5 : 1

So we can take R1= 5kOhm and R2=1kOhm

You can design voltmeter of any range using the above equation.

Making the Box and Scale

Making the Box and Scale

·        First take a cardboard/ plastic box and cut a rectangular hole to fit in the servo motor.

Image of plastic box taken to make voltmeter

Fig. 3: Image of plastic box taken to make voltmeter

Image showing marking on box to make a cutout

Fig. 4: Image showing marking on box to make a cutout

Image of cut out for servo motor made on the box

Fig. 5: Image of cut out for servo motor made on the box

Image of servo motor attached to the box

Fig. 6: Image of servo motor attached to the box

· Now add another layer of cardboard sheet to cover up the servo exposing only the rotating part of it. Download the template image given below and take a printout of it on an A4 sheet (landscape). Stick it onto the cardboard sheet neatly. Make sure you align the printout correctly.

Template Image for display panel of analog voltmeter

Fig. 7: Template Image for display panel of analog voltmeter

·Now take another part of card board piece and cut it in shape of an arrow mark. Then make a hole at the end of the arrow so that it can be fixed to servo axle.

OR

Simply take a needle/ pointy object and attach it to the servo horn and you are good to go!

Image showing a pen placed as needle of the analog voltmeter

Fig. 8: Image showing a pen placed as needle of the analog voltmeter

Servo Working Principle

Servo Working Principle:

The image below will give you a quick review on Servo motor working principle. You can get more details about the working principle here:  Servo Motor Control using 555 Timer IC

Diagram of Pulse Width Modulation and respective rotation of Servo Motor

Fig. 9: Diagram of Pulse Width Modulation and respective rotation of Servo Motor

Servo motor is capable of rotating 180 degrees, but here for our convenience we are using only 150o span (-90 to +60 degrees) so that we get a resolution of 5o/volt (i.e. 150o/30V)

Table listing servo motor angle respective to supplied voltages

Fig. 10: Table listing servo motor angle respective to supplied voltages

Code Explanation

Well the code is pretty simple and straight forward.

–         Initialize the 16 bit ADC mode of the controller

–         Initialize the Pulse Width Modulation function for the servo control

–         Enter an infinite loop

–         If PC0 goes low then move the pointer to maximum deflection position and come back to original position

–         Read the voltage level at ADC1, convert it into a 16-bit discreet value (0 to 1023) and store it in a variable “val”.

–         Divide the value at “val” by 1024 and then multiply it with 30. This gives you the original applied voltage value.

–         Now adjust the servo angle according to the original applied voltage.

Conversion Process Example

·        Let us say that we applied some input voltage Vin= 24V to the system

·        Now from the design equation the output voltage of voltage divider circuit can be calculated. Here the output would be 4V which is the input to the ADC pin of microcontroller

·        The controller would covert the analog value (0-5V) into a discreet value of range 0-1023. In this case the value would be around 819.

·        Next, this discreet value is again converted into the original input voltage range which is 0-30V through programming. Here the value obtained would be 23.99 which is almost equal to 24V!

·        Now the obtained value is used to set the angle of the servo motor. The voltage range of 0-30V is scaled to 0-150o range giving us a resolution of 0.2V/degree

Block Diagram of AVR ATMega16 and Servo Motor based Analog Voltmeter

Fig. 11: Block Diagram of AVR ATMega16 and Servo Motor based Analog Voltmeter

Initial Setup:

·        Dump the code into the controller and connect everything together.

·        Connect nothing to the input. Now the voltage applied to the system is zero so fix the pointer to the servo axle such that the needle coincides with “0” mark on the scale.

·        Now press the TEST button and you should see the pointer moving to maximum deflection point, i.e. to the “30” mark. After few seconds it will go to the zero point.

Troubleshooting:

Case 1: If there is deflection of 150o but the pointer doesn’t coincide with 0 and 30 mark.

Error: The pointer is not placed correctly on the axle. Adjust the pointer position by removing from servo axle and putting it back properly.

Case 2: Deflection produced when TEST button is pressed is more or less than 150o (i.e. the pointer doesn’t coincide with 30th mark.)

Error: There is something wrong in the OCR1A value. Look into your servo motor’s datasheet to find out the pulse width for the standard angles.

Case 3: The pointer keeps on fluctuating.

Error: The external voltage which you are measuring may contain some noise or AC components. Remember that the controller needs some time to convert the analog input voltage into a digital value.

OR

Check the power supply to the system. Note that servo draws large amount of current.

 

Note

Please do not expect this project to replace a commercial digital voltmeter. Although it shows the voltage value correctly up to a certain extent, it is not as accurate as a commercial voltmeter.

 

 

Project Source Code

###


/*

 * analogm.c

 *

 * Created: 11/23/2013 6:35:25 PM

 *  Author: GANESH SELVARAJ

 */ 


#define F_CPU 16000000UL

#include <avr/io.h>

#include <util/delay.h>


void Waiting(int j) // simple delay function

{

uint8_t i;

for(i=0;i<j;i++)

_delay_ms(200);

}

void SetADC()

{

ADMUX|=(1<<REFS0);

ADCSRA=(1<<ADEN)|(7<<ADPS0);

}



uint16_t ReadADC(uint8_t ch)

{

//Select ADC Channel ch must be 0-7

ch=ch&0b00000111;

ADMUX|=ch;


//Start Single conversion

ADCSRA|=(1<<ADSC);


//Wait for conversion to complete

while(!(ADCSRA & (1<<ADIF)));


//Clear ADIF by writing one to it

ADCSRA|=(1<<ADIF);


return(ADC);

}


int main(void)

{

     DDRC=0b11111110;

PORTC=0b00000001;

int val=0,servo=0;

float dig_val=0.00;

//Configure TIMER1

     TCCR1A|=(1<<COM1A1)|(1<<COM1B1)|(1<<WGM11);   //NON Inverted PWM

     TCCR1B|=(1<<WGM13)|(1<<WGM12)|(1<<CS11)|(1<<CS10); //PRESCALER=64 MODE 14(FAST PWM)


     ICR1=4999; //fPWM=50Hz (Period = 20ms Standard).


     DDRD|=(1<<PD5); //PWM Pins as Out

SetADC();



while(1)

    {

        

if (PINC==0)

{

OCR1A=150; //Full Scale Deflection which is 150 degrees or +60 degrees

Waiting(20);

OCR1A=525; //zero deflection which is 0 degrees or -90 degrees

Waiting(20);

}

val=ReadADC(1);

servo=((val/1023.00)*375.00);

dig_val=((val/1023.00)*30.00);


OCR1A=525-servo;


Waiting(1);

    }

return 0;

}

###

 


Circuit Diagrams

Circuit-Diagram-AVR-ATMega16-Servo-Motor-based-Analog-Voltmeter


Filed Under: Electronic Projects
Tagged With: atmega16, voltmeter
 

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Introduction to Brain Waves & its Types (Part 1/13)
  • Understanding NeuroSky EEG Chip in Detail (Part 2/13)
  • Performing Experiments with Brainwaves (Part 3/13)
  • Amplification of EEG Signal and Interfacing with Arduino (Part 4/13)
  • Controlling Led brightness using Meditation and attention level (Part 5/13)
  • Control Motor’s Speed using Meditation and Attention Level of Brain (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • What are the battery-selection criteria for low-power design?
  • Key factors to optimize power consumption in an embedded device
  • EdgeLock A5000 Secure Authenticator
  • How to interface a DS18B20 temperature sensor with MicroPython’s Onewire driver
  • Introduction to Brain Waves & its Types (Part 1/13)

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Slope compensation ramp calculation for UCC38084
  • Parts storage / inventory best practices and organization
  • Unusual gap shape of ETD59 ferrite core?
  • Vco cadencd
  • WH-LTE-7S1 GSM module and SIM card problem

RSS Electro-Tech-Online.com Discussions

  • HV Diodes
  • intro to PI
  • Very logical explanation on low calue C3
  • Need help working with or replacing a ferrite tube
  • Help wanted to power an AC120v induction motor ( edited from Brushless motor - thank you @SHORTBUS= )
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering