Usage of IC 74152¶
from __future__ import print_function
from BinPy import *
# Usage of IC 74152:
ic = IC_74152()
print(ic.__doc__)
This is 14-pin 8:1 multiplexer with inverted input.
Pin Number Description
1 D4
2 D3
3 D2
4 D1
5 D0
6 Output W
7 Ground
8 select line C
9 select line B
10 select line A
11 D7
12 D6
13 D5
14 Positive Supply
Selectlines = CBA and Inputlines = D0 D1 D2 D3 D4 D5 D6 D7
# The Pin configuration is:
inp = {1: 1, 2: 0, 3: 1, 4: 0, 5: 1, 8: 0, 9: 0, 10: 1, 11: 1, 12: 0, 13: 0}
# Pin initinalization
# Powering up the IC - using -- ic.setIC({14: 1, 7: 0})
ic.setIC({14: 1, 7: 0})
# Setting the inputs of the ic
ic.setIC(inp)
# Draw the IC with the current configuration\n
ic.drawIC()
┌─────────◡─────────┐
│ │
[1] ──┤ 1 14 ├── [1]
│ │
│ │
[0] ──┤ 2 7 13 ├── [0]
│ │
│ │
[1] ──┤ 3 4 12 ├── [0]
│ │
│ │
[0] ──┤ 4 1 11 ├── [1]
│ │
│ │
[1] ──┤ 5 5 10 ├── [1]
│ │
│ │
[Z] ──┤ 6 2 9 ├── [0]
│ │
│ │
[0] ──┤ 7 8 ├── [0]
│ │
└───────────────────┘
# Run the IC with the current configuration using -- print ic.run() --
# Note that the ic.run() returns a dict of pin configuration similar to
print (ic.run())
{6: 1}
# Seting the outputs to the current IC configuration using -- ic.setIC(ic.run()) --\n
ic.setIC(ic.run())
# Draw the final configuration
ic.drawIC()
┌─────────◡─────────┐
│ │
[1] ──┤ 1 14 ├── [1]
│ │
│ │
[0] ──┤ 2 7 13 ├── [0]
│ │
│ │
[1] ──┤ 3 4 12 ├── [0]
│ │
│ │
[0] ──┤ 4 1 11 ├── [1]
│ │
│ │
[1] ──┤ 5 5 10 ├── [1]
│ │
│ │
[1] ──┤ 6 2 9 ├── [0]
│ │
│ │
[0] ──┤ 7 8 ├── [0]
│ │
└───────────────────┘
# Seting the outputs to the current IC configuration using -- ic.setIC(ic.run()) --
ic.setIC(ic.run())
# Draw the final configuration
ic.drawIC()
# Run the IC
print (ic.run())
┌─────────◡─────────┐
│ │
[1] ──┤ 1 14 ├── [1]
│ │
│ │
[0] ──┤ 2 7 13 ├── [0]
│ │
│ │
[1] ──┤ 3 4 12 ├── [0]
│ │
│ │
[0] ──┤ 4 1 11 ├── [1]
│ │
│ │
[1] ──┤ 5 5 10 ├── [1]
│ │
│ │
[1] ──┤ 6 2 9 ├── [0]
│ │
│ │
[0] ──┤ 7 8 ├── [0]
│ │
└───────────────────┘
{6: 1}
# Connector Outputs
c = Connector()
# Set the output connector to a particular pin of the ic
ic.setOutput(6, c)
print(c)
Connector; State: 1