[Solved] Best way to amplify a sine wave without distorsion. - Page 1
Forum section: electronics / beginners

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 26, 2017, 12:02:13 am
content: Hello.I'm building a Capacitive Touch Morse Keyer with an Arduino and a MPR121 module.I managed to make a Wien bridge oscillator with all calculations to generate a quite nice 860-960Hz sine wave. Later I moved the wave above 0V and turn it on and off with a PWM, now I want to amplify it to feed a VHF handheld radio mic with a minimum distorsion. The circuit is attached.Radio's in/out interface is done. It was a previous project and the arduino programming is also finished.I thought I could use a class AB amplifier circuit like this.I have read the pros and cons of A, B and AB amplifiers circuits but as I still don't fully understand transistors and it's calculations, I used a LM386 with a 20 gain config (I guess it's a class A) but I found some problems.There is always a hiss on the output when the input signal is off and I can't hear the output when the signal is on but there is no hiss and the wave in the scope is very distorted.Also found that I can hear a commercial radio when the IC input is not wired. I didn't know it was possible.Should I keep using the IC and make it work or should I use the class AB transistor amplifier circuit? What is best or easier or both?Thanks in advance!

author: FrankBuss
author_rank: Unknown
timestamp: January 26, 2017, 12:44:33 am
content: I don't know the answers to your questions, but your attached Fritzing circuit diagram is difficult to understand. Some obvious problems: You should remove the long bottom wire from -5V to the output of the negative voltage power supply IC, it is sufficient to show that it is connected if you use on both sides the -5V symbol. For C5 you should not connect it to the same GND symbol as used for the neg input of the LM386, place an additional ground symbol, because it has nothing to do with the neg input.The outputs of the LM358 are not connected, are you sure this is what you built? And would be nice to have standard OpAmp symbols for the two OpAmps in the LM358. I don't know Fritzing, but better PCB CAD programs like KiCad or Eagle don't limit the number of independent symbols per IC packages. You should use one of those programs, if Fritzing doesn't support it.

author: FrankBuss
author_rank: Unknown
timestamp: January 26, 2017, 12:50:49 am
content: PS: if you really use a PWM signal to switch your sine wave on an off, it will produce a lot of distortions. Just use a digital out pin of your Arduino and set it to 1 or 0.

author: Audioguru
author_rank: Super Contributor
timestamp: January 26, 2017, 01:38:33 am
content: Like most audio amplifiers, the LM386 is class-AB. It has hiss because it is cheap. Its internal gain is 4500 times and it uses negative feedback to reduce the gain to a useable amount and cancel most of its distortion. With a 5V supply its output power before clipping distortion into an 8 ohm speaker is only 0.14W which is almost nothing. It works best with a 9V supply then its output is 0.5W.Your transistor "amplifier" has a gain of only a little less than one and it has plenty of distortion.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 26, 2017, 02:46:06 pm
content: Thank you for your commentsQuote from: FrankBuss on January 26, 2017, 12:44:33 amI know it's easier to follow it in the way you describe. Fritzing saves the breadboard view, schematic and pcb traces in only one file and creates ratsnets lines in the PCB tab, but if I wire this ways it's easier to convert the netlist to traces in the pcb designer tab later.Quote from: FrankBuss on January 26, 2017, 12:44:33 amThe circuit has a 20 gain config just like it's shown in the datasheet. I can't find any obvious error on this. Am I missing something?https://iamzxlee.files.wordpress.com/2014/05/gain-20.jpgHere is another example.https://iamzxlee.files.wordpress.com/2014/05/lm-386-main.jpg?w=736&h=424Quote from: FrankBuss on January 26, 2017, 12:44:33 amYes, I'm aware of that. Pins 1,7 and 8 are not needed. I'm trying to slowly move from Fritzing to Kicad. I'm sure it's a better EDA tool it's not as friendly as Fritzing and the learning curve is steep.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 26, 2017, 02:58:15 pm
content: Hello!Quote from: FrankBuss on January 26, 2017, 12:50:49 amAs far as I understand for a non-PWM pin, analogWrite() with a value below 128 is the same a digitalWrite(LOW) and analogWrite() with a value above 127 is the same a digitalWrite(HIGH). I'll check the program again to verify what i'm doing, but I don't get a distorted signal. Here is the output before it goes to the amplifier stage.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 26, 2017, 03:33:53 pm
content: Quote from: Audioguru on January 26, 2017, 01:38:33 amThat's a problem. I want to power it with a usb port or cell phone charger. I only need the minimum power required to feed a VHF handheld mic.Quote from: Audioguru on January 26, 2017, 01:38:33 amI found this circuit that I want to test. Would you say that the tone could not be a clean sine wave before I build it?

author: FrankBuss
author_rank: Unknown
timestamp: January 26, 2017, 04:13:57 pm
content: Quote from: HoracioDos on January 26, 2017, 02:46:06 pmThere is nothing wrong with the netlist, only how it is drawn. In your version at first glance it looks like C5 has something to do with the neg input of the LM386, even if that's not the case. That's why I suggested to use 2 GND symbols, one for C5 and one for the neg input of LM386. Sorry when my phrasing is a bit odd, I'm German

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 26, 2017, 04:22:08 pm
content: Quote from: FrankBuss on January 26, 2017, 04:13:57 pmLOL!! No problem. I feel the same many times!!!. English is not my mother language either or mother tongue or whatever..

author: Zero999
author_rank: Super Contributor
timestamp: January 26, 2017, 06:27:27 pm
content: Quote from: HoracioDos on January 26, 2017, 02:46:06 pmI think you'll find that pin 1 (the output of the first amplifier) is needed. You must mean pins 5, 6 & 7 aren't needed. The unused op-amp should be correctly terminated, not simply left unconnected, which can cause trouble. Configure the unused op-amp as a unity gain buffer, with the input grounded. Connect the inverting input (pin 6) to the output (pin 7) and the non-inverting (pin 5) input to 0V.I seriously doubt you actually built the circuit as drawn. What is Q2 supposed to do? Its gate is just connected to the source so it will be off all the time.As drawn, there's no automatic gain control on the oscillator so the signal will either slowly fade away or clip to form a horribly distorted waveform. Perhaps Q2 is supposed to be the gain control.Why not AC couple the signal from the Wien bridge oscillator to the LM386 amplifier?It should also be possible to build a Wien bridge oscillator using a single power supply so you can eliminate U3. Heck, I'd consider removing the U1 and using the LM386 to make the Wien bridge oscillator. There's even an example on the data sheet.http://www.ee.ic.ac.uk/pcheung/teaching/DE1_EE/Labs/LM386.pdf

author: Audioguru
author_rank: Super Contributor
timestamp: January 26, 2017, 06:33:04 pm
content: An LM386 power amplifier has negative feedback so that its gain is only 20 but without negative feedback its gain is about 4500. Its datasheet shows that a capacitor added between pin 1 and pin 8 reduces the negative feedback so that the gain becomes 200.Your first circuit with many problems drives an 8 ohm speaker.Your last circuit drives a whopping high signal into a very low level microphone input. Its needs an attenuator.Your last twin-T filtered "sinewave" oscillator has no automatic-gain-control so its output will probably rise high enough for the transistors to cause clipping that is almost a squarewave.

author: Richard Crowley
author_rank: Super Contributor
timestamp: January 26, 2017, 06:55:03 pm
content: If you are only sending out a single tone, I would just make a classic L/C or R/C filter which could take your 5V square wave and make a nice sine-wave out of it. No fooling around with linear amplification etc.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 26, 2017, 08:28:28 pm
content: Quote from: Hero999 on January 26, 2017, 06:27:27 pmHello!I'm a little bit confused. Let's go by parts...I wrote that LM386 pins 1,7 and 8 are not needed, not the LM358.I didn't use the LM386 for a Wien bridge for these reasons:a) I first began using a LM741 to generate a sinewave and then switched to a LM358.b) I didn't want anything with a light bulb.c) LM386 was introduced later in the design as an audio amplifier.Yes, I'm aware I'm not using the 2nd op-amp in the LM358 based on reason a) and I can't see why it should be a problem. There's an image of the sine wave before going to the LM386 amplifier stage and it's clean.I decided to use a LM386 to amplify the sine wave because I have read in many websites that a LM358 is not an audio amplifier and It shouldn't be used as one.Also, I don't fully understand the calculations to build a class ab amplifier with transistors and I didn't want to do it by trial and error. So a low power amplifier should do it easily with less components.R5 and R6 move the signal above 0V to avoid the transistors could clip the signal. I tested it without the resistors and the sine wave was awful. If I'm wrong I would like to fix that.Q1 and Q2 was the best way I found to turn on and off the sinewave from the arduino without any distorsion. Arduino pin is always HIGH and switched to LOW when the keyer is touched. If there's a better way, I'll love to learn it.Yes, You are right, there's no automatic gain control to fade away the signal when it's cut off. I never thought it should be necesary. Perhaps it's a big mistake. I attached an image from the DSO when it happens.The circuit was built exactly as it's described. I'm sure it can be optimized to be more simple with less components.First I have to find out how to do the calculations with the proposed circuit and replace the light bulb with something else to get a 800hz sine wave.In the mean while I would like to find out how to amplify the signal and take advantage of what I've done. Once it's working I'll try to replace the LM358 with the LM368, drop the ICL7660 and leave only one IC.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 26, 2017, 08:40:15 pm
content: Quote from: Audioguru on January 26, 2017, 06:33:04 pmThanks for the explain. I saw the 200 gain config in the datasheet.Quote from: Audioguru on January 26, 2017, 06:33:04 pmOk, I could try to use 9 volts as you told me previously or try something else.Quote from: Audioguru on January 26, 2017, 06:33:04 pmI thought the output could be too high for the input mic but as It's a published circuit in a Ham Radio Magazine, well I guess I was wrong.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 26, 2017, 08:45:11 pm
content: Quote from: Richard Crowley on January 26, 2017, 06:55:03 pmLOL!. That was my very first option and I failed miserably. Large story with capacitors, inductors and calculations.Do you have some circuit at hand?

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 26, 2017, 09:28:06 pm
content: Quote from: Audioguru on January 26, 2017, 06:33:04 pmI was reading your comment again, Do you refer to the circuit that I built not the one published (The third one). If that's the case, yes, it was already in my mind, I thought in a voltage divider with a potentiometer. I don't know if it's the correct way to do an attenuator.Thanks again!

