LED triggering with Sin0

Algorithm development and general DSP issues

Moderator: frank

Post Reply
frotaitalos
Posts: 16
Joined: Wed Feb 07, 2018 9:06 am
Location: Brazil

LED triggering with Sin0

Post by frotaitalos »

Hi Guys, I'm working on a Delay with taptempo with pitch shifter, for this I needed to put the led indicator to be triggered by sin0, however I get a lot of noise in the audio output due to sin0, I already tested this system with other delay that does not has pitch shifter and the noise does not exist, could anyone help me solve this?

The time tap code came from the topic "tap tempo snippet"

Code: Select all


equ  db reg0      ;debounce 
equ  mom reg1      ;saída momentânea do interruptor +1 high, -1 low 
equ  latch reg2      ;saída bloqueada do comutador +1 high, -1 low 
equ ramp reg3      ;valor atual de rmpo, escalado para 0 a 1 
equ taptempo reg4   ;valor taptempo, 0 a 1 
equ fback reg5      ;feedback 
equ delayout reg6      ;delay output 
equ clip reg7      ;clipping 
equ led reg8      ;taptempo LED 
equ  time_pot reg9
equ   mod_depth reg10
equ   tri_original reg11
equ   tri_amp reg12
equ	filter	reg13
equ	filter1	reg14
equ        pitchout  reg15
equ tri_gain 0.017 ; max triangle amplitude

equ count 0.01      ;debounce counter 
equ delaytime 100     ;tempo de atraso inicial em milissegundos

mem delay 25000
mem pitch 4096
mem temp 1

skp run,START 
wldr rmp0,0.064,4096   ;set up rmp0 
wlds 0,24,30000  ;
wldr 1,4096,4096 ; modulation LFO
sof 0,0.99       
wrax latch,1      ;set latch = 1 high 
wrax led,0      ;set led = 1 high 
sof 0,delaytime/1000   ;definir o tempo de atraso inicial
;ldax pot1
;sof 1, 0.1
wrax ramp,0 


START: 


ldax pot2
and 	%01100000_00000000_00000000 
skp zro, P1
sof 1,-0.25
skp zro, P2
sof 1,-0.25
skp zro, P3

sof 0,0.1299605249
wrax rmp1_rate,0
skp zro, DODELAY

P1:
sof 0,0.2491535384
wrax rmp1_rate,0
skp zro, DODELAY

P2:
sof 0,0.4438743127
wrax rmp1_rate,0
skp zro, DODELAY

P3:
sof 0,0.5
wrax rmp1_rate,0,

DODELAY:

;Troque o Debounce e o filtro de pote ao redor

ldax   adcr   ;leia pot2 
sof 1,-0.5   ;mudança de nível para -0,5 a 0,5
skp neg,DOWN   ;se negativo pular para baixo
ldax db      ;Se não Alto, leia db
sof 1,count   ;add count 
wrax db,0   ;escrever novo valor para db
skp zro,ENDDB   ;pule para o ENDDB
DOWN: 
ldax db      ;leia db 
sof 1,-count   ;deduzir contagem
wrax db,0   ;escrever novo valor para db

ENDDB: 

;interruptor de travamento, borda de queda acionada flip-flop
;A saída da rotina de debounce de <-0,9 é baixa,> 0,9 é alta, valores entre
;são ignorados e o switch não faz nada, Schmitt aciona a ação.


ldax db         ;leia db 
absa         ;obter valor absoluto 
sof 1,-0.9      ;deduzir 0.9, portanto, apenas valores <-0.9 ou> 0.9 dão um resultado positivo
skp neg,ENDSWITCH   ;se negativo, pule para ENDSWITCH
ldax db         ;read db 
sof 1,-0.9      ;deduzir 0,9 
skp neg,LO      ;se o salto negativo para LO, a saída do debounce é baixa
sof 0,0.999      ;Se não, outra saída de debounce é alta
wrax mom,0      ;definir mom para 1 (alta)
skp zro,ENDSWITCH   ;ir para ENDSWITCH
LO: 
ldax mom      ;read mom 
skp neg,ENDSWITCH   ;se for negativo, então debounce já foi baixo da última vez, então não faça nada, pule para ENDSWITCH
sof 0,-0.999      ;Se não, mom foi alta da última vez, então switch acaba de ser pressionado (borda de queda)
wrax mom,0      ;definir mom para -1 (baixa) 
ldax latch      ;read latch 
sof -1,0         ;invertido, alto torna-se baixo, baixo torna-se alto
wrax latch,0      ;escrever para o valor latch

