Exact match. Not showing close matches.
PICList
Thread
'[PIC]:Exponential function on PWM output'
2002\10\11@194018
by
OTT,TONY (HPRoseville,ex1)
I need to create an exponential function, programmable between 100% to 0%
to +100% in steps of 12.5%, on a PWM output. The driver is a nonexponential
PWM signal input that the output should track either directly or
exponentially depending on value programmed. Pulse width variation is 0.75ms
to 2.25ms, period = 20ms. I am new to programming PIC's and would be
grateful for help. Have searched archives and could not find applicable
material. Thanks
Tony Elliott
Engineering Program Manager
PC Customization Services
HewlettPackard Company

http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
2002\10\11@195731
by
Doug Hewett
what do you mean by '100%'? I thought the duty cycle was 0% to 100%.
Thanks,
Doug Hewett
Software engineer
StarTrac, Inc.
{Original Message removed}
2002\10\11@204542
by
Andy Kunz
At 04:56 PM 10/11/02 0700, you wrote:
>what do you mean by '100%'? I thought the duty cycle was 0% to 100%.
Sounds like he's doing reverse on an ESC. Think Hbridge with PWM on +
side going to one bottom of the H, and on the  side going to the other
side of the H bottom.
The easy way is to use a table lookup.
Andy
>Thanks,
>Doug Hewett
>Software engineer
>StarTrac, Inc.
>
>
>{Original Message removed}
2002\10\12@004029
by
OTT,TONY (HPRoseville,ex1)
This is not a question regarding duty cycle. Imagine the input PWM signal
varying linearly over time between 1ms and 2ms. The output PWM signal pulse
width would vary nonlinearly over time according to a positive or negative
exponential curve (imagine it graphically  linear = 1:1 ratio input to
output). On the negative exponential, let's say, input = 1.1ms, output =
1.06ms, input = 1.5ms, output = 1.3ms, input = 1.8ms, output = 1.6ms, input
= 2ms, output = 2ms. On the other side (positive Expo) input = 1.1ms, out =
1.2ms, input = 1.5ms, out = 1.6ms, input = 1.8ms, output = 1.9ms, input =
2ms, output = 2ms. (these are examples for description purposes). The
difference between input and output follow a number of different exponential
curves that are selectable.
Hopefully this describes the problem a little better.
Thanks
Tony Elliott
Engineering Program Manager
PC Customization Services
HewlettPackard Company
> {Original Message removed}
2002\10\12@085306
by
Olin Lathrop
> I need to create an exponential function, programmable between 100% to 0%
> to +100% in steps of 12.5%, on a PWM output.
That would require an infinite number of steps, since the exponential series
can never reach zero.
It is probably easiest to think about this problem in Log2 space, in other
words in terms of bits. Log2(1.125) = .167 bits, or conversely there are
5.89 x1.125 steps in a bit. If your PWM output resolution is 8 bits, then
any desired PWM fraction less than 1/512 would be rounded to 0 anyway. An
exponential series to cover the 9 bit range from 1/512 to 1 requires 9 x
5.89 = 53 steps. You can reduce this requirement by 5.89 steps for every
bit of PWM output resolution you are willing to give up. The conversion
from the linear input value to the PWM output fraction is best done in a
table. If you're clever, you can have assembly contants define the input
range, output resulution, and step size, and have the assembler compute the
table for you automatically. I did something similar once to make a motor
drive PWM output table.
> The driver is a nonexponential
> PWM signal input that the output should track either directly or
> exponentially depending on value programmed. Pulse width variation is
0.75ms
> to 2.25ms, period = 20ms.
Unfortunately you didn't say what your output resolution needs to be.
Otherwise these parameters seem within range of using the PWM hardware. If
you use 8 bit PWM duty cycle resolution, you will get 20mS/255 = 78.4uS
resolution. That only gives you 19 steps within the 750uS to 2.25mS range.
10 bit PWM resolution will give you 4 times that, or 76 steps. If that
isn't enough, you will have to manually start a pulse every 20mS and
probably use timer 1 to adujust the digital "one shot" duration. This will
give you plenty of resolution but may cause some jitter on the 20mS period.
*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 7429014, http://www.embedinc.com

