Undefined Component Kind: CD4051AnalogControl

Hi all,

I’ve been trying to connect a CD4051 Multiplexer to the Daisy Pod for use with oopsy & gen, as per the tutorial & comments in this thread: Cd4051 Multiplexer Tutorial Is Here!

I updated the seed.pod.json file to include the CD4051 (as shown below) but after selecting it in oopsy & attempting to compile the patch I get the error:

node.script: undefined component kind: CD4051AnalogControl

{
	"name":"pod",
	"defines": {
		"OOPSY_TARGET_HAS_MIDI_INPUT": 1
	},
	"parents": {
		"pot_mux": {
		"component": "CD4051",
		"mux_count": 8,
		"pin": {
			"adc": 16,
			"sel0": 7,
			"sel1": 8,
			"sel2": 9
			}
		}
	},
	"components": {
		"sw1": {
			"component": "Switch",
			"pin": 27
		},
		"sw2": {
			"component": "Switch",
			"pin": 28
		},
		"knob1": {
			"component": "AnalogControl",
			"pin": 21
		},
		"knob2": {
			"component": "AnalogControl",
			"pin": 15
		},	
		"knob3": {
			"component": "CD4051AnalogControl",
			"index": 0,
            "parent": "pot_mux"
		},
		"encoder": {
			"component": "Encoder",
			"pin": {"a":26, "b":25, "click":13 }
		},
		"led1": {
			"component": "RgbLed",
			"pin": {"r":20, "g":19, "b":18 }
		},
		"led2": {
			"component": "RgbLed",
			"pin": {"r":17, "g":24, "b":23 }
		},
        "led3": {
			"component": "Led",
			"pin": 16
		}
	},
	"aliases": {
		"switch": "sw1",
		"button": "sw1",
		"switch1": "sw1",
		"button1": "sw1",
		"switch2": "sw2",
		"button2": "sw2",
		"enp": "encoder_press",
		"switch3": "encoder_press",
		"press": "encoder_press",
		"knob": "knob1",
		"ctrl": "knob1",
		"ctrl1": "knob1",
		"ctrl2": "knob2",
		"led": "led1"
	}
}

Any help would be much appreciated!

Hello Michael!

Could you add the line "som": "seed", after "name":"pod",?

Hi Takumi, Thanks for the quick reply.

I’ve added that line:

{
	"name":"pod",
	"som": "seed",
	"defines": {
		"OOPSY_TARGET_HAS_MIDI_INPUT": 1
	},
	"parents": {
		"pot_mux": {
		"component": "CD4051",
		"mux_count": 8,
		"pin": {
			"adc": 16,
			"sel0": 7,
			"sel1": 8,
			"sel2": 9
			}
		}
	},
	"components": {
		"sw1": {
			"component": "Switch",
			"pin": 27
		},
		"sw2": {
			"component": "Switch",
			"pin": 28
		},
		"knob1": {
			"component": "AnalogControl",
			"pin": 21
		},
		"knob2": {
			"component": "AnalogControl",
			"pin": 15
		},	
		"knob3": {
			"component": "CD4051AnalogControl",
			"index": 0,
            "parent": "pot_mux"
		},
		"encoder": {
			"component": "Encoder",
			"pin": {"a":26, "b":25, "click":13 }
		},
		"led1": {
			"component": "RgbLed",
			"pin": {"r":20, "g":19, "b":18 }
		},
		"led2": {
			"component": "RgbLed",
			"pin": {"r":17, "g":24, "b":23 }
		},
        "led3": {
			"component": "Led",
			"pin": 16
		}
	},
	"aliases": {
		"switch": "sw1",
		"button": "sw1",
		"switch1": "sw1",
		"button1": "sw1",
		"switch2": "sw2",
		"button2": "sw2",
		"enp": "encoder_press",
		"switch3": "encoder_press",
		"press": "encoder_press",
		"knob": "knob1",
		"ctrl": "knob1",
		"ctrl1": "knob1",
		"ctrl2": "knob2",
		"led": "led1"
	}
}

But the error persists. Here’s the console output I get in full:

gen~: exported: C:/Users/pauld/OneDrive/Desktop/Michael/Songs/patches/muxtest.cpp
oopsy-verbose: script start "C:\Users\pauld\OneDrive\Documents\Max 8\Packages\oopsy\source\seed.pod.json" 48kHz block48 C:\Users\pauld\OneDrive\Desktop\Michael\Songs\patches/muxtest.cpp boost
oopsy-verbose: stop success dictionary u760000500
oopsy-verbose: start success dictionary u591000501
oopsy-verbose: loadstart success dictionary u180000502
oopsy-verbose: "Target seed_pod configured in path C:\Users\pauld\OneDrive\Documents\Max 8\Packages\oopsy\source\seed.pod.json"
node.script: undefined component kind: CD4051AnalogControl
oopsy-verbose: loadend success dictionary u125000503

