Skip to content

Commit b1ad31b

Browse files
authored
Update with nidaqmx
1 parent 9631b01 commit b1ad31b

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

nintan/pstim.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
import time
44
import 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+
611
global uglobal
712
uglobal = 0.5
813
PULSE_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

2233
pwm_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+
2439
concore.delay = 0.001
2540
init_simtime_u = "[0.0, 0.0, 0.0]"
2641
init_simtime_ym = "[0.0, 0.0, 0.0]"

0 commit comments

Comments
 (0)