Source code for process control...

Hello,
I would like to (automatically) tune output of an audio source (i.e input) using a program which I will be writing. Do you know any source
codes for PID-controller or for adaptive controller? Mostly I'd be interested in software libraries I can include to my program. Would you prefer PID or adaptive model?
BR, John
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
filia&sofia wrote:

If you don't know whether you need a simple PID loop or an adaptive loop you're probably not ready to start downloading code and randomly applying it.
What are you tuning? For any controller to work there has to be a defined input/output relationship that you can affect to control it, and that you can sense to use for feedback. If this I/O relationship is reasonably straightforward and does not change then you don't need adaptive control; if this I/O relationship is reasonably linear then a fairly simple loop will do -- you may not even need a full PID loop.
If you already know that you have something that's fit for PID control you can see my article at http://www.wescottdesign.com/articles/Sampling/pidwophd.html .
I wouldn't recommend that you try applying an adaptive control solution unless you really understand it thoroughly. In fact, I would recommend that you investigate every alternative that you can to adaptive control -- it's a powerful method, but it's not a magic bullet that you can casually apply and have everything turn out right.
--

Tim Wescott
Wescott Design Services
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
I am trying to control audio source. So the input would be audio stream, and output would be, again, audio stream, which is tuned to make constant audio power level. At this point, it seems that PID- control is proper choice for the task, but since the task is to control audio stream on a computer, I need an PID-algorithm to do this. The article was good and it gave me good insight of what my program should do and how it should be done.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
filia&sofia wrote:

If you want to keep the volume flat, look up volume compressors. They have been around for a long time. (You will need to become familiar with attack and release times ans be able to set them properly.)
If that's not what you want, and PID is really appropriate, then I don't understand what you ask for.
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

You do not need a PID algorithm to do this. A standard PID loop is not frequency-sensitive.
If you're just trying to feed an audio source into a computer, what you need is called an Automatic Gain Control (AGC). A compressor (on it's own) won't do the job properly because it doesn't expand the quiet bits.
Tri-band AGC's (as used by radio & tv stations worldwide) are available off-the-shelf from several professional audio suppliers including www.aphex.com
Google is your friend.
Cameron:-)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

[snipped response]
Apologies to all - I was on the phone and hit send too fast!...
What I should have said was that a standard PID loop is not frequency-sensitive *enough for the application*. An AGC *does* contain a feedback loop - that's how it works.
Cameron:-)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Cameron Dorrough wrote:
...

But ir usually *doesn't* have an integrator and only rarely an differentiator.
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Thu, 24 May 2007 22:16:00 -0400, Jerry Avins wrote:

The only AGC circuit I ever implemented in a radio had an integrator -- it was for a data link application that was feeding an 8-bit ADC into the processor.
--
Tim Wescott
Control systems and communications consulting
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Tim Wescott wrote:

Interesting! The closest thing to an integrator in the ones I used -- and used to see -- was the lowpass filter.
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Fri, 25 May 2007 23:50:32 -0400, Jerry Avins wrote:

I did it for my Master's thesis. Afterward, a friend of my thesis adviser mentioned that an integrating AGC doesn't sound good in an AM system because it just amplifies noise, but that it isn't a bad way to go in a digital system.
--
Tim Wescott
Control systems and communications consulting
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Tim Wescott wrote:
...

History as I remember it: AGC in receivers (mostly AM receivers) was done at IF by varying the bias on so-called "variable-mu" or "remote cutoff" tubes. The distortion products created by the bias-dependent transfer characteristic were primarily at harmonics of the IF and filtered out by the selective coupling between stages. AGC is used in receivers to keep the carrier level at the detector constant, not the demodulated volume. Better receivers had an AGC threshold, below which no gain reduction was applied. That was called "delayed AGC".
Relatively distortion-free voltage-controlled gain is harder to get at audio. Devices that did that were called compressors to distinguish them from the 6SK7-style variable-mu approach. At least one early compressor for broadcast studios modulated the signal to a low RF, varied the RF gain, and restored the signal to audio with a synchronous detector. In my lexicon at least, "volume compression" and "audio AGC" are different names for the same collection of techniques.
Naturally, perfect audio AGC acting instantaneously would remove all of the signal. To avoid that, some sort of low-pass filtering is always used. Separately adjustable attack and release times are common, as well as gain suppression when the signal becomes too small to be useful.
Please expand my picture by telling me how an integrator fits into it.
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Cameron Dorrough wrote:
...

