From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Digital output timing possible with NI621X?

I have an NI6215 DAQ that I'm trying to use for simultaneous analog and digital I/O.

 

The analog output requires precise synchronization, so I'm using hardware timing.

I want to simultaneously output a digital signal that uses the same sample timing.

I have a generic example below, but really I want to output a digital rising edge every time the analog voltage changes.

 

I'm able to use software timing to control the digital output, but all attempts at hardware timing have failed.

 

 

    # Set up bit stream
    num_bits = 200
    bit_sequence = np.random.choice(a=[False, True], size=num_bits)
    bit_time = 0.2 # seconds
    sample_freq = 5 # Hz

    print(bit_sequence)

    # Set up marker task
    marker_task = nidaqmx.Task()
    marker_task.do_channels.add_do_chan("Dev1/port1/line2")

    # set up analog output for hardware timing
    ao_task = nidaqmx.Task()
    ao_task.ao_channels.add_ao_voltage_chan("Dev1/ao0")
    ao_task.timing.cfg_samp_clk_timing(sample_freq, samps_per_chan=num_bits)
    ao_task.write(np.zeros(num_bits), auto_start=False)

    # Set up marker task timing
    marker_task.timing.cfg_samp_clk_timing(rate=sample_freq, source='ao/SampleClock', samps_per_chan=num_bits)
    marker_task.write(bit_sequence, auto_start=False)

    marker_task.start()
    ao_task.start()

    marker_task.wait_until_done()
    ao_task.wait_until_done()

    marker_task.stop()
    ao_task.stop()

    marker_task.close()
    ao_task.close()

 

 

Unfortunately, I always get the error:

 

Property: DAQmx_SampTimingType
Requested Value: DAQmx_Val_SampClk
Possible Values: DAQmx_Val_OnDemand

Task Name: _unnamedTask<0>

Status Code: -200077

 

 

Does this mean that it's not possible to set the digital output timing for the NI6215?

It looks like maybe On-Demand timing is the only valid configuration, and that is maybe how I interpret the discussion of correlated DIO here. 

Or am I just going about this the wrong way??

 

Thanks for any advice you have.

 

-Rapp

0 Kudos
Message 1 of 4
(214 Views)

Yeah, though many M-series DAQ devices *do* support hardware-clocked "correlated DIO", your particular 6215 device is one that does *not*.

 

Best simple advice: use your other ao channel to generate a digital-like 0V or 5V signal as part of the same ao task.

- double your ao sample rate

- double up every ao sample value for your original channel (so instead of 0,1,2,3..., write 0,0,1,1,2,2,3,3...).  The net effect is the same as a single entry at the original rate.

- alternate between 0V and 5V for your new pseudo-digital channel

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 2 of 4
(201 Views)

Thanks for the reply, Kevin.

That's too bad that not all M-series DAQs have the same correlated IO functionality.

 

I had thought of creating a pseudo-digital output, but I actually need *both* AO channels for analog outputs.

Any other possibilities using only the digital pins?

 

 

0 Kudos
Message 3 of 4
(186 Views)

No, not with your DAQ device.  It simply doesn't support hardware-timed DIO.  The only workaround was the one I mentioned where you use an AO channel to do pseudo-DO.  If you don't have spare AO, then there are no workarounds left.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 4
(140 Views)