Beispiel #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()
Beispiel #2
0
# In[31]:

# Initializing the counter

# Initializing DecadeCounter with clock_conn

b = DecadeCounter(clk_conn)


# In[32]:

# Initiating the oscilloscope

o = Oscilloscope(
    (clk_conn, "CLK"), (b.out[0], "BIT3"), (b.out[1], "BIT2"), (b.out[2], "BIT1"), (b.out[3], "BIT0"), (enable, "EN1")
)

# starting the oscillioscope thread - This does not initiate the recording.

o.start()

# setting the scale

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

# Set the width of the oscilloscope to fit the ipython notebook.

o.setWidth(100)

Beispiel #3
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()
Beispiel #4
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()
Beispiel #5
0
clock = Clock(1, 4)
clock.start()
# A clock of 4 hertz frequency
clk_conn = clock.A

enable = Connector(1)

# 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)

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.unhold()

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())

# Sending a positive edge to ff
while True:
Beispiel #6
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())
Beispiel #7
0
#   3          Bistable

out = Connector(0)

# <codecell>

# Initialize mutivibrator in MODE 3

m = Multivibrator(0, mode=3)
m.start()
m.setOutput(out)

# <codecell>

# Initialize the oscilloscope
o = Oscilloscope((out, 'OUT'))
o.start()
o.setScale(0.05)
o.setWidth(100)
o.unhold()
# This is done to let the oscilloscope thread to synchronize with the main
# thread...
time.sleep(0.001)

# <codecell>

# Trigger the multivibrator to change the state
print(out())
time.sleep(0.1)
m.trigger()
Beispiel #8
0
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()
Beispiel #9
0
# A clock of 1 hertz frequency
print("clk_conn = clock.A")
clk_conn = clock.A
print("\n")
print("Initializing Binary Counter with 2 bits and clock_conn")
print("b = BinaryCounter(2, clk_conn)")
b = BinaryCounter(2, clk_conn)

print("\n")
print("Initializing the Oscillioscope")
print(
    "o=Oscilloscope((clk_conn, 'CLK'), (b.out[0], 'MSB'), (b.out[1],'LSB')')")
print("o.start() # starting the oscillioscope")
print("o.setScale(0.05) # setting the scale")

o = Oscilloscope((clk_conn, 'CLK'), (b.out[0], 'MSB'), (b.out[1], 'LSB'))
o.start()
o.setScale(0.05)  # Set scale by trial and error.
print("o.unhold() #then unhold")
o.unhold()

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

print("\n")
print("Triggering the counter Sequentially")
print("")
for i in range(5):
    b.trigger()
    print(b.state())
Beispiel #10
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()
Beispiel #11
0
out = Connector()


# In[3]:

# Initialize mutivibrator in MODE 1

m = Multivibrator(0, mode=1, time_period=1)
m.start()
m.setOutput(out)


# In[4]:

# Initialize the oscilloscope
o = Oscilloscope((out, 'OUT'))
o.start()
o.set_scale(0.005)  # Set scale by trial and error.
o.set_width(100)
o.unhold()
time.sleep(0.1)
m.trigger()  # Also works with m()
time.sleep(0.1)


# In[5]:

# Display the oscilloscope
o.display()

Beispiel #12
0
# Initialize the clock
clock = Clock(1, 4)
clock.start()
# A clock of 1 hertz frequency
clk_conn = clock.A

enable = Connector(1)

# 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)

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

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
        srff.trigger()
        break
print (srff.state())
Beispiel #13
0
#   3          Bistable

out = Connector(0)

# <codecell>

# Initialize mutivibrator in MODE 3

m = Multivibrator(0, mode=3)
m.start()
m.setOutput(out)

# <codecell>

# Initialize the oscilloscope
o = Oscilloscope((out, 'OUT'))
o.start()
o.setScale(0.05)
o.setWidth(100)
o.unhold()
# This is done to let the oscilloscope thread to synchronize with the main
# thread...
time.sleep(0.001)

# <codecell>

# Trigger the multivibrator to change the state
print(out())
time.sleep(0.1)
m.trigger()