author: Zero999
author_rank: Super Contributor
timestamp: January 26, 2017, 10:58:54 pm
content: Quote from: HoracioDos on January 26, 2017, 08:28:28 pmI apologise for the confusion.I was indeed talking about the LM358, which doesn't have its output connected to anything, so it can't work. Clearly you are getting a sinewave out of this circuit, so the schematic you've posted here is different to what you've actually built.QuoteYou must be mistaken.Ignore the rest of the circuit for now. Focus on the Wien bridge oscillator. The output (pin 1 on the LM358 goes nowhere) therefore it can't possibly work, as drawn. If it does work, then you've built something different.

author: Richard Crowley
author_rank: Super Contributor
timestamp: January 27, 2017, 01:54:00 am
content: Quote from: HoracioDos on January 26, 2017, 08:45:11 pmGoogle returned many interesting options when I searched for: 3rd order notch filterOf course you need the "opposite" of a notch filter, but it is trivial to invert a filter circuit to make a sharp (high-Q) bandpass filter.

author: Audioguru
author_rank: Super Contributor
timestamp: January 27, 2017, 05:51:45 am
content: Your "keyer" changes the DC input on the LM386 audio amplifier so it will make a loud POP sound each time it is keyed and again when the key is turned off.The LM358 is the dual version of the LM324 quad. They are low power so they are missing output biasing and create crossover distortion.

author: FrankBuss
author_rank: Unknown
timestamp: January 27, 2017, 06:10:43 am
content: Quote from: Audioguru on January 27, 2017, 05:51:45 amInteresting, I didn't know that the crossover distortion is so high for such a common OpAmp. Is there any other standard OpAmp with lower distortion? I found the OPA388, for which the datasheet says "zero-crossover", "zero-drift" and it is not too expensive, but max supply voltage is very low.

author: sibeen
author_rank: Frequent Contributor
timestamp: January 27, 2017, 07:54:30 am
content: Quote from: HoracioDos on January 26, 2017, 08:40:15 pmBut how does Q2 do anything? The way you have it configured it is permanently off and cannot possibly be turned on.

author: Zero999
author_rank: Super Contributor
timestamp: January 27, 2017, 08:46:14 am
content: Quote from: FrankBuss on January 27, 2017, 06:10:43 amMost op-amps don't have crossover distortion like that. Even the old uA741 didn't have that much crossover distortion.Fortunately it's fairly straightforward to remove the crossover distortion by ensuring only one of the transistors in the LM358's output stage is active at a time. This can be achieved by connecting a resistor between the output and either supply rail.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 27, 2017, 12:53:40 pm
content: Quote from: Hero999 on January 26, 2017, 10:58:54 pmI can't stop laughing at myself. How ridiculous I'm! I've learned a lot in this thread.When I read your first reply, I thought: "Well, he didn't like the circuit even a bit. I'm a noob. I don't have any problems with that. He knows a lot more, that's why I'm here... but ...is he suggesting I didn't build the circuit way I said in front of a lot of people? Is he really saying that? I should post a picture to prove the circuit exists. This circuit have been giving me headaches for so long that I can draw it with my left ear" ... A big avalanche was already going down the hill eating everthing in it's path....Then I read this reply yesterday and finally the snow swallowed my pride. I was so blind worried about my own interpretation of things that I didn't see what it was so obvious for you about the LM358 connections. I was so sure that the schematic was showing the reality, I would have bet a month salary! You would have loved to see my face when I checked the breadboard! So I must say it " YOU ARE RIGHT!!!"So, first I must check the schematic very carefully against the breadboard, make corrections in the schematic and review all the previous replies.Thank you very much!!!

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 27, 2017, 01:58:37 pm
content: Quote from: Richard Crowley on January 27, 2017, 01:54:00 amThese were my first attempts to convert a square wave to a sine wave with transistors and rc network calculations and a 555 also. But the result was a triangle wave or worst.http://www.learningaboutelectronics.com/Articles/Sine-wave-generator-circuit-with-a-555-timer.phphttp://www.learningaboutelectronics.com/Articles/Square-to-sine-wave-converter-circuit.phpIt could been easier for me to use an arduino to generate an square wave and find a way to convert it to a sine wave.It have been a too long journey for such a small project.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 27, 2017, 02:04:04 pm
content: Quote from: sibeen on January 27, 2017, 07:54:30 amHero999 opened my eyes. I must check if Q1 and Q2 for sure are connected as it's shown. The circuit is obviously working but the schematic may be wrong with this too.

