ESE 190 Final Project Initial Write Up

Mason Elms and Neil Shweky

For our final project, we aim to create a simple synthesizer that is capable of connecting to a Bluetooth speaker to play its audio output. The synth will use 8 pushbuttons to play the major notes in an octave, using a digitally generated square wave as the audio signal. The synth will include an analog high pass and low pass filter, activated by 2 additional buttons. The HPF will use a light sensor as the resistor component to allow for variable frequency. The LPF will use an RLC circuit with a cutoff frequency of 700hz. The square wave frequency (or pulse width, we need to do a little more research here) will be varied with accelerometer input using a simple implementation. Positive values correspond to a higher frequency, negative values correspond to lower frequency. The accelerometer unit will not be attached to the same breadboard as the main synth body.

Parts required:

  • 10x pushbuttons
  • 1x light sensor
  • 1x accelerometer
  • 2x capacitors (1x 82pF, 1x 2200uF)
  • 1x 220uF inductor
  • 1x Bluetooth module
  • Resistors (Not sure exactly how many or what values but these are very available around engineering)

ESE 190 Final Project final Write-up

Introduction

The overall goal of this project was to develop a simple synthesizer with Bluetooth connectivity. Synthesizers are an essential part of music production in the modern era, especially in the relatively young electronic genre, and analog synthesizers are famed for their unique sounds and modularity. Wireless connectivity is rarely utilized in modern synthesizers, for a number of reasons- response time, data fidelity, etc- but the opportunity to experiment with Arduino’s capacity to use wireless connection seemed like an interesting avenue to explore.

After some design iterations (discussed below), the authors settled on a simple square wave synthesizer that made use of the Tone Master Library from Arduino to play the eight major notes of the piano, from C5 to B5. The analog signal was sent from the Arduino to an analog amplifier circuit. The synthesizer also includes a passive High Pass and active Low Pass filter. These filters receive a signal from separate pins and output to the same analog amplifier as the unfiltered signal. The device is controlled using the Blynk app, with one button for each note and toggle buttons for the high and low pass filters.

With traditional analog synthesizers, control voltages are used to modulate a variety of sound parameters. The difficulty of implementing a CV mechanism for the simple project at hand dissuaded us from an attempt, but we still wanted to be able to modify the sound in some way. Thus, a photoresistor was placed in the low pass filter to allow the user to modulate the cutoff frequency. The details of this mechanism are discussed below.

Design Iteration and Construction:

Initially, the project aimed to use physical pushbuttons to play the eight major notes of the piano and connect the Arduino to a Bluetooth speaker to play the generated sound. After examining the details of Bluetooth speaker connectivity, and the difficulty of implementing this idea via the Blynk app, the project shifted directions to use Blynk as a control mechanism and play the sound out of a piezoelectric buzzer. The first iteration of the circuit was constructed using an Arduino UNO WiFi board, for proof of concept and troubleshooting. This board has a built-in tone library, and Blynk connectivity was not explored for this portion of the design process.

The circuit used 2 LM356 Op-Amps to form an active high pass, active low pass, and amplifier circuit. The high pass filter had unity voltage gain with two 3.3KOhm resistors and a 68nF capacitor, making the cutoff frequency 709.2 Hz. The low pass filter had a voltage gain range of 23 to 200, with the photoresistor varying from 2.3kOhm to ~20 kOhm, and a 68nF capacitor making the cutoff frequency range 1017 Hz to 117 Hz. The amplifier circuit was inverting at this point in the process, with a voltage gain of 10 using a 12kOhm and 1.2kOhm resistor. The layout is pictured in the image gallery.

When transitioning to using the MKR1000 board, problems ensued. This board, having only one timer, does not include the tone library. In an effort to circumvent this and retain the capacity to generate frequencies other than the PWM standard of 490kHz, the code was modified to analogWrite(pin) from a duty cycle of 0 to 100%, with a delay between each write that was equal to half the period in milliseconds of the requisite piano note frequency. This should have generated a saw wave of the expected frequency based on the principles of PWM, but the implementation proved to be difficult when attempting to send the signal in repetition. The saw wave signal would send once, but after the for loop iterating through duty cycles completed, the output would remain at a duty cycle of 100% and no differentiation was apparent between the notes. As such, this idea was scrapped and a tone library was found online that could use even a single timer board like the MKR1000 to send tones of a specified frequency from a pin.

Problems also began to arise with the circuit. The high pass filter ceased to send output signal, for reasons that are not obvious to the authors of this report. Even after adjusting the resistor and capacitor values to give a cutoff frequency well below the lowest note frequency, no sound would pass through. Thus, a passive high pass filter was implemented using the same 3.3K kOhm resistor and a 68nF capacitor. This circuit output directly to the amplifier as before, and was able to filter the signal above 709.2 Hz. The low pass filter continued to function as intended in the active configuration, and frequency and voltage gain modulation were achievable with the photoresistor. Interestingly, covering the photoresistor, which should correspond to a lower cutoff frequency, seemed to increase the cutoff frequency when tested. The voltage gain across the filter, and the resultant decibel gain was also very low despite an expected gain of 23 to 200. This is likely due to the inverting configuration used. The amplifier was changed to a non-inverting amplifier to avoid the possibility of negative or non-unity voltage gain. The final circuit diagram is shown in the image gallery.

Hardware Implementation:

This section will discuss the mechanisms and configurations used to implement the high pass filter, low pass filter, and amplifier. Justification for the design choices is provided above. Given the rudimentary circuit knowledge of the authors, these explanations will be simple, general, and possibly incorrect.

