Page 1 of 1
Idea - Audio ADC as a digital input
Posted: Mon Jul 16, 2018 11:06 am
by knutolai
So I have a pedal concept where a switch parameter (on/off parameter) for the FV-1 would be useful in addition to the 3 knob parameters. The hardware I have available includes an ATTINY microcontroller (basically a small arduino) that runs on the same supply voltage (3.3V) as the FV-1 chip. My idea is the following:
A toggle switch connects to the ATTINY. The ATTINY either outputs a static low signal or a ~100Hz square wave (alternating high/low voltage) dependent on the switch input. This connects to one of the FV-1 ADC (via a series capacitor?). An alternating current is necessary as the audio ADC input can't read 0Hz signals. This input is then run through a rough level detector:
Code: Select all
equ Rfilter reg0
rdax ADCR, 1 ; read input
absa ; get absolute value
sof 0.01, 0 ; perform portamento filter (could be consolidated with the 'rdax ADC...' instruction)
rdax Rfilter, 0.09 ; ...
wrax Rfilter, 0 ; store filtered output, clear
From here I could measure 'Rfilter' up against a threshold that would generate my digital input. I haven't been able to try this approach yet, but I feel quite confident it would work though there would be some latency due to the portamento filter (which may also need to be tuned). Can anyone think of a more efficient approach to turn one of the audio ADC inputs into a digital input?
Re: Idea - Audio ADC as a digital input
Posted: Mon Jul 16, 2018 6:21 pm
by Digital Larry
I think another one of the public projects used just this approach.
Re: Idea - Audio ADC as a digital input
Posted: Tue Jul 17, 2018 8:29 am
by Aaron
I have used a similar technique to use the ADC as a fourth pot. For a digital type of input you would only need to determine whether the signal is present or not. I think doing a skp statement could be more appropriate:
Code: Select all
ldax adcr ;read input
skp zro,STATE ;if switch is off, no signal is present, jump to STATE
;otherwise switch is on,
;do whatever is needed here
clr ;clear acc
skp zro,FIN ;skip to FIN
STATE:
;do whatever is needed
;for switch off state here
FIN:
Re: Idea - Audio ADC as a digital input
Posted: Tue Oct 16, 2018 3:54 am
by potul
Is this really working? I had the impression that the ADC is only valid for AC signals.....so a DC only would not be detected.. But I might be wrong.
Mat
Re: Idea - Audio ADC as a digital input
Posted: Wed Oct 17, 2018 4:10 am
by igorp
Square wave is bad idea. You will get interference on high volumes. So, make RC filter as closer to MCU as it possible.
Better to use internal Sin LFO (up to 20 Hz), or do your own sine LFO , somthing like that (was previously in forum and battling LFOs patch):
Code: Select all
skp run , start
SOF 0 , 0.5 ;setup LFO with amplitude of 0.5
wrax sinus2 , 0
start:
rdax cosinus2 , 1
mulx freq
rdax sinus2 , 1
wrax sinus2 , -1
mulx freq
rdax cosinus2 , 1
wrax cosinus2 , 1
wrax DACR , 0
; Freq=2 * Pi * 0x100 * F
; examle: 0x000100 * 6.28318530717959 * 440 = ~440,5Hz
Re: Idea - Audio ADC as a digital input
Posted: Thu Oct 18, 2018 12:32 am
by potul
potul wrote: ↑Tue Oct 16, 2018 3:54 am
Is this really working? I had the impression that the ADC is only valid for AC signals.....so a DC only would not be detected.. But I might be wrong.
Mat
My fault.... I didn't realize he was feeding the ADC with a square wave... I thought it was just a high or low state.
So, igorp, what you propose is to generate a sinwave (internally or externally) and feed this into the ADC, and then use an envelope or similar to "sense" this signal. Is this the idea?
Mat
Re: Idea - Audio ADC as a digital input
Posted: Thu Oct 18, 2018 1:43 am
by igorp
ADC could work with square waves, 20Hz and higher (you will get harmonics on input), I tested it.
Square waves is ticking and clicking in audio path, because adcr & adcl pins are close to each other and square waves are rich with higher order harmonics.
So you can generate sine internally via FV-1 hardware/software LFO , send it to button or xpression pedal and receive by ADCR(L).
Most FV-1 pedals with expression are working this way.