Skip to content

Commit

Permalink
Update with nidaqmx
Browse files Browse the repository at this point in the history
  • Loading branch information
pradeeban authored Mar 24, 2023
1 parent 9631b01 commit b1ad31b
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions nintan/pstim.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import time
import threading

from hardware.util_functions import *
import nidaqmx
from nidaqmx.constants import AcquisitionType
from nidaqmx.stream_writers import DigitalSingleChannelWriter

global uglobal
uglobal = 0.5
PULSE_WIDTH = 10
Expand All @@ -14,13 +19,23 @@ def pwm():
ulocal = 0.0
if ulocal > 1.0:
ulocal = 1.0
print("+")
time.sleep(PULSE_WIDTH*ulocal)
print("-")
time.sleep(PULSE_WIDTH*(1.0-ulocal))

writer.write_one_sample_one_line(data=1,timeout=10)
accurate_delay(PULSE_WIDTH*ulocal)
writer.write_one_sample_one_line(data=0,timeout=10)
accurate_delay(PULSE_WIDTH*(1.0-ulocal))

# print("+")
# time.sleep(PULSE_WIDTH*ulocal)
# print("-")
# time.sleep(PULSE_WIDTH*(1.0-ulocal))

pwm_thread = threading.Thread(target=pwm, daemon=True)

task = nidaqmx.Task()
task.do_channels.add_do_chan("Dev1/port0/line0")
writer = DigitalSingleChannelWriter(task.out_stream)

concore.delay = 0.001
init_simtime_u = "[0.0, 0.0, 0.0]"
init_simtime_ym = "[0.0, 0.0, 0.0]"
Expand Down

0 comments on commit b1ad31b

Please sign in to comment.