gj12-09 Square wave Generator
For Tone Translator
15 points

OEES 235

Back to Main Page

 


 




The purpose of this circuit is to take the number from the output counter, and then keep producing square waves with periods based on that number until a new number is available from the output counter. This is necessary because the input counter may not be able to catch every cycle coming from the microphone. Also, we will eventually have circuitry that takes the average of several output counter cycles, and then sends this average on to the square wave generator. Thus, the square wave generator will produce steady tones based on the waveforms from the microphone and the octave shifts requested by the musician.

The down-counter in the above circuit will eventually receive it's parallel input data (D0 through D3) from the output counter (which we haven't implemented yet). This binary number determines the period of the square wave to be produced by the tone translator. This square wave will be amplified and sent to a loudspeaker. Later, we may add-on circuitry to create additional waveforms to mimic different musical instrument sounds. (Luckily, the square wave itself produces a pleasing sound similar to that of a clarinet.)

Once the down-counter in the schematic above has been loaded with the number representing the desired period for the SWOUT square wave, the counter should count down until it reaches the number two. It seems like we should have the counter count down to zero instead of two, but because of various timing delays, we would then end up with a square wave that's two clock pulses too long. By having the counter stop at two, SWOUT will have the correct period.

Incidentally, the squarewave produced will have a period twice as long as desired. This is due to the fact that the positive half of the square wave will have a duration equal to the time required for the down-counter to reach two. The negative half of the square wave will have the same duration. Thus, the period of the square wave will be twice that of the time required for the counter to reach two--in other words, twice the desired period. Luckily, this will easily be corrected for once we design the octave control circuit. We'll simply have this circuit shift the frequency one octave higher than it would otherwise be.

Legend
  • QSW0 through QSW3 = Square-wave counter outputs.
  • LDSWCNT = Load square-wave counter.
  • SWOUT = Square-wave out.
Test Vector
Right-click here to get the test vector file. When you save the file, be sure the file type is set to all files.

Directions and Hints
  1. As always, create a new Windows folder for this project.
  2. Use Lever's default device.
  3. The schematic above contains all the macros (components) you'll need, except for some additional circuitry to provide inputs to the flip-flops.
  4. The D flip-flop's output (LDSWCNT) should go high when the counter contains the number two (and there is a rising edge on the clock input).
    • LDSWCNT stands for load square-wave counter. When it goes high, data from the output counter is loaded with whatever data is present on the D0 through D3 inputs.
      • At present, we are simply hardwiring a 6 (binary 0110) into the D0 through D3 inputs. Eventually, D0 through D3 will be connected to a latch that gets it's number from the output counter.
    • There is a reason LDSWCNT appears to go high when the counter reaches one (as can be seen in the waveforms above): When the counter contains the number two, the next clock-pulse rising edge will both set the D flip-flop and cause the counter to count down. Thus, the D flip-flop will be high during the time the counter contains a one.
  5. The JK flip-flop should toggle once each time the counter counts down to two.
Back to Main Page
1