About SPICE |
SPICE Basics |
Running SPICE |
CIRCUIT COLLECTION
SPICE Commands |
SPICE Downloads |
About |
Contact |
Home
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
Here's the fast track version of running a C program (sketch) on your Arduino Board.
The schematic shows the physical world that the code can control to implement our meter.
Here's a shortened Flow Chart that skips the Pushbutton reading so we can focus on the ADC Read and Display.
A quick refresh of the ADC equation shows Vinput given the digital code ADCword.
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.
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.
The variable declararions occur before the setup() function.
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.
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.
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.
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