Hello again,
Mathematically a sine wave with no phase shift can be represented as:
V(t)=A*sin(w*t)
The rate of change of this is:
dv/dt=w*A*cos(w*t)
and one place where the rate of change is maximum is at t=0 so we end up with:
dv/dt=w*A
Since w=2*pi*f we have:
dv/dt=2*pi*f*A
and this means that the max dv/dt with an op amp is when:
2*pi*f*A=sr
where sr is the slew rate in volts per second.
Since the slew rate is usually given in volts per microsecond we can change this to:
2*pi*f*A=sr*1000000
and that is with sr in volts per microsecond.
Since the LM358 has a slew rate of about 0.5v/us we end up with:
2*pi*f*A=500000
and dividing by 2*pi we end up with:
f*A=79577
We can then easily calculate the maximum amplitude A knowing the maximum frequency f:
A=79577/f
Knowing the max frequency is 20000Hz we end up with:
A=79577/20000
which of course equals 3.98 volts, and since A is in peak volts that is 3.98 volts peak which is about 4 volts peak which is 8 volts peak to peak.
This of course assumes that you have a supply voltage that can actually allow that voltage output. For the LM358 the output can swing close to the negative rail but the positive output can only get within about 1.5v of the positive rail. This means for a dual power supply circuit you would need a negative supply rail of a minimum of -4 volts and a positive rail of a minimum of +5.5 volts, or a single rail power supply of 9.5 volts in order to put out the maximum at 20kHz.
Now we can also calculate the minimum slew rate needed to attain a certain peak output voltage.
Starting again with:
2*pi*f*A=1000000.0*sr (and sr in units of volts per microsecond again)
and solving for sr we get:
sr=2*pi*f*A/1000000
if we wanted a peak output of 8 volts at 20000Hz then we end up with:
sr=2*pi*20000*8/1000000
which of course comes out to:
sr=1 volt per microsecond.
This follows from the fact that it is a simple linear expression, so if we got 4 volts peak from 0.5v/us then it follows that we should be able to get 8 volts peak from 1v/us.
In reality though we might want to go a little higher than that for practical purposes.1.5v/us or 2v/us should get us there.
It should also be pointed out that the maximum output is still limited by the power supply voltages. This means we need at the very least a plus and minus 8v power supply, or 16v single supply, but that only works with a true rail to rail output op amp. Since most op amps drop at least a little, like 0.1 volts with any current, we probably need at least plus and minus 8.5 volts as a min. For the LM358 though, the positive rail has to be at least 1.5 volts higher, so we would need a supply with about -8.5 volts and +9.5 volts to ensure proper operation.
Some op amps can not get very close to either rail, so the min supply voltages then have to be higher by an amount that includes that overhead voltage:
+Vs=A+VohP
-Vs=A-VohN
where +Vs is the required positive rail voltage, and -Vs is the required negative rail voltage, and VohP is the positive rail overhead voltage, and VohN is the negative rail overhead voltage. For the LM358 the negative rail overhead should be taken as about 0.1 volts, and for the positive overhead voltage should be 1.5 volts.