My arduino synth project only makes clicking sounds - code and diagram below

Thread Starter

COB300

Joined Feb 9, 2023
11
Hi, this is my first post on here.

I have been working on this synthesiser project for a year or two and am now seeking help as I can get no further by myself.

My teenage son who is a musician was given a Tech Will Save Us Stutter synth. He built it, it worked. It has two potentiometer inputs - one for frequency, one for a "stutter" effect, a 556 timer IC, and a loudspeaker output.

Original circuit, drawn by Glenn K Lockwood <a href=https://www.glennklockwood.com/electronics/twsu-synth-kit.html>here: </a>.

I was inspired to attempt to MIDI control it. How hard could that be? LOL. I wanted to use Mixpad software to send a single MIDI channel to an Arduino UNO, in lieu of the manual frequency input.

I initially tried to take control of Pin 7 of the 556 to try and control the PWM output, but this failed as the output was very granular - about 5 sounds were available that bore little relationship to the music.

I did some reading and decided to replace the manual potentiometer with a digital potentiometer. Digital potentiometers are available in much lower resistances than 470k, so I chose a 10k MCP41XXX resistor, adjusted the time constant to be as close to the original as possible, and built the circuit below:
1675942768391.png
and photo attached.

I am using loopmidi and Hairless Midi to connect the Mixpad to the Arduino. The Hairless MIDI displays the correct MIDI data, the Arduino flashes as it receives the data.
The problem I have is that when I press play the circuit does not make any sounds beyond clicking at the start and end of each note, but the 'stutter' part of the circuit with the other 470k pot still works.

I have put a crude monitor into the code to display ASCII codes in the Hairless MIDI bridge, this has worked before, but not this time. I get this error now: +38.224 - Warning: got a status byte when we were expecting 1 more data bytes, sending possibly incomplete MIDI message 0xaa

Here is the Arduino code:

C:
[CODE=c]#include <SPI.h>

//****C S O'Brien Arduino Controlled Tech Will Save Us Stutter Synth ************

//variables setup

byte incomingByte;

double note; // note read in from MIDI source
double freq; //desired note frequency
double Vctrl; // control voltage for pin 7 of 556 no longer used
double PulseWM;// pulse width modulation from 1 to 128 this is no longer used
double RW; // wiper resistance of digipot
double RA; // resistance of RA is 10,000K
int CS =10; // arduino pin for digipot control
int i=0; // value between 0 and 128 to control digipot wiper
  byte velocity; // to determine whether it is note off or some other velocity value from MIDI source

  int state=0;  // State machine variable 0 = MIDI command 1 = Note 2 = velocity e.g. note off velocity = 0



int channel = 1; // Only reading from channel 1 to make things easier

//Setup
void setup() {
  RA = 0;
  pinMode(2,OUTPUT);        // Pin 2 switches the voltage on and off
  pinMode(CS, OUTPUT);   // set output to CS from PIN 10
  //Check if the DAC is still needed to smooth the input to the CS pin. ???? This has been removed from the circuit now.

state = 0;  // state machine starts at 0
  //start serial with MIDI baudrate 115200
//  digitalWrite(2,HIGH);//****TEMP OFF***
  Serial.begin(115200);
  SPI.begin();
// digitalWrite(10, LOW);
// byte address = 0x00;
// SPI.transfer(0x00);
//SPI.transfer(0);
//digitalWrite(10, HIGH);
  //turn off the output ready to begin 
  digitalWrite(2,LOW);  //****TEMP OFF****

}


