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 3
3
import time
4
4
import threading
5
5
6
+ from hardware .util_functions import *
7
+ import nidaqmx
8
+ from nidaqmx .constants import AcquisitionType
9
+ from nidaqmx .stream_writers import DigitalSingleChannelWriter
10
+
6
11
global uglobal
7
12
uglobal = 0.5
8
13
PULSE_WIDTH = 10
@@ -14,13 +19,23 @@ def pwm():
14
19
ulocal = 0.0
15
20
if ulocal > 1.0 :
16
21
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))
21
32
22
33
pwm_thread = threading .Thread (target = pwm , daemon = True )
23
34
35
+ task = nidaqmx .Task ()
36
+ task .do_channels .add_do_chan ("Dev1/port0/line0" )
37
+ writer = DigitalSingleChannelWriter (task .out_stream )
38
+
24
39
concore .delay = 0.001
25
40
init_simtime_u = "[0.0, 0.0, 0.0]"
26
41
init_simtime_ym = "[0.0, 0.0, 0.0]"
You can’t perform that action at this time.
0 commit comments