http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body
2002\10\12@104730
by
OTT,TONY (HPRoseville,ex1)
Olin,
Thanks. Bottom line, a lookup table for the different curves. There will be
10 selectable rates on the less than 1:1 side and 10 rates greater than 1:1
with 1:1 in the middle. The resolution needs to be to 5 clock cycles at 1Mz
or 5us. This obviously implies Timer1. Since I need 6 PWM outputs from the
PIC, I think I will have to start each pulse manually and sequence them.
Jitter on the period is not an issue as the driven circuit can manage 16ms
to 25ms.
Unfortunately, I have never done math functions in PIC's before so don't
know how to do that yet. Maybe it's not math but a simple conversion. Any
pointers?
Tony Elliott
Engineering Program Manager
PC Customization Services
HewlettPackard Company
> {Original Message removed}
2002\10\12@110541
by
Alan B. Pearce
>Unfortunately, I have never done math functions in PIC's before
>so don't know how to do that yet. Maybe it's not math but a
>simple conversion. Any pointers?
Then this sounds like it is time to investigate a C or other high level
language compiler that can do a module for the maths that you can link in,
if you don't want to do the whole program in C.
However there is another trick I have done to make a table. Use Excel. In my
case I wanted to have a table for a 16 bit sine wave, with entries every 2
degrees. Using Excel it took me about a half hour to set up formulae that
would automatically calculate the values, set up a column full of "DT ",
then set up the next two columns to display the hex values as text, using
two columns to split the value into high and low halves, with the formula
putting a comma after the first data column. Once it was all calculated just
highlight the three columns (DT and two data columns) and copy and paste
into your favourite text editor. The other sneaky trick with this is it is
easy to offset the data with constants as you go, in my case I needed to
offset by 32768 because of the way I needed to drive a DAC.
This makes doing tables real easy, and if you wish to rearrange the data
because of a different strategy on your PIC, it takes a very short time to
modify the Excel spreadsheet to regenerate the table.

http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body
2002\10\12@123542
by
Wagner Lipnharski

Alan B. Pearce wrote:
{Quote hidden}>> Unfortunately, I have never done math functions in PIC's before
>> so don't know how to do that yet. Maybe it's not math but a
>> simple conversion. Any pointers?
>
> Then this sounds like it is time to investigate a C or other high
> level language compiler that can do a module for the maths that you
> can link in, if you don't want to do the whole program in C.
>
> However there is another trick I have done to make a table. Use
> Excel. In my case I wanted to have a table for a 16 bit sine wave,
> with entries every 2 degrees. Using Excel it took me about a half
> hour to set up formulae that would automatically calculate the
> values, set up a column full of "DT ", then set up the next two
> columns to display the hex values as text, using two columns to split
> the value into high and low halves, with the formula putting a comma
> after the first data column. Once it was all calculated just
> highlight the three columns (DT and two data columns) and copy and
> paste into your favourite text editor. The other sneaky trick with
> this is it is easy to offset the data with constants as you go, in my
> case I needed to offset by 32768 because of the way I needed to drive
> a DAC.
>
> This makes doing tables real easy, and if you wish to rearrange the
> data because of a different strategy on your PIC, it takes a very
> short time to modify the Excel spreadsheet to regenerate the table.
Translating Alan's good example of table generation, into Qbasic;
Open "SinVal.Txt" for output as #1
For N=0 to 358 step 2
sinv = int(sin(n * 0.01745329251995) * 65535)
Sinvh = int(sinv/256)
Sinvl = sinv mod 256
Print #1, "DT "; sinvh;",";sinvl
Next N
Close #1
VV46NER

http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservKILLspammitvma.mit.edu with SET PICList DIGEST in the body
2002\10\12@124345
by
Scott Dattalo

