In electronics, if I interconnect various different components, say a control logic circuit to an actuator or op amp driving circuit, I would imagine it is important to validate the inputs are within range before proceeding with potentially damaging or dangerous voltages/currents or values.
YES! Thank you!
It is very unusual for a beginner (to electronics) to understand intuitively that domain (input) and range (output) should match up.
And, accordingly, the domain and range should perform proportionally, to whatever extent the circuit is supposed to be proportional (or not, as the case may be). Example: an analog level shifter (nothing more than an amplifier with whatever voltage offset and gain settings) should not only match up input and output ranges, but they should be smooth, proportional and linear, to as much extent as is required.
In a control loop, the requirement might not be too strict (feedback solves modest errors), but a gross discrepancy (like a 2:1 difference in slope over the range) is just dumb.
The classic EEVBlog example being any of the linear bench supply circuits floating around, which illustrate why a common-emitter transistor (with no emitter degeneration) is a bad idea: the input domain is narrow (Vbe of 0.5 to 0.7V, say), the output range is poorly constrained (the maximum collector current might be limited by hFE only), and the gain varies tremendously over that range (maybe 4:1 or worse, because of the exponential Ic(Vbe) curve).
This is equivalent to inserting a nonlinear function in a PID loop, say -- which is utterly pointless and extraneous in a digital system (where you have to go out of your way to make a nonlinearity), but supposing it were more incidental instead, you can see that, if the PID's transfer function is mostly linear, who really cares, but if it's out by a lot, it's going to lead to problems.
Hmm, which is an interesting thing in favor of DSP, that's not usually emphasized: you don't have any incidental nonlinearities. After the ADC, it's 100% pure math. You shouldn't need anything besides basic arithmetic in the inner loop (special cases aside), which means zero additional distortion!
So anyway, back to analog ranges: some things are okay with out-of-range, others not so much. Clearly, you don't want to dump an ampere into a 2N3904, that's not what that's for. Whereas you can make the software throw an error (or something equivalent, give or take what language you're developing in), analog throws sparks.
So there are ranges where:
1. Expected values in normal operation
2. Unexpected values, leading to normal operation with exceptions (e.g., clamping values to min/max, perhaps with a flag to record this action)
3. Absurd values, leading to abnormal operation (throwing faults, gibberish values, overflow, buffer overruns, and beyond)
In my beginner level stuff this would apply to a current limiter in a dummy load or power supply. Should I want to hook it up to a DAC to test, learn, tinker I would like a way to physically set an absolute limit on the input to the current sensed driver opamp. Thus when my code or interface to the DAC goes tits up and I send the value of 9V to the opamp I do NOT get 9V worth of output and fry the mosfet and cabling. The driver circuit would clamp itself to a set limit. Obviously I would like that clamped limit to be configurable by swapping in and out a few components or by tweaking a pot.
Precisely how good design is done. Assume the software is out to get you!
Some examples:
- Match up DAC and REF range, so the DAC physically cannot produce more than 1.2V for the current limit/setpoint parameter.
- Design the REF range to be opamp MAXVAL: even if the op-amp saturates, or fails shorted to +V or -V, its output cannot exceed the
normal operating range (#1 above).
- Put a clamp on the REF input, so that "#1" range is, say, 0 to 1.2V, compression and clipping (the curved segment between linear operation and hard clipping) occurs in the 1.3 to 2.5V (say) range (a "#2" sort of situation), and damage only occurs under extreme conditions (like the very short, 10A+ peak current surge that very high voltage ESD can deliver).
It's perfectly alright to rely on components behavior in this way, like op-amp saturation. There are many "buts" associated with components themselves -- not all op-amps saturate at the same voltage, not all are even well-behaved in saturation (the usual problem is "phase reversal" for out-of-range inputs), and so on -- but these are all documented in the datasheet (and if they aren't, assume the worst, and pick another one instead!). Typical RRIO (rail to rail input/output) amps are rated for full range input and output voltage, will saturate very close to +V and -V, and will not suffer from output reversal, or slow saturation recovery. TLV2372 is a good jellybean-ish example.
My go-to example is a switching power supply, where an oscillator and comparator are used to generate a PWM waveform. This is amplified with a power transistor, driving an inductor. The inductor current is sensed, and an error amplifier (or PID loop, if you like -- this could all be pure digital) controls PWM% to set output current. The current reference/setpoint is, in turn, controlled by another error amp, which senses output voltage, thus producing a stable voltage regulated output. Well, the voltage error amp can only "request" a setpoint between 0V and +V (the saturation limits of the opamp output), so it's a simple matter of designing the current loop for the same range (or scaling the ranges appropriately, with a voltage divider or preamp).
More discussion of that example here:
https://www.eevblog.com/forum/projects/building-a-simple-switching-circuit/msg1252706/#msg1252706Tim