[image of digits] C++ Builder - Sampling

Sensors - Actuators - Encoders - Steppers - Switches
Pneumatics
- Realworld Interfacing - Circuit Bending - Robots
Sampling the Analog Realworld with an Analog-to-Digital (AD) Converter

How does the computer* sense and perceive the world around it? How do we sense and perceive the world around ourselves? Some representations of that world are ANALOG** or continuous, while others are DIGITAL** or discrete. As humans, we perceive colors ranging across a continuous ANALOG spectrum; yet we name individual colors on that spectrum with discretely different words. Natural language is DITIGAL. Our emotional atttachment to another person may similarly range across an ANALOG spectrum, yet we may dichotomize those feelings as the DIGITAL states of "love," "indifference" and "hate." With similar DIGITAL logic we may conclude that a "friend" of a "friend" is a "friend," and a "friend" of an "enemy" is an "enemy." Translations from ANALOG to DIGITAL and from DIGITAL to ANALOG are foundational to human perception, to our emotions, our language and our reasoning. In like manner they are foundational to the senses and perceptions of the world in which computers are imbedded.

Much of the realworld is perceived as ANALOG; it comprises relatively continuous, smooth, changes in the intensities of things (variables), with no apparent jumps or gaps.
In a computer, the world is sensed and perceived as DIGITAL; the computer SAMPLES the state of the world at intervals and ignores the state of the world between those intervals.

For both humans and computers, problems arise when the samples do not accurately represent the state of the changing world.

* In this context we are only considering digital computers like PCs and Macs. Analog computers are much more elegant and efficient for certain realworld applications, but that's another story...
** If the DIGITAL sampling rate of the world approaches the order of Planck time, the sample is, for all practical purposes, ANALOG.

 

 

Let's say we have an ANALOG sensor that is converting an ANALOG SIGNAL, say DISTANCE, into an ANALOG voltage, ranging from -10 to +10 volts over time. The graph of VOLTAGE versus TIME is shown above. The SIGNAL is represented by the GREEN curve outlining the ORANGE fill color inside. The rate at which we DIGITALLY SAMPLE the signal is represented by the INTERVAL between SAMPLES, and the intensities of the SAMPLES are represented by the voltages at the sampled points in BLUE. How does the sampling rate effect the perception of the event in the realworld? Too fast a sampling rate may provide unneeded detail and cost valuable computational resources. Too slow a sampling rate may miss important changes but save valuable computational resources. We should should always adjust the sampling rate to provide an adequate representation of the realworld signal we wish to collect.

The sample INTERVAL must be significantly smaller than the EVENT we wish to sense and perceive.
Any single SAMPLE can only tell us the STATIC STATE of the world at that instant.
We must monitor a sequence of samples to detect realworld changes.

 
We cannot know if a DYNAMIC EVENT is increasing or decreasing in intensity,

To know this, we need a memory of at least one previous sample.
If we want to know if a variable is increasing we need code similar to this:

// at each sampling interval
get currentSample;
if (currentSample > lastSample) {
// the quantity is increasing so do something
}
lastSample = currentSample;

 
We cannot count individual DYNAMIC EVENTS.

To know this, we need a memory of at least one previous sample.
If we want to count a digital event, say the first rising orange hump, we need code similar to this:

// at each sampling interval
get currentSample;
if (currentSample > 5 && lastSample < 5) {
// the quantity is increasing so do something
}
lastSample = currentSample;

 

This technique is used in a number of applications we have on our website, for example:

FLOCKING: To signal the initiation of an encounter between individuals forming a couple, specifically the lastNN and lastMouseOver.
BALLY REEL: To count the number of notches encountered by the "home" and "icon" optical interruptors.
DIAL TELEPHONE: To count the pulses returned by the rotary dial. We cannot count individual events.

It could be added to the following applications:

THEREMIN: With a higher sampling rate to signal a change in the note at which time the last note is turned off and a new sustaining note is turned on. Currently the sampling rate is slow, resulting in a uniform beat, with the same note repeated if the distance has not changed.