Generating sine with triangle and multiplier - Page 1
Forum section: electronics / projects

author: MrWifiHifi
author_rank: Regular Contributor
timestamp: July 09, 2025, 11:06:52 pm
content: HiI would like to ask. Wherever I have come across generating a sine from a triangle so far, it has always been done through some non-linearity. Whether diodes or transistors were used for this. But I wondered if it would be possible to use an analog multiplier to generate a sine from a triangle. The option would be to use a multiplier to generate the x^2 function that would be used for this. I am also attaching a link to the simulation in Falstad. For now, it's just a concept. I assume, however, that cosine could also be made with it, which would expand the possible uses.https://tinyurl.com/ymoe5b4wI will be grateful in advance for any useful insights.

author: ledtester
author_rank: Super Contributor
timestamp: July 10, 2025, 01:46:45 am
content: One reason is cost... analog multipliers are a lot more expensive than diodes and transistors.Are you approximating sin(x) with x*(pi-x) on the interval [0,pi]?Here's my go at computing the THD...For the sine terms one has:Code:[ integrate(x*(pi-x)*sin(n*x), (x, 0, pi)) for n in range(1,12) ][4, 0, 4/27, 0, 4/125, 0, 4/343, 0, 4/729, 0, 4/1331, ...]or b_n = 4/n^3 for odd n and zero otherwise.The cosine terms are all zero.The THD comes out to:$$\text{THD} = \sqrt{ \sum_{n=1}^{\infty} \frac{1}{(2n+1)^{6}} } = 0.038...$$So about 3.8%.At 7:26 in this video is a simple A/B comparison in an audio application between a pure sine wave and the quadratic approximation:Fast and Simple Approximation of Sine Functionhttps://youtu.be/1xlCVBIF_ig?t=7m26s

author: David Hess
author_rank: Super Contributor
timestamp: July 10, 2025, 04:25:58 am
content: National Semiconductor application note AN-263, included below, shows several sine wave generation techniques, including logarithmic.Burr-Brown's "Function Circuits - Design and Applications" has several examples of analog multipliers used for sine shaping:https://bitsavers.trailing-edge.com/components/burrBrown/Burr_Brown_Function_Circuits_1976.pdf

author: MathWizard
author_rank: Super Contributor
timestamp: July 10, 2025, 04:38:47 am
content: If x is in radians, x*(pi-x)/2.47 would at least give sin(pi/2)=1deg x (x*(pi-x)/2.4674) sinx0 0.00 0.00 0.0010 0.17 0.21 0.1720 0.35 0.40 0.3430 0.52 0.56 0.5040 0.70 0.69 0.6450 0.87 0.80 0.7760 1.05 0.89 0.8770 1.22 0.95 0.9480 1.40 0.99 0.9890 1.57 1.0000 1.00100 1.75 0.99 0.98110 1.92 0.95 0.94120 2.09 0.89 0.87130 2.27 0.80 0.77140 2.44 0.69 0.64150 2.62 0.56 0.50160 2.79 0.40 0.34170 2.97 0.21 0.17180 3.14 0.00 0.00

author: Terry Bites
author_rank: Super Contributor
timestamp: July 11, 2025, 07:32:38 am
content: You'll love this:Nonlinear Circuits Handbook Analog Devices, 1976.www.analog.com/media/en/training-seminars/design-handbooks/Nonlinear-Circuits-Handbook/Nonlinear-Circuits-Handbook-1976.zip

author: ledtester
author_rank: Super Contributor
timestamp: July 12, 2025, 12:32:36 am
content: Here's a recent youtube video on a squaring circuit:Squaring Function Circuit Design Explained with Temperature Compensation -- Engineering Prof.The guy has another video on a square-root circuit:Accurate Analog Square Root Circuit with Temp Compensation Explained -- Engineering Prof.https://youtu.be/tjzYZ4FlUtE

