eCircuit  Center 
EE Design Series - DVM 1

About SPICE | SPICE Basics | Running SPICE | CIRCUIT COLLECTION
SPICE Commands | SPICE Downloads | About | Contact | Home

Software - Initial Test

pic

INTRO

Our first program verifies the basic functions of the voltmeter using a manual setting of voltage range. This limited test helps us focus on the ADC reading and display only. The Pushbutton for Range Select will be implemented in the next test.

NOTE: Even though we have NO analog prototype built yet, we can still write code and run a basic PRE-TEST with the Arduino UNO Board by itself.

Check out the Software Design overview.

Back to Design Series
 

ARDUINO BASICS

Here's the fast track version of running a C program (sketch) on your Arduino Board.

 

ARDUINO + ANALOG SCHEMATIC

The schematic shows the physical world that the code can control to implement our meter.

sch

 

FLOW CHART

Here's a shortened Flow Chart that skips the Pushbutton reading so we can focus on the ADC Read and Display.

pic

 

CODE STRATEGY / THEORY

A quick refresh of the ADC equation shows Vinput given the digital code ADCword.
   pic

You just need to set Kdiv depending on the present Voltage Range 

Similarly, set the divider switches according to the Voltage Range

Arduino Pin usage.

 

THE CODE

Caution Ahead - hardware person writing code! Granted, the program is so straighforward it's easy to create some reasonable code. However, I'm open to any suggestions from those with more Software experience.

Declarations

The variable declararions occur before the setup() function.

pic

 

Setup()

This code excecutes once in the Arduino Sketch. Note how the Vrange is set and then the digital bits D12,13 are set for resistor divider switches SW1,2. See comments in gray for code description.

pic

 

Loop()

This code runs continuously. The main voltmeter tasks happen here. To write this function, simply follow the flow chart and write the C code for each block. See comments in gray for program description.

pic

 

PRE-TEST

What can we test even though the analog circuitry has NOT been prototyped? Good news! We can jumper the Arduino's 3.3V supply directly into the A0 analog input.

 

NEXT UP

Having built and tested our initial working code, let's take the next step in creating software for a Basic Voltmeter by adding a pushbutton for Vrange change.

Back to Design Series