Close
0%
0%

SquareTone

A hardware project that generates square waves frequencies and sums them together, Fourier style.

Similar projects worth following
Additive Synthesis using Square Waves

You can make a square wave out of a bunch of sine waves. Can you make a sine wave out of a bunch of square waves?

SquareTone is a device that generates the first eight harmonics of a given frequency of range ~[0.1, 500] Hz and then preforms a weighted summation of them. The end result is a bunch of funky "square-like" waves. (Simulated waveforms can be seen to the left.)

I wanted to make a project that would preform additive synthesis. Eight harmonics seemed about right for some interesting looking outputs. This is usually done with sine waves but those are comparatively difficult to generate if you want all the harmonics in phase. Square waves, however, are very easy to generate. If you generate 1680 Hz (for 1 Hz output) and frequency dividing it down to your desired harmonics, they should a

For a project overview, please see the Overall Specifications project log.

In the comments, Bruce Land pointed out that this project may be similar to Walsh synthesis. I will have to look into that more. http://en.wikipedia.org/wiki/Walsh_function

CD4017B Divider.pdf

Counter/Divider Used to divide frequency by integers other than 2.

application/pdf - 1.00 MB - 12/28/2015 at 23:16

Preview
Download

CD1206_S01575 Diode.pdf

Switching Chip Diode

application/pdf - 157.13 kB - 12/28/2015 at 23:16

Preview
Download

SN74HC109 JK FF.pdf

Dual J-K Positive Edge Triggered Flip-Flop with Clear and Preset Used to divide frequency by 2.

application/pdf - 825.79 kB - 12/28/2015 at 23:15