That json file is compiling fine for me so that’s odd.
Could you select Field as the board and see if you can compile a patch with that option? You don’t need to have your Daisy connected to the computer to check this.

Hi Takumi - I am helping Michael with his project. The error that he is seeing is coming from the oopsy.js file in the source folder C:\Users\Paul\OneDrive\Documents\Max 8\Packages\oopsy\source. There is a definition in there of ‘component_defs’ that is a list of all the possible hardware, this list does not include the CD4051AnalogControl as an option and the code that checks this definition is where the error is being generated from: (see below). Does this mean there is an updated version of this file that does include the mux control ??

	  .map((pair) => {
		let [name, def] = pair;
		def.name = name;
		console.log( "Search for component " + def.name + "," + def.component );
		let component = component_defs[def.component];
		if (component) {
		  // copy component defaults into the def
		  // TODO this should be recursive for object structures...
		  for (let k of Object.keys(component)) {
			if (def[k] == undefined) def[k] = component[k];
		  }
		} else {
		  throw new Error("undefined component kind: " + def.component);
		}
		return def;

bump

this is currently a roadblock to using the pod/gen~ for a university project - any assistance would be greatly appreciated. has anyone used a CD4051 mux with gen ???

Compiling with that json file is working for me on this version of Oopsy, so I recommend giving that a try next :slight_smile:

Let me know how that goes!

Hi Takumi,

Using the oopsy branch you suggested has allowed the patch to compile successfully! I’ve been able to make a simple patch that maps a knob to a sine wave frequency. This works fine using a knob directly going into an ADC input, but one running through the multiplexer produces a signal that while affected by the knob is incredibly noisy.

Any ideas on how to get a usable signal through a multiplexed input?

Here’s a scope of the sine wave as controlled by a direct knob vs a multiplexed one. Thank you!
image
image

I recommend revisiting the multiplexer tutorial and make sure things are connected the same way.
And using DaisyDuino/Arduino IDE may be better for troubleshooting since you can see the values in real-time. You can just copy and paste that code in the tutorial so the possibility of the software being the issue should be minimal.

The same problem has not been solved. Currently I can only use arduino and plugdata, but plugdata will be problems with more than 2 knobs link with mux 4051.

I haven’t tried using mux with plugdata yet, so I would have to give that a try.
I have gotten mux to work with the Daisy using pd2dsy.

Does mux work for you when you use Oopsy?

sorry no Unfortunately, including updates version of oopsy to unreleased versions (can be compilied successfully, but nothing happens. Bdw Takumi,please check my another topic about mpr121 how to work with oopsy:)thank you!

The E-S Field uses 8 pots on the CD4051 and this works great.

yeah,I am going to check the pins about 4051 in the field and try again. Can the field be used successfully under gen?

Ok - Our ongoing quest to get a 4051 working with gen~ continues. The current state is that I have a breadboard with a 4051 setup to a single pot that works perfectly with a C++ program but does not work with what I think is the identical setup using oopsy.

As far as I can see I have got everything correct. I know the wiring is correct as the C++ example works correctly reading the pot thru the mux. I know that the gen~ environment is working as I can download and run the default patch and it works ok when I use knob1 (note that on the breadboard I do have a pot connected as knob1 as if this was a pod). But when I try to use knob3 defined as a the mux knob in the pod.json file I just get a noisy tone and no knob affect at all.

I can’t think of anything else to try. It feels like under oopsy that the mux is not being initialised and I am getting noise on the pin. We are using the bootloader_additions version of oopsy and I updated it just today. Any help or suggestions would be hugely appreciated.

Here is an image of the breadboard setup.

and this the c++ code that works perfectly.

#include "daisysp.h"
#include "daisy_seed.h"

using namespace daisysp;
using namespace daisy;

static DaisySeed  hw;
static Oscillator osc;
int v1;

static void AudioCallback(AudioHandle::InterleavingInputBuffer  in,
                          AudioHandle::InterleavingOutputBuffer out,
                          size_t                                size)
{
    float sig;
    for(size_t i = 0; i < size; i += 2)
    {
        // osc.SetFreq(hw.adc.GetMux(0,0));
        osc.SetFreq( mtof(hw.adc.GetMuxFloat(0,0) * 127));
        sig = osc.Process();

        // left out
        out[i] = sig;

        // right out
        out[i + 1] = sig;
    }
}

int main(void)
{
    // initialize seed hardware and oscillator daisysp module
    float sample_rate;
    hw.Configure();
    hw.Init();
    hw.SetAudioBlockSize(4);
    sample_rate = hw.AudioSampleRate();

    /** Configure the ADC
     * 
     *  One channel configured for 8 inputs via CD4051 mux. 
     * 
     */
    AdcChannelConfig adc_cfg;

    adc_cfg.InitMux(seed::A1, 8, seed::D7, seed::D8, seed::D9); 

    /** Initialize the ADC with our configuration */
    hw.adc.Init(&adc_cfg, 1);  

    osc.Init(sample_rate);

    // Set parameters for oscillator
    osc.SetWaveform(osc.WAVE_SIN);
    osc.SetFreq(440);
    osc.SetAmp(0.5);

    /** Start the ADC conversions in the background */
    hw.adc.Start();

      /** Startup the USB Serial port */
    hw.StartLog(true);
    hw.PrintLine( "We are connected");

    // start callback
    hw.StartAudio(AudioCallback);

    while(1) {
        float f = hw.adc.GetMuxFloat(0,0);
        hw.PrintLine( "Input Mux 1: " FLT_FMT(3), FLT_VAR(3,f));
        System::Delay(100);
    }
}

This is the pod.json file modified to have the 4051 mux and knob3 defined

{
	"name": "pod",
	"som": "seed",
	"defines": {
		"OOPSY_TARGET_POD": 1,
		"OOPSY_TARGET_HAS_MIDI_INPUT": 1,
		"OOPSY_HAS_ENCODER": 1
	},
	"max_apps": 8,
	"display": {},
	"audio": {
		"channels": 2
	},

	"parents": {
		"pot_mux": {
		  "component": "CD4051",
		  "mux_count": 8, 
		  "pin": {
			"adc": 16,  
			"sel0": 7, 
			"sel1": 8, 
			"sel2": 9  
		  }
		}
	},	
	"components": {
		"sw1": {
			"component": "Switch",
			"pin": 27
		},
		"sw2": {
			"component": "Switch",
			"pin": 28
		},
		"knob1": {
			"component": "AnalogControl",
			"pin": 21
		},
		"knob2": {
			"component": "AnalogControl",
			"pin": 15
		},
		"knob3": {
			"component": "CD4051AnalogControl",
			"index": 0, 
			"parent": "pot_mux"
		},			
		"encoder": {
			"component": "Encoder",
			"pin": {
				"a": 26,
				"b": 25,
				"click": 13
			}
		},
		"led1": {
			"component": "RgbLed",
			"pin": {
				"r": 20,
				"g": 19,
				"b": 18
			}
		},
		"led2": {
			"component": "RgbLed",
			"pin": {
				"r": 17,
				"g": 24,
				"b": 23
			}
		}
	},
	"aliases": {
		"switch": "sw1",
		"button": "sw1",
		"switch1": "sw1",
		"button1": "sw1",
		"switch2": "sw2",
		"button2": "sw2",
		"encswitch": "encoder_rise",
		"enp": "encoder_press",
		"press": "encoder_press",
		"knob": "knob1",
		"ctrl": "knob1",
		"ctrl1": "knob1",
		"ctrl2": "knob2",
		"led": "led1"
	}
}

and finally the gen~ patch

Screenshot 2024-09-08 170141

Thank you for the follow up.

Could you try connecting the mux to the Seed like how it’s done with the Field?

This is from the json file for the Field to see which pins are used.

“pot_mux”: {
“component”: “CD4051”,
“mux_count”: 8,
“pin”: {
“adc”: 16,
“sel0”: 21,
“sel1”: 20,
“sel2”: 19
}

Then, you can flash oopsy_field.maxpat (you’ll need to adjust a little bit so that the knob’s output is mapped to an oscillator rather than the LED) after selecting Field as the board.
This is so that we have as little as variables as possible for troubleshooting.

Hi Takumi

It works !!!

At the moment I am not 100% sure what the difference is/was between what we were testing and what is now working. We changed the following

a) Used pins 21,20 and 19 as per the standard field.json setup
b) removed the clashing LED definition

This sort of worked, in that the changing the pot changed the tone BUT it was still full of noise and was not a clean sine wave. We then removed everything else from the max patch except the in/out passthru, the knob and the cycle generation. This then worked perfectly, so I am guessing that something else in the patch was messing with one of the pins.

Once this worked I was able to get multiple Mux setups running using a variety of different select pins after checking that no other gates etc were using these pins and removing the gate/cv definitions as needed, including the ones that we were originally using with the pod.json file.

So my current best guess is that we missed something in the pod.json file that was interfering and we also did not try the pod with a minimal max gen~ patch.

When I get time I will work thru this again and try to work out what was stopping it working with the default patch. I was also write up a little summary showing the final modified field.json, the c++ test code and the breadboard setup that works in case this is useful to others.

I am awaiting delivery of a PCA9685 breakout board from ADAFruit and will then launch into testing that.

thanks for the assistance, it is greatly appreciated.

Paul

1 Like

Hey Paul!
I’m super glad to hear that it’s working now!! Thank you for letting me know.

And I would greatly appreciate the write-up! It’ll be great for the community :slight_smile:

bump!

a write-up on how this is going would be great. Currently also in the works getting the mux to work with gen.

Curious to hear what you ended up doing.