signal amplification/attenuation

Thread Starter

Standisher

Joined Jan 16, 2015
156
Hoping someone may be able to give me a steer. I have constructed a function generator (from a design on Youtube using the XR2206 IC). The generator works extremely well and puts out pretty accurate sine/square/triangle waveforms. I would like, if possible, to add a 'frequency counter' feature to the project.

The square wave signal generated by the XR2206 (@ about 2.5V) is fed to a 74HC14 schmitt trigger and it's output passed to an arduino nano (see attached sub-circuit diagram) which is coded to display the frequency on a seven segment display and, as I say, it works very well. Switching the input to use the Schmitt trigger/nano setup with an external signal instead of a signal generated by the XR2206 is straight forward but I struggle to think of a with a way of getting the voltage of the external signal to be sufficient, but not excessive for the 74HC14 whilst maintaining the signal integrity. For example, the signal could come from a mobile device in the mV range or from another source at a voltage in excess of 7V (the maximum input voltage for the 74HC14) so I need to be able to identify the voltage of the signal and then amplify or attenuate it accordingly to a level acceptable to the 74HC14. To complicate things, I would need to ensure any external sine waves were converted to square waves. Am I looking to do the impossible? All the ways I have considered (comparators & opamps etc.) would, I suspect, have a significant effect on the integrity of the signal?. I would really appreciate your thoughts.

external signal.JPG
 
Last edited by a moderator:

MrChips

Joined Oct 2, 2009
30,795
What you are requesting is perfectly reasonable and doable.

Firstly you need to establish the max frequency of your external signal. When you know this you can use passive filters to remove very high frequencies from the signal.

Next, you have to ensure that the external signal, when conditioned is of reasonable amplitude (about 2v peak-to-peak) and DC offset to Vdd/2 to be acceptable to the input of the 74HC14.

Since the input signal might have a wide range of amplitudes, you can either have a manual gain/attenuation control using a potentiometer or have an automatic gain control (AGC) circuit.

I would simply opt for a pot, followed by some amount of amplification plus DC offset and two diodes to limit the signal to Vdd and GND.
 

crutschow

Joined Mar 14, 2008
34,411
I would add a high speed comparator in front of the 74HC15.
That can operate from small signals to large signals without necessarily requiring amplification.
You can add diode clamps to prevent damage from large signals, and and a pot adjustment for the trigger point to get a stable reading with various signal levels.
 

Thread Starter

Standisher

Joined Jan 16, 2015
156
Thank you @MrChips & @crutschow for your replies. I like what I'm hearing and would be pleased if we could develop the advice given into something I, with my limited ability/knowledge can implement. The max frequency, I want to be able to handle is about 90 KHz (the level I have been happy to fix the function generator part at) though, if was important, the max frequency expectancy could be lower. The manual gain/attenuation control is fine...other than I would need to be careful that the range did not allow the level to rise above 7V. I also like the idea of a comparator before the Schmitt trigger (not least because this was one of things I was thinking about [I had an LM311 in mind] ...which makes a change :) ). Being a 'learner', my problem is how I implement these excellent thoughts.

Regards
 

crutschow

Joined Mar 14, 2008
34,411
Here's the LTspice simulation of a comparator circuit using an LM311.
Note the clean output with a 10mVpk, 100kHz, sinewave input.
The pot U2 adjusts the trigger point to give a stable display with a noisy signal.
Capacitor C2 rolls off the high frequency response to minimize high frequency noise.
Diodes D1 and D2 clamp the signal to prevent damage to the comparator input from a large signal voltage.

Edit: Hysteresis added to minimize oscillations.
R5 and R6 add ≈5mV of hysteresis.

upload_2017-4-8_0-41-54.png
 
Last edited:

Thread Starter

Standisher

Joined Jan 16, 2015
156
Here's the LTspice simulation of a comparator circuit using an LM311.
Note the clean output with a 10mVpk, 100kHz, sinewave input.
The pot U2 adjusts the trigger point to give a stable display with a noisy signal.
Capacitor C2 rolls off the high frequency response to minimize high frequency noise.
Diodes D1 and D2 clamp the signal to prevent damage to the comparator input from a large signal voltage.

If the circuit oscillates when you build it, you may have to add a small amount of hysteresis by connecting a resistor from the output to the (+) input of the comparator.
A 500kΩ resistor will give about 10mV of hysteresis.

View attachment 124224
Fantastic @crutschow ! I should get time to build that up over the next couple of days but it seems to be exactly what I need; straightforward and I have all the components. Thank you
 

crutschow

Joined Mar 14, 2008
34,411
Fantastic @crutschow ! I should get time to build that up over the next couple of days but it seems to be exactly what I need; straightforward and I have all the components. Thank you
Note that you need a 0.1μF ceramic decoupling capacitors to ground from the comparator power pin (not shown).
Also you need a good ground plane (or at leas a good ground bus, no daisy chained wires) to minimise spurious operation and oscillations of the circuit.
 
Last edited:

Thread Starter

Standisher

Joined Jan 16, 2015
156
@crutschow .... I put this together (admittedly on a breadboard which I appreciate is a recipe for disaster) and it works very well but only up to 5kHz. After that, the results are very random and way off the frequency being delivered. Looking at the incoming signal on my oscilloscope everything (pk-pk voltage and rise time etc.) remains constant up to 100kHz (and beyond).Do you have any idea what could be the possible cause of this frequency limitation when used as input to the Schmitt trigger ?

Regards
 

AnalogKid