author: LvW
author_rank: Frequent Contributor
timestamp: January 27, 2017, 02:59:55 pm
content: Quote from: Richard Crowley on January 27, 2017, 01:54:00 amDid you ever try to solve such a "trivial" task? I doubt. There are specific bandpass design procedures which can (and should) be applied.

author: Richard Crowley
author_rank: Super Contributor
timestamp: January 27, 2017, 04:42:49 pm
content: Quote from: LvW on January 27, 2017, 02:59:55 pmYes I have. Sorry you found it so difficult.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 27, 2017, 07:08:08 pm
content: Quote from: HoracioDos on January 26, 2017, 08:28:28 pmI think I found the crux of the matter in my own answer.a) I replaced LM741 with LM358 in the last minute. As the pinouts are quite similar I made corrections in the breadboard but forgot to do them in the schematics.b) Q1 and Q2 were OK. Q1 Collector was connected to Q2 Gate and Q2 Source to R10. But... R10 was overlaping Q1 so it seemed that R10 was connected to Q1 Collector and to Q2 Gate.c) Also R11 and R12 were missing.I updated the schematic. It should be fine now. (Finger crossed)So I'm back on track to find out a proper way how to amplify the sine wave.

author: Audioguru
author_rank: Super Contributor
timestamp: January 27, 2017, 07:29:38 pm
content: 1) Your opamp used in the Wien Bridge oscillator will produce a clipped sinewave because it is missing an automatic gain control (a light bulb or a Jfet).2) The output of the LM386 power amp will have its positive excursion clipped because it amplifies the DC from the Mosfet. A coupling capacitor to block the DC is needed between the R10 volume control and the pin 3 input of the LM386.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 27, 2017, 09:13:32 pm
content: Requiescat in pace Fritzing. There is no light bulb or jfet n-channel parts. Moving to Kicad this weekend. It's going to take a while...Quote from: Audioguru on January 27, 2017, 07:29:38 pmIt seems that the easiest change could be replacing R4 with a 5V light bulb (light bulbs are chasing me after all) and R3 with a 100K trimpot. It will allow me to find the correct value later. If I use a JFet N-Channel. Can a 2N5457/8 or BF244A/5A be used?Quote from: Audioguru on January 27, 2017, 07:29:38 pmI have many 0.1uF (104) capacitors. I guess It could work.

author: Audioguru
author_rank: Super Contributor
timestamp: January 28, 2017, 12:14:36 am
content: Quote from: HoracioDos on January 27, 2017, 09:13:32 pmYou will not find a light bulb with a warm resistance as high as 47k ohms so the value of R3 must be reduced a lot. You probably know that the opamp gain for a Wien bridge oscillator must be about 3. Also you need to use a power amplifier to drive the light bulb instead of an opamp.QuoteA 2N5459 or a 2N5486 has a lower range of cutoff voltage. You should also re-design the attenuator so that it has no DC voltage on it (your R6 causes a huge POP and should be removed).QuoteDon't guess, look at the input resistance of 50k ohms for the LM386 in its datasheet then calculate that a 0.1uF capacitor will pass frequencies above about 32Hz.

author: Zero999
author_rank: Super Contributor
timestamp: January 28, 2017, 12:30:58 am
content: The LM386 can be used as a Wien bridge oscillator with a J-FET AGC circuit, rather than the light bulb suggested on the data sheet.

author: Audioguru
author_rank: Super Contributor
timestamp: January 28, 2017, 01:42:45 am
content: The datasheet for the LM386 says that it becomes unstable if its gain is reduced to less than 9 but here it is 3. Do you think the capacitor between pin 1 and pin 8 reduces its high frequencies enough to make it stable with a gain of only 3?