void loop () {
digitalWrite(10, LOW);
if (Serial.available() > 0) {
    // read the incoming byte:
   incomingByte = Serial.read();
//  digitalWrite(2,LOW);  // clear any previous note just in case it is still on //****TEMP OFF****
  
  
   switch (state){
  
      case 0:
    // look for MIDI channel 1, for relevant note on signal
   if (incomingByte== (144 | channel)){

  // next byte is the note
    state = 1;
//   Serial.print((int)incomingByte); //this would send an ASCII code corresponding to the MIDI note to the hairless MIDI bridge for debugging
   }   


   if (incomingByte== (128 | channel)){
    //Look for NOTE OFF No incoming byte of 128 in this particular midi file as it uses velocity = 0 instead 
    digitalWrite(2,LOW);

    state = 1;
  //  Serial.print((int)incomingByte); //this should send an ASCII code corresponding to the MIDI note off to the hairless MIDI bridge for debugging - e.g. this
//  is useful to see whether any NOTE OFFs are in the file
   }


  
      
      case 1:
       // get the note to play or stop
       if(incomingByte < 128) {
          note=incomingByte;
       // set the state to 2 if the note number is less than 128, e.g, it is an actual note to be played
       //then set state to 2 get the velocity, e.g. check whether the note is meant to be on or off
          state=2;
       }
       else{
       state = 0;  // state = 0 if the note number is on or above 128.
       }
       break;
     //After the break go back to void loop and read in another byte, with case set to 0 or 2
    
      case 2:
       // get the velocity
       if(incomingByte == 0){
  //If a NOTE OFF has been received velocity = 0 then switch the note off. Otherwise, regardless of the velocity, play the note
    digitalWrite(2,LOW);
  

     }
     else{
      digitalWrite(2,HIGH);
      
      freq = ((2^((int(note)-69)/12)*440));
      RW = 1.44/(100E-9*freq)-2*100;
      i = int((RW/10000)*128);
  //if (i>128) {
//   Serial.write(i);
//    Serial.write(" ");
//   state=0;
// }
//  else
//  {
SPI.transfer(0x00);
SPI.transfer(i);
//digitalWrite(2,HIGH);
digitalWrite(CS, HIGH);
Serial.write(i);
Serial.write(" ");
//  }
  //     digitalPotWrite(i); // Old function no longer called
     }
       state = 0;  // Back to start       
     }
  }

}





int digitalPotWrite(int value)
{


}
Thank you for your help in advance. I don't know much about electronics so I am worried I have gone down the wrong path and it is actually impossible to MIDI-fy the stutter synth. I can't think what else to do now. Let me know if you have any questions or need more detail. I kept the post brief.
 

Attachments

StefanZe

Joined Nov 6, 2019
191
In the picture you wrote a + and a - to Vdd and Vss, if this shows the supply voltage of the IC it is the wrong way around.
Vss is GND and VDD is max. 5.5V.
 

Thread Starter

COB300

Joined Feb 9, 2023
11
According to the datasheet the voltage range of the digital resistor is 0-Vdd and Vdd max is 5.5V. The 9V probalby killed the MCP41xx
Thanks - if you look at the photo I have connected the digipot to the 5V. I'll correct the diagram and repost.
 

Thread Starter

COB300

Joined Feb 9, 2023
11
I will take a close up photo of my actual connection to the IC - my diagram may be wrong. Thank you for your patience and courtesy,
 

Thread Starter

COB300

Joined Feb 9, 2023
11
OK - the red lead goes from the + rail to the top right pin of the IC, the - lead goes to the bottom right pin of the IC. The notch on the IC is on the left. Is this right?

Thank you for helping me eliminate the really obvious errors I may have made :)1675945713623.png
 

StefanZe

Joined Nov 6, 2019
191
Yes, so that would be the top of the photo.
Vdd (+5V) should be top right and Vss (ground) should be bottom left on the picture.
On the picture it looks like supply is connected to the bottom right.

Please check all connections according to the datasheet. the notch is shown in the pin diagram of the datasheet
 

Thread Starter

COB300

Joined Feb 9, 2023
11
Yes, you are right. Thank you so much. I will correct this and re-post when I have done this. You were so fast in figuring it out, I am very grateful. Poor IC! Best wishes.
 

