How to Measure (almost) Anything
VOLTMETER

We have designed a Volt Meter which measures the Microcontroller’s voltage. The process turned out to be complicated due to some pre-assumed definitions in the code which have brought about a journey into physical debugging. So here’s the spiel unfolding the luxury of learning from our mistakes.


STEP01
Circuit Design and Components Layout

The circuit is fabricated according to this weeks assignments protocols (see image to the left). 
We have de-soldered the resistor on the chip to make life easier and voltage “irresistible”. So there is no resistor on circuit board.



STEP02
Circuit Design and Components Layout

When executing the current code, the Python GUI is prompted to show the step-response cycle.
So we are essentially using Neil’s code to measure capacitance to begin with. The capacitance is defined as the property of a circuit element that allows it to store an electrical charge. The notion of “storing” is essential to the understanding of the “step response” design: The step response is basically the response of a filter to a sudden change in voltage amplitude at the filter input can result in overshoot (ringing). In this example we are using our finger (or the sampling of milk for that matter) as an additional resistor (and indeed capacitor) introducing voltage to the circuit.



STEP03
Testing the existing GUI

Curvature indicates capacitance value per one step (1 2 3 4 framing) over time.
STEP04
Modifying the existing Assembly code to measure voltage

The actual file is posted on site.
In short there is no need to add much more code, but mainly to take out bits and pieces which allow us to measure voltage. The main chunk of the code which is represented in the main loop and relates to the Delay-Loop routines has to do with the chunking of capacitance for the step-response reading. As we’re measuring voltage – we don’t really need that.
And so we remain with a slim code that initially measure capacitance to measuring voltage. We have not modified the registers and pin assignments. Far right image – a screen shot of the modified code.



STEP05
Testing the Code (running the rx.py)

Once we have modified the Python code we expect this to run smoothly and display the voltage values as numerical value. So upon stripping a short wire and connecting it to the ground and hi-pin we expect it to show values of [0] when grounded. Remember: the header pins from bottom to top are for now defined as ground, sense and hi-pin. Keep this in mind – this is where some of the confusion came from.

We were not entirely sure why we’re not getting serial data and all the more so – why zero values are not appearing when grounded. So we’ve decided to build a voltage divider.




STEP06
Voltage Devider and Trimpot

The two resistor voltage divider is used often to supply a voltage different from that of an available battery or power supply. In application the output voltage depends upon the resistance of the load it drives. Resistors: a (physically) larger one which carries the resistance of 100 ohms and a smaller one which carries the resistance of 910 ohms (together: 1000 ohms).




STEP07
Voltage Devider Test

The two resistor voltage divider is used often to supply a voltage different from that of an available battery or power supply. In application the output voltage depends upon the resistance of the load it drives. Resistors: a (physically) larger one which carries the resistance of 100 ohms and a smaller one which carries the resistance of 910 ohms (together: 1000 ohms)
Essentially we are pulling the (mid-pin) voltage and ground (bottom pin) close together and this exceeds the Tiny’s current capacity. If V=IR (voltage=current*resistance), and we know that V=5 volts and R=100 then I=1/20 (0.05 Amper). The Tiny microcontroller can only (by design) source 0.04 amps and so this is equivalent to turning the Tiny off.
We then expected to see the zero value upon grounding. But there was more to the story then just building a fancy voltage-divider.
STEP08
Physical Debugging 101: switching pin allocation by crossing wires

Since the code kept on reporting weird values and no zero values upon grounding we have realize that perhaps the problem is not in the code but rather – the physical circuit. David’s revelation brought about a new discovery: assuming the pins might be placed in the wrong order we decided to switch between the sense pin and the hi-pin. See image below for the detailed add-on.

Left images represents the voltage in its correct format (see following steps to learn how we got there). The top one shows ADC values (0-1023) and the bottom one shows actual values (0-5 VOLTS).
STEP09
Step_05: Physical Debugging 2: Trimpot

The trimpot is a device that controls the amount of current that flows through a circuit (such as a volume switch on a radio). This basically allows us to modify the resistance by displacing the dial in a continuous fashion and looking up the output values as voltage measurements. Note: the application of the Trimpot to the circuit is simply another way of controlling resistance in a continuous fashion as opposed to a “discrete” one-value fashion (such as the case of the voltage divider).

CLIK
NEXT at the bottom of the page to look at the modified GUI.