author: FrankBuss
author_rank: Unknown
timestamp: January 28, 2017, 06:58:43 am
content: Another easy way to create a clean and stable sin wave is to use a DAC. I tried it with aMAX5712, a 12 bit DAC, which can be directly connected to the Arduino with SPI. This is a test with a Mega2560, which allows up to 24 kHz samplerate, here with 20 kHz samplerate, generating a sin wave of 943 Hz:Only one small 6 pin IC, two capacitors and one resistor are needed, and you can change the frequency in software, and switch it on and off without more external parts. You can even program it in a way, that it switches it off at zero crossover and starts at zero (1/2 VDD with the current circuit), to avoid any clicks, or add an envelope. If you need more power for the output, you can still use your LM386. Depending on the output frequency and the samplerate, you need to adjust the lowpass filter with R1/C1. Unlike most audio DACs, the output of the MAX5712 can be DC. This is the filtered output for 0.1 Hz, only one variable change in the Arduino sketch:Below is the Arduino source code. The output is generated in an interrupt, you can use the loop for other things like reading switches or analog values, blinking LEDs etc. But the interrupt uses timer 1, which means you can't use the Arduino PWM functions anymore. For low frequencies, you can even use the sinf function for calculating the DAC value in realtime, no need for the big table, but this works only up to 5 kHz samplerate. I tried this with a STM32F4 discovery kit, which has an ARM microcontroller, and it is no problem to calculate the sinf function @48 kHz samplerate in stereo and 24 bit in realtime, if running with 168 MHz CPU clock.Code:/*** Generates a sin 943 Hz wave with a MAX5712, connected with SPI. Tested with a Mega2560 Arduino.* Samplerate works up to 24 kHz.* SCK: pin 52* MOSI: pin 51*/#include "SPI.h"// pin numbersconst int ledPin = 13;const int csPin = 12;// signal generatorconst float samplerate = 20000.0f;const float frequency = 943.0f;uint32_t increment = 1024.0f / samplerate * frequency * 4194304; // multiplicator for 22 bit shiftuint32_t sinIndex = 0;uint16_t nextValue = 0;// 1024 values sin table, 12 bit unsignedconst uint16_t sinTable[] = {0x0800, 0x080c, 0x0819, 0x0825, 0x0832, 0x083e, 0x084b, 0x0857, 0x0864, 0x0870, 0x087d, 0x088a, 0x0896, 0x08a3, 0x08af, 0x08bc,0x08c8, 0x08d5, 0x08e1, 0x08ee, 0x08fa, 0x0907, 0x0913, 0x091f, 0x092c, 0x0938, 0x0945, 0x0951, 0x095d, 0x096a, 0x0976, 0x0983,0x098f, 0x099b, 0x09a7, 0x09b4, 0x09c0, 0x09cc, 0x09d8, 0x09e5, 0x09f1, 0x09fd, 0x0a09, 0x0a15, 0x0a21, 0x0a2e, 0x0a3a, 0x0a46,0x0a52, 0x0a5e, 0x0a6a, 0x0a76, 0x0a82, 0x0a8e, 0x0a99, 0x0aa5, 0x0ab1, 0x0abd, 0x0ac9, 0x0ad4, 0x0ae0, 0x0aec, 0x0af8, 0x0b03,0x0b0f, 0x0b1a, 0x0b26, 0x0b32, 0x0b3d, 0x0b48, 0x0b54, 0x0b5f,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, 0x096a, 0x095d, 0x0951, 0x0945, 0x0938, 0x092c, 0x091f, 0x0913, 0x0907, 0x08fa, 0x08ee, 0x08e1, 0x08d5,0x08c8, 0x08bc, 0x08af, 0x08a3, 0x0896, 0x088a, 0x087d, 0x0870, 0x0864, 0x0857, 0x084b, 0x083e, 0x0832, 0x0825, 0x0819, 0x080c,0x0800, 0x07f3, 0x07e6, 0x07da, 0x07cd, 0x07c1, 0x07b4, 0x07a8, 0x079b, 0x078f, 0x0782, 0x0775, 0x0769, 0x075c, 0x0750, 0x0743,0x0737, 0x072a, 0x071e, 0x0711, 0x0705, 0x06f8, 0x06ec, 0x06e0, 0x06d3, 0x06c7, 0x06ba, 0x06ae, 0x06a2, 0x0695, 0x0689, 0x067c,0x0670, 0x0664, 0x0658, 0x064b, 0x063f, 0x0633, 0x0627, 0x061a, 0x060e, 0x0602, 0x05f6, 0x05ea, 0x05de, 0x05d1, 0x05c5, 0x05b9,0x05ad, 0x05a1, 0x0595, 0x0589, 0x057d, 0x0571, 0x0566, 0x055a, 0x054e, 0x0542, 0x0536, 0x052b, 0x051f, 0x0513, 0x0507, 0x04fc,0x04f0, 0x04e5, 0x04d9, 0x04cd, 0x04c2, 0x04b7, 0x04ab, 0x04a0, 0x0494, 0x0489, 0x047e, 0x0472, 0x0467, 0x045c, 0x0451, 0x0446,0x043b, 0x042f, 0x0424, 0x0419, 0x040f, 0x0404, 0x03f9, 0x03ee, 0x03e3, 0x03d8, 0x03ce, 0x03c3, 0x03b8, 0x03ae, 0x03a3, 0x0399,0x038e, 0x0384, 0x0379, 0x036f, 0x0365, 0x035b, 0x0350, 0x0346, 0x033c, 0x0332, 0x0328, 0x031e, 0x0314, 0x030a, 0x0300, 0x02f7,0x02ed, 0x02e3, 0x02da, 0x02d0, 0x02c6, 0x02bd, 0x02b4, 0x02aa, 0x02a1, 0x0298, 0x028e, 0x0285, 0x027c, 0x0273, 0x026a, 0x0261,0x0258, 0x024f, 0x0246, 0x023e, 0x0235, 0x022c, 0x0224, 0x021b, 0x0213, 0x020a, 0x0202, 0x01fa, 0x01f1, 0x01e9, 0x01e1, 0x01d9,0x01d1, 0x01c9, 0x01c1, 0x01ba, 0x01b2, 0x01aa, 0x01a2, 0x019b, 0x0193, 0x018c, 0x0184, 0x017d, 0x0176, 0x016f, 0x0168, 0x0160,0x0159, 0x0153, 0x014c, 0x0145, 0x013e, 0x0137, 0x0131, 0x012a, 0x0124, 0x011d, 0x0117, 0x0111, 0x010a, 0x0104, 0x00fe, 0x00f8,0x00f2, 0x00ec, 0x00e7, 0x00e1, 0x00db, 0x00d5, 0x00d0, 0x00ca, 0x00c5, 0x00c0, 0x00ba, 0x00b5, 0x00b0, 0x00ab, 0x00a6, 0x00a1,0x009c, 0x0098, 0x0093, 0x008e, 0x008a, 0x0085, 0x0081, 0x007c, 0x0078, 0x0074, 0x0070, 0x006c, 0x0068, 0x0064, 0x0060, 0x005c,0x0059, 0x0055, 0x0051, 0x004e, 0x004b, 0x0047, 0x0044, 0x0041, 0x003e, 0x003b, 0x0038, 0x0035, 0x0032, 0x0030, 0x002d, 0x002a,0x0028, 0x0025, 0x0023, 0x0021, 0x001f, 0x001d, 0x001a, 0x0019, 0x0017, 0x0015, 0x0013, 0x0011, 0x0010, 0x000e, 0x000d, 0x000c,0x000a, 0x0009, 0x0008, 0x0007, 0x0006, 0x0005, 0x0004, 0x0004, 0x0003, 0x0002, 0x0002, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0002, 0x0002, 0x0003, 0x0004, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009,0x000a, 0x000c, 0x000d, 0x000e, 0x0010, 0x0011, 0x0013, 0x0015, 0x0017, 0x0019, 0x001a, 0x001d, 0x001f, 0x0021, 0x0023, 0x0025,0x0028, 0x002a, 0x002d, 0x0030, 0x0032, 0x0035, 0x0038, 0x003b, 0x003e, 0x0041, 0x0044, 0x0047, 0x004b, 0x004e, 0x0051, 0x0055,0x0059, 0x005c, 0x0060, 0x0064, 0x0068, 0x006c, 0x0070, 0x0074, 0x0078, 0x007c, 0x0081, 0x0085, 0x008a, 0x008e, 0x0093, 0x0098,0x009c, 0x00a1, 0x00a6, 0x00ab, 0x00b0, 0x00b5, 0x00ba, 0x00c0, 0x00c5, 0x00ca, 0x00d0, 0x00d5, 0x00db, 0x00e1, 0x00e7, 0x00ec,0x00f2, 0x00f8, 0x00fe, 0x0104, 0x010a, 0x0111, 0x0117, 0x011d, 0x0124, 0x012a, 0x0131, 0x0137, 0x013e, 0x0145, 0x014c, 0x0153,0x0159, 0x0160, 0x0168, 0x016f, 0x0176, 0x017d, 0x0184, 0x018c, 0x0193, 0x019b, 0x01a2, 0x01aa, 0x01b2, 0x01ba, 0x01c1, 0x01c9,0x01d1, 0x01d9, 0x01e1, 0x01e9, 0x01f1, 0x01fa, 0x0202, 0x020a, 0x0213, 0x021b, 0x0224, 0x022c, 0x0235, 0x023e, 0x0246, 0x024f,0x0258, 0x0261, 0x026a, 0x0273, 0x027c, 0x0285, 0x028e, 0x0298, 0x02a1, 0x02aa, 0x02b4, 0x02bd, 0x02c6, 0x02d0, 0x02da, 0x02e3,0x02ed, 0x02f7, 0x0300, 0x030a, 0x0314, 0x031e, 0x0328, 0x0332, 0x033c, 0x0346, 0x0350, 0x035b, 0x0365, 0x036f, 0x0379, 0x0384,0x038e, 0x0399, 0x03a3, 0x03ae, 0x03b8, 0x03c3, 0x03ce, 0x03d8, 0x03e3, 0x03ee, 0x03f9, 0x0404, 0x040f, 0x0419, 0x0424, 0x042f,0x043b, 0x0446, 0x0451, 0x045c, 0x0467, 0x0472, 0x047e, 0x0489, 0x0494, 0x04a0, 0x04ab, 0x04b7, 0x04c2, 0x04cd, 0x04d9, 0x04e5,0x04f0, 0x04fc, 0x0507, 0x0513, 0x051f, 0x052b, 0x0536, 0x0542, 0x054e, 0x055a, 0x0566, 0x0571, 0x057d, 0x0589, 0x0595, 0x05a1,0x05ad, 0x05b9, 0x05c5, 0x05d1, 0x05de, 0x05ea, 0x05f6, 0x0602, 0x060e, 0x061a, 0x0627, 0x0633, 0x063f, 0x064b, 0x0658, 0x0664,0x0670, 0x067c, 0x0689, 0x0695, 0x06a2, 0x06ae, 0x06ba, 0x06c7, 0x06d3, 0x06e0, 0x06ec, 0x06f8, 0x0705, 0x0711, 0x071e, 0x072a,0x0737, 0x0743, 0x0750, 0x075c, 0x0769, 0x0775, 0x0782, 0x078f, 0x079b, 0x07a8, 0x07b4, 0x07c1, 0x07cd, 0x07da, 0x07e6, 0x07f3,};// send a word to the DACvoid sendDacWord(uint16_t word){digitalWrite(csPin, LOW);SPI.transfer(word >> 8);SPI.transfer(word & 0xff);digitalWrite(csPin, HIGH);}void setup(){// init pinspinMode(ledPin, OUTPUT);pinMode(csPin, OUTPUT);digitalWrite(csPin, HIGH);// init SPISPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));SPI.begin(); // additional begin is required, otherwise the second call to SPI.transfer hangs// send wakeup command to DACsendDacWord(0xf000);// initialize timer1noInterrupts(); // disable all interruptsTCCR1A = 0;TCCR1B = 0;TCNT1 = 0;OCR1A = 16000000.0f / samplerate; // compare match register for IRQ with selected samplerateTCCR1B |= (1 << WGM12); // CTC modeTCCR1B |= (1 << CS10); // no prescalerTIMSK1 |= (1 << OCIE1A); // enable timer compare interruptinterrupts(); // enable all interrupts}// timer 1 interruptISR(TIMER1_COMPA_vect){sendDacWord(nextValue & 0x0fff);nextValue = sinTable[sinIndex >> 22];sinIndex += increment;}void loop(){digitalWrite(ledPin, HIGH);delay(500);digitalWrite(ledPin, LOW);delay(500);}Code to generate the sin table:Code:#!/usr/bin/pythonimport mathimport syslength = 1024for i in xrange(length):s = math.sin(2 * math.pi * i / length) * 2047 + 2048sys.stdout.write("0x" + format(int(s), '04x') + ", ")sys.stdout.flush()if i % 16 == 15: print("")

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 28, 2017, 08:17:17 am
content: Cool! I read something like this some time ago.Quote from: FrankBuss on January 28, 2017, 06:58:43 amI guess an 8 bit fast pwm could be still available on timer 0. (Uno, Mega, etc)

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 28, 2017, 11:07:35 am
content: Quote from: Audioguru on January 28, 2017, 12:14:36 amI didn't know the resistance values for a light bulb. According to this, it's 115 ohms @ 5V. As the gain should be equal or greater than 3. R3 should not be greater than 200 ohms, that's why R4 is 47K? almost 1/2 of R3 with 100 Kohms?. Is that correct? So 100 Kohms is too high. I didn't know that an Op-Amp can't drive a ligh bulb.Quote from: Audioguru on January 28, 2017, 12:14:36 amIt should be about 0.0033uF for a 964hz frequency. I feel I'm at school again. is it correct?

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 28, 2017, 11:37:31 am
content: Quote from: Hero999 on January 28, 2017, 12:30:58 amSo options are:1) Use LM358 and AGC with a JFET2) Use LM386 and AGC with a light bulb3) Use LM386 and AGC with a JFET4) Use MAX5712.I like them all and would like to build them for a learning aim but option 3 is quite tempting to finish this project. I can't see the RC network so clearly to calculate it's frequency but everything between 800-1200 Hz is fine. Does it require something else like an attenuator?

