Circuit board that displays the digits of e

Circuit board display first 16 digits of e

This is the final project for our CP 120 Digital Electronics lab. We are to build a circuit board display first 16 digits of e. It takes in a number (the nth digit) and output that digit of e.

In general, we create the logic equation, reduce it with Karnaugh map, program it with a complex programmable logic device (CPLD), and wire it all up to light up a 7-segment display.

Let’s start:

How does one simplify the work of creating outputs to a 7-segment display?
Traditionally, you’d have to use k-maps, and repeat the process for each lighting diode. This means a lot of errors could result.

So how does one automate the process of creating equations?

Let’s start of by defining:

  1. Inputs
  2. Outputs


Let’s assume you want to display the first 16 digits of pi – basically one would specify which place you digit you want to call.
Example, the 0th digit would be 3, 1st would be 1, 2nd would be 4, etc.

Assuming one uses a binary digit representation of those numbers, 0 -> 0000, 1 -> 0001, 2-> 0010, etc.
You would map when each diode turns on/off according to the inputs, let’s call them Q3, Q2, Q1, Q0.

Since the diode has a, b, c, d, e, f, g as outputs, you’d figure out the equation for each of these.
You can do so with karnaugh maps, but this is a tedious task.

Basically, here is the program that will automate the generation of the equations.


# Python 3.1

# Let’s define our output, the first 16 digit of pi
PI = [ 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3 ]

# Then we need to create a dictionary, of what each number maps to define the inputs one would get for a 7-segment display.
def segment_7d_dictionary():
di = {}

# We define the nth digit’s relation to the outputs of a to g.
# So digit 0 would have all the diodes on except for diode g
# di[n] = [a, b, c, d, e, f, g]

di[0] = [1, 1, 1, 1, 1, 1, 0]
di[1] = [0, 1, 1, 0, 0, 0, 0]
di[2] = [1, 1, 0, 1, 1, 0, 1]
di[3] = [1, 1, 1, 1, 0, 0, 1]
di[4] = [0, 1, 1, 0, 0, 1, 1]
di[5] = [1, 0, 1, 1, 0, 1, 1]
di[6] = [1, 0, 1, 1, 1, 1, 1]
di[7] = [1, 1, 1, 0, 0, 0, 0]
di[8] = [1, 1, 1, 1, 1, 1, 1]
di[9] = [1, 1, 1, 1, 0, 1, 1]

return di

def cr_7d_display_eqn ( dictionary, constant, node ):
segmenent_representation = []
for digit in constant:
segmenent_representation.append( dictionary[digit][node] )

print( segmenent_representation )
m_lines = []
for i in range( 0, len( segmenent_representation ) ):
if segmenent_representation[i] == 1:
m_lines.append( i )

equation = qm.qm( ones = m_lines )
return equation

Now that we have our functions defined and out of the way, here is the main program:


import qm
# To reduce equations http://robertdick.org/python/qm.html

for node in range ( 0, 7 ):
cr_7d_display_eqn ( segment_7d_dictionary(), E, node )

 

So there we have it.
If you run this, you get:


[1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1]
['XX0X', 'XXX1']
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0]
['XX0X', '0XXX', 'XXX0']
[0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]
['XXX1', '11XX', 'XX1X']
[1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1]
['XX00', 'XX11', 'X10X', '1X0X']
[1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0]
['0X00', '0X11', '100X', 'X101']
[0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1]
['X1X1', '1X1X', '1XX1', '11XX', 'XX11']
[1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1]
['010X', 'XX11', 'XX00', '10XX', '1XX0']

 

This returns what place of digit it turns on (1), and the corresponding equation.
X = don’t care
0 = negated (let’s define NQ0 as negation of Q0, etc.)
1 = itself
For the last one
([‘010X’, ‘XX11’, ‘XX00′, ’10XX’, ‘1XX0’])
the sum of product equation would be:
g = NQ3 BQ2 NQ1 + Q1 Q0 + NQ1 NQ0 + Q3 NQ2 + Q3 NQ0
Now we have simplified the equation with the k-map program, we have to wire it up.

After hooking everything up, it looks something like this (note, the PLD is not present):
RC

2 thoughts on “Circuit board that displays the digits of e”

  1. This is great, reducing a lot of lower level work, head scratching.
    I think Microcontroller does not recognize advanced languages, such as Python, so in order to do this, we have to compile Python language into binary codes before down load it, this is great in lab, but code size matters, if wrote in C or C++ would be more compact.

  2. Wow, marvelous blog layout! How long have you ever been running a blog for? you make running a blog look easy. The whole look of your website is great, well the content material!

Leave a Reply

Your email address will not be published. Required fields are marked *