Hello everyone
I'm a new user of NI boards and am a bit lost with a dual stream_writers problem that I can't seem to find a solution to.
I'm trying to use a NI 6229 card with 2 x BNC-2090A (or even a single one) to send periodic simultaneous TTL pulses. One TTL pulse controls a speaker (plays sound waves) the other opens a port for a water release valve.
Independently, these two tasks are easy to do using the
function and these individual commands:
But when I run them in series (i.e. without closing the first one), I get this error when the second task tries to write:
I've added a 2nd BNC-2090A breakout board (see ao2 above) and I get the same error. I do have a 2nd 6229 card - but! my computer doesn't have any more slots to insert it into.
Should I not be using the stream-writers function to write TTL output?
Any advice is much appreciate! As I said, I'm quite new at NI + python configuration and a bit lost.
Thanks so much,
Catalin
Here's the entirety of my code, including a function that converts frequency values to oscillations playable via TTL pulse:
C:\Users\rg-fd02-user\anaconda3\envs\bmi\lib\site-packages\nidaqmx\task.py:98: ResourceWarning: Task of name "_unnamedTask<1>" was not explicitly closed before it was destructed. Resources on the task device may still be reserved. warnings.warn( C:\Users\rg-fd02-user\anaconda3\envs\bmi\lib\site-packages\nidaqmx\task.py:98: ResourceWarning: Task of name "_unnamedTask<2>" was not explicitly closed before it was destructed. Resources on the task device may still be reserved. warnings.warn( C:\Users\rg-fd02-user\anaconda3\envs\bmi\lib\site-packages\nidaqmx\task.py:98: ResourceWarning: Task of name "_unnamedTask<3>" was not explicitly closed before it was destructed. Resources on the task device may still be reserved. warnings.warn(
---------------------------------------------------------------------------DaqWriteError Traceback (most recent call last) Input In [6], in <cell line: 47>() 49for p inrange(duration): 50 water_Writer.write_one_sample(5)---> 51audio_Writer.write_many_sample(tone) 53# pause and give 0 pluse 54for q inrange(100000-duration): File ~\anaconda3\envs\bmi\lib\site-packages\nidaqmx\stream_writers.py:234, in AnalogSingleChannelWriter.write_many_sample(self, data, timeout) 229self._verify_array(data, False, True) 231 auto_start = (self._auto_start ifself._auto_start isnot 232 AUTO_START_UNSET elseFalse)--> 234return_write_analog_f_64( 235self._handle,data,data.shape[0],auto_start,timeout) File ~\anaconda3\envs\bmi\lib\site-packages\nidaqmx\_task_modules\write_functions.py:28, in _write_analog_f_64(task_handle, write_array, num_samps_per_chan, auto_start, timeout, data_layout) 18 cfunc.argtypes = [ 19 lib_importer.task_handle, ctypes.c_int, c_bool32, 20 ctypes.c_double, ctypes.c_int, 21 wrapped_ndpointer(dtype=numpy.float64, flags=('C')), 22 ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)] 24 error_code = cfunc( 25 task_handle, num_samps_per_chan, auto_start, timeout, 26 data_layout.value, write_array, 27 ctypes.byref(samps_per_chan_written), None)---> 28check_for_error(error_code,samps_per_chan_written=samps_per_chan_written.value) 30return samps_per_chan_written.value File ~\anaconda3\envs\bmi\lib\site-packages\nidaqmx\errors.py:191, in check_for_error(error_code, samps_per_chan_written, samps_per_chan_read) 189raise DaqReadError(error_buffer.value.decode("utf-8"), error_code, samps_per_chan_read) 190elif samps_per_chan_written isnotNone:--> 191raise DaqWriteError(error_buffer.value.decode("utf-8"), error_code, samps_per_chan_written) 192else: 193raise DaqError(error_buffer.value.decode("utf-8"), error_code)DaqWriteError: The specified resource is reserved. The operation could not be completed as specified. Task Name: _unnamedTask<4> Status Code: -50103