| View previous topic :: View next topic |
| Author |
Message |
The Phantom Guest
|
Posted: Sat Jun 14, 2008 12:01 am Post subject: Re: Tri to Sine diode shaper |
|
|
On Fri, 13 Jun 2008 09:34:19 -0700, Jim Thompson wrote
<SNIP>
[quote]
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
[/quote]
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. |
|
| |
|
Back to top |
Jim Thompson Guest
|
Posted: Sat Jun 14, 2008 8:55 pm Post subject: Re: Tri to Sine diode shaper |
|
|
On 13 Jun 2008 14:01:02 -0500, The Phantom <phantom@aol.com> wrote:
[quote]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.
[/quote]
Great!
My oldest son, Aaron, wrote (with some pointers from Brian Hirasuna)
these for me for PSpice a number of years ago ...
..FUNC FRACT(X) {(ATAN(TAN(((X+1e-11)-0.5)*PI))/PI+0.5)}
..FUNC TRUNC(X) {((X)-FRACT(X))}
..FUNC ROUND(X) {(TRUNC((X)+0.5))}
..FUNC BIT(X,Y) {(SGN(X-(2**Y)+0.1)+1)/2}
..FUNC DIV(X,MOD) {TRUNC((X+1u)/MOD)}
..FUNC MODULO(X,MOD) {(FRACT(X/MOD))*MOD}
..FUNC INT(X) {((X)-FRACT(X))}
I had forgotten I had them... had to do a HD search to remember where
they were ;-)
...Jim Thompson
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC>s and Discrete Systems | manus |
| Phoenix, Arizona 85048 Skype: Contacts Only | |
| Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
| E-mail Icon at http://www.analog-innovations.com | 1962 |
America: Land of the Free, Because of the Brave |
|
| |
|
Back to top |
Jim Thompson Guest
|
Posted: Mon Jun 16, 2008 2:54 am Post subject: Re: Tri to Sine diode shaper |
|
|
On 13 Jun 2008 14:01:02 -0500, The Phantom <phantom@aol.com> wrote:
[quote]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.
[/quote]
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
--
| James E.Thompson, P.E. | mens |
| Analog Innovations, Inc. | et |
| Analog/Mixed-Signal ASIC>s and Discrete Systems | manus |
| Phoenix, Arizona 85048 Skype: Contacts Only | |
| Voice:(480)460-2350 Fax: Available upon request | Brass Rat |
| E-mail Icon at http://www.analog-innovations.com | 1962 |
America: Land of the Free, Because of the Brave |
|
| |
|
Back to top |
The Phantom Guest
|
Posted: Mon Jun 16, 2008 4:24 am Post subject: Re: Tri to Sine diode shaper |
|
|
On Sun, 15 Jun 2008 14:54:49 -0700, Jim Thompson
<To-Email-Use-The-Envelope-Icon@My-Web-Site.com> wrote:
<SNIP>
[quote]
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.[/quote]
See: http://en.wikipedia.org/wiki/Rounding
Also, Knuth in Vol 2 of "The Art of Computer Programming" discusses rounding. |
|
| |
|
Back to top |
Joel Koltner Guest
|
Posted: Mon Jun 16, 2008 8:53 pm Post subject: Re: Tri to Sine diode shaper |
|
|
"Phil Hobbs" <pcdhSpamMeSenseless@electrooptical.net> wrote in message
news:485145A5.3030509@electrooptical.net...
[quote]Yes, it>s a pretty good book attached to some reasonably functional although
sometimes ugly code.
[/quote]
I have a suspicion that all those high-powered math guys who initlally created
the contents are often long gone and they>re just hiring some generic
programmers to port it from language to language, using some sort of
regression testing to make sure nothing gets broken in the process.
Not to mention they have some bizarre licensing scheme where just buying the
book doesn>t entitle you to use the printed code -- that>s a separate
purchase!
I suppose it>s still cheaper than Matlab with the appropriate toolboxes... |
|
| |
|
Back to top |
John Devereux Guest
|
Posted: Mon Jun 16, 2008 10:55 pm Post subject: Re: Tri to Sine diode shaper |
|
|
"Joel Koltner" <zapwireDASHgroups@yahoo.com> writes:
[quote]"Phil Hobbs" <pcdhSpamMeSenseless@electrooptical.net> wrote in message
news:485145A5.3030509@electrooptical.net...
Yes, it>s a pretty good book attached to some reasonably functional although
sometimes ugly code.
I have a suspicion that all those high-powered math guys who initlally created
the contents are often long gone and they>re just hiring some generic
programmers to port it from language to language, using some sort of
regression testing to make sure nothing gets broken in the process.
Not to mention they have some bizarre licensing scheme where just buying the
book doesn>t entitle you to use the printed code -- that>s a separate
purchase!
[/quote]
That was the major disappointment for me. The book is not cheap,
then they *still* want money off you if you use the contents!
--
John Devereux |
|
| |
|
Back to top |
Phil Hobbs Guest
|
Posted: Tue Jun 17, 2008 12:24 am Post subject: Re: Tri to Sine diode shaper |
|
|
John Devereux wrote:
[quote]"Joel Koltner" <zapwireDASHgroups@yahoo.com> writes:
"Phil Hobbs" <pcdhSpamMeSenseless@electrooptical.net> wrote in message
news:485145A5.3030509@electrooptical.net...
Yes, it>s a pretty good book attached to some reasonably functional although
sometimes ugly code.
I have a suspicion that all those high-powered math guys who initlally created
the contents are often long gone and they>re just hiring some generic
programmers to port it from language to language, using some sort of
regression testing to make sure nothing gets broken in the process.
Not to mention they have some bizarre licensing scheme where just buying the
book doesn>t entitle you to use the printed code -- that>s a separate
purchase!
That was the major disappointment for me. The book is not cheap,
then they *still* want money off you if you use the contents!
[/quote]
There>s a whole pile of better numerical code out there, once you figure
out what you want to do--I bought the floppy disc back in the day, which
entitled me to use it myself. I>ve been doing that for about 15 years,
which makes it pretty cheap at the price.
Cheers,
Phil Hobbs |
|
| |
|
Back to top |
John Devereux Guest
|
Posted: Tue Jun 17, 2008 2:36 am Post subject: Re: Tri to Sine diode shaper |
|
|
Phil Hobbs <pcdhSpamMeSenseless@pergamos.net> writes:
[quote]John Devereux wrote:
"Joel Koltner" <zapwireDASHgroups@yahoo.com> writes:
"Phil Hobbs" <pcdhSpamMeSenseless@electrooptical.net> wrote in
message news:485145A5.3030509@electrooptical.net...
Yes, it>s a pretty good book attached to some reasonably
functional although sometimes ugly code.
I have a suspicion that all those high-powered math guys who
initlally created the contents are often long gone and they>re just
hiring some generic programmers to port it from language to
language, using some sort of regression testing to make sure
nothing gets broken in the process.
Not to mention they have some bizarre licensing scheme where just
buying the book doesn>t entitle you to use the printed code --
that>s a separate purchase!
That was the major disappointment for me. The book is not cheap,
then they *still* want money off you if you use the contents!
There>s a whole pile of better numerical code out there, once you
figure out what you want to do--I bought the floppy disc back in the
day, which entitled me to use it myself. I>ve been doing that for
about 15 years, which makes it pretty cheap at the price.
[/quote]
I>ve just reread the available licenses (in the book). They appear to
want to license per instance of any algorithm used from the book.
Prices from $65 per instance...
Actually they say "per screen". So I guess it is free for my embedded
systems after all :)
--
John Devereux |
|
| |
|
Back to top |
Martin Brown Guest
|
Posted: Tue Jun 17, 2008 4:20 am Post subject: Re: Tri to Sine diode shaper |
|
|
Joel Koltner wrote:
[quote]"Phil Hobbs" <pcdhSpamMeSenseless@electrooptical.net> wrote in message
news:485145A5.3030509@electrooptical.net...
Yes, it>s a pretty good book attached to some reasonably functional although
sometimes ugly code.
I have a suspicion that all those high-powered math guys who initlally created
the contents are often long gone and they>re just hiring some generic
programmers to port it from language to language, using some sort of
regression testing to make sure nothing gets broken in the process.
[/quote]
They were physicists and engineers and the orignal was in Fortran.
You have to treat it with a little bit of caution. Some of the NA
algorithms contain typos in some of the languages and versions. And the
C/Pascal code shows its Fortran arrays with base index of 1 heritage in
places. Something which makes the bitreverse slightly opaque for instance.
[quote]
Not to mention they have some bizarre licensing scheme where just buying the
book doesn>t entitle you to use the printed code -- that>s a separate
purchase!
I suppose it>s still cheaper than Matlab with the appropriate toolboxes...
[/quote]
Although these days there are better free libraries available online
once you have a few keywords/references out of the book. The references
in the chapters are excellent. See sci.numerical-analysis for various
gripes about the known defects of the NA code. I think they go a bit
overboard on criticising it unfairly but you do need to treat the sample
code with a bit of caution. There are more robust solutions but most of
the time the NA code will work OK.
Reasonably functional sums it up pretty well.
Test carefully that it does what you want and you should be OK.
Regards,
Martin Brown
** Posted from http://www.teranews.com ** |
|
| |
|
Back to top |
Phil Hobbs Guest
|
Posted: Tue Jun 17, 2008 7:42 am Post subject: Re: Tri to Sine diode shaper |
|
|
John Devereux wrote:
[quote]Phil Hobbs <pcdhSpamMeSenseless@pergamos.net> writes:
There>s a whole pile of better numerical code out there, once you
figure out what you want to do--I bought the floppy disc back in the
day, which entitled me to use it myself. I>ve been doing that for
about 15 years, which makes it pretty cheap at the price.
I>ve just reread the available licenses (in the book). They appear to
want to license per instance of any algorithm used from the book.
Prices from $65 per instance...
Actually they say "per screen". So I guess it is free for my embedded
systems after all :)
[/quote]
I have no intention of ever using it in a product. NR has probably
saved me 6 months' work over the years, so that sum is completely
reasonable for development purposes.
Cheers,
Phil Hobbs |
|
| |
|
Back to top |
|