author: janoc
author_rank: Super Contributor
timestamp: January 28, 2017, 11:44:42 am
content: Hmm,Am I the only one who has noticed this in the OPs post (emphasis mine)?QuoteSomething like a LM386 is an enormous overkill there that will overdrive the radio. More likely what you need is a simple buffer for the oscillator/DAC/whatever you use to generate the signal and then anattenuator(= voltage divider). Microphone inputs take very small signals (in the order of milivolts), because there is an amplifier right there.

author: Richard Crowley
author_rank: Super Contributor
timestamp: January 28, 2017, 12:23:59 pm
content: Yes. If the OP needs only microphone-level, he doesn't need ANY kind of amplification at all. If he has a 5V square wave (or even a 3.3V square wave), he can easily make a sharp (High-Q) filter to create a nice sine wave for a fixed frequency. And even then likely require an attenuator (like a simple pot) to create mic-level.OTOH, he also mentioned driving a speaker which was acoustically-coupled (?) to the transmitter microphone. Although that logic-level signal would likely drive a small dynamic speaker transducer.Ham radio forums and websites are rich sources of exactly this kind of tone-generator. This is a rather common project an the amount of pathos and drama here seems overwrought for such a simple task.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 28, 2017, 01:30:58 pm
content: Quote from: Richard Crowley on January 28, 2017, 12:23:59 pmI agree, there are a lot of circuits out there but not everything works as it is said. I attached a design in a previous post from QST Magazine for a Modulated CW keyer with transistors but It has a lot of distortion. I have another "proven" design with too many components, a lot more than the current circuit in discussion, are them really necesary?Little example: Last month I've built two input/output radio interfaces (one for a yaesu and the other for a baofeng). I'm sure you know them (very easy project). Internet is full of them. They have a lot of low pass filters that are not needed or it's values doesn't make sense at all and in many cases are very risky. I made my own design with the components that are really necesary and they work just fine.Google is not heaven.Quote from: Richard Crowley on January 28, 2017, 12:23:59 pmI love drama I'm a latin. It makes people to be humans.

