Electronics Computer-Aided Design Re: Tri to Sine diode shaper

Bookmark this page:  YahooMyWeb Yahoo!  Google Google  Windows Live Favorites Windows Live  del.icio.us del.icio.us  digg digg  Add to Netscape Netscape
Subject Author Date
Re: Tri to Sine diode shaper The Phantom 06-13-08
Posted by The Phantom on June 13, 2008, 1:57 am
Please log in for more thread options
On Wed, 11 Jun 2008 17:54:52 -0700, Jim Thompson

>On Wed, 11 Jun 2008 09:33:12 +1000, Mike Kendall
>
>>Can someone please direct me to a passive circuit using breakpoint
>>diodes, preferably no more than six, to shape a sine wave from a 5Vpp
>>triangle? The available power source is single supply 6V.
>>
>>I did check the net, but had no luck with finding a basic approach.
>>
>>Mike Kendall
>
>Patent:3737642 shows one way to do it.
>
>General question comes to mind... has anyone written a program that
>would derive the "best" piecewise linear fit to a function, f(x), for
>a given number of segments?
>
> ...Jim Thompson

A nifty way to do it if the function you're trying to fit has an analytical
derivative is this:

Create a stepped approximation to the derivative of the function you're
trying to fit; in this case find a stepped approximation to a cosine.

Integrate the stepped approximation and you will get a linear segment
approximation.

The slopes of the linear segments are, of course, the values of the steps.
The start and finish point of each linear segment is the same as the start
and finish of each associated step.

It may not be the exact minimum error fit, but it's really fast to compute
and it's good enough for the sort of thing the OP wants. If you want
better accuracy, generate more steps.

See the graphic over on ABSE.

Posted by The Phantom on June 13, 2008, 12:11 pm
Please log in for more thread options
On Fri, 13 Jun 2008 07:04:46 -0700, Jim Thompson

>wrote:
>
>>On Wed, 11 Jun 2008 17:54:52 -0700, Jim Thompson
>>
>>>On Wed, 11 Jun 2008 09:33:12 +1000, Mike Kendall
>>>
>>>>Can someone please direct me to a passive circuit using breakpoint
>>>>diodes, preferably no more than six, to shape a sine wave from a 5Vpp
>>>>triangle? The available power source is single supply 6V.
>>>>
>>>>I did check the net, but had no luck with finding a basic approach.
>>>>
>>>>Mike Kendall
>>>
>>>Patent:3737642 shows one way to do it.
>>>
>>>General question comes to mind... has anyone written a program that
>>>would derive the "best" piecewise linear fit to a function, f(x), for
>>>a given number of segments?
>>>
>>> ...Jim Thompson
>>
>>A nifty way to do it if the function you're trying to fit has an analytical
>>derivative is this:
>>
>>Create a stepped approximation to the derivative of the function you're
>>trying to fit; in this case find a stepped approximation to a cosine.
>>
>>Integrate the stepped approximation and you will get a linear segment
>>approximation.
>>
>>The slopes of the linear segments are, of course, the values of the steps.
>>The start and finish point of each linear segment is the same as the start
>>and finish of each associated step.
>>
>>It may not be the exact minimum error fit, but it's really fast to compute
>>and it's good enough for the sort of thing the OP wants. If you want
>>better accuracy, generate more steps.
>>
>>See the graphic over on ABSE.
>
>I see an EXE and a bunch of RAR files over on ABSE. What do I do with
>them ?:-)

Those aren't for you. You want the one called "Linear segment approximation
method".

>
> ...Jim Thompson


Posted by The Phantom on June 13, 2008, 3:01 pm
Please log in for more thread options
On Fri, 13 Jun 2008 09:34:19 -0700, Jim Thompson wrote

<SNIP>
>>
>>Those aren't for you. You want the one called "Linear segment approximation
>>method".
>>
>>>
>>> ...Jim Thompson
>
>OK. What process did you use to space the segments? (I'm not
>conversant in Mathematica.)
>
> ...Jim Thompson

You just plot a certain function of t and you will get the steps.

For the first sine graph, use:

(Ceiling(y+Cos(t))/y + Floor(y+Cos(t))/y)/2

where y is the number of steps you want. You will get a good approximation for
any value of y, but if you make it an integer plus .66, you will get slightly
lower distortion than otherwise.

For the second sine graph, the one with a flat on top, use:

(Round(y+Cos(t))/y

where y is the number of steps you want. Make y an integer plus .16 for best
results.

For positive numbers:

Ceiling(z) means the integer just greater than z (the integer part of z plus 1).

Floor(z) means the integer just less than z (the integer part of z).

Round(z) means the integer part of (z + .5).

Make the obvious changes for negative numbers.

Posted by The Phantom on June 15, 2008, 7:24 pm
Please log in for more thread options
On Sun, 15 Jun 2008 14:54:49 -0700, Jim Thompson

<SNIP>
>
>Mr. Phantom,
>
>Please comment on this discussion...
>
>http://mathforum.org/library/drmath/view/71202.html
>
>Which convention is generally followed with negative numbers?
>
> ...Jim Thompson
I think there are good reasons to use the round-to-even method.

See: http://en.wikipedia.org/wiki/Rounding

Also, Knuth in Vol 2 of "The Art of Computer Programming" discusses rounding.

Similar ThreadsPosted
Re: Tri to Sine diode shaper June 13, 2008, 1:57 am
Re: Tri to Sine diode shaper June 12, 2008, 12:53 pm
Re: Tri to Sine diode shaper June 16, 2008, 11:53 am
ltspice sine wave voltage source question July 2, 2005, 3:42 pm
diode voltage February 8, 2008, 11:09 am
diode 1n4733 May 2, 2008, 11:04 am
PSpice Ideal Diode ... and Crash October 12, 2005, 9:10 pm
Convert HSpice Diode Model to PSpice? March 28, 2007, 12:02 pm
diode protection in battery charger circuit? July 17, 2008, 1:36 am
diode protection in battery charger circuit? July 17, 2008, 1:34 am