Spin Semiconductor Forum Index Spin Semiconductor
Support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Trying to make really long exponential decay

 
Post new topic   Reply to topic    Spin Semiconductor Forum Index -> Algorithm development
View previous topic :: View next topic  
Author Message
Digital Larry



Joined: 12 Nov 2012
Posts: 274

PostPosted: Sat Jun 18, 2016 4:12 pm    Post subject: Trying to make really long exponential decay Reply with quote

Here's what I've tried:

(detect trigger and initialize pulse level to -1.0)
sof 0, -1.0
wrax pulse, 0

(decay)
rdax pulse, 0.9999
wrax pulse, 0

This is a vast over simplification but I hope you get what I am describing. The issue that I am having is that I'd like a decay to last a few seconds. The resolution of the multiplier used in an rdax, an S1.14 format number, is 2^(-14) or 0.0000610352-something.

So the largest number less than 1.0 would be 1.0 - 0.0000610352, or 0.999938965.

If I use that value, then after 0.1 second, or 3277 samples, the pulse will have decayed to (about) 0.999938965^3277 or 0.8187.

This would seem to be OK, however in practice I don't seem to be able to get a decay that is much longer than 150 msec. I can make the rdax statement:

rdax pulse, 0.9999999

but it doesn't make any difference after a certain point so I seem to be hitting the maximum value that is less than 1.0 and it doesn't seem as large as I thought it was going to be. Any idea where I am going wrong?

Follow up:
I'm guessing (haven't tried it yet) that I can use a register initialized with a 24-bit value and then mulx this with the current value of the pulse after an rdax pulse, 1.0. That way I can get as much resolution as is possible with the FV-1.

I have seen a few examples among all the FV-1 code where there appeared to be some precision-extending approach used to get around various coefficient quantization limits of different instructions. It would be nice to get these strategies gathered together and more fully explained.
Back to top
View user's profile Send private message Visit poster's website
MacroMachines



Joined: 12 Dec 2014
Posts: 70
Location: Detroit,MI

PostPosted: Thu Jul 07, 2016 10:35 pm    Post subject: Reply with quote

could you maybe use 2 registers to double the precision and do the calculation twice/add .5 of each?
_________________
http://MacroMachines.net
Digital Control for your Analog Soul.
Back to top
View user's profile Send private message Visit poster's website AIM Address
MacroMachines



Joined: 12 Dec 2014
Posts: 70
Location: Detroit,MI

PostPosted: Sun Nov 27, 2016 2:56 am    Post subject: Reply with quote

I was able to make a very long counter using:

Code:

equ    counter       reg0

            
or   %00000000_00000000_00001000   ; add the increment to count upwards towards zero
rdax    counter,       1.0    
wrax    counter,       1.0
skp    gez,       reset       
skp    run,       output

reset:          ; reset counter to -1
sof    0,       -1.0
wrax    counter,       1.0

output:
ldax counter
wrax dacl, 1
wrax dacr, 0

_________________
http://MacroMachines.net
Digital Control for your Analog Soul.
Back to top
View user's profile Send private message Visit poster's website AIM Address
donstavely



Joined: 07 Jan 2010
Posts: 52
Location: Windsor, Colorado

PostPosted: Mon Feb 20, 2017 2:30 pm    Post subject: Long exponential decay Reply with quote

I don't know if you are still interested in this, but I recently hit on an easy way to do very long decays. Instead of your:
rdax pulse, 0.999
wrax pulse, 0
Use a delay memory in place of the register, so the delay time is multiplied by the delay length:
rda pulse_dly+1000, 0.998 ; use long delay for filter reg
wra pulse_dly, 0
The value ticks down by 0.2% every 1000 cycles, so its time constant is about 500,000 cycles, or over 15 seconds at 32KHz.
Don't make the coefficient too close to 1.000, due to the limited precision of the delay memory. Make the delay longer if you need a longer decay.
Clever, eh?
_________________
Don Stavely
Back to top
View user's profile Send private message
Digital Larry



Joined: 12 Nov 2012
Posts: 274

PostPosted: Thu Feb 23, 2017 12:48 pm    Post subject: Reply with quote

That is pretty clever! However it is going to be stepped rather than smooth, which is probably what I was more interested in (can't remember what I was doing when I first posted here).

Thx Don.

DL
Back to top
View user's profile Send private message Visit poster's website
donstavely



Joined: 07 Jan 2010
Posts: 52
Location: Windsor, Colorado

PostPosted: Mon Mar 06, 2017 12:40 pm    Post subject: Reply with quote

Thanks, D.L.

Assuming that the decay value is used as some sort of control voltage, a 0.2% step in amplitude would not be noticeable. On the other hand, it very well could be noticeable as a step change in pitch.

I 'll bet a coefficient closer to 1.000 could be used, but I haven't done the math about the delay memory precision. We wouldn't want the decay to get "stuck" on one value because the multiply by the coefficient got rounded to the same value in the delay memory.

Don
_________________
Don Stavely
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Spin Semiconductor Forum Index -> Algorithm development All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group