PatchSM with 4051 mux not reading from ADC

Hey! I’m currently working on moving a project to the patch submodule. I’m currently unable to read floats from a mux attached to the ADC on my desired pin.

I can see all of the pot values on my oscilloscope on pin C9, as well as the select lines all firing correctly. However, I am reading ~0.5 on all mux pins. I will attach the code and terminal output below.

Am I missing something in the initialization of C9? Thanks in advance <3

#include "daisy_patch_sm.h"
#include "daisysp.h"

using namespace daisy;
using namespace patch_sm;
using namespace daisysp;

DaisyPatchSM hw;

void AudioCallback(AudioHandle::InputBuffer in, AudioHandle::OutputBuffer out, size_t size)
{
	for (size_t i = 0; i < size; i++)
	{
		OUT_L[i] = IN_L[i];
		OUT_R[i] = IN_R[i];
	}
}

int main(void)
{
	hw.Init();
	hw.StartLog();

	System::Delay(100);

	hw.adc.Stop();
	AdcChannelConfig adc[1];
	adc[0].InitMux(
		DaisyPatchSM::C9,
		8,
		DaisyPatchSM::D5,
		DaisyPatchSM::D4,
		DaisyPatchSM::D3
	);
	hw.adc.Init(adc, 1);
	hw.adc.Start();

	hw.SetAudioBlockSize(4); // number of samples handled per callback
	hw.SetAudioSampleRate(SaiHandle::Config::SampleRate::SAI_48KHZ);
	hw.StartAudio(AudioCallback);

	while (1)
	{
		System::Delay(200);

		for(int i = 0; i < 8; i++) {
			hw.Print("%f\t", hw.adc.GetMuxFloat(0, i));
		}

		hw.PrintLine("");
	}
}

I’ve also added the following to my makefile:

LDFLAGS += -u _printf_float

Hello Rafael!

Mux should work with the Patch SM. There are mentions of that and also a code like this that should work, which looks pretty close to yours.

I don’t think it’s the issue, but could you try using one of the ADC pins for the mux like in the code that was linked?

Thank you so much @Takumi_Ogata :slight_smile: This worked! Unfortunately I am trying to use a combination of a 4051 mux and the eurorack compatible CV inputs. Working on doing this manually right now, and will update when I have something clean and usable!

1 Like