
Spin Semiconductor Support forum

View previous topic :: View next topic 
Author 
Message 
Aaron
Joined: 04 Mar 2015 Posts: 42

Posted: Thu Jan 14, 2016 1:48 pm Post subject: 


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.
AN0001 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 


smear
Joined: 01 Jul 2016 Posts: 12

Posted: Thu Aug 03, 2017 5:43 pm Post subject: 


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 


slacker
Joined: 01 Feb 2011 Posts: 115

Posted: Sat Aug 05, 2017 1:14 am Post subject: 


Yeah just an emitter follower, I stick a 100k resistor between the FV1 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 




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