author: PCB.Wiz
author_rank: Super Contributor
timestamp: July 12, 2025, 01:19:02 am
content: Quote from: MrWifiHifi on July 09, 2025, 11:06:52 pmYes, but x^2 is only one of many terms for a cosine polynomial, so it will be approximate.There are log-shapers that try to do a bit better, and you can buy matched NPNs easily today.https://till.com/articles/sineshaper/index.html

author: MrAl
author_rank: Super Contributor
timestamp: September 28, 2025, 11:54:38 am
content: Quote from: MathWizard on July 10, 2025, 04:38:47 amThat's the technique of generating a near sine with a squared time value. This can be obtained from a triangle wave by integration. There's a little more to it but that's the main idea. The generated sine bulges a little at the sides but it's not bad.

author: MrAl
author_rank: Super Contributor
timestamp: September 28, 2025, 12:00:48 pm
content: Quote from: Terry Bites on July 11, 2025, 07:32:38 amA browser flagged this as not being able to be downloaded securely, but when checked with several virus scanners they all say it's ok.

author: MrAl
author_rank: Super Contributor
timestamp: September 28, 2025, 12:16:12 pm
content: Quote from: PCB.Wiz on July 12, 2025, 01:19:02 amHi,Of course, but sometimes the idea is to get a simple circuit to do it not perfect accuracy. If we wanted better we can add a 4th degree term (see attachment).The image shows 2nd degree and 4th degree approximations. The 2nd degree is not as accurate but is much easier to generate.Blue: 2nd degreeRed: 4th degreeGreen: exact cos()

author: MrAl
author_rank: Super Contributor
timestamp: September 28, 2025, 12:21:55 pm
content: Hello again,Since I worked in the industry designing and testing sine converters we had different ways to go about doing this.One of the best we came up with was actually very simple. Store some of the sine amplitudes in a ROM, then run the ROM from 0 to N. The output is then filtered.The result was a sine converter with less than 1 percent THD. It was a significant improvement for the time.It also had sub-cycle feedback to keep the THD this good even with nonlinear loads. That was one of the other reasons for the sine generation.

author: mtwieg
author_rank: Frequent Contributor
timestamp: September 28, 2025, 01:51:56 pm
content: Quote from: MrAl on September 28, 2025, 11:54:38 amAgreed, if you start with a triangle wave and you want to generate a sinewave using parabolas as an approximation, then simply integrating the triangle wave is far simpler than actually squaring it. However the output amplitude will be inversely proportional to the triangle wave frequency.Long ago I had to make a function generator for a class project, and got around this issue by also making the triangle wave generator design such that its amplitude was proportional to frequency, which mostly eliminated this problem.However, I still found that a triangle > sine converter made out of diodes/LEDs seemed to have lower distortion overall, and was even simpler.Quote from: MrAl on September 28, 2025, 12:21:55 pmSounds like you're describingdirect digital synthesis.

author: mawyatt
author_rank: Super Contributor
timestamp: September 28, 2025, 02:40:13 pm
content: Way back in 80 when we were working with a Real Time SA based around Chirp-Z Transform this required a complex (Sine and Cosine) sweep multiplication of the input. This was done by using a custom very fast hybrid multiplying DAC and feeding the input to the DAC Reference, the DAC Digital input came from a ECL ROM that was cycled thru and swept for the Sine and Cosine coefficients which created the necessary swept Sine and Cosine multiplication for the CZT. Sort of a DDS type solution.Best

author: PCB.Wiz
author_rank: Super Contributor
timestamp: September 28, 2025, 02:40:30 pm
content: Quote from: MrAl on September 28, 2025, 12:21:55 pmWhat size rom ?I would have expected a ROM to manage well under 1% THD?Years ago we looked at PLD & MCU for sine generation, which stepped always the same in Y, but varied the X axis, so had much wider steps at the ‘flat’ tops. This also allowed fastest and even steps at 45’ slopes and did not waste any DAC steps. FWIR, ~804 time units gave the best fit with 8b DAC.