Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I control digital output?

I am programming in VC++ with the NIDAQmx API. I am using the PCI-6052e and PCI-6154 cards.

I would like to be able to control two digital channels, i.e. line 0 go high, line 1 go low.  Then a few seconds or minutes later, I would change the output of line 0.

// create the task
DAQmxCreateTask("",&taskDigitalHandle);        
DAQmxCreateDOChan(taskDigitalHandle,"Dev1/port0/line0","",DAQmx_Val_ChanPerLine);
// line 0 high
DAQmxWriteDigitalScalarU32(taskDigitalHandle, 1, 10.0, true, NULL);
// do something (removed)
// line 0 low
DAQmxWriteDigitalScalarU32(taskDigitalHandle, 1, 10.0, false, NULL);

I am getting the warning -200012 (Clock rate specified exceeds the maximum conversion rate of the ADC) back, which I have no idea how to resolve.
But I feel like I'm missing something big here... can this even be done, and am I right to use DAQmxWriteDigitalScalarU32 to do it?

Also, I can't find much documentation on these functions, is there any available?
0 Kudos
Message 1 of 7
(4,997 Views)
Looks like I had the wrong error description.  The actual description of -200012 is "Specified physical channel does not support digital output."

Any ideas why Dev1/port0/line0 doesn't support digital output?
0 Kudos
Message 2 of 7
(4,980 Views)
Is Dev1 the 6154? If it is, then port0 is all inputs and port1 is all outputs. This configuration is fixed and you can't change the line direction.
0 Kudos
Message 3 of 7
(4,975 Views)
dear sir,
currently my requirement is to perform On/Off operations using digital output channels....
im using code like this
DAQmxCreateTask("",&g_DWriteTaskHandle);
 DAQmxCreateDOChan(g_DWriteTaskHandle,"Dev1/port1/line0","",DAQmx_Val_ChanPerLine);
 DAQmxStartTask(g_DWriteTaskHandle);
 DAQmxWriteDigitalScalarU32(g_DWriteTaskHandle, 1, 10.0, true, NULL);
 DAQmxWriteDigitalScalarU32(g_DWriteTaskHandle, 1, 10.0, false, NULL);
 DAQmxStopTask(g_DWriteTaskHandle);
 CleanupTask(g_DWriteTaskHandle);
 
 DAQmxCreateTask("",&g_DWriteTaskHandle1);
 DAQmxCreateDOChan(g_DWriteTaskHandle1,"Dev1/port1/line1","",DAQmx_Val_ChanPerLine);
 DAQmxStartTask(g_DWriteTaskHandle1);
 DAQmxWriteDigitalScalarU32(g_DWriteTaskHandle1, 1, 10, true, NULL);
 DAQmxWriteDigitalScalarU32(g_DWriteTaskHandle1, 1, 10, false, NULL);
 DAQmxStopTask(g_DWriteTaskHandle1);
 CleanupTask(g_DWriteTaskHandle1);
 
but the problem is it is responding well for the first digital line "Dev1/port1/line0", but when it comes to second channel "Dev1/port1/line1" it is not responding well....
so please can you suggest me in the right direction
 
Thanks in Advance
0 Kudos
Message 4 of 7
(4,782 Views)
'Not responding well' is not much of a problem description. You would be better off creating a new thread for a new qeustion and providing a few more details. Start with the type of device and exactly describe the issue you are having with it. If you are getting an error, provide the error code.
0 Kudos
Message 5 of 7
(4,767 Views)

Thanku Mr Dennis for giving reply to my problem...

here iam giving detailed information about my problem....

iam using NI PCI 6221 card for conducting  Thermal battery test....

here iam suppose to use Digital Output channels for relay on/off purpose....

the method iam using for that is DAQmxWriteDigitalScalarU32(),

this method is working for only one line in a selected port... for example i am using "Dev1/port1/line0"

iam writing code like this

DAQmxCreateTask("",&g_DWriteTaskHandle);
 DAQmxCreateDOChan(g_DWriteTaskHandle,"Dev1/port1/line0","port0",DAQmx_Val_ChanPerLine);
 DAQmxStartTask(g_DWriteTaskHandle);
 DAQmxWriteDigitalScalarU32(g_DWriteTaskHandle, 1, 10.0, 1, NULL);
 DAQmxWriteDigitalScalarU32(g_DWriteTaskHandle, 1, 10.0, 0, NULL);
 DAQmxStopTask(g_DWriteTaskHandle);
 CleanupTask(g_DWriteTaskHandle);

this code is working perfectly for Line0  On/Off is working well.......

but if iam using similary implimentation for "Dev1/port1/line1"  On/Off is not responding.....

this is the code iam using for line1

DAQmxCreateTask("",&g_DWriteTaskHandle1);
 DAQmxCreateDOChan(g_DWriteTaskHandle1,"Dev1/port1/line1","port1",DAQmx_Val_ChanPerLine);
 DAQmxStartTask(g_DWriteTaskHandle1);
 DAQmxWriteDigitalScalarU32(g_DWriteTaskHandle1, 1, 10, 1, NULL);
 DAQmxWriteDigitalScalarU32(g_DWriteTaskHandle1, 1, 10, 0, NULL);
 DAQmxStopTask(g_DWriteTaskHandle1);
 CleanupTask(g_DWriteTaskHandle1);

these two are similar if you compare... but workin only for Line0 and not working for Line1.....

so please help me how to correct the problem

0 Kudos
Message 6 of 7
(4,758 Views)

Hi

What I would strongly suggest is to take a look at this knowledge base: Location of ANSI C NI-DAQmx Shipping Examples and DAQmx Library File for Windows and find this example: “WriteDigChan.c”. You will see that you can take a much simpler approach for what you are trying to accomplish. For troubleshooting proposes I would try setting a wait between both “writes” and see what happens. But the example should work fine.

I have attached the source in case you don’t find it. Hope it helps.



Message Edited by Jaime F on 01-08-2008 02:33 PM
Jaime Hoffiz
National Instruments
Product Expert
0 Kudos
Message 7 of 7
(4,736 Views)