Idea - Audio ADC as a digital input

Algorithm development and general DSP issues

Moderator: frank

Post Reply
knutolai
Posts: 65
Joined: Wed Nov 23, 2016 9:43 am
Location: Bergen, Norway

Idea - Audio ADC as a digital input

Post 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?
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Re: Idea - Audio ADC as a digital input

Post by Digital Larry »

I think another one of the public projects used just this approach.
Aaron
Posts: 54
Joined: Wed Mar 04, 2015 8:10 pm
Location: Oklahoma

Re: Idea - Audio ADC as a digital input

Post 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: 
potul
Posts: 76
Joined: Tue Sep 26, 2017 12:33 am

Re: Idea - Audio ADC as a digital input

Post 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
igorp
Posts: 65
Joined: Tue May 19, 2015 6:10 am
Location: RU

Re: Idea - Audio ADC as a digital input

Post 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
potul
Posts: 76
Joined: Tue Sep 26, 2017 12:33 am

Re: Idea - Audio ADC as a digital input

Post 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
igorp
Posts: 65
Joined: Tue May 19, 2015 6:10 am
Location: RU

Re: Idea - Audio ADC as a digital input

Post 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.
Post Reply