author: Audioguru
author_rank: Super Contributor
timestamp: January 28, 2017, 03:22:02 pm
content: Quote from: HoracioDos on January 28, 2017, 11:07:35 am5V/115 ohms is an average current of 44mA and a peak of 62mA. The datasheet of the opamp tells you that its maximum output current is much less.Quote3.3nF into the 50k input of an LM386 produces a cutoff frequency of about 970Hz (I round it off a little) but then the fundamental frequency level is reduced to 0.707 times but the distortion frequencies remain at full level. Use a capacitor value 5 times more for no attenuation.

author: Zero999
author_rank: Super Contributor
timestamp: January 28, 2017, 05:27:47 pm
content: Quote from: Audioguru on January 28, 2017, 01:42:45 amI got the circuit off the datasheet but modified it, swapping the lamp for a J-FET. Unfortunately I made a mistake. I missed that the frequency determining resistors are different: 4k7 & 47k, so the gain needs to be much higher than 3 and the resonant frequency is 1kHz with C1 & C2 = 10nF and R1 = 4k7 & R2 = 47k.

author: orolo
author_rank: Frequent Contributor
timestamp: January 28, 2017, 06:55:15 pm
content: Last week I built a Wien bridge oscillator with an LM358 and aJKL 7210, miniature 5V 30mA light builb. It worked, giving a very clean sinewave. I think I still have the protoboard somewhere in the lab. I used a pot to set the gain; the circuit oscillates a little below the bulb's threshold of visibility. After building the circuit I thought it was doubtful anyone would care about that circuit, and just a week later there is a post about that very same thing! BTW, unless you want a very low distortion sinewave, why don't you try some of the manyalternatives? In thispagethere is a great discussion about Wien bridge oscillators. I found they use far stouter bulbs than I used.

author: SeanB
author_rank: Super Contributor
timestamp: January 28, 2017, 08:10:14 pm
content: Built one years ago, and, while I do actually have a RA53 or two around somewhere, I used a small 28VDC wire ended grain of wheat bulb as a control element. 28V 20mA IIRC, and it runs at a non glowing voltage, but still enough to give a good control of level in the oscillator.

author: Zero999
author_rank: Super Contributor
timestamp: January 28, 2017, 10:28:39 pm
content: Quote from: HoracioDos on January 28, 2017, 11:07:35 amUsing the correct circuit on the data sheet. The value of the bulb's resistance can be calculated.See the formulae on Wikipedia:https://en.wikipedia.org/wiki/Wien_bridge_oscillator#Wien_bridgeAnd compare the schematic to the one on the LM386 data sheet.C1 = C2 = 10nF = 10×10-9R1 = 4k7 = 4700R2 = 47k = 47×103Rf/Rb= 10×10-9/10×10-9+ 47×103/4700 = 1 + 10 = 11The bulb is Rband the 390R resistor Rf.Therefore:Rb= 390/11 = 35.5RIn real life RBneeds to be slightly less because the amplifier has an open loop gain of much less than infinity: 200 in the LM386's case.QuoteF = 1/(2pi(C1×C2×R1×R2)½)F = 1/(2pi(10×10-9×10×10-9×4700×R2 = 47k = 47×103)½) = 1.07kHzHere's the correct version with the J-FET, based on the data sheet schematic.If anyone is interested, I'll post the LTSpice file and LM386 model.

author: Audioguru
author_rank: Super Contributor
timestamp: January 29, 2017, 06:28:57 pm
content: Shouldn't the RC frequency of the lowpass be the same as the RC frequency of the highpass?

author: Zero999
author_rank: Super Contributor
timestamp: January 29, 2017, 11:07:26 pm
content: Quote from: Audioguru on January 29, 2017, 06:28:57 pmNo. The cut-off frequencies of both RC circuits don't have to be the same. They normally are the same because it makes the calculations and designing the circuit easier. If the two RC circuits are different, then it will still work but the attenuation factor at the resonant frequency is no longer 3.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 30, 2017, 07:50:13 pm
content: Quote from: Hero999 on January 28, 2017, 10:28:39 pmThank you very much for the schematic and the calculations!! Yes! I'm interested in the spice model. You've done a big effort helping me so I would like to learn as much as I can from it.I've uploaded the Kicad schematic to give something back to the community.By the way, this is the first time I used Kicad so it might have some error. If someone downloads it, please check it against the spice picture.

author: Zero999
author_rank: Super Contributor
timestamp: January 30, 2017, 11:43:17 pm
content: I don't have KiCAD installed on this PC at the moment, so can't view that file now. I'll do tomorrow.Attached is the LTSpice (if you don't have it, it's a fee download) file for the circuit I posted previously. I've embedded the model for the LM386. Unfortunately, there doesn't seem to be any way to embed the symbol I used for the LM386, so I had to use the 8-pin package which should come with LTSpice. I've labelled the pins, in the hope it makes it more clear.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 31, 2017, 12:09:47 pm
content: Quote from: Hero999 on January 30, 2017, 11:43:17 pmI installed LTspice XVII(x64) under wine and it works fine. This is the Vout graph.As far as I can understand, you had to recreate the LM386 internals in spice! What a huge job!As soon as I test the whole project in the breadboard I'll upload the schematics and PCB. The circuit will also have an atmega328p, on-off switching transistors, a voltage regulator and some other stuff. As I've done all this things before there will be no problems.

