Bases: threading.Thread
This class uses threading technique to create a clock with a certain time period. This is how you can create a clock with this class:
>>> myClock = Clock(0,time_period=2,name="My First Clock")
>>> myClock.start() #Do not call run method
>>> myClock.getState()
0
Following are the parameters of the class
param frequency: It will decide time interval of the clock, use SI unit i.e. Hertz param time_period: It will also decide time interval of the clock, use SI unit i.e. second param init_state: It is the initial state of the clock(1 by default) param name: It is the name of the clock.(optional) If time_period and frequency both have been provided, then time_period will override frequency If nothing is provided, then it will set time_period = 1s by default
Methods : start(), getState(), setState(value), getName(), getTimePeriod(), kill()
This class emulates a 7 segmented display(Common Cathode)
>>> myDisplay = DigitDisplay("Display1")
>>> print myDisplay.evaluate([1,1,1,1,1,1,1])
8
http://tronixstuff.files.wordpress.com/2010/05/7segpinout.jpg
Models a Ground from which various connectors can tap by connecting to it. taps: The list of all connectors connected to this ground. connect(): Takes in one or more connectors as input and connects them to the ground. disconnect(): Takes in one or more connectors as input and disconnects them from the ground.
Bases: threading.Thread
This class uses threading technique to create a multivibrator with a certain time period. USAGE:
>>> m1 = Multivibrator()
>>> m1.start() # Start this thread
>>> m1.trigger() # or m1()
>>> m1.getState() # or m1.A.state
0
>>> m1.setMode(2)
>>> m1.trigger()
>>> m1.getstate()
>>> conn = Connector()
>>> m1.setOutput(conn) # To set the output to connector conn
>>> conn() # Retrieves the current state
>>> m1.kill()
Following are the parameters of the class
frequency: It will decide time interval of the Multivibrator, use SI unit i.e. Hertz time_period: It will also decide time interval of the Multivibrator, use SI unit i.e. second
If time_period and frequency both have been provided, then time_period will override frequency If nothing is provided, then it will set time_period = 1s by default
init_state: It is the initial state of the multivibrator(1 by default)
- mode: It is the mode of operation.
- 1 –> Monostable 2 –> Astable 3 –> Bistable
Methods : trigger(),setMode(), getState(), setState(value), getTimePeriod(), kill(), stop(), setOutput()
Bases: threading.Thread
Oscilloscope is helpful in visualizing simulations.
USAGE: # A clock of 1 hertz frequency clock = Clock(1, 1) clock.start() clk_conn = clock.A
bc = BinaryCounter() os1 = Oscilloscope( (bc.out[1],’lsb’) , (bc.out[0],’msb’)) os1.start() #Triggering the counter: for i in range(5):
b.trigger() print (b.state())
os1.stop() os1.display()
Acceptable values are: 1 –> RED 2 –> GREEN 4 –> BLUE 7 –> WHITE
To RESET call without parameters.
Please note that serColor is not supported by all operating systems. This will run without problems on most Linux systems.
This decides the time per unit xWidth. To avoid waveform distortion, follow NYQUIST sampling theorem. That is if the least time period of the waveform is T; Set the scale to be greater than T/2 [ preferably T/5 - To avoid edge sampling effects ]
There is a lower bound on the scale value [ use trial and error to identify this for your particular PC ] This limitation is set by the processing time taken to set a plot etc.
Models a Power Source from which various connectors can tap by connecting to it.
taps: The list of all connectors connected to this power source.
connect(): Takes in one or more connectors as input and connects them to the power source.
disconnect(): Takes in one or more connectors as input and disconnects them from the power source.