ENDSWITCH: 

;toque tempo, usa rmp0 como uma rampa de subida de 1 Hz, funciona enquanto a trava está baixa e é amostrada e mantida quando a trava está alta

ldax latch      ;read latch 
skp neg,LOW      ;se negativo pular para LOW
jam rmp0      ;Se não, trava é alta, jam rmp0 (redefinir para 0) 
ldax ramp      ;leia rampa, conterá o último valor de rmp0 antes que a trava fique alta  
wrax taptempo,0      ;escreva para taptempo
skp zro,ENDTT      ;ir para ENDTT
LOW: 
sof 0,0.064       
wrax rmp0_rate,0      ;defina a taxa rmp0 para 1Hz
cho rdal,rmp0      ;leia o valor de rmp0
sof -2,0.999 
sof 1,0.001      ;mudança de nível para 0 a 1 rampa crescente
wrax ramp,1      ;escrever para a rampa
sof 1,-0.999      ;deduzir 0,999 da rampa   
skp neg,ENDTT      ;Se a resposta for positiva, o segundo toque não aconteceu com 0,999 ms do primeiro          
ldax taptempo      ;então mantenha o último valor de taptempo
wrax ramp,0       
sof 0,0.999      ;e redefinir trava alta
wrax latch,0 
ENDTT: 

;Taptempo rate indicator, creates a square wave at the tap tempo rate 
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 rat;
cho rdal,sin0
sof 1, 0.25
rdax taptempo,-0.2   ;deduct half of the taptempo value 
skp neg,ENDLED 
ldax led         ;and invert value of led register, creates square wave at taptempo rate ;
sof -1,0  
wrax led,0


ENDLED: 

rdax adcl, -0.5
rdax fback,0.95
wra pitch,0
cho rda,rmp1,reg|compc,pitch
cho rda,rmp1,,pitch+1
wra temp,0
cho rda,rmp1,rptr2|compc,pitch+1
cho rda,rmp1,rptr2,pitch+1
cho sof,rmp1,na|compc,0
cho rda,rmp1,na,temp
rdfx filter,0.5		;lowpass filter
wrlx filter,-1
rdfx filter1,0.5		;lowpass filter
wrlx filter1,-1
wra delay,0
;
ldax taptempo
sof 0.48,0
wrax addr_ptr,0
;
rmpa 1
wrax delayout,1
mulx pot0
wrax fback, 1
;
ldax delayout
wrax dacl,0
ldax led         ;read led register 
wrax dacr,0      ;write to DACR, flashes LED attached to DACR 
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Re: LED triggering with Sin0

Post by Digital Larry »

At this point, when you skip ahead, your ACC is non zero.

skp neg,ENDLED

In general I have found that usually the code just after any skip target label (e.g. ENDLED) wants to start by clearing ACC unless you are 100% sure it is zero in all paths that lead to that label.

This is based on a 30 second scan of your code and for all I know that's not the real problem or there could be others.
frotaitalos
Posts: 16
Joined: Wed Feb 07, 2018 9:06 am
Location: Brazil

Re: LED triggering with Sin0

Post by frotaitalos »

Digital Larry wrote: Sat Oct 06, 2018 9:21 am At this point, when you skip ahead, your ACC is non zero.

skp neg,ENDLED

In general I have found that usually the code just after any skip target label (e.g. ENDLED) wants to start by clearing ACC unless you are 100% sure it is zero in all paths that lead to that label.

This is based on a 30 second scan of your code and for all I know that's not the real problem or there could be others.
Thanks buddy, I really had not observed the ACC, zeroing solved the problem :)
Post Reply