Introduction: Digital Voltmeter With CloudX

About: Am an Embedded Systems Engineer, an Inventor, Tech Instructor and Educationist, Father of Opensource Technology in Africa, Co-Founder ByteHub Embedded

Batteries provide a purer form of DC (direct current) power when employed in circuits. Their low noise level always makes them a perfect fit for some very sensitive circuits. However, at times when their voltage level run down below a certain threshold point, the circuits −(which they are meant to power), might enter into an erratic behavior; especially when they are not well designed to handle that.

Hence, there arises the need to regularly monitor the battery power level to properly guide us as to when it is due for a total replacement, or charging −in case of a rechargeable battery. Therefore, in this DIY (Do It Yourself), we are to design a simple battery voltage meter using the CloudX –using the 7Segment as our display.

Step 1: Hardware Requirement

Step 2: CloudX M633 Microcontroller

CloudX Microcontroller Module

CloudX module is an electronics design hardware tool that allows you a much convenient and easy way of interfacing with the physical world via a simple microcontroller board. The whole platform is based on an open-source physical computing. Its simplicity of an IDE (Integrated Development Environment) really makes it a perfect fit for beginners, yet retaining an enough functionality to allow the advanced end-users navigate their way through. In a nut-shell, CloudX provides for a much simplified process of handling the microcontroller −by abstracting away the normal complex details associated with it; while at the same time offering a very rich user-experience platform. It finds wide applications cutting across board: schools, as a great Educational tool;industrial and commercial products;and as a great utility tool in the hands of a hobbyist.

Step 3: Pin Connections

The 7-segment pins: A, B, C, D, E, F, G, 1, 2 and 3 are connected to the CloudX-MCU’s pin1, pin2, pin3, pin4, pin5,pin6, pin7, pin8, pin9, pin10 and pin11 respectively.

Step 4: Circuit Diagram

The microcontroller module, being at the center stage here, can be powered on:

either via the Vin and the Gnd points (ie. connecting them up to your external power-supply-unit’s +ve and –ve terminals respectively) on the board;

or through your CloudX USB softcard module

. More over, as could be easily seen from the circuit diagram above, the input battery voltage is interfaced with the MCU (microcontroller) module such that the –point of the voltage divider network (formed by and ) is connected to A0 of the MCU pin.

and are chosen in such a way as to:

limit the amount of current that flows through the network;

limit within a safe range of (0 – 5)V for the MCU.

Using the formula: VOUT = (R2/(R1+R2)) * VIN; and can easily be evaluated.

Voutmax = 5V

and for this project, we choose: Vinmax = 50V;

5 = (R2/(R1+R2)) * 50
R1 = 45/5 * R2
Taking R2 = 10kΩ for instance;
R1 = 45/5 * 10 = 90kΩ

Step 5: ​Principle of Operation

When the input measured voltage is read via the VOUT point of the voltage divider network, the data is further processed in the MCU to evaluate to the final actual value that displays on the segment unit. It (the system design) is an automatic decimal point placer, in that it (decimal point) actually shifts position on the display-unit itself in accordance to what the float value dictates at any given point in time. Then, the whole hardware 7-Segment display unit is wired up in the multiplex-mode. It is a special arrangement whereby the same data bus (8-data pins) from the MCU feeds the three active 7-segments in the display unit. Sending data pattern into each of the component parts is achieved by a process referred to as Scanning. Scanning is a technique involving sending data across to each of the component 7-segments; and enabling (ie. switching on) them in quick succession as their respective data arrive. The rate of addressing each of them is done such that it succeeds in deceiving the human vision into believing that all of them (the component parts) are enabled (addressed) at the same time. It (scanning) simply, in effect, utilizes a phenomenon known as Persistence Of Vision.

Step 6: The Software Program

#include<CloudX\CloudX.h>

#include<CloudX\stdlib.h>

#include<CloudX\Adc.h>

#define segment1 pin9

#define segment2 pin10

#define segment3 pin11

float batt_voltage;

int decimalPoint, batt;

/*arrays that store segment-pattern for each given digit*/

char CCathodeDisp[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F};

char CAnodeDisp[] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};

int disp0, disp1, disp2;

display() {

unsigned char i;

if(decimalPoint < 10) {

disp0 = (int)batt_voltage /100; //fetches the MSD (Most Significant Digit)

//being the highest weighted

/* fetches the next weighted digit; and so on */

disp1 = ((int)batt_voltage % 100)/10;

disp2 = ((int)batt_voltage % 10);

}

else {

disp0 = (int)batt_voltage /1000;

disp1 = ((int)batt_voltage % 1000)/100;

disp2 = ((int)batt_voltage % 100)/10;

}

/*Patterns are poured out for display; and 0x80 character adding a decimal point

if the associated condition holds true*/

for(i=0; i<50; i++) {

pin9 = pin10 = pin11 = HIGH;

if(decimalPoint < 10 )

portWrite(1, CCathodeDisp[disp0] | 0x80);

else portWrite(1, CCathodeDisp[disp0]);

segment1 = LOW;

segment2 = HIGH;

segment3 = HIGH;

delayMs(5);

pin9 = pin10 = pin11 = HIGH;

if((decimalPoint >= 10) && (decimalPoint < 100))

portWrite(1, CCathodeDisp[disp1] | 0x80);

else portWrite(1, CCathodeDisp[disp1]);

segment1 = HIGH;

segment2 = LOW;

segment3 = HIGH;

delayMs(5);

pin9 = pin10 = pin11 = HIGH;

if (decimalPoint >= 100)

portWrite(1, CCathodeDisp[disp2] | 0x80);

else portWrite(1, CCathodeDisp[disp2]);

segment1 = HIGH;

segment2 = HIGH;

segment3 = LOW;

delayMs(5);

}

}

setup(){ //setup here

analogSetting(); //analog port initialized

portMode(1, OUTPUT); //Pins 1 through to 8 configured as output pins

/* scan pins configured as output pins */

pin9Mode = OUTPUT;

pin10Mode = OUTPUT;

pin11Mode = OUTPUT;

portWrite(1, LOW);

pin9 = pin10 = pin11 = HIGH; //scan pins (which are active-low)

//are disabled at the start

loop(){ //Program here

batt_voltage = analogRead(A0); //takes in the measured value

batt_voltage = ((batt_voltage * 5000) / 1024); //conversion factor for 5Vin

batt_voltage = (batt_voltage * 50)/5000; //conversion factor for 50Vin

decimalPoint = batt_voltage; //marks where decimal point appears in

//the original value before data manipulation

display();

}

}