Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-6509 Python performance issue when writing to Output

Hi All, I'm using an NI-6509 / PCI card   to generate encoder pulses. All we do is write to the outputs every 2ms. It seems the write is a blocking call, and when we check the min/max time for a write is varies from 0.1ms to 1ms, sometimes we even get write times up to 2ms, which causes some issues.

 

So I have 2 questions:

1.  Is there a way to make this call "non-blocking"

2.  Why does the call take so much time

 

Here is the Python code to create the task:

    def __init__(self😞
        try:  
            self.OutputStates = [False,False,False,False,False,False,False,False]  # NI DAQ port 0 initial

            # Configure and setup the tasks
            self.task0 = nidaqmx.Task()
            self.task0.do_channels.add_do_chan("Dev2/port0/line0:7,line_grouping=LineGrouping.CHAN_PER_LINE)
            self.task0.start()

            # set default values
            self.task0.write(self.OutputStates)
        except Exception as e:
            self.task0 = None
            print("NationalInstrumentGpio::__init__() exception: {}".format(e))



Here is the write method, called every 2msec

    def WriteOutputs(self😞
        try:  
            self.task0.write(self.OutputStates)
        except Exception as e:
            print("NationalInstrumentGpio::SetOutputState() exception: {}".format(e))
            raise NationalInstrumentGpioException("NationalInstrumentGpio::SetOutputState() exception: {}".format(e))
 

 

 

0 Kudos
Message 1 of 4
(1,123 Views)

In my opinion, you have got the wrong device for your job. 6509 is software timed digital I/O - this means the software defines the duration between any digital state change. With this said, there are software overheads (like the driver) and in the end, you're at the mercy of your OS to let you execute at the time you want it to execute (which is typical of Windows).

 

You need a device with Hardware timed digital output (this means a dedicated circuit on the device ensures that the digital states are updated at specified time intervals without any interruption).

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 4
(1,122 Views)

Thank you very much Santhosh, can you suggest some PCI cards with hw timed digital outputs ? We need about 8 IOs, 5volts.

 

Best regards,

 

Jeff

0 Kudos
Message 3 of 4
(1,094 Views)

Going the PCI or PCIe route will fetch far fewer options for the cards and most of them are obsolete. Before I get to suggest a new HW, please elaborate on your requirements to make the right choice.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 4 of 4
(1,087 Views)