Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

USB-6009 digital output

I'm attempting to use a USB-6009 to provide a temporary SPI 4 wire interface to a programmable power supply. My application is a simple Microsoft Excel user form coded in Visual Basic. I use the NIDAQmxWriteDigitalU8 function (I think that's the correct spelling but essentially it's the 8 bit digital write function) to output a chip select, a clock, and data out.
 
All the function calls seem to work: creating tasks, data out channels, etc. the assigned channels are "Dev1/Port0/Line2:0" with a clock (Clk) at bit 2, chip select at bit 1 (CS), and Data at bit 0.
I'm currently using a 'For' loop to output the serial stream and am monitoring the outputs, CS, Clk, Data with a digital 'scope.
 
The waveforms look correct except that the data bit is ahead of itself. I can step through the application code and the data in the array is correct. Clk and CS work as expected; Data goes high on the 'scope before the function is executed to write a '1'.
 
I'm completely stumpted unless the hardware is faulty. Has anyone else seen this behavior?
0 Kudos
Message 1 of 8
(5,707 Views)

Hello Tommy,

The behavior you are explaining is not expected normal.  I have attached ascreenshot of my USB-6009 changing the digital lines properly.  I have attached a very simply VB application that change lines 2:0 on port 0 of the USB-6009 all at the same time so I can tell if they are changing when expected.  Can you run the attached code to see if you experience the same problem with it?  If the example code works, there might be something wrong in your code.

Regards,

Jesse O.
Applications Engineering
National Instruments

Jesse O. | National Instruments R&D
Download All
Message 2 of 8
(5,682 Views)
Thanks, Jesse. I'll give it a shot.
0 Kudos
Message 3 of 8
(5,662 Views)
Jesse,
 
Your sample code uses the DAQmxWriteDigitalLines function while mine uses the DAQmxWriteDigitalU8. Can you explain the difference between the 2 functions? It seems to me according to the function descriptions that DAQmxWriteDigitalU8 is the correct function.
 
I tried to the DAQmxWriteDigitalLines function in my code but  get an error that says,
 
"Attempted writing digital data that is not supported.
 Data: 4
 Supported Values: 0 , 1"
 
Does the '...Lines' function expect binary? I don't get this error with the '...U8' function.
0 Kudos
Message 4 of 8
(5,647 Views)
Hi Tommy,

The function DAQmxWriteDigitalU8 is not actually included in the Visual Basic API, so the bigger issue is why that function worked at all in your original code.  If you were to use each of these functions in C, they would both accept the same data type, uInt8 [ ], as listed in the NI-DAQmx C Reference Help found under Start >> Programs >> National Instruments >> NI-DAQ.  Make sure that this is the data type that you are passing to the function in Visual Basic.

The most important point here is that if you are programming in Visual Basic, you should be using the function DAQmxWriteDigitalLines. 

I hope this information helps.

Best regards,
Message 5 of 8
(5,624 Views)

Jarrod,

Thanks for your support. The DAQmxWriteDigitalLines function is working for us. And so is DAQmxReadDigitalLines.

0 Kudos
Message 6 of 8
(5,603 Views)
hi jesse

the write to dig VB6 for 6009 has been very helpful for me.Is there any way u could provide me VB sorce program for reading from the digital lines.
Thanx in advance

Message Edited by perk_bud on 10-11-2006 08:23 AM

0 Kudos
Message 7 of 8
(5,425 Views)
Hello,

I have attached a VB 6 shipping example below.  This example demonstrates how to perform software timed digital input.  This example and many others should be installed when you install DAQmx.  You can typically find these examples here:

C:\Program Files\National Instruments\NI-DAQ\Examples\Visual Basic 6.0

I hope this helps,

Jesse O.
Applications Engineering
National Instruments
Jesse O. | National Instruments R&D
0 Kudos
Message 8 of 8
(5,393 Views)