예제 #1
0
# Mode No. :  Description
#   1          Monostable
#   2          Astable
#   3          Bistable

out = Connector(0)

# MODE 3

m = Multivibrator(0, mode=3)

m.start()
m.setOutput(out)

o = Oscilloscope((m.A, 'OUT'))
o.start()
o.setScale(0.05)
o.unhold()

time.sleep(0.1)
m.trigger()
print(m.A())
time.sleep(0.5)
m.trigger()
print(m.A())
time.sleep(1)
m.trigger()
print(m.A())
time.sleep(2)
m.trigger()
예제 #2
0
# Initializing the counter
print("\n")
print("Initializing Ripple Counter with 4 bits and clock_conn")
print("b = NBitRippleCounter(4, clk_conn)")
b = NBitRippleCounter(4, clk_conn)

# Initiating the oscilloscope
print("\n")
print("Initializing the Oscillioscope")
print(
    "o = Oscilloscope((clk_conn, 'CLK'), (b.out[0], 'BIT3'), (b.out[1], 'BIT2'), (\
    b.out[2], 'BIT1'), (b.out[3], 'BIT0'), (enable, 'EN1'))")
print("o.start() # starting the oscillioscope")
print("o.setScale(0.05) # setting the scale")
o = Oscilloscope((clk_conn, 'CLK'), (b.out[0], 'BIT3'), (b.out[1], 'BIT2'), (
    b.out[2], 'BIT1'), (b.out[3], 'BIT0'), (enable, 'EN1'))
o.start()
o.setScale(0.0005)  # Set scale by trial and error.
o.unhold()


print ("Initial State")
print (b.state())

print ("Triggering the counter sequentially 2^4 + 1 times")

for i in range(1, 2 ** 4 + 1):
    b.trigger()
    print (b.state())
o.display()
o.kill()
예제 #3
0
# In[2]:

# A clock of 1 hertz frequency  With initial value as 0

clock = Clock(0, 1)
clock.start()
clk_conn = clock.A

# In[3]:

# Initializing Binary Counter with 2 bits and clock_conn
b = BinaryCounter(2, clk_conn)

# Initializing the Oscillioscope
o = Oscilloscope((clk_conn, 'CLK'), (b.out[0], 'MSB'), (b.out[1], 'LSB'))

# Starting the oscillioscope
o.start()

# Set scale by trial and error.
o.setScale(0.15)

# Set the width of the oscilloscope [ To fit the ipython Notebook ]
o.setWidth(100)

# In[4]:

# Then unhold [ Run the Oscilloscope ]
o.unhold()
예제 #4
0
enable = Connector(1)

# <codecell>

# Initialize the T-FlipFlop
tff = TFlipFlop(toggle, enable, clk_conn, a=p, b=q)

# To connect different set of connectors use :
# tff.setInputs(conn1,enab,clk)
# To connect different outputs use:
tff.setOutputs(A=p, B=q)

# <codecell>

# Initialize the oscilloscope
o = Oscilloscope((clk_conn, 'CLK'), (toggle, 'TOGGLE'), (p, 'OUT'),
                 (q, 'OUT!'), (enable, 'ENABLE'))
o.start()
o.setScale(0.01)  # Set scale by trial and error.
o.setWidth(100)
o.unhold()

# <codecell>

print("Toggle is 1")
toggle.state = 1
while True:
    if clk_conn.state == 0:
        # Falling edge will trigger the FF
        tff.trigger()
        break
print(tff.state())
예제 #5
0
파일: DFlipFlop.py 프로젝트: vovkd/BinPy
enable = Connector(1)

# <codecell>

# Initialize the D-FlipFlop
dff = DFlipFlop(data, enable, clk_conn, a=p, b=q)
# To connect different set of connectors use :
# dff.setInputs(conn1,enab,clk)
# To connect different outputs use s.setOutputs(op1,op2)
dff.setOutputs(A=p, B=q)

# <codecell>

# Initiating the oscilloscope
o = Oscilloscope((clk_conn, 'CLK'), (data, 'DATA'), (p, 'OUT'), (q, 'OUT!'),
                 (enable, 'ENABLE'))
o.start()
o.setScale(0.01)  # Set scale by trial and error.
o.setWidth(100)
o.unhold()

# <codecell>

print("Data is 1")
data.state = 1
while True:
    if clk_conn.state == 0:
        # Falling edge will trigger the FF
        dff.trigger()
        break
print(dff.state())
예제 #6
0
from BinPy.tools.oscilloscope import Oscilloscope
import time

# MODE selects the mode of operation of the multivibrator.

# Mode No. :  Description
#   1          Monostable
#   2          Astable
#   3          Bistable

out = Connector()

# MODE 2

m = Multivibrator(0, 2, on_time=0.2, off_time=0.8)

m.start()
m.setOutput(out)
m.trigger()

o = Oscilloscope((out, 'OUT'))
o.start()
o.setScale(0.2)
o.unhold()

time.sleep(10)

o.display()

m.kill()
예제 #7
0
파일: SRLatch.py 프로젝트: vovkd/BinPy
enable = Connector(1)

# <codecell>

# Initialize the sr latch
srff = SRLatch(s, r, enable, clk_conn)

# To connect outputs use s.setOutputs(op1,op2)
srff.setOutputs(A=p, B=q)

# <codecell>

# Initialize the oscilloscope

o = Oscilloscope((clk_conn, 'CLK'), (s, 'S'), (r, 'R'), (p, 'OUT'),
                 (q, 'OUT!'), (enable, 'ENABLE'))
o.start()
o.setScale(0.015)  # Set scale by trial and error.
o.setWidth(100)
o.unhold()

# <codecell>

print("SET STATE - S = 1, R = 0")
# Set State
s.state = 1
r.state = 0
# The same thing can also be done by --> srff.setInputs(s = 1, r = 0)
while True:
    if clk_conn.state == 0:
        # Falling edge will trigger the FF
예제 #8
0
파일: JKFlipFlop.py 프로젝트: vovkd/BinPy
# A clock of 4 hertz frequency initialized to 1
clk_conn = clock.A

enable = Connector(1)

jkff = JKFlipFlop(j, k, enable, clk_conn, clear=enable)

# To connect outputs use s.setOutputs(op1,op2)
jkff.setOutputs(A=p, B=q)

# <codecell>

# Initiating the oscilloscope

o = Oscilloscope((clk_conn, 'CLK'), (j, 'J'), (k, 'k'), (p, 'OUT'),
                 (q, 'OUT!'), (enable, 'ENABLE'))

o.start()
o.setScale(0.02)  # Set scale by trial and error.
o.setWidth(100)
o.unhold()

# <codecell>

print("SET STATE - J = 1, K = 0")

# Set State
j.state = 1
k.state = 0

# The same thing can also be done by --> jkff.setInputs(j = 1, k = 0)