Monday, July 4, 2016

Simulating a Peak Detector in the Sampled Domain

D I G I T A L   P E A K   D E T E C T O R

I'm using this blog as documentation for myself and as a resource for other people who want to accomplish similar or the same thing as I am trying to do, which is to make a software PLL all in code, that synchronizes to a digital input signal.

In an effort to jot down things quickly, and because I'm lazy, I'm going to cut to the chase. I'm trying to build an auto gain digital control system to equalize an input signal to the PLL I have yet to build. As you can imagine, if input [carrier] were a sampled audio signal or data from a SDR, it could have any amplitude.

I don't know if any of my ideas will work, but I'm jotting them down as I go. I'm not coming back.

~Q U E S T I O N S   T H A T   I   A S K E D   M Y S E L F~

I asked the following questions to myself:
  • What is the process you are trying to control?
    • The input power.
  • What is the process's input and output?
    • input = its volume, output = output power.
  • What is your reference?
    • The desired output power.
Quick Sketch of AGC system:

~I M P L E M E N T I N G   T H E   P R O C E S S / P L A N T~

Now I will talk about my approach to the Process/Plant.
The input to the process is the volume, which results in an output power. Volume is easy, I just multiply the input sample by a gain factor. Output power/amplitude? In circuits, I would use a peak detector with RC tank attached. 

The diode is simulated with an if statement in code. If the input voltage is greater than the output voltage, the output voltage becomes the input voltage. Otherwise, let the difference equation do its thing, which is exponentially decay. 

The following is the resistor capacitor parallel tank derivation.

 I'd love to be a better teacher right now and baby you through the MATLAB code but here it is:

Sick. This is a good warmup for the big PLL. 

No comments:

Post a Comment