I am exploring using a Windows-based program called Soundcard Scope, which uses the computer's soundcard to process signals and display them, oscilloscope style. One of the options it describes for signal input involves using an Arduino to pre-process the signal via an analog input port, and then send the data to the program via USB. I am hung up on the rationale for the opamp circuit it says is necessary when using an Arduino. The sample code sets the ADC to use 1.1V as the reference voltage (#define ADCREF INTERNAL, and then in setup(), analogReference(ADCREF)). The documentation says this circuit needs to be used to provide signals to the Arduino. It further provides resistor values for three scenarios -- UMax values of 1V, 5V and 10V. Why would an opamp be used if voltage dividers are needed to limit the input signal voltage? And doesn't the opamp negate that (and then some)? I must be missing something very basic here, but then, I am new to this application.
The Arduino analog input cannot be used to read negative voltages.
If the thing you are trying to implement allows negative input voltages, then it requires some sort of offset circuit. An op amp is not required for that, but would work.
The LM358 is a poor choice, though. Use a rail to rail op amp instead.
There are some trade-offs -
If you have audio signals you probably can't beat a soundcard, especially if you have a "full" soundcard in a desktop/tower computer with a line input. For low level signals you can use the microphone input (on a laptop or with a full soundcard).
A soundcard isn't voltage calibrated, but the software MIGHT have a way to calibrate it if you have a multimeter.
A soundcard (usually) can't read DC (zero Hz).
With the Arduino, an op-amp is the best way to bias the input so you can read positive and negative voltages or AC voltage.
But if you power from 5V the op-amp should be "rail-to-rail" so it can go all the way to +5V and down to zero. Alternatively, you can power the op-amp from plus and minus 12V, but then you'll need a protection circuit to protect the Arduino from negative voltages or excess positive voltage. (The protection circuit is only a resistor and two diodes, and that's what I do for audio input.)
This post shows a bias circuit that doesn't require an op-amp.. The resistors make a voltage divider to create the bias voltage. The capacitor blocks the bias from getting-into your audio circuit, and it also blocks other DC voltages from getting into the Arduino.
If you want to use the 1.1V reference (for weaker signals) you can change the resistors for a bias of 0.55V.
The "regular arduino" can't sample fast enough for the audio frequency range. I'm not sure what the practical limit is, but for digital audio the audio frequency can't be higher than half the sample frequency. (You need at least one sample for the top-half of the wave and one sample for the bottom-half.) If the signal is more than half the sample rate you get aliasing (false frequencies). Soundcards have a low-pass anti-aliasing filter.
The USB communications will also slow things up... You'll have to read the waveform data into memory, and than pause and send-out the data to the computer.
I assume that's so you can get a wider range. By using different voltage dividers, or leaving it out. Real oscilloscopes have a range switch. (They also have robust over-voltage protection so you don't fry the scope if you have it on a millivolt range and connect it to the power line or some other high voltage.)
The LM358 is an asymetric rail2rail opamp.
It can handle signals close to ground very well, just not signals near VCC.
So I think using the LM358 is not a problem here, since all signals are below 1.1volt DC.
An input capacitor is missing on the diagram, and needed to preserve DC offset.
And yes, the 1:1 voltage divider is there to set the A/D to the middle of it's range without input,
so positive and negative going signals can be measured.
Aref shouldn't be loaded too much, so high value divider resistors and the opamp buffer.
Leo..
Thanks for all this input. I had no idea the opamp would take care of the bias. Nor had I considered the implications of negative voltage on the Arduino's analog IN. It's a reminder how much I have yet to learn. In the spirit of better understanding this -- is the voltage in on opamp 2 (-) going to be (Vout on 1 * R1/(R1+R2)? And does this have a sort of bootstrap effect? It looks like Vout is determined in part by Vin at 2, which in turn is a function of Vout. Sorta circular?
That is a standard differential amplifier. Here is a complete analysis of that op amp circuit: https://www.electronics-tutorials.ws/opamp/opamp_5.html
That's just excellent. Thank you!
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.