That depends on the implementation. With enough gain before volume compression takes place, the output can be made quite constant.
...
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Ahh...not really. What you end up with is an overall increase in background noise level.
A compressor reduces the volume of the peaks (reduces dynamic range). An AGC makes loud bits softer and soft bits louder, without affecting the dynamic range (or the noise floor if set up properly).
Cameron:-)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Cameron Dorrough wrote:

The compressor built into the microphone amplifier for the Mercury space capsule had a 2 dB output change for a 60 dB input change*. The headphone amplifier had only a 40 dB dynamic range, AGC in the receiver taking care of the rest.
Whenever gain to makes softer bits louder, noise is made louder as well. How could it be otherwise?
Jerry ____________________________ * The spec was 3 dB. We accomplished it with diodes, resistors, and capacitors. Distortion never reached 1% THD even at the highest input levels.
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Hi, Jerry. Using a compressor and turning up the volume increases the background noise level continuously - start, end and at all times during transmission.
An AGC will not increase background noise level during loud bits (it will probably decrease it) and will only increase noise level during quiet bits (volume increase) and then not much at all ifg properly set up, then once the input level falls below a set threshold, it will turn off the output all together.
Cameron:-)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Cameron Dorrough wrote:
...

How so? When the compressor cuts the gain back, everything through the amplifier is reduced. We probably mean different things. As I see it, a compressor is an amplifier with AGC. Here's what we did:
Microphone (5 ohm, 5 millivolts shouting). Matching transformer for 500 ohm load. (50 millivolts at output.) Current-controlled attenuator at the input to the first base, followed by 80 dB of gain to the transformer-coupled output. An extra winding on the output primary went below ground before the collector hit the rail, pulling current through the attenuator. 5 microvolts was enough to provide -3 dB audio to modulate the transmitters. 5 millivolts gave only 2 dB more. I managed to make the amplifier stable on a circuit board 1.4 x 6 inches using all discrete components (including both transformers). Whew!

We suggested a squelch, but NASA said no because it would have been a frill that could go wrong. With everything doubly redundant, there were two noise-canceling throat (contact) microphones, each with its own AGCed amplifier chain. Background noise wasn't an issue. When the astronaut wasn't talking, it didn't matter what he wasn't saying.
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

[snipped stuff]
Yes, I think we do mean different things.
The "compressor" part of a "modern professional audio compressor" (likes of Aphex, Beringer, and numerous others out there) only reduces gain by a set amount (say 3db) above a set threshold (say 0dB) _leaving the rest of the the audio stream untouched_.
In this way, the peaks are gently limited and the overall "volume" (as you hear it) can be increased without risk of distortion by clipping. There is no AGC involved (not in a true "compressor" anyway).
It is common to find such things as a "Tri-band AGC/Compressor/Expander/Limiter" used for radio & TV broadcast that splits the incoming audio stream into high, mid and low frequencies, adjust the level of each to what you want, squashes the peaks, lifts the low spots, blocks any spikes and pops and then recombines it all for transmission... and from the sound of it would have been ideal for the Space Program. :-)
Cameron:-)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Cameron Dorrough wrote:

Maybe so. I wish car ratios had a way to reduce the dynamic range of a received signal. When soft passages of, say, Schubert are loud enough to be heard despite road noise, crescendos get to be unpleasantly loud.
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.