Driving RLC circuit and measuring voltage

Hello,

As part of a university project I need to design an RLC circuit and a way to drive/power it with a microcontroller, at different frequencies including the resonance frequency, and then using the same microcontroller measure the voltage RMS value across a chosen component to establish the resonance curve (V vs f). There are several obstacles I could not get around and for which I need help. Please note that I am pretty new with microcontrollers but previously took basic electronics courses as a physics undergrad :

  1. The microcontroller needs to drive the RLC circuit with a 5V sine wave, which I know is not perfectly possible, would I get close enough to a harmonic excitation with PWM ?
  2. The microcontroller I am using (Atmega328 on the arduino NANO) has a 10 kHz sampling rate and thus I need to stay below 5 kHz to avoid aliasing. My question regarding this is: around how many (k)Hz should I design my resonance frequency to be in order to be safe from aliasing when I measure the voltage while mainting a "fairly smooth harmonic excitation".
  3. Would the microcontroller be able to generate this AC voltage at different frequencies with the help of a potentiometer ?
  4. Would an amp op be necessary in this project or are the currents and voltages good enough ?
  5. Is this microcontroller precise enough to establish this frequency curve ?

The final data, which is the amplitude of the voltage across a component, should simply be displayed on an LCD screen or sent to the arduino IDE on a computer.

I hope I am not being too vague, if I am please ask me further information and I will gladly answer you.

Thanks.

Your questions are presented in a manner that suggests you haven't tried any of these steps yet, but

  1. yes

  2. the ADC sampling rate can be much faster than 10 kHz. The default is about 9.6 kHz.

  3. yes

  4. no, but you must respect the 20 mA recommended maximum current draw from a port pin, when driving the RLC circuit.

  5. yes

Thanks a lot ! Also I guess the fact that there is a DC offset, since the arduino cannot produce negative voltages, won't be a problem to measure the resonance frequency?

Drive the RLC circuit with AC, by using a small capacitor to remove the DC component of the driving signal.

As a guess, you might try 100 nF for AC coupling, but you want the driving signal to have as high impedance as possible, to avoid loading the RLC circuit. So smaller capacitors are better.

But won't the problem be that by adding a capacitor I change the resonance frequency of the circuit ? And isn't the capacity of the RLC already doing that job?
Thank you for your answers.

Yes, of course, and that is why you want the source impedance to be as high as possible, and to avoid DC components in the excitation.

It is an unavoidable fact that the equipment used to stimulate a circuit, and/or to measure the behavior of a circuit, becomes part of the circuit and alters its behavior from ideal.

Part of the reason for doing this (presumably assigned) experiment is to learn that fact, and how to deal with it.

Oh ok I see, seems fair. Thank you for your patience jremington I really appreciate it.

@castorr: One of the moderators pointed out privately to me that the peak voltage across a sufficiently high-Q RLC circuit can greatly exceed the driving voltage, and could damage the ADC input if it exceeds 5V.

I think it is unlikely that an audio frequency RLC circuit, resonant at a few kHz, would have high enough Q for this to be a problem, although if the inductor were wound on a ferrite core, then perhaps.

So, to protect the analog input, use a 10K series resistor between the ADC input and the RLC circuit. That should prevent excessive current flow and damage to the ADC.

1 Like

Oscillators

Ok thanks a lot ! And talking about damage, won't the negative part of the AC voltage (from which the DC shift has been filtered out) damage the arduino when measuring the voltage ? Or does the arduino simply measure amplitude regardless of the sign and I'll get an accurate RMS measurement either way ?

And talking about damage, won't the negative part of the AC voltage (from which the DC shift has been filtered out) damage the arduino when measuring the voltage ? Or does the arduino simply measure amplitude regardless of the sign and I'll get an accurate RMS measurement either way ?

So in your original post, you indicated you would be using PWM from the microcontroller to generate the signal. If that is the case your signal will not have a negative component, it will be a square wave from 0 to Vcc.

Of course, but putting a capacitor after the analog outpin pin and before the RLC circuit, would remove the DC shift and the signal will thus have a negative component of about Vcc/2. Since I want to measure the voltage across the RLC components (one by one), won't the negative component of the AC signal damage the analog input pin or just give a wrong measurement?

Correct. The analogue input must remain within the supply voltage range and not go negative. However, there are 2 ways I can think of to deal with this: you could bias the analogue input to half supply voltage with a pair of (say) 100k resistors in series, or you could ignore the negative half cycles on the assumption that they are the mirror image of the positive ones so are the same but inverted.

What is your signal source then? If it is from PWM from the arduino, then no, that is never going to have a negative component.

Ok I see. So if I'm understanding your (first) explanation correctly, the two resistors in series would in a sense oppose the effect of the first capacitor to give an always positive voltage that I can accurately measure ?
Thank you all for your insightful answers and your patience.

Getting an RMS measurement is not trivial.

You have to:

  • Take multiple analogue readings over a whole cycle of the waveform.
  • Remove the offset introduced by the bias resistors.
  • Square all the results of the sampling.
  • Add all the squared samples together.
  • Divide by the number of samples taken to get the mean.
  • Take the square root of the mean.

Yes, however I don't necessarily need the RMS value, it's just what I assumed the arduino would actually measure with the input pin and thus the data I would need to process. Is that a correct assumption?

No, it does not read the RMS value, it reads the voltage at the instant the measurement is taken.

You could take multiple samples, find the minimum and maximum, and work out the RMS from the peak to peak value, knowing the crest factor.

Okay I see, I will look into ways to measure AC voltage amplitudes, there might be libraries online. Thanks a lot.