Quick aside regarding the video below…admittedly, my second video attempt using KDEnlive (which I really like) was kind of so-so . My video editing quality is definitely bush league, but like I said, it was my second attempt. Watch it if you like. Both the content here in this post and the video is pretty much the same.
This is a quick tutorial for a Quartus Prime block schematic that uses a 7490 decade counter to “count” from 0 to 9, and then uses a 7447 BCD to seven segment decoder to display the number on the EPM240’s on-board seven segment display. Typically, the circuit uses a clock signal coming into the decade counter that drives the “counting” of the circuit which is what I originally did, but this method deprived me of my secondary goal which was playing around with debouncing noisy pushbutton switches. So for this example, I am using an external pushbutton switch to act as my clock signal.
I tested the circuit with and without debouncing the switch, and it definitely needed to be debounced. I used a simple RC network and Schmitt Trigger on the input pin connected to the pushbutton. The Schmitt Trigger is conveniently part of the EPM240T100C5 I/O pin standard, and while the MAX II pins do allow for setting inputs with the 3.3V Schmitt Trigger, I’m unsure about which other boards do and do not. It’s probably a lot easier to do this in Verilog which I’ll add or post about later.
Setup the Project
Setup a new Quartus Prime project and add a new Block Schematic to the workspace. I like to detach the block schematic window (right click the window tab, select detach) to have more room. Then use the “Symbol Tool” to add the following symbols:
- input pin for pushbutton
- VCC and GND
- 7490 and 7447
- output pin for transistor driver LED1
- seven output pins for the 7 segment LED (1 for each segment)
- NOT symbol
Often, you can type the name of the symbol in the “Name” field of the Symbols dialog, and it will auto find the correct symbol. Place the symbols and wire up the schematic like below:
Assign the Pins
Save the project and then click the “Start Compilation” icon to compile. Once compiled, click the “Pin Planner” to designate the board pins to use for the inputs and outputs. I used PIN_68 for the pushbutton input, but choose whatever pin you want. Just remember to connect that pin to the pushbutton circuit once it’s built. The other pin designations are:
Note that in the image, next to the pushbutton input pin (PIN_68), I have already selected the “3.3V Schmitt Trigger Input” in the “I/O Standards” section. For now, do not select the Schmitt Trigger input. Instead, leave the selection as the “3.3 V LVTTL”. Come back and change it later after you see how much you need to debounce to the pushbutton. You should have a total of nine pins to assign:
- 1 input pin for the pushbutton
- 7 output pins for the 7 segment LED
- 1 input pin for the PNP transistor to turn on bank 1 of the 7 segment display (LED1)
Be sure to close the “Pin Planner” when you are done to make sure it saves your assignments. Save, compile, and use the “Programmer” icon to program the MAX II.
Build the Pushbutton and Debounce Circuit
On a separate breadboard, setup the pushbutton switch circuit along with the RC portion of the debounce circuit – meaning everything is setup except for the Schmitt Trigger. I used a pair of 10K resistors and a 1uF capacitor. You can try other nearby values. Read more about the math behind the RC debouncer here. Here is the circuit:
Be sure to connect the output from the circuit to the input you assigned earlier in the pin planner. Use jumpers from available ground and 3.3V from Max II board pins to power your breadboard circuit. If you have everything wired up correctly, pressing the pushbutton should change the seven segment LED display on the board. Depending on how noisy your button is, you’ll probably notice some unstable and jittery changes in the 7 segment LED. Mine was so bad, it was nearly impossible to use with any accuracy.
Now that you have a point of reference how the circuit works without the Schmitt Trigger, you can go back to the “Pin Planner” and change the I/O Standard for the pushbutton input pin to use the “3.3V Schmitt Trigger Input”. Be sure to close the “Pin Planner” after making the change. Save, compile, and program again. Try the button again. It should provide clean, jitter free clicks and should drive the 7 segment display with no glitches.