Thursday, 23 August 2018

jfet - How can I make a simple voltage-controlled attenuator?



Having discovered just how awful the AC ripple is on some of my 5VDC wall-adaptors, I decided to make an Arduino program to calculate the RMS AC component and DC component of an adaptor under varying current loads.


My current issue is that the Arduino (and it's ADC's and DAC's) run on 5V, so 0-5V is it's analog input and output range. Many "5V" adaptors output a little more than that (and I want to be able to test 9V and 12V adaptors as well). So, I want a way for the Arduino to attenuate the input down to something within the 0-5V range, and the only way I can think of to do this is to use the Arduino's analog voltage output (which, I realize, is just PWM digital). Hence, I need a voltage-controlled attenuator.


The application requirements are:



  1. It must be able to attenuate the input anywhere from a gain of 1 down to a gain of about 0.25 (to get, say, a 15V input well within the 0-5V ADC range)

  2. The range of controlling voltages must also be within 0-5V. Furthermore, the range cannot be too small, since the Arduino can only select 256 values between 0-5V. In other words, I can't have a controlling voltage of 2.000V give me a gain of 1 and a controlling voltage of 2.001V give me a gain of 0.25, as the Arduino doesn't have that kind of control over its analog output.

  3. Any attenuation needs to affect the AC and DC portions equally, or else my ac_component/dc_component ratios will be erroneous.

  4. I would very much like not having to supply additional voltage rails. For example, I don't want to have to supply a +12V and -12V for a certain op-amp. If it can all be done with a 5V rail, that's optimal. Or, +12V will probably also be fine.

  5. Attenuation does not need to be linear with voltage. All I'm after is being able to calculate (RMS ac_component / dc_component), and those ratios will stay the same without my knowing the exact attentuation.

  6. I understand that JFETs (see the schematics below) aren't all that well-suited to DC operation for thermal issues or something. Gradual drift in the attenuation is okay. My Arduino program only samples the voltages from the wall-adaptor for about 1/10 of a second. As long as the gain doesn't change appreciably over that time span, things are fine.



The first thing I tried was this sample which I found. It kinda did what I wanted, but it's inverting, so the output ends up being negative (and out of the 0-5V range of the Arduino).


schematic


simulate this circuit – Schematic created using CircuitLab


Then, I realized that the op-amp was probably just lowering the output impedance of the what's really just a voltage-divider with a JFET in place of one of the resistors, and I didn't need that because the Arduino has a much higher input impedance than the power-supplies I'll be testing, so I tried this ...


schematic


simulate this circuit


but I'm getting something strange. It looks like the AC component is getting affected by the gain-control input voltage, but not the DC component (see requirement 3). I clearly don't understand FETs like I should. Can someone either suggest some fixes to this approach, or suggest an alternative?




No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...