Soulsby Synths Forum

Products => miniAtmegatron => Topic started by: shabbee on March 08, 2016, 11:19:47 PM

Title: multiplex signal to replace S6
Post by: shabbee on March 08, 2016, 11:19:47 PM
I'm trying to edit the code so that I can have 12 pots instead of the 6 with the little slide switch to change between functions. The hardware is no problem but as I'm just learning Arduino I'm struggling with the software.

I've tried to add the blink sketch lines to the miniatmegatron.ino so that D1 is sending out a clock pulse to control the multiplexing hardware. As you probably guessed this doesn't work as I get no signal when I scope D1. I'm convinced D1 is possibly defined elsewhere in the miniatmegatron code thus cancelling my setup and loop function, but I have no clue. I've also noted that the slower the clock frequency this interrupts the running of the miniatmegatron, my conclusion is that my approach is very lame and crude.

If I upload the blink example sketch alone, I can see the clock function working ok.

I need some pointers as my only option is to build a clock generator but I'm hopeful to the skilled programmer this would be an easy  piece of code to write. I'm also mindful that I may need some additional debounce for when then pots are read but one step at a time!

Thanks for reading and any help
Title: Re: multiplex signal to replace S6
Post by: paulsoulsby on March 09, 2016, 10:15:42 AM
So the 2 things you need are this: (
and (

D0 and D1 are routed to the USB port on the Uno.  This is then used to read/write MIDI data.  To use these pins, you'll need to remove all the UART (serial) code in MinHardware.cpp

It may be better to sacrifice a different D pin.  Poss the play button on SW1 (D2). 
The way the code is structured  is:

MinHardware.cpp - just deals with the interface, it has no knowledge of the audio engine
MinEngine.cpp - just deals with the audio engine, it has no knowledge of the interface
Min.cpp - stitches the engine and the interface together

I would edit Min.cpp:
goto Min::hardwareSwitchChanged(unsigned char switch_, unsigned char newValue)
use this to determine the state of the multiplexer
and change this code to alter:  engine_.getPatchPtr()->setFunctionValue(***whatever engine function you want to tweak here***);

hope this helps!


Title: Re: multiplex signal to replace S6
Post by: shabbee on March 15, 2016, 11:55:41 PM
Hi Paul,

Thanks for the reply, I may not have explained my plan clearly so want to add a bit more detail.

Assuming the filter Q and cutoff as an example, The wiper of each pot is connected to its own 4066 analog switch, I'm looking to control each 4066 switch from D2 (currently play switch) as suggested but with an inverted clock to one to enable switching between the 2 pot wipers.The outputs of both 4066 switches will be connected to the same A input of the UNO. I will use the same clock signal to replace the slide switch signal emulating either state of the switch. I'm hoping this approach will minimise the amount of code I need to change as I'm very new to that side.

I'm guessing/hoping I only need to make changes to MinHardware?

Does this correspond with your post above?

Title: Re: multiplex signal to replace S6
Post by: paulsoulsby on March 22, 2016, 12:31:16 AM
Ah yeah, I think you're right.  Because the spec of the synth isn't changing you should only have to edit the Hardware class.   
So the edit to the library will changing the D2 from an input to an output - change:
Code: [Select]
bitClear(DDRD,PIND2);  //play to
Code: [Select]
bitSet(DDRD,PIND2);  //play)then remove D2's interrupt: 
Code: [Select]
bitSet(PCMSK2,PCINT18);then remove all trace of switch_[0] throughout the library.
then add your own code to control D2 in
Code: [Select]
void MinHardware::pollAnlControls(unsigned char ticksPassed)
That should work!