Thread Starter

COB300

Joined Feb 9, 2023
11
This is the data sheet diagram. 1675947098772.png
I am using a new IC now in case old one is fried. So - notch at the top. Pin 8 - Positive 5V, top right. Pin 4, - ground, bottom left. 1675947457950.png
I will test this later today and post what happens. Thanks once again!
 

Thread Starter

COB300

Joined Feb 9, 2023
11
[Fixed CODE tags, from inline code to code block. Added @ to StefanZE to alert user —Moderator]

Hello @StefanZe , Thank you for all your help.

The problem I am trying to solve is to use an Arduino to control a Tech Will Save Us stutter synth to make it controllable by a computer rather than by twisting a potentiometer.

I feel I have made a some progress since we last chatted. I have updated and debugged my Arduino code and I feeling confident that integer values are being sent to the MCP41 from the Arduino. However the Synth is still only making clicking sounds (I think it is from the speaker switching on and off).

I checked the connections from the Arduino to the MCP41 carefully.

The main Synth circuit is powered by the Arduino from Pin 2 and is switched on and off by the program when notes play or stop.

The MCP is powered on all the time from the Arduino 5V output.

The code is below and I attach photos of the board, and updated circuit diagram.

What should my next steps be?

Thank you,

Caroline

1683452221080.png


Code:
#include <SPI.h>


byte incomingByte;
bool noteDown;

byte noteStatus;
byte note;
float freq;
float Duff;
float diff;
float Vctrl;
float PulseWM;
float RW;
float RA;
int count = 5;
int CS =10;
int i=0;
  byte velocity;


  int state=0;  // state machine variable 0 = command waiting : 1 = note waitin : 2 = velocity waiting
const int ssMCPin = 10;




void setup() {
  RA = 0;
  pinMode(2,OUTPUT);      
   pinMode (ssMCPin, OUTPUT);


state = 0;
  Serial.begin(115200);
  SPI.begin();

  digitalWrite(2,LOW);  //****TEMP OFF****

}


void loop () {
  digitalWrite(10,LOW);

if (Serial.available() > 0) {

   incomingByte = Serial.read();

  
   switch (state){
  
      case 0:
      noteStatus=incomingByte;

   if (noteStatus >=144 && noteStatus <= 159){

   noteDown = HIGH;

    state = 1;

   }   
 

   if (noteStatus >= 128 && noteStatus <= 143){

    digitalWrite(2,LOW); /****TEMP OFF***/
    noteDown = LOW;
 

    state = 1;
    }
   break;

      
      case 1:

       if(incomingByte < 128) {
          note=incomingByte;
  
           diff=float(note-69);
      
           Duff = pow(2, diff/12);
           freq = Duff*440;

      RW = ((1.44/freq)-(1E-6*100))/(2*1E-6);

      i = int((RW/10000)*128);
   

          state=2;
       }
       else{
       state = 0;
       }
       break;
   
      case 2:
   
       if(incomingByte == 0 || noteDown == 0){

    digitalWrite(2,LOW);//****TEMP OFF***

     }
     else{
     digitalWrite(2,HIGH);

  Serial.print(" i ");
Serial.print(i);
    SPI.transfer(0x00);
    SPI.transfer(i);
    digitalWrite(10,HIGH);
    Serial.print(" ");
    Serial.println (i);
  

  
 



  //     digitalPotWrite(i); // play it if it is one of our notes //TEST VALUE****/
     }
       state = 0;  // reset state machine to start          
     }
// }




}










}
 

Attachments

StefanZe

Joined Nov 6, 2019
191
Hi,
can you measure the 5V and the speaker with an osciloscope?
I have a feeling that the arduino pin cannot deliver enough current for your circuit (especially the speaker). This could reset your circuit every time it tries to turn on the speaker (resulting in a click noise).
Can you supply the circuit with 5V with another powersupply (connect the grounds)?
 
Top