Useful Notes: Analog Vs Digital

All electronics come in two forms: analog and digital. Either can do what we want, but there are advantages/disadvantages to using them.

Analog

A sine wave, a typical analog signal
Analog electronics use a continuous signal. A continuous signal is where if you had a paper of infinite length, you could draw the signal without ever lifting your hand. The signal (as far as electronics are concerned) essentially represents the voltage or current at that particular point in time. Since the real world is analog, it was probably easier to make electronics analog at first. But it's losing ground as the dominant form of signaling due to everything also capable of being digitized. However, at the end of the day, what you get out is analog, because the world is analog.

The defining quality of an analog signal is that it's easy to amplify, attenuate, and filter out a meaningful signal, even if the signal appears to look like garbage. As an example, when tuning into a radio station, it's first static, then static and the radio station, and then finally the radio station as the tuner can filter out the proper frequency from the "noisy" signal. The radio waves that also travel in the air are very low power, but the correct signal is filtered out before being amplified and making its way to the speakers. Another advantage of this is that when the signals degrade, it's a gradual degradation.

The problems with analog signals, in regards to electronics, is that they consume more power as components are rarely completely off, and the maximum value range of their variables is limited by the quality of its components and the amount of power they can safely handle; an analog computer pushed beyond its tolerances can be a real world example of both Tim Taylor Technology and Explosive Overclocking. If you're designing or analyzing analog circuits, it also makes for some Mind Screw math such as Fourier series and Laplace transforms.

Another issue is that due to the random nature of the universe, it's very hard, if not impossible, to manipulate and maintain an analogue signal perfectly: gears skip, belts slip, pipes leak, and electrical currents fluctuate. This inherent randomness can actually be an advantage in some cases, however, as it allows for rapid, naturalistic "fuzzy math" modeling of inherently chaotic and vaguely defined situations. A common historical usage for electronic analogue computers has been in modeling air circulation and liquid flow through complex pipe systems, for instance. They have also been used to rapidly generate accurate-enough solutions for certain differential equations which are extremely difficult or tedious to solve using digital computation or traditional precision calculation.

In short, analogue electronics are less efficient and harder to program, but are also more robust and tolerant of errors, and model the world more realistically. In trope terms, an analogue computer embraces "Don't Think, Feel.".

Digital

A square wave, a typical digital signal. Also well known for its use in chiptunes.
Digital electronics use a discrete signal, that is, there are hard values with nothing in between them. You couldn't take a pencil and draw a digital signal without lifting it up. Despite what the picture on the right shows, vertical lines are just representations. note A digital signal can either be a binary signal, in which case an "on or off" state, or a series of defined levels.

In a binary digital system, typically 0 volts is the off state, while some other voltage (commonly, 1.5V, 3.3V, 5V, and 12V, usually based on what batteries can provide) are used as the on state. note 

The defining characteristic is that digital signal can be copied perfectly, in the sense that small bits of noise won't kill the signal. In regards to electronics, digital signals require less average power, since they can be in a state that's fully off (or mostly off)

The problem with digital signals though is that if part of the signal is trashed, then the entire signal has to be thrown away unless something to correct it is available. This is akin to handwriting, where if someone writes a letter sloppily, forgets a letter, or misspells the word, you may not be able to make out what the word really is. And if you're in a part of the world that has digital TV, you can find it very annoying that poor reception means the channel cuts out completely, rather than just getting staticky like in an analog system.

A digital computer, in short, requires the employment of a Abstract Scale to function note  and is inherently unstable due to the efficient approximations it has to make, but makes up for this with versatility and simplicity.

Converting Between Analog and Digital

There are two hardware devices use to convert signals from analog to digital and back, conveniently they're called Analog to Digital Converter (ADC) and Digital to Analog Converter (DAC).

An analog to digital converter has two fundamental properties to it: sampling rate and sampling resolution. The sampling rate is how many times per second (in Hertz) the ADC takes a measurement while the resolution is how fine a granularity there is between the maximum and minimum signal amplitude. In general, the higher both of these are, the more accurate the digital signal is. However, higher is not necessarily better. Two smart people came up with the Nyquist-Shannon Sampling Theorem, which states that the sampling rate of an ADC must be double that of the highest frequency component of the signal in order reconstruct it perfectly. Of course, that's a very simple explanation, but it works very well for most applications. Where this is most applicable is in recording music. As the upper range of human hearing is 20KHz, this implies that 40KHz is the most you need to reconstruct any audio signal.

A digital to analog converter has the same properties as the ADC. When converting a digital signal into an analog one, it usually doesn't mean it's trying to transplant the stair step looking signal into the analog world. Instead it continuously raises or lowers the amplitude of the signal to that point using two methods. The first is called Pulse Code Modulation (PCM), which is where each sampling point is given some value between a minimum and maximum threshold. Imagine if you were Slalom skiing, the flags are the sampled points and you're recreating the signal. The trail in the snow you leave behind is essentially the reconstructed signal. The other type is Pulse Width Modulation, which requires a much faster sampling rate as the samples are binary (0 or 1). When the sample is 1, the amplitude of the signal raises and if it's 0, it lowers. The amount of time a PWM signal is "1" is referred to as its duty cycle. An example of PWM devices that you encounter are fluorescent and LED lights. The higher the duty cycle, the brighter and less flickering the light appears.

The biggest issue with conversion is something called the quantization error. Because analog signals have infinite subdivisions, it's impossible for any digital system to perfectly reconstruct an analog signal. For instance, if you have a signal level of 3.5 but you can only store 3 or 4 as its value, then you're going to have to pick which value makes more sense. One solution, which takes advantage of our brains constantly interpreting signals based on the previous one, is constantly going back between 3 and 4 which will achieve an effective level of 3.5. note