File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed
Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change 33import time
44import threading
55
6+ from hardware .util_functions import *
7+ import nidaqmx
8+ from nidaqmx .constants import AcquisitionType
9+ from nidaqmx .stream_writers import DigitalSingleChannelWriter
10+
611global uglobal
712uglobal = 0.5
813PULSE_WIDTH = 10
@@ -14,13 +19,23 @@ def pwm():
1419 ulocal = 0.0
1520 if ulocal > 1.0 :
1621 ulocal = 1.0
17- print ("+" )
18- time .sleep (PULSE_WIDTH * ulocal )
19- print ("-" )
20- time .sleep (PULSE_WIDTH * (1.0 - ulocal ))
22+
23+ writer .write_one_sample_one_line (data = 1 ,timeout = 10 )
24+ accurate_delay (PULSE_WIDTH * ulocal )
25+ writer .write_one_sample_one_line (data = 0 ,timeout = 10 )
26+ accurate_delay (PULSE_WIDTH * (1.0 - ulocal ))
27+
28+ # print("+")
29+ # time.sleep(PULSE_WIDTH*ulocal)
30+ # print("-")
31+ # time.sleep(PULSE_WIDTH*(1.0-ulocal))
2132
2233pwm_thread = threading .Thread (target = pwm , daemon = True )
2334
35+ task = nidaqmx .Task ()
36+ task .do_channels .add_do_chan ("Dev1/port0/line0" )
37+ writer = DigitalSingleChannelWriter (task .out_stream )
38+
2439concore .delay = 0.001
2540init_simtime_u = "[0.0, 0.0, 0.0]"
2641init_simtime_ym = "[0.0, 0.0, 0.0]"
You can’t perform that action at this time.
0 commit comments