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 

Pulse and Ramp Switch Control

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



Joined: 03 Jul 2011
Posts: 14
Location: Italia

PostPosted: Fri Jul 08, 2016 3:26 pm    Post subject: Pulse and Ramp Switch Control Reply with quote

Hello,
I've a board with a Switch connected on POT2 that I used wiht Tap Tempo and Infinite Reverb Code.
Now I would like to grnerate from Switch pressed different signals. One is a simple Pulse to triger the infinite Reverb only when Switch engaged. So when I I press the switch I Have one pulse, when I release do nothing.
I don't want use the ramps because I use that for Pog fx and I would be able to decide the pulse width.

The second idea is to generate a ramp to control the whammy code instead of pedal(http://www.spinsemi.com/forum/viewtopic.php?t=296)

The code for control Infinite Reverb I tried works but don't do exactly what I think:

equ db reg0 ;debounce
equ count 0.001 ;debounce counter

skp RUN,start
sof 0,0
wrax db,0

start:

ldax   pot2    ;read pot2
sof 1,-0.5 ; -0.5 button pressed, +0.5 no button
skp gez,reset ;if pot2 high reset db counter
sof 0,0
wrax db,0
sof 0,0.5
reset:
skp gez,ENDDB    ;if maggiore uguale zero jump to ENDDB
ldax db      ;else high, read db
sof 1,count   ;sum count
wrax db,1   ;write new value to db
sof -1,0.5
skp neg,DOWN   ;if magg. = zero jump to DOWN

sof 0,0 ;clear Acc
sof 0,-0.5
skpneg,ENDDB

DOWN:
sof 0,0
or 0.99 ;set high
sof 1, -0.5

ENDDB:
sof -2,0
WRAX DACR,0

For the hardware I have a led attached to DACR output, it flashes one time when I pressed the switch and one time when Ireleased it. It seems to me that the count do nothing.

Hope someone can help me!
Back to top
View user's profile Send private message
deepMago!



Joined: 03 Jul 2011
Posts: 14
Location: Italia

PostPosted: Fri Jul 08, 2016 3:34 pm    Post subject: Reply with quote

And here more funny the working code.
On Dacr we have a sin LFO controled by POT1 that I used for analog tremolo via LDR.
On Dacl we have the POG note by note, when we pressed the switch we have a freeze effect, when released we come back to pog note by note.
Also Ihave an external lfo adcr that control the filter sweep setted by POT0.

I called it FOLLOWPOG
;tremolo lfo + pog
;pot2 = infinite reverb
;pot1 = tremolo time
;pot0= 4 pole low pass filter
;freeze out dacl
;lfo out dacr

equ krt reg0
equ kin reg1
equ db reg2
equ ctl2 reg3
equ lpal reg4
equ lpbl reg5
equ stop reg6
equ pbyp reg7
equ pol reg8
equ kfl reg9
equ temp reg10
equ lbyp reg11
equ taptempo reg12
equ lfo reg13
equ mega reg14
equ lbyp1 reg15
equ kfl1 reg16
equ count 0.01

mem ap1 502
mem ap2 821
mem dap1a 2204
mem dap1b 2701
mem del1 4456
mem dap2a 2532
mem dap2b 2201
mem del2 6325

equ kap 0.6
equ kql -0.2



;mix variables

equ engage reg17
equ engage1 reg18
equ octave reg19
equ rev reg20

;pog variables

equ oct1 reg21
equ oct2 reg22
mem delayd 4096
mem ctemp 1

skp run,START
wlds sin0,0,32767 ;set up sine lfo
wldr RMP0,16384,4096 ;set ramp oct up and down
wldr RMP1,-8192,4096

START:

;tremolo out to dacr

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
cho rdal,sin0
wrax dacr,0


;rate lfo POT1

ldax pot1      ;else read pot1
OR $007FFF00
MULX POT1
RDFX mega,0.00125
WRAX mega,1
SOF 0.9859924316,0.0000305176
sof 0.8,0.2 ; 20mS to 1s
wrax taptempo,0 ;write new tempo value


;prepare pots to affect control variables:
;pot2 = 0 switch pressed, reverb on direct oct off
;pot2 = 1 reverb off direct on

rdax pot2,1.3 ;get pot2
wrax engage,1
sof 1,-1
absa
wrax engage1,1

sof 1,-0.5 ; -0.5 button pressed, +0.5 no button
skp gez,reset ;if pot2 high reset db counter
sof 0,0
wrax db,0
sof 0,0.5
reset:
skp gez,ENDDB    ;if maggiore uguale zero jump to ENDDB
ldax db      ;else high, read db
sof 1,count   ;sum count
wrax db,1   ;write new value to db
sof -1,0.5
skp neg,DOWN   ;if magg. = zero jump to DOWN

sof 0,0 ;clear Acc
sof 0,-0.5
skpneg,ENDDB

DOWN:
sof 0,0
or 0.99 ;set high
sof 1, -0.5

ENDDB:
sof 1,0.5
wrax ctl2,-1
sof 1,0.999 ;now +1 to 0
sof 1.999,0 ;now +1 until midpint, then decreases to 0
wrax kin,0 ;write the input attenuator value

rdax ctl2,1 ;get pot1 again
wrax krt,1 ;save in krt, keep in ACC
sof 1,-0.5 ;subtract 1/2
skp gez,2 ;skp if pot is in upper half of range
sof 0,0.5 ;load accumulator with +0.5
wrax krt,0 ;overwrite if pot is in lower half of range

;prepare pot0 for low pass frequency control:

rdax pot0,1 ;get pot0
sof 0.35,-0.35 ;ranges -0.3 to 0
exp 1,0
wrax kfl,0 ;write to LP filter control

;now derive filter bypass function (at open condition)

rdax pot0,1 ;read pot0 (LP) again
mulx pot0
mulx pot0
mulx pot0
mulx pot0
wrax lbyp,0


;LFO from ADCR

rdax adcr,1 ;read LFO input and scale
;rdfx lfo, 0.0038
;wrax lfo, 0 ;write lfo register
;rdax lfo,1
rdax kfl,1
wrax kfl,0


;now do reverb, simple, twin loop, mono drive:

rdax adcl,0.7 ;get inputs, leave headroom
mulx kin ;scale by input attenuator
rda ap1#,kap ;4 all passes:
wrap ap1,-kap
rda ap2#,kap
wrap ap2,-kap
wrax temp,0 ;write ap output to temp reg

rda del2#,1
mulx krt
rdax temp,1
rda dap1a#,kap
wrap dap1a,-kap
rda dap1b#,kap
wrap dap1b,-kap
wra del1,0
rda del1#,1
mulx krt
rdax temp,1
rda dap2a#,kap
wrap dap2a,-kap
rda dap2b#,kap
wrap dap2b,-kap
wra del2,0

rda del1,1.9
mulx engage1
wrax rev,0

;now oct up and down

;first mix signals

rdax adcl,1
mulx engage
rdax rev,1

wra delayd,0

cho rda,RMP0,REG|COMPC,delayd
cho rda,RMP0,,delayd+1
wra ctemp,0
cho rda,RMP0,RPTR2|COMPC,delayd
cho rda,RMP0,RPTR2,delayd+1
cho sof,RMP0,NA|COMPC,0
cho rda,RMP0,NA,ctemp
wrax oct1,0

cho rda,RMP1,REG|COMPC,delayd
cho rda,RMP1,,delayd+1
wra ctemp,0
cho rda,RMP1,RPTR2|COMPC,delayd
cho rda,RMP1,RPTR2,delayd+1
cho sof,RMP1,NA|COMPC,0
cho rda,RMP1,NA,ctemp
wrax oct2,0

rdax rev,0.33
rdax oct1,0.33
rdax oct2,0.33

;now filter

wrax pol, 0
rdax lpal, 1
mulx kfl
rdax lpbl, 1
wrax lpbl,-1
rdax lpal,kql
rdax pol, 1
mulx kfl
rdax lpal,1
wrax lpal,0

rdax lpbl,-1
rdax pol, 1
mulx lbyp
rdax lpbl, 1

wrax dacl,0
Back to top
View user's profile Send private message
MacroMachines



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

PostPosted: Sat Jul 09, 2016 12:54 am    Post subject: Reply with quote

I'm not sure if I fully understand what you are asking, or if this is relevant:

the pot inputs have some heavy hysteresis that will slew anything coming in. WRAX DACL what you have coming into the pot and clip a probe to it and scope it, it's been very enlightening and helpful to do this.

Also the audio adc channels have high pass dc offset filtering so the audio adcs can't be used for control signals.
_________________
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
deepMago!



Joined: 03 Jul 2011
Posts: 14
Location: Italia

PostPosted: Sat Jul 09, 2016 5:23 am    Post subject: Reply with quote

Hi,
thank you for the reply.
In ADCR i put an LFO generated by an Arduino and It do what I aspected, move the filter frequency and works well. maybe a little tweaking but it's satisficatory.
My doubt it's regarding the part of code in the first post. It works in the followpog but it seems to me that don't to exactly what I wanna do.
I want that part of code generate a pulse every time I pressed a switch connected to pot2 and nothing else.
My purpose is to trigger the "freeze" part of code when engage the switch. With the equ ENGAGE and ENGAGE1 when button is pressed I have the freeze effect, when release I have the pog effect.
The Fx is fully working in the way I mean but I would understnd (and now I can't figure it) why the code in the first post work but don't do what i want.

It's a little difficult to explain what I mean in english, hope it's clear now.
Back to top
View user's profile Send private message
deepMago!



Joined: 03 Jul 2011
Posts: 14
Location: Italia

PostPosted: Sat Jul 09, 2016 5:44 am    Post subject: Reply with quote

Referred to the first post the output and input signals that I want:
[img]https://www.dropbox.com/s/zvymx6znsvgdyza/signals.jpg?dl=0[/img]
Back to top
View user's profile Send private message
deepMago!



Joined: 03 Jul 2011
Posts: 14
Location: Italia

PostPosted: Sat Jul 09, 2016 5:51 am    Post subject: Reply with quote



Last edited by deepMago! on Sat Jul 09, 2016 7:23 am; edited 1 time in total
Back to top
View user's profile Send private message
deepMago!



Joined: 03 Jul 2011
Posts: 14
Location: Italia

PostPosted: Sat Jul 09, 2016 5:58 am    Post subject: Reply with quote

https://www.dropbox.com/s/zvymx6znsvgdyza/signals.jpg?dl=0
Back to top
View user's profile Send private message
slacker



Joined: 01 Feb 2011
Posts: 115

PostPosted: Sun Jul 10, 2016 11:21 am    Post subject: Reply with quote

The code in your first post probably isn't doing what you want it to.

If the pot is 0.5 or more, then the first SKP instruction skips to "reset" which then skips to "ENDDB". If the pot is less than 0.5 then it runs this part of the code
Code:

sof 0,0
wrax db,0
sof 0,0.5


The sof 0,0.5 is setting the accumulator to 0.5 so when it gets to "reset" the SKP makes it skip to "ENDDB" so it never gets to this part of the code.
Code:

ldax db      ;else high, read db
sof 1,count   ;sum count
wrax db,1   ;write new value to db
sof -1,0.5
skp neg,DOWN   ;if magg. = zero jump to DOWN


If you change the first SKP instruction to neg instead of gez then it will get to that part of the code when the pot is less than 0.5. I don't know if that will make it do what you want though.
Back to top
View user's profile Send private message
deepMago!



Joined: 03 Jul 2011
Posts: 14
Location: Italia

PostPosted: Thu Jul 14, 2016 2:46 pm    Post subject: Reply with quote

Thanks for the reply Slacker!
I post a reply the day you wrote by my phone but today I realize somethings went wrong.
Anyway, I think your code seems to do what I wanna do but when I tried the led stay always on. It's possible I haven't wrote the eeprom right so I have to give it another try.
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