Joined Aug 1, 2013
11,037
The sync output pin 11 is an open collector square wave output straight from the internal VCO. It doesn't need a comparator to produce a square wave trigger signal to the arduino. It *does* need a 10K resistor to Vcc as a pullup.

ak
 

Thread Starter

Standisher

Joined Jan 16, 2015
156
The sync output pin 11 is an open collector square wave output straight from the internal VCO. It doesn't need a comparator to produce a square wave trigger signal to the arduino. It *does* need a 10K resistor to Vcc as a pullup.

ak
Hi, the frequency generator generator is working very well as configured for the XR2206 output. I am not using a comparator for the XR2206 output.The comparator bit was about using the arduino/7 segment display part of the project as a frequency counter for external input from other signal sources (i.e not the signal generated by the XR2206).

Regards
 

Thread Starter

Standisher

Joined Jan 16, 2015
156
Here's the LTspice simulation of a comparator circuit using an LM311.
Note the clean output with a 10mVpk, 100kHz, sinewave input.
The pot U2 adjusts the trigger point to give a stable display with a noisy signal.
Capacitor C2 rolls off the high frequency response to minimize high frequency noise.
Diodes D1 and D2 clamp the signal to prevent damage to the comparator input from a large signal voltage.

Edit: Hysteresis added to minimize oscillations.
R5 and R6 add ≈5mV of hysteresis.
Well, I've solved the problem I was having (see post #8). I added a 1nf capacitor from the 311 output [Pin 7] to ground and everything is working perfectly now! Thank you very much for the circuit @crutschow .

fcoun2t.jpg fcount.jpg
 
Last edited:

crutschow

Joined Mar 14, 2008
34,411
Well, I've solved the problem I was having (see post #8). I added a 1nf capacitor from the 311 output [Pin 7] to ground and everything is working perfectly now! Thank you very much for the circuit @crutschow .
You could be having oscillation of the comparator.
For that it would probably be better to reduce the value of R5 to increase the hysteresis, rather than add a capacitor, which reduces the frequency response of the comparator to about 150kHz or so, but if you are happy with that response then you are okay.
 

Thread Starter

Standisher

Joined Jan 16, 2015
156
You could be having oscillation of the comparator.
For that it would probably be better to reduce the value of R5 to increase the hysteresis, rather than add a capacitor, which reduces the frequency response of the comparator to about 150kHz or so, but if you are happy with that response then you are okay.
Interesting, I'll try a lower value of R5 to see what effect that has. As you say however, I can count up to 153kHz reliably at the moment which is great for my needs. I have gained a lot from experimenting with the schematic/advice you provided (the learning, for me, is probably as important as the final project result) so I'm really grateful for your input.
 

crutschow

Joined Mar 14, 2008
34,411
I should add that increasing the hysteresis does reduce the minimum signal level that can be detected, so that's a tradeoff.
If you are more interested in sensitivity than frequency response, then the capacitor solution may be better.
 

Thread Starter

Standisher

Joined Jan 16, 2015
156
I should add that increasing the hysteresis does reduce the minimum signal level that can be detected, so that's a tradeoff.
If you are more interested in sensitivity than frequency response, then the capacitor solution may be better.
I did try lower values for R5 without any significant change.Having said that, most of my hobby is focused on audio and the most useful frequency range is 20Hz - 20 kHz so the current, very accurate, reading of signals between 10Hz & (I now find) 250kHz is more than ideal for my needs. I would not want to loose the lower end. Thanks again.
 

bertus

Joined Apr 5, 2008
22,276
Hello,

Why don't you use a resistor of 10K on pin 11 to the powersupply of the arduino, as @AnalogKid told you in post #9?
When no resistor is used, you will see the leakage signal on the open collector output of pin 11 of the XR2206:

XR2206_basic_circuit.png

With the resistor you will have a clear squarewave that can be used by the arduino.

Bertus
 

Thread Starter

Standisher

Joined Jan 16, 2015
156
Hello,

Why don't you use a resistor of 10K on pin 11 to the powersupply of the arduino, as @AnalogKid told you in post #9?
When no resistor is used, you will see the leakage signal on the open collector output of pin 11 of the XR2206:

With the resistor you will have a clear squarewave that can be used by the arduino.

Bertus
Sorry @bertus , I don't think you can have read my opening post or my reply (post #10) to @AnalogKid . I HAVE got a pull-up resistor on pin 11 and the signal generated by the XR2206 is working perfectly well without any additional circuitry (the schmitt trigger is there for future expanded functions of the generator and does not impact the operation of the XR2206/Arduino whether it is there or not ).The signal generator and it's output displayed on a seven segment display is stable and accurate as constucted.

I only showed the output portion in my original sub-schematic because the generator was working perfectly from day 1. The point of this thread was that I wanted to added a function counter of external signals (i.e not generated by the XR2206) which could come from many signal sources (such as mobile phone, prototype circuits etc.) & which therefore could be sinusoidal, triangle or square & have signals at either very low or quite high voltages. I wanted to attenuate/amplify the incoming signal accordingly and convert to a square wave when appropriate so that the signal could be fed to the arduino (via the schmitt trigger) and displayed on the 7 segment display. The schematic provided by @crutschow has achieved that goal and I now have a fully functional function generator & function counter (ext).

I hope this clarifies.
 
Last edited:

Thread Starter

Standisher

Joined Jan 16, 2015
156
Sure. The Author's (Loius) Channel goes under the name 'Scullcom Hobby Electronics' and he has a really nice presentation style. This was a three part series and you really have to watch all 3 as things change as he progresses and resolves issues. He did intend to add an external 'counter' function but didn't get round to it. The links are:



&
 
Top