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 

tap tempo snippet
Goto page Previous  1, 2, 3, 4, 5, 6
 
Post new topic   Reply to topic    Spin Semiconductor Forum Index -> Algorithm development
View previous topic :: View next topic  
Author Message
Aaron



Joined: 04 Mar 2015
Posts: 42

PostPosted: Thu Jan 14, 2016 1:48 pm    Post subject: Reply with quote

For those interested in using a sin for the LED rate indicator you will have to convert the "taptempo" register's values from a time to a frequency which can be done using the log and exp functions.

AN-0001 gives us the formula for finding the frequency coefficient for the wlds instruction which is:

Kf = 2^17 * (2piF/R)


Since the taptempo register is giving us a time value, we can find its frequency by inverting it using the log and exp functions which would look like:
Code:

ldax taptempo     ;load taptempo
log -1,0              ;log base 2 of taptempo/16 * K + C
exp 1,0              ;2^(ACC * 16) * K + C

So now we can use this value and plug it into the formula for Kf. The only problem being that all of these values are way too large for the ACC to handle. Luckily, we can scale all of these values by doing all of the necessary math within the log and exp functions.

log(a*b) = log(a) + log(b)
log(a/b) = log(a) - log(b)


log(F) + log(2pi/R) + log(2^17) - log(512)

So we will end up with something like this:

Code:

ldax     taptempo         ;load taptempo
log     -1,-0.271785      ;C = a reduced value of log(2pi/R) + log(2^17) - log(512)
exp     1,0                  ;
wrax    sin0_rate,0      ;save this value to sin0 rate



This can now replace:

Code:

;Taptempo rate indicator, creates a square wave at the tap tempo rate

sof   0,0.0625
wrax   rmp1_rate,0         ;set rmp1 rate to 1Hz
cho   rdal,rmp1         ;read value of rmp1
sof   -2,0.999            ;level shift to 0 - 1 rising ramp
sof   1,-0.001          ;
rdax   taptempo,-0.5         ;deduct half of the taptempo value
skp   neg,ENDLED         ;if negative skip to ENDLED
jam   rmp1            ;else reset ramp1
ldax    led            ;and invert value of led register, creates square wave at taptempo rate
sof   -1,0             ;increase gain to cause clipping
wrax   led,0             ;save to led, clear ACC
Back to top
View user's profile Send private message
smear



Joined: 01 Jul 2016
Posts: 12

PostPosted: Thu Aug 03, 2017 5:43 pm    Post subject: Reply with quote

Thanks for the info on using a sin for the LED.

Speaking of which, what are you guys using as drivers? A simple transistor circuit?
Back to top
View user's profile Send private message
slacker



Joined: 01 Feb 2011
Posts: 115

PostPosted: Sat Aug 05, 2017 1:14 am    Post subject: Reply with quote

Yeah just an emitter follower, I stick a 100k resistor between the FV-1 output and the base of the transistor but may not be needed.

Something like this example, pretty much any NPN will work, adjust resistor value to taste.
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
Goto page Previous  1, 2, 3, 4, 5, 6
Page 6 of 6

 
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