Hello Robert,
I have extracted the code which manages the IO acess to NI 6534. In the example the output to the
IIO card works in unbuffered mode for an IO-acess for one byte (8 bit)
Following code works on my computer:
Public Sub write_port(port, writeValue)
' Write zeros or ones to the digital lines
Dim writeArray(0 To 7) As Byte
Dim wert As Byte
Dim sampsPerChanWritten As Long
' Configure port
configure_write_port (port)
For i = 0 To 7
wert = Dec2BinLine(writeValue, i)
If wert = 1 Then
writeValue = writeValue - 2 ^ (7 - i)
End If
writeArray(i) = wert
Next
DAQmxErrChk DAQmxWriteDigitalLines(taskHandle, 1,
True, 10#, DAQmx_Val_GroupByChannel, writeArray(0),
sampsPerChanWritten, ByVal 0&)
'Clear Task
DAQmxStopTask (taskHandle)
DAQmxClearTask (taskHandle)
End Sub
--------------------------------------------------------------------------------------------------
Comments :
The subroutine write_port(port,value) is called from main with the parameter
Public Sub configure_write_port(port)
' Configure port
DAQmxErrChk DAQmxCreateTask("", taskHandle)
DAQmxErrChk DAQmxCreateDOChan(taskHandle, port, "", DAQmx_Val_ChanForAllLines)
DAQmxErrChk DAQmxStartTask(taskHandle)
End Sub
The function Dec2BinLine(writeValue, i) converts the value into binary. So each of the 8 bytes contents the value "0" or "1"
'Rückgabe von 0 bzw. 1 aus einer Zahl 0 ..255
Public Function Dec2BinLine(dwert, position)
Dim val As Byte
If dwert >= 2 ^ (7 - position) Then
val = 1
Else
val = 0
End If
Dec2BinLine = val
End Function
port = "Dev3/port0" because the NI 6534 is Dev3
writeValue is integer (0 to 255)
That will work sucessful, I had checked it with the Logic Analyzer on the outputs of port0
In a version which the writeArray is filled with values type of integer an error occurs.
May be you can give me answers to following question:
1. Why have I to convert the integer value into bytes ?
Thanks you for your answer
best regards
Bernd