-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpb_infinite_on_example.py
45 lines (34 loc) · 1.21 KB
/
pb_infinite_on_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# example: pulse blaster pin held on indefinitely
from pulseblaster.PBInd import PBInd
import pulseblaster.spinapi
cycle_length = 1e3 * pulseblaster.spinapi.ns # ns
hardware_pins = [23] # using pin 23 (AOM modulation)
delays = [] # delays for each individual channel
N=float('inf') # number of loops (N = float('inf') to repeat indefinitely
pb=PBInd(pins=hardware_pins,
on_time=cycle_length,
DEBUG_MODE=0,
auto_stop=0) # default resolution is 50 ns
# select board 1
pb.spinapi.pb_select_board(1)
# initialize board
if pb.spinapi.pb_init() != 0:
print("Error initializing board: %s" % pb.spinapi.pb_get_error())
input("Please press a key to continue.")
exit(-1)
# Configure the core clock
pb.spinapi.pb_core_clock(100 * pulseblaster.spinapi.MHz) # MHz
pb.spinapi.pb_reset()
# initialize PBInd object to individually program pulse blaster pins
#program hardware_pins to be on from t0=0 to tend=cycle_length
pb.spinapi.pb_start_programming(0)
pb.on(hardware_pins[0],0,cycle_length)
pb.program(delays,N)
pb.spinapi.pb_stop_programming()
#trigger the board
pb.spinapi.pb_reset()
pb.spinapi.pb_start()
#to stop, use pb_stop()
pb.spinapi.pb_stop()
#to close connection to pulseblaster
pb.spinapi.pb_close()