On Sat, 12 Oct 2002, ELLIOTT,TONY (HPRoseville,ex1) wrote:
> Olin,
>
> Thanks. Bottom line, a lookup table for the different curves. There will be
> 10 selectable rates on the less than 1:1 side and 10 rates greater than 1:1
> with 1:1 in the middle. The resolution needs to be to 5 clock cycles at 1Mz
> or 5us. This obviously implies Timer1. Since I need 6 PWM outputs from the
> PIC, I think I will have to start each pulse manually and sequence them.
> Jitter on the period is not an issue as the driven circuit can manage 16ms
> to 25ms.
>
> Unfortunately, I have never done math functions in PIC's before so don't
> know how to do that yet. Maybe it's not math but a simple conversion. Any
> pointers?
http://www.dattalo.com/technical/software/software.html
In particular, you may wish to look at the logarithm code:
http://www.dattalo.com/technical/software/pic/piclog.html
You can also find examples for sine, arcsine and arctan. All of these use
lookup tables. The technique is suitable for any function approximation
(including exponentials, for example). In general, the technique involves
identifying the domain and range of your function. For example, write your
function as:
y = f(x)
find xmin, xmax, ymin and ymax. Once you've got these, transform them into
a format suitable for PICs. E.g. if x varies from .5 to 2, then you'll
want to scale x such that .5 ==> 0 and 2 ==> 255.
Once you've identified the scaling factors, then creating a table is
straight forward. (Even if you don't have Excel at your disposal  or as
the case may be you've already disposed Excel.)
Depending on your objective, you can trade speed for memory. In my
examples, I use linear interpolation between successive entries in the
table. However, this takes time. You can get rid of linear interpolation
and just increase the size of the table. For example, Eric Smith
implements the sine function using a table without linear interpolation:
http://www.brouhaha.com/~eric/pic/sine.html
His table is 64 words versus my 16, but his much faster.
Scott

http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspam.....mitvma.mit.edu with SET PICList DIGEST in the body
2002\10\12@140619
by
Alan B. Pearce
>Translating Alan's good example of table generation, into Qbasic;
snip..
Yeah well that of course is another way to do it. For me the copy and paste
was easier, but the QBasic way should generate an include file quite nicely.

http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body
2002\10\12@143435
by
Bob Barr

On Sat, 12 Oct 2002 16:03:09 +0100, "Alan B. Pearce" wrote:
<snip>
>
>However there is another trick I have done to make a table. Use Excel. In my
>case I wanted to have a table for a 16 bit sine wave, with entries every 2
>degrees. Using Excel it took me about a half hour to set up formulae that
>would automatically calculate the values, set up a column full of "DT ",
>then set up the next two columns to display the hex values as text, using
>two columns to split the value into high and low halves, with the formula
>putting a comma after the first data column.
As a very occasional Excel user, I have to ask: How do you get Excel
to display values in hex? That sounds like a very handy thing to be
able to do, but I've never seen any way to do it.
Also, in Excel, is there any way to force exponent display into
'engineering' units (10^3, 10^6 etc) rather than the regular
'scientific' (10^4, 10^5, etc) exponents?
Thanks, Bob

http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body
2002\10\12@181336
by
Karl Seibert

Quoting Bob Barr <@spam@bbarrKILLspamCALIFORNIA.COM>:
> As a very occasional Excel user, I have to ask: How do you get Excel
> to display values in hex? That sounds like a very handy thing to be
> able to do, but I've never seen any way to do it.
This is for Excel 2000. I'm not sure about other versions.
The function DEC2HEX will convert a decimal integer to
hexidecimal. You need to install the Analysis ToolPak
and enable it in the Tools/Addins menu. Look DEC2HEX
in Help for details.
> Also, in Excel, is there any way to force exponent display into
> 'engineering' units (10^3, 10^6 etc) rather than the regular
> 'scientific' (10^4, 10^5, etc) exponents?
Go to Format/Cells. Select Custom from the category list
and select ##0.0E+0 from the Type list. Add more zeros after
the decimal to increase precision.
> Thanks, Bob
Your welcome,
Karl

http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservKILLspammitvma.mit.edu with SET PICList DIGEST in the body
2002\10\12@201824
by
Matt Pobursky

These both work in Excel97 as well.
Matt Pobursky
Maximum Performance Systems
On Sat, 12 Oct 2002 18:09:01 0400, Karl Seibert wrote:
{Quote hidden}>Quoting Bob Barr <
RemoveMEbbarrTakeThisOuTCALIFORNIA.COM>:
>> As a very occasional Excel user, I have to ask: How do you get Excel
>> to display values in hex? That sounds like a very handy thing to be
>> able to do, but I've never seen any way to do it.
>
>This is for Excel 2000. I'm not sure about other versions.
>
>The function DEC2HEX will convert a decimal integer to
>hexidecimal. You need to install the Analysis ToolPak
>and enable it in the Tools/Addins menu. Look DEC2HEX
>in Help for details.
>
>> Also, in Excel, is there any way to force exponent display into
>> 'engineering' units (10^3, 10^6 etc) rather than the regular
>> 'scientific' (10^4, 10^5, etc) exponents?
>
>Go to Format/Cells. Select Custom from the category list
>and select ##0.0E+0 from the Type list. Add more zeros after
>the decimal to increase precision.
>
>> Thanks, Bob
>
>Your welcome,
>Karl

http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservspamBeGonemitvma.mit.edu with SET PICList DIGEST in the body
2002\10\16@231515
by
Bob Barr
On Sat, 12 Oct 2002 19:15:58 0500, Matt Pobursky wrote:
>These both work in Excel97 as well.
>
Thanks for the original tip on this, Karl. I've installed the Analysis
ToolPak now and the HEX2DEC function is working like a champ. :=)
Thanks for the confirmation on versions, Matt. Once I installed the
Analysis ToolPak, all fell into place. Very handy.
Regards, Bob
<snip>

http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
2002\10\16@235803
by
Matt Pobursky

Glad it helped Bob!
On a related note, if you've never tried "Solver" you should give it a
look. It's great for solving a function with variables, you know the
output you want and need to find the condition(s) which make the
function true. It manipulates the chosen variables within limits you
set and solves the function variables (if possible) for you.
Also very handy.
Matt Pobursky
Maximum Performance Systems
On Wed, 16 Oct 2002 19:53:25 0700, Bob Barr wrote:
{Quote hidden}>On Sat, 12 Oct 2002 19:15:58 0500, Matt Pobursky wrote:
>
>>These both work in Excel97 as well.
>>
>
>Thanks for the original tip on this, Karl. I've installed the Analysis
>ToolPak now and the HEX2DEC function is working like a champ. :=)
>
>Thanks for the confirmation on versions, Matt. Once I installed the
>Analysis ToolPak, all fell into place. Very handy.
>

http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
More... (looser matching)
 Last day of these posts
 In 2002
, 2003 only
 Today
 New search...