The non-inverting amplifier functions by creating a feedback loop from the voltage output back to the input. Specifically, the input signal goes into the positive terminal of the Op-amp, and the negative terminal goes through a resistor to ground. A feedback resistor runs from the output terminal back to the negative terminal. Gain is described by A(v)=1 + Rf/R1, where Rf is the resistance of the feedback resistor in Ohms and R1 is the resistance of the ground resistor. As is clear from this equation, the voltage gain will always be above unity.

The active low pass filter functions similarly, creating a feedback loop to amplify the filtered signal, but across the negative terminal of the Op-amp instead. This filter uses a capacitor and a resistor in series, and since capacitance varies inversely with frequency, the voltage drop across the capacitor is much less than across the resistor at high frequencies. This allows the filter to roll-off high frequencies above fc=1/2RC. For the purposes of this lab, all filters were assumed to have ideal cutoff behavior and roll off was not considered. By covering and uncovering a photoresistor in place of the feedback resistor, the cutoff frequency can be varied. As discussed above, the filter seemed to operate in reverse of expectations- higher resistance from the covered photoresistor corresponded to an audible increase in frequency, and vice-versa.

The passive high pass filter makes use of the same idea as the low pass filter, the variance of capacitance with frequency. The disadvantage of using a passive filter as compared to an active filter is the risk of low voltage gain, but this did not prove to be an issue for this project. By placing a capacitor in line with the signal and branching a resistor to ground from the output, the filter allows high frequencies through while stopping lower ones.

As shown in Figure 2, both filters received a signal from separate pins and fed into the amplifier, allowing the user to choose whether to high pass filter, low pass filter, or not filter the audio.

Code Implementation:

The implementation of code for this project, once the master Tone library was installed, was relatively simple. The full code is available in the attached files. The Blynk setup code from the previous lab was used to instantiate Blynk and allow for wireless connectivity. A variable, synthPin, was declared as an int to allow the specification of the signal sending pin. The initial value of 3 corresponds to the unfiltered pin output, and pins 2 and 0 correspond to the low and high pass filters, respectively. As stated above, initial attempts to implement PWM to create a saw wave were unsuccessful. This method relied on using the frequency to calculate the period, and consequently the required delay between pulses. The artifacts of this implementation remain in the code. Frequency is of type double here, in order to allow the aforementioned calculations. Two state variables, LPF and HPF, are instantiated to allow the code to keep track of whether a filter is active.

In 'setup()', the serial monitor is begun for debugging purposes, and Blynk is run with the credentials instantiated previously. The bulk of the code makes use of the BLYNK_WRITE() function, which allows the Arduino to read values from the buttons on Blynk. The buttons were mapped to virtual pins 0 through 8, with 0 through 6 for the notes and 7 & 8 for the filter toggle buttons. BLYNK_WRITE() takes the specified pin number as an input and fetches the value associated with it from the server. Using param.asint(), the value can be read as an integer, as the default value is of type string. The overall implementation is identical for each note button, with changes only to the frequency corresponding to the note.

The code reads the input as an integer value using 'param.asint()' to a variable, NOTE_true. The variable freq, the frequency, is set to the frequency of the note. A series of if statements are used to determine if the signal should be filtered, using the HPF and LPF variables instantiated above. Depending on the combined values of LPFand HPF, the code selects either pin 0, pin 2, or pin 3 for synthPin. A simple if-statement is used to determine whether the button is pressed based on the value of NOTE_true. If NOTE_true == HIGH, the code plays a square wave tone using tone(synthPin, freq). If NOTE_true == LOW, the code sends a noTone(synthPin) message and stops the note. The other pieces of code are artifacts from the attempted implementation of the PWM saw wave. The note buttons are push buttons rather than switch buttons, so no handling of state was necessary.

For the filter toggle buttons, BLYNK_WRITE() and param.asint() were once again used to extract the value of the button. HPF and LPF were respectively assigned to these output values, depending on the button in question. The code then checks to see if the other variable is HIGH, and uses Blynk.virtualWrite() to update the value of the other button. It also changes the other variable to LOW.

Future Developments:

This project has significant room for further development. Debugging of the low pass filter, or possibly simply changing it to a non-inverting filter, might help with the very low voltage gain expressed after the filter is toggled off and on. This low gain means that sometimes the low pass signal is difficult to hear in a loud room when the photoresistor is uncovered. Additionally, decreasing the form factor of the circuit and moving it to a circuit-board to solder and secure the connections would benefit the integrity of the hardware components. Delving deeper into PWM and implementing different waveforms, like sine and saw, would also be beneficial, as well as the inclusion of a wired speaker rather than a buzzer to improve audio quality. With more circuits knowledge, perhaps other changes can be made to increase the fidelity of the project and reduce bugs. The use of multi-pole filters might also be useful, to improve the roll-off behavior of the current implementation.

As far as creating a product, the authors of this report are unsure if a market really exists for synthesizer products that are controllable from a mobile device. Several wireless products exist in the general realm of electronic music but mostly focus on the wireless connection of a controller to a DAW or sound library. As far as the authors are aware, no device currently exists that operates similarly to this project. As such, it is difficult to say for certain what the market potential of a product based on this project would be. Our guess, however, is that with tweaks to make the synthesizer itself more functional, and a custom user interface, a product developed from this project could very well succeed.

Built With

Share this project:

Updates