Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxReadDigitalLines - need help to do in VB 6.0

Can any one help me to write a code for reading digital output lines using NI- DAQmx functions.
I am new here. I succeeded in  writing output lines using DAQmxWriteDigitalLines
But, while trying to read lines, I am getting 2 error messages one says "referenced memroy cannot be written" and second message says "reference memory cannot be read" (Not actual phrases in the error message) It shows some memory addreses also.
 
Please help me to find out prameters of DAQmxReadDigitalLines in Vb 6.0
I have a requirement to Monitor digital lines that an application program writes into. This is for the purpose of finding out cause of malfauction in our 4 coulour offset machine.
 
Vb Code:
 
    DAQmxErrChk DAQmxCreateTask("", TaskHandle)
    ' Add a digital output channel to the task.
    DAQmxErrChk DAQmxCreateDOChan(TaskHandle, txtChannelString.Text, "", DAQmx_Val_ChanForAllLines)
   
    ' Start the task running, and write to the digital lines.
    DAQmxErrChk DAQmxStartTask(TaskHandle)
    DAQmxErrChk DAQmxWriteDigitalLines(TaskHandle, 1, 1, 10#, DAQmx_Val_GroupByChannel, writeArray(0), sampsPerChanWritten, 0)
    MsgBox "OK 2"
   
    DAQmxErrChk DAQmxReadDigitalLines(TaskHandle, 1, 10#, DAQmx_Val_GroupByChannel, ReadArray(0), 8, Null, 1, 0)
   
    MsgBox "Samples per channel written = " & sampsPerChanWritten
   
    DAQmxErrChk DAQmxStopTask(TaskHandle)
    DAQmxErrChk DAQmxClearTask(TaskHandle)
 
0 Kudos
Message 1 of 2
(3,175 Views)

Hi Najeepkp,

With our DAQ boards, we must be careful in the setting of the digital lines. If you would like to write and then read from the same lines, we must create a task for DO, write, finish and clear the task. Next create a task for DI, read, and then finish and clear the task. The code above is trying to write and then read, without changing the lines from output to input.

 

If you would like to do digital reads and writes at the same time, but on different lines, you can create two separate tasks (one for the DO, and one for the DI) and run them both simultaneously.

I am glad to hear that you got the shipping example for digital output to work. You may try the digital input example before trying to interlace the two.

David L.
Systems Engineering
National Instruments
0 Kudos
Message 2 of 2
(3,155 Views)