Preview
Download

  • Overall Specifications

    Adam Gulyas01/04/2016 at 04:38 0 comments

    This is somewhat a living document. It may change if a certain requirement is discovered to be difficult to implement and fails a cost benefit analysis. The next step is to use it to generate a block diagram of the proposed system.

    Basic Purpose

    Preform additive synthesis with square waves.

    Sum square waves of arbitrary magnitude and output the result as audio, a control voltage, and a visualization of the resulting waveform. The square waves frequencies are multiples of a fundamental frequency. If the fundamental frequency is 100 Hz, the other available frequencies will be [200, 300, …, 800] Hz.

    The output fundamental frequency range will be decided during the design phase. As a minimum it should cover [0.1, 100] Hz for use as a LFO. Ideally it should go up to 10 kHz, in order to cover the useful audio range.

    Read more »

  • Project Management

    Adam Gulyas01/03/2016 at 07:05 0 comments

    Edit: The Engineering Art Show is no longer happening, so this project has been pushed back in priority.

    If I'm going to finish this project in a month, I will need some way to plan out the entire thing. Enter Gantt charts. I've never made one before, but a quick google search told me that GanttProject is an open source program I can use to make them.

    I've tried to make this one as general as possible so I can use it on other projects.

    I'm not experienced enough to know how long some of the design steps will take so I'm using it more like a flow chart that tells me what to focus on. As an example, I would sometimes become distracted by sourcing parts. With this plan, I know I can leave it alone entirely.

    Also, after making this it seems like there's no way I'll be done in a month. I think I will still push for that goal, but set a new hard deadline of two months. The UofA Engineering Art Show is at the beginning of March, and this would make a great entry.

  • System Block Diagram

    Adam Gulyas06/12/2015 at 11:36 0 comments

    Here's the overall block diagram. It was developed from the overall specifications. Explanations of each block are below:

    Read more »

  • PCB Design

    Adam Gulyas06/07/2015 at 08:13 0 comments

    Note: this log was created in 2015 and may not be valid anymore. Starting January 2016 I'm going through the design process systematically and may add or change details.

    The general approach will be to put the initial frequency generator, divider network, and summing op-amp on three different boards and then stack them. I want to be able to swap out the initial frequency generator if I find a design that can produce a higher frequency, and the summer is easy enough to assemble on perf board. The divider network, however, has a lot of connections and would be a mess if I used perfboard. I can also use this chance to learn how to use Eagle.

    The best board house I've found so far is OSH Park, which will give you a double layer board at $5 per square inch. In order to minimize size, I'm going with surface mount components. (Imagine how much space 14 x DIP-16 packages would take up.)

    Divider Network

    This is the first PCB I've designed in Eagle, and the first double sided board. It took a while because I also had to learn how to use Eagle's part creator utility, which isn't exactly self explanatory. (Google was able to offer up a lot of useful guides.)

    Since it's my first board, I would love any feedback. Are my traces too thin? Too close together? Should I not put vias under SOIC packages? Did I not account for digital signal noise enough?

    Read more »

  • Waveform Display

    Adam Gulyas06/03/2015 at 12:34 0 comments

    It seems to me that half the fun of this project is seeing the changes you're making to the waveform. With that in mind, I'm going to include a tiny oscilloscope:

    It's the XMEGA Xprotolab. It will be mounted on the top of the enclosure, unless I'm able to mount it behind the lid and have the buttons still accessible. (Maybe I should find someone in industrial design to do the enclosure. They could probably design those plastic nubs that are set in the enclosure surface, which are used to press tactile switches...)

    Unfortunatly, it costs about $50. I'll have to wait to design the enclosure until I have a bit more money and can order one of them.

  • Frequency Division Scheme

    Adam Gulyas05/26/2015 at 09:59 0 comments

    Note: this log was created in 2015 and may not be valid anymore. Starting January 2016 I'm going through the design process systematically and may add or change details.

    I'm calling this part of the project the division network. It's the part that takes the initial high frequency square wave and pulls out all the harmonics (which are then sent to the summing op-amp).

    First, I found circuits which I could blackbox and just think of as (with regards to frequency) "divide by n".

    In general, you can make a "divide by n" circuit by using the input pulse as a clock, and then pulsing the output every n pulses. The IC I found which does this is the CD4017B, a CMOS Counter/Divider (TI Datasheet). I picked the SOIC 16 package.

    Here's the "divide by 2" circuit:

    Now that I have blackbox dividing circuits, here's the block diagram for the divider network:

    To find this configuration I tried every possible way of dividing 840 by its factors to get the desired harmonics, 840 being the LCM. I chose the way that used the least number of divisions, letting me chain multiple outputs together.

    Something that kind of sucked was that originally the 8 Hz signal was coming out of the divide by 7 block. I had to double the input frequency oy to 1680 Hz and add an extra divide by 2 block. This will end up halving the maximum output frequency of the project.

    The dashed boxes indicate which divide by 2 blocks share an IC.

    Also note that, although the outputs are labeled numerically, the input frequency will be variable. I labeled the circuit nodes that way to make sure my math was right.

    This is a bit nitpicky, but I noticed something after I had designed the pcb for this project. If I want to decrease the presence of high frequency signals on the board, I should rearrange the divide by n blocks to divide by the larger numbers first. In the case of U1 - U3, instead of having 560 Hz, 112 Hz, 16Hz, I could instead get 240 Hz, 48 Hz, 16 Hz. However, I don't think it will be that big of a deal and doesn't justify changing all my documentation and design. If I had proof it would be a problem I would put in the effort, but at this point it's just a small maybe.

    That concludes the theory of the divider network. Check the PCB Design project log for the implementation.

  • Initial Frequency Generation

    Adam Gulyas05/26/2015 at 09:56 0 comments

    Note: this log was created in 2015 and may not be valid anymore. Starting January 2016 I'm going through the design process systematically and may add or change details.

    The chosen design involves generating an initial square wave and then frequency dividing it. This section talks about how to generate that initial waveform.

    The easiest way I can think of to generate a square wave is with a 555 timer. Other methods would include an opamp relaxation oscillator or a comparator/integrator circuit.

    Because of all the dividing necessary, the initial frequency is quite high. if I want a 1 kHz output signal, the initial frequency would have to be 1.26 MHz. That's getting pretty high, and I'm not sure if that's within the 555's frequency range.

    The circuit used is shown below (image from wikipedia). Note that C is really C1.

    Read more »

  • Matlab code to show end result

    Adam Gulyas03/03/2015 at 08:56 0 comments

    Below is code you can run in matlab to see what this project will output when it's done. Change the values of a - f to generate different waveforms. (In general, keep the values between 0 and 1.)

    t = 0:0.001:4*pi;
    y1 = sign(sin(t));
    y2 = sign(sin(2*t));
    y3 = sign(sin(3*t));
    y4 = sign(sin(4*t));
    y5 = sign(sin(5*t));
    y6 = sign(sin(6*t));
    y7 = sign(sin(7*t));
    y8 = sign(sin(8*t));
    
    a = 1;
    b = 0.2;
    c = 0;
    d = 0;
    e = 0.5;
    f = 0;
    g = 0;
    h = 0;
    
    sum = a*y1 + b*y2 + c*y3 + d*y4 + e*y5 + f*y6 + g*y7 + h*y8;
    
    plot(t,sum)
    axis([0,15,-3,3])

View all 8 project logs

Enjoy this project?

Share

Discussions

Vikas V wrote 04/30/2015 at 04:46 point

Hey, I had this exact same idea 6 months ago! Anyway, its very cool. Its very compelling because of the idea that you can use square waves to synthesize sine waves, and generating square waves is pretty easy. Even I came across walsh functions when researching the idea. I tried doing an implementation in octave but did not work.

  Are you sure? yes | no

Bruce Land wrote 03/04/2015 at 12:38 point

It is a complete basis, but the concept of frequency is hazy.  Look toward the end of this page 

http://people.ece.cornell.edu/land/courses/ece4760/Math/avrDSP.htm

  Are you sure? yes | no

Bruce Land wrote 03/03/2015 at 13:28 point

This looks more like Walsh synthesis

  Are you sure? yes | no

Adam Gulyas wrote 03/03/2015 at 16:18 point

Hey, thanks for the reference! I hadn't heard of that before. From the looks of it, the waveform set Walsh synthesis uses is a bit different. I don't think it includes the odd harmonics?

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates