Discussion:
How do I control digital output?
(too old to reply)
brahma
2008-01-07 10:40:07 UTC
Permalink
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
brahma
2008-01-08 05:40:06 UTC
Permalink
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
Jaime F
2008-01-08 20:40:08 UTC
Permalink
Hi

What I would strongly suggest is to take a look at this knowledge base: <a href="http://digital.ni.com/public.nsf/allkb/FB26BDA52FFFD4EE86257124005C36C3?OpenDocument" target="_blank"> Location of ANSI C NI-DAQmx Shipping Examples and DAQmx Library File for Windows</a> 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


WriteDigChan.c:
http://forums.ni.com/attachments/ni/70/8031/1/WriteDigChan.c

Continue reading on narkive:
Loading...