author: Zero999
author_rank: Super Contributor
timestamp: January 31, 2017, 07:14:02 pm
content: Quote from: HoracioDos on January 31, 2017, 12:09:47 pmI do that too.Notice how the waveform starts off slightly clipped, then the amplitude decays and it becomes smooth? This is because when power is first applied J1 is on, so it oscillates until it's limited by the supply rail. Then C5 charges via the negative voltage doubler, causing J1 to turn off which increases its resistance and reduces the gain, until the circuit reaches equilibrium. C5 could be reduced to minimise the clipping but at a cost of slightly more distortion.QuoteFortunately there was no need to do that. I downloaded the model from somewhere. Unfortunately it was a long time ago and can't remember where. I think it might have been the Texas Instruments website.QuoteAs you're using an MCU when why not use the digital method for generating the sine wave?Quote from: HoracioDos on January 30, 2017, 07:50:13 pmOh dear. Sorry, that won't work because wires aren't connected to the nodes (the circles on the components) properly.Only connect wires to the component notes. Never try to make a connection by pushing the components next to one another. It may look like it's connected up, but when you come to making a PCB you'll find the KiCad can't see the connections. You can verify a component is connected by right clicking on it and selecting drag component.Attached is a cleaned up version of the KiCad schematic, which should work with the PCB package.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 31, 2017, 08:42:55 pm
content: Quote from: Hero999 on January 31, 2017, 07:14:02 pmThat's strange! This is the ERC output. If the output has no errors, the connections should be OK, isn't it?ERC report (Tue 31 Jan 2017 05:28:54 PM ART, Encoding UTF8 )***** Sheet /** ERC messages: 0 Errors 0 Warnings 0When I opened your version Kicad warned that components library is not the last version. Is it possible that if you open a circuit with newer library version the components are disconnected?

author: HoracioDos
author_rank: Frequent Contributor
timestamp: January 31, 2017, 08:58:07 pm
content: I guess it could be related.I just opened a schematic in eeschema and since the size of the capacitor component changed in the official library since I created the schematic, they all got disconnected:eeschema should probably prefer using the components from the cache file rather than reloading the component from the library, potentially doing serious damage to the the schematic.https://bugs.launchpad.net/kicad/+bug/1435338

author: Audioguru
author_rank: Super Contributor
timestamp: February 01, 2017, 12:53:23 am
content: The distortion caused by the Jfet can be reduced by adding half the drain signal level to the gate.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: February 01, 2017, 05:05:49 pm
content: Quote from: Audioguru on February 01, 2017, 12:53:23 amIs it possible with a simple resistor? Which value it should have? Please, could you elaborate more?Thanks!!!

author: Zero999
author_rank: Super Contributor
timestamp: February 01, 2017, 06:55:06 pm
content: Quote from: HoracioDos on January 31, 2017, 08:58:07 pmIt looks like it. Does the KiCad schematic I posted earlier look alright to you?Here's what the schematic looks like when I load it in the latest version of KiCad.Quote from: HoracioDos on February 01, 2017, 05:05:49 pmHe didn't say that it's possible to reduce the distortion by using a simple resistor (technically the filament lamp does that, but we're talking about an ordinary resistor, not a PTC resistor) rather than a J-FET. I believe he was talking about improving the existing J-FET AGC circuit by adding some negative feedback to it.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: February 01, 2017, 07:45:06 pm
content: Quote from: Hero999 on February 01, 2017, 06:55:06 pmNo, It doesn't. This is the ERC output.ERC report (Wed 01 Feb 2017 04:13:34 PM ART, Encoding UTF8 )***** Sheet /ErrType(3): Pin connected to some others pins but no pin to drive it@ (67,31 mm,85,09 mm): Pin 1 (Power input) of component #POWER_FLAG06 is not driven (Net 1).ErrType(3): Pin connected to some others pins but no pin to drive it@ (105,41 mm,60,96 mm): Pin 6 (Power input) of component U1 is not driven (Net 4).ErrType(6): Mismatch between hierarchical labels and pins sheets@ (143,51 mm,50,80 mm): Hierarchical label Output is not connected to a sheet label.** ERC messages: 3 Errors 0 Warnings 3This is my kicad version. It's the latest for Mint 18.1 Serena (based on Ubuntu 16.04 Xenial Xerus)Kicad 4.0.5+e0-6337~49~ubuntu16.04.1Kicad-library 4.0.5+e0+1097~2~ubuntu16.04.1and I get this warning when I open the schematic.Quote from: Hero999 on February 01, 2017, 06:55:06 pmIs it your version or mine? Look at the capacitors. They have a different symbol in my version. It's in a previous post.I guess that's why so many people hate open source.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: February 01, 2017, 07:58:26 pm
content: Quote from: Hero999 on February 01, 2017, 06:55:06 pmLOL I imagined that the solution could not be so simple!

author: Audioguru
author_rank: Super Contributor
timestamp: February 02, 2017, 12:13:19 am
content: I moved R3 of the original schematic and added two resistors making a voltage divider of the signal at the drain and I fed it to the gate.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: February 02, 2017, 03:15:05 pm
content: Quote from: Audioguru on February 02, 2017, 12:13:19 amI should have thought in a voltage divider when you said half of the signal. I uploaded the spice model with your changes. This is the output with and without zoom. It seems that the amplitude decreases and increases later.This is what I did yesterday. I thought It was all wrong but look at the output. The amplitude decreases just a little bit and stays there. It seems that the clipping stops between 260-280ms.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: February 02, 2017, 04:11:14 pm
content: I didn't realize about this before. If the oscillator gets stable somewhere between 260-280 ms I should switch on and off the output as it was in the first design due to morse code timing.At 13 Words per Minute: Dit = 92ms, Dah = 276ms, Spacing = 92ms, Word Spacing = 644ms. So the signal will always be clipped.Can I use still the previous method, moving the signal above 0V and usign a NPN and MOSFET transistors? Or should I use something like this?

author: Zero999
author_rank: Super Contributor
timestamp: February 02, 2017, 09:18:01 pm
content: Quote from: HoracioDos on February 01, 2017, 07:45:06 pmThe schematic I posted previously is yours. Yes, the default capacitor symbol in my library is different to yours.QuoteMany people use open source software on their phone and are totally unaware of it.It's KiCad which is crap, not open source software in general. I hadn't used it for years and hoped it had improve but it's still rubbish.Quote from: HoracioDos on February 02, 2017, 03:15:05 pmThe waveform looks worse to me, than it did before.The low frequency oscillation is caused by the AGC circuit being unstable.Quote from: HoracioDos on February 02, 2017, 04:11:14 pmIs the muting transistor just two NPNs back to front?What about using an analogue switch such as the CD4066?

author: HoracioDos
author_rank: Frequent Contributor
timestamp: February 02, 2017, 09:59:40 pm
content: I was playing around LTSpice graphs and started to tweak resistors values just to see what it may happen and I found this strange case.The AGC seems not to be working any more but the signal is never clipped from start to end and frequency is still about 1.1Khz. Can you check this?

author: Zero999
author_rank: Super Contributor
timestamp: February 02, 2017, 10:23:58 pm
content: Quote from: HoracioDos on February 02, 2017, 09:59:40 pmAll you've done is disabled the AGC by shorting the gate to the source, via a low value resistor and set the gain of the amplifier to exactly the right value. It may work in simulation but I doubt it will in real life, as the gain only has to change slightly for it to either stop oscillating or clip.The speed of the AGC circuit can be increased by decreasing the capacitor values but there will be slightly more distortion.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: February 05, 2017, 05:51:04 pm
content: I built the circuit and the wave is very distorted. I checked it all many times, I replaced components and can't find if i'm doing something wrong. Frequency is very far away from it's supposed.Any tips?

author: FrankBuss
author_rank: Unknown
timestamp: February 05, 2017, 05:59:45 pm
content: Quote from: HoracioDos on February 05, 2017, 05:51:04 pmUse my DAC solution?Just kidding, can be helpful to find the problems, if you want to learn more about analog electronics, which I don't have a clue of, and not just somehow create a sine wave.

author: Zero999
author_rank: Super Contributor
timestamp: February 09, 2017, 12:07:33 pm
content: Quote from: HoracioDos on February 05, 2017, 05:51:04 pmThe LM386 appears to be oscillating at a high frequency, completely independent of the Wien bridge circuit. This isn't very surprising as the data sheet says the LM386 is only stable down to gains of 20. I'm surprised it suggested a gain of 12 for the Wien bridge circuit.You could have a go at frequency compensation (a capacitor across R1 or between pins 2 & 3) but I suspect the easiest way is to increase the gain to >20 and adjust the other component values to compensate.

author: Audioguru
author_rank: Super Contributor
timestamp: February 09, 2017, 06:07:32 pm
content: I think the circuit oscillates because it is built on a solderless breadboard that has stray capacitance all over the place?Also, it is missing some very important parts shown in the datasheet.

author: Zero999
author_rank: Super Contributor
timestamp: February 09, 2017, 07:25:03 pm
content: Quote from: Audioguru on February 09, 2017, 06:07:32 pmWhich important parts?Whether the missing parts are required or not depends on how the amplifier is being used. The Zobel network is only necessary, if it's being used to drive a speaker. If it's driving a purely resistive load then it's not needed. Adding a bypass capacitor between pin 7 and 0V would improve the supply rejection factor but it's pointless if the circuit is run from a stabilised power supply.Connecting pin 2 to +V, via a 1000µF capacitor, would be a bad idea because we want to set the gain using a potential divider connected between the output pin 2 and 0V, in much the same manner as an op-amp non-inverting amplifier.There should be a 100µF capacitor connected across the supply rails, which is missing because it is not necessary when simulating the circuit, even though it's required in real life.I didn't know the LM386 is suitable for use at gains as low as 9. Anyway, it doesn't seem to like a gain of 12, so should be more stable with a gain of 22.36, with slightly large frequency determining capacitors.

author: Audioguru
author_rank: Super Contributor
timestamp: February 10, 2017, 12:33:17 am
content: Quote from: Hero999 on February 09, 2017, 07:25:03 pmConnecting pin 2 to +V, via a 1000µF capacitor, would be a bad idea because we want to set the gain using a potential divider connected between the output pin 2 and 0V, in much the same manner as an op-amp non-inverting amplifier.My sketch shows pin 2 grounded and an important 100uF supply capacitor also connected to pin 2 which is ground.

author: Zero999
author_rank: Super Contributor
timestamp: February 10, 2017, 08:44:51 am
content: Quote from: Audioguru on February 10, 2017, 12:33:17 amSorry missed, that pin 2 was grounded. It's still a bad idea in this case, as we want the gain to be set by a potential divider between the output and pin 2: R1, R2 and R6 in series with the J-FET. Pin 2 isn't grounded on the original Wien bridge schematic on the LM386 datasheet. It is connected to the output via a potential divider, consisting of a 390R resistor and filament lamp.QuoteI agree, it needs a decoupling capacitor in real life. There was no decoupling on any of schematics I posted because they were for simulation only.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: February 10, 2017, 09:04:37 pm
content: Quote from: Hero999 on February 10, 2017, 08:44:51 amThere was a decoupling capacitor in the original design (at least in the breadboard). I removed it and I forgot to put it back when I switched from LM358 to LM386.I had some problems with sensors before so I've started to use them.About breadboard capacitance, this pic was taken without the gain capacitor, it's supposted that the oscillator shouldn't work at all without it.I must clear my mind and start all over again.Meanwhile I started a different approach this week with a NE555 and the LM386 spice model was the perfect excuse to learn and use it. I've got a quite nice sine wave (about 1kHz) and it takes less than 4ms to be stable. It goes from -1.5 to 1.5V and -15 to 15mA. I guess it's good enough to feed into a radio mic.I'm not giving up with the oscillator, I've learn a lot with it. I started from the scratch today with the LM741 but including the AGC this time. It took too much time and everybody's effort to leave it behind unfinished.

author: Zero999
author_rank: Super Contributor
timestamp: February 10, 2017, 10:55:08 pm
content: Yes, you can make a sine wave from a square wave by using a filter to remove the harmonics. It will work with an RC filter too.Why use the old 741? There are much better op-amps around and they aren't expensive.You'll probably see lots of schematics for Wien bridge oscillators which use a dual supply. Here's one which will work from a single supply.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: February 12, 2017, 01:47:05 pm
content: Quote from: Hero999 on February 10, 2017, 10:55:08 pmYou are right, I don't need to go back to basics with a LM741. I'll go right ahead with a newer Op-Amp like OP07. I'll buy some of them this week.Thanks again!!

author: HoracioDos
author_rank: Frequent Contributor
timestamp: February 23, 2017, 02:01:04 am
content: I've been learning about the phase shift oscillator and the buffered version in the last weeks. They are really fast and quite easy to set up within 9V. I used the TL071 in the spice model but a quad op-amp like TL074 could be used instead.I added an op amp follower for buffering, gain and amplitude adjustment and one stage bandpass filter (1Khz - 100Hz width) designed with TI FilterPro. I've uploaded a new version with NE555 and the oscillators. All off them have a very similar output of about 1Khz.By the way, I signed up for a basic electronics course at the end of next month and bought some books.

author: Zero999
author_rank: Super Contributor
timestamp: February 23, 2017, 09:05:49 am
content: I'm glad to here that.By the way, the symbols you used for the TL071 are not in the standard LTSpice library so others might not be able to see them. Fortunately it's possible to use one of the standard op-amp symbols in the LTSpice library and embed the model directly in the .asc file.Use the symbol named opamp2 in the schematic, right click on it and set its value to TL071.Open up TL071.sub (normally saved in LTspiceXVII\lib\sub) in a text editor. I use LTSpice's built-in text editor.Select the whole file and copy it to the clipboard.In the schematic, insert a SPICE directive, by clicking on the .op button, on the far right hand side of the tool bar.Paste the file into the text box.Click OK.Place the text in a convenient part of the schematic, away from any symbols.Now you can be sure you can post it on the Internet and others will still be able to read it.Attached is the 555 timer version of the schematic you posted but with the TL072 model I have on my computer.

author: HoracioDos
author_rank: Frequent Contributor
timestamp: February 23, 2017, 11:34:54 am
content: Done! Thanks!!!

author: HoracioDos
author_rank: Frequent Contributor
timestamp: February 23, 2017, 01:55:15 pm
content: I want to order the op-amps. I can't find any difference now between TL07x and TL08x series. They are low noise now. What's I'm missing?http://www.ti.com/assets/js/compareParts/compare.html?familyId=1562&parts=TL071,TL081&cols=o1,p480,p1261min,p1261max,p23typ,p22typ,p78,p2max,p1typ,p7typ,p1498,p1192,p2954,p1130&lang=enQuote from: Audioguru on January 16, 2017, 10:15:05 pm

author: HoracioDos
author_rank: Frequent Contributor
timestamp: March 03, 2017, 08:18:08 pm
content: Bunch of oscillators