Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

digital out using DAQmxDigitalWriteU32

I was hoping I could get this done on my own and that it would not be that difficult.  After all, I recently got through a pDaq-55 (Omega sells one of your USB units) project OK.  I've quickly found myself needing to ask someone a few questions.   That, of sample code to study.  Anyway... this is a PCI-6229 project.

At this point I am trying to do a little digital-out.  In one case I am just trying to toggle one line using the following sequence:

DAQmxCreateTask         create the task
DAQmxCreatDoChan             selecting one line for output Dev1/Port0/Line0
DAQmsStartTask          start the task
DAQmxDigitalWriteU32    do the write, the data is simply one longint = FFFFFFFFh or 0 and only one is written.
DAQmxStopTask           stop the task
DAQmxClearTask          clear the task

This seems to work OK, but, I have a question.  Can I create the task, then start/stop it many times and then close it, or do I need to create/start/stop/clear each time I want to toggle the same line?

Next job, create a task where I write to several lines at once:

DAQmxCreateTask         create the task
DAQmxCreateDoChan             selecting six lines for output Dev1/Port0/Line0, line1, line3, line8, line9, line10
DAQmsStartTask          start the task
DAQmxDigitalWriteU32    do the write, trying different values for the data but nothing works so far.  Again, only one integer is sent.
DAQmxStopTask           stop the task
DAQmxClearTask          clear the task

Here I am not getting the results I expect, and I think my question boils down to what data I need to send.  I've tried sending one 32-bit integer where the bits corresponding to each line (0,1,2,8,9,10) are set to 1 or 0 (i.e. hex 707 to set lines 0-2 and 8-10 high), then I tried sending a 32-bit integer where only bits 0-5 were set, each bit corresponding to a channel instead of a line (hex 3F for channels 0-5).  Finally, I have tried sending a sequence of numbers to see what happens, and all that happens is line 0 is toggled low every time I send an even number, and high if I send and odd number.  This makes me think that I need to send one integer per line, 6 data total, for six channels. 

But, the other thing that is odd about this is that lines while line 0 toggles, line 2,9,1 and 0 are low and lines 1 and 10 are either high or high-z.  (The LED I have hooked to them do not light.)  This makes me think I've screwed up the channel configuration, but I've viewed every argument the ChanU32 function is sent and it looks OK, plus I'm using the same procedure in both cases here.  When I write to one line it works, which tells me I can configure at least one channel correctly, when I write to 6 lines, it doesn't.  In this latter case I call the Chan function 6 times, each time specifying one channel.

So far the help files have been able to explain the commands, but not really how to use them.  After the install all of the sample code provides using functions other than the DAQmx type.  I seem to recall having more sample code with my v7.4 drivers, but the update seems to have deleted them.

Thanks in advance.
0 Kudos
Message 1 of 4
(3,612 Views)

Hi m610,

 

As a troubleshooting technique, what if you try writing to the entire port (not just a couple of lines on the port)?  Please take a look at the "Write Dig Port" example vi.

David
Applications Engineer
National Instruments


Digital Multimeters
0 Kudos
Message 2 of 4
(3,573 Views)

That's a good idea.  I'm not using the other lines anyway.

 

For now I am simply using  a loop to write to 6 different lines, one task at a time, but it really bugs me that I couldn't do it all in one task.

 

More and more I suspect that the problem is in my code, but not know exactly how data are to be written is not helping, so I am trying to figure both things out at the same time.

 

I've got my A-out code working, and my A-In, except for the CJC thing which I've asked about in another thread, so progress is being made.

0 Kudos
Message 3 of 4
(3,571 Views)

Hi m610,

 

The write dig port example vi shows how to write to multiple lines from one task.  Try writing to the entire port like the example shows.  This way we can see if the issue lies in how we are specifying the lines to write to.

Message Edited by DavidMN on 03-13-2009 12:27 PM
David
Applications Engineer
National Instruments


Digital Multimeters
0 Kudos
Message 4 of 4
(3,556 Views)