From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

ChD works, but ChDx doesn't?

I wish to create a channel with 10 numbers. The following code will
not fill my channel with numbers:

''''begin code''''
call DataDelAll(1)
call RootPropSet("Name","MyChannel")
Call ChnAlloc("Frequency",10,,DATATYPEFLOAT64)
CHDX(1,CNo("Frequency")) = 2.0
CHDX(2,CNo("Frequency")) = 2.1
CHDX(3,CNo("Frequency")) = 2.2
CHDX(4,CNo("Frequency")) = 2.3
CHDX(5,CNo("Frequency")) = 2.4
CHDX(6,CNo("Frequency")) = 2.5
CHDX(7,CNo("Frequency")) = 2.6
CHDX(8,CNo("Frequency")) = 2.7
CHDX(9,CNo("Frequency")) = 2.8
CHDX(10,CNo("Frequency")) = 2.9

But, if I replace CHDX with CHD, the channel will populate correctly.
I wish to use CHDX so my program will run faster.

Thanks
0 Kudos
Message 1 of 2
(3,109 Views)
ChnAlloc doesn't set the actual channel length, only the maximum channel length. As a result, when you try to populate your channel, DIAdem thinks the channel length is 0 and therefore doesn't put the values into your channel.

Add the following line to your code after the ChnAlloc command to fix this:


CL("Frequency")=10


CL is the variable that contains the actual channel length of a channel.


Hope that helps,


Otmar
Otmar D. Foehner
0 Kudos
Message 2 of 2
(3,109 Views)