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 

Detecting zero crossings from sin LFO

 
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: Wed Feb 24, 2016 11:18 am    Post subject: Detecting zero crossings from sin LFO Reply with quote

I should be able to do this, right?

<init LFO>

sin equ reg0

ldax sin
cho rdal, sin0
skp zrc sincrossing
wrax sin, 0

skp run, notcrossing

sincrossing:
etc, etc, etc.

notcrossing:
etc, etc, etc
-------------------------
Right now what it appears is happening is that the zrc is detected for fully half of the cycle.

I'll try it later tonight and post actual code example. There aren't a ton of skp zrc cases and I didn't find one yet that used the sin LFO as the source.

Thanks,

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



Joined: 12 Nov 2012
Posts: 274

PostPosted: Wed Feb 24, 2016 5:56 pm    Post subject: Reply with quote

Think I got it.

Code:
equ sinreg reg0
equ output reg1

skp run, initend
wlds sin0, 111, 32767
initend:

ldax sinreg
cho rdal, sin0
skp zrc, sincrossing
wrax sinreg, 0
skp zro, nocrossing

sincrossing:
wrax sinreg, 0
ldax adcl
wrax output, 1
wrax dacr, 1
wrax dacl, 0
skp run, finish

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

finish:
Back to top
View user's profile Send private message Visit poster's website
frank



Joined: 19 Oct 2005
Posts: 972

PostPosted: Wed Feb 24, 2016 6:50 pm    Post subject: Reply with quote

That looks good, could save an instruction doing:
Code:
equ sinreg reg0
equ output reg1

skp run, initend
wlds sin0, 111, 32767
initend:

ldax sinreg
cho rdal, sin0
skp zrc, sincrossing
wrax sinreg, 0
ldax output
wrax dacr, 1
wrax dacl, 0
skp zro, finish

sincrossing:
wrax sinreg, 0
ldax adcl
wrax output, 1
wrax dacr, 1
wrax dacl, 0

finish:

_________________
Frank Thomson
Experimental Noize
Back to top
View user's profile Send private message Visit poster's website
Digital Larry



Joined: 12 Nov 2012
Posts: 274

PostPosted: Thu Feb 25, 2016 6:18 am    Post subject: Reply with quote

Thanks Frank.

I could save a couple more with:

Code:
equ sinreg reg0
equ output reg1

skp run, initend
wlds sin0, 111, 32767
initend:

ldax sinreg
cho rdal, sin0
skp zrc, sincrossing
wrax sinreg, 0
ldax output
skp run, finish

sincrossing:
wrax sinreg, 0
ldax adcl
wrax output, 1
finish:
wrax dacr, 1
wrax dacl, 0

Back to top
View user's profile Send private message Visit poster's website
Digital Larry



Joined: 12 Nov 2012
Posts: 274

PostPosted: Fri Feb 26, 2016 7:34 am    Post subject: Reply with quote

Hi Frank,

Somewhat esoteric question about skp zrc, x:

Suppose the waveform we are tracking is oscillating +/- around 0. But on its way from + to -, it actually lands right on zero. Then in the next cycle it goes from 0 to - something. Will the zero crossing (over two cycles) be detected or missed?

Thanks,

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



Joined: 19 Oct 2005
Posts: 972

PostPosted: Fri Feb 26, 2016 8:18 am    Post subject: Reply with quote

Good question, been years since I looked at that part of the circuit. If I remember correctly I am looking at a sign change so it should only fire on 0-to-negative if you hit exactly 0.
_________________
Frank Thomson
Experimental Noize
Back to top
View user's profile Send private message Visit poster's website
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