DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Channel length too short for calculation

I've just switched from 9.1 to 2010 and I was told that our VBS scripts wouldn't need updating - not so it seems.

 

I have the following piece of code:

 

Call ChnAlloc("Input PSD") 

L1=Cno("RealPart")

L2=Cno("ImaginaryPart")

Call FormulaCalc("Ch('Input PSD'):=Ch(L1)^2+Ch(L2)^2")

 

but this doesn't work anymore. I get an error message saying that channel 7 (Input PSD) is too short for calculation. Previously I would have checked the data matrix but I can't find this anymore so I assume DIAdem works in a different way know. The help files suggest that the channel length option for ChnAlloc is optional so I don't understand why it thinks the channel is too short.

 

Any help appreciated.

 

Thanks, Si.

0 Kudos
Message 1 of 9
(4,816 Views)

Hi SI,

 

You only need a minor addition, and you get the benefit that all new channels can have their length(s) dynamically changed.  Please add this line of code after creating the channel and before the FormulaCalc() command:

 

ChnLength("Input PSD") = NeededNumberOfRows

 

Back in the dark days of the DIAdem memory matrix, DIAdem would by default launch with 60 static channels of exactly 8196 rows each.  As you apparently know, you could customize the memory matrix to have fewer or more channels, and you could change their static lengths assigned when DIAdem launched.  The fully dynamic channel lengths are a vast improvement, but it does mean that for FormulaCalc() commands you need to tell the channel to be big enough first.  Interestingly, none of the ANALYSIS commands require you to do explicitly set the channel length before writing to them-- just the channel calculator.

 

Ask if you have any further trouble,

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 9
(4,813 Views)

Hi Brad,

 

I entered this line of code as you suggest and it didn't work. After checking the help files and finding no reference to 'NeededNumberOfRows' it occured to me that you might be suggesting that I define a variable that represents the required length of the channel. Is this the case?

 

If so, then why is this any more efficient than changing my ChnAlloc statement to read ChnAlloc("Input PSD", 512)?

 

If I defined a variable such as 'NeededNumberOfRows' and set it to a value much larger than I think I will need so that all eventualities are catered for, will I be increasing my file size unneccesarily?

 

Regards,

 

Si.

 

0 Kudos
Message 3 of 9
(4,795 Views)

Hi Brad,

 

I entered this line of code as you suggest and it didn't work. After checking the help files and finding no reference to 'NeededNumberOfRows' it occured to me that you might be suggesting that I define a variable that represents the required length of the channel. Is this the case?

 

If so, then why is this any more efficient than changing my ChnAlloc statement to read ChnAlloc("Input PSD", 512)?

 

If I defined a variable such as 'NeededNumberOfRows' and set it to a value much larger than I think I will need so that all eventualities are catered for, will I be increasing my file size unneccesarily?

 

Regards,

 

Si.

 

0 Kudos
Message 4 of 9
(4,794 Views)

Hi Si,

 

Sorry I was unclear.  I don't know why it is insufficient to just set the length in the ChnAlloc() command.  I agree that this is odd, but you really do need to set it "again" with the ChnLength command after creating the channel.

ChnAlloc("Input PSD", 512)
ChnLength("Input PSD") = 512

I think nowadays you can leave the length in the ChnAlloc() set to 0, but you HAVE to set the ChnLength to the right value if you're going to use that channel with channel calculator equations (FormulaCalc).  Another poster is running into this same issue with setting the channel values with ActiveX from a remote compiler-- same principle.  DIAdem doesn't think the channel has room for this data action without the proper ChnLength() command PRIOR to the data action.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 5 of 9
(4,786 Views)

Thanks Brad.

 

Tinckering has since shown me that setting the length via the ChnAlloc command doesn't work, presumably because it is the maximum channel length that is set and the FormulaCalc command won't accept that in all cases. I had a calculation within a loop that was equivalent to "Channel(X) = Channel(X) + Y * Z" and it wouldn't work on the first loop as Channel(X) had a maximum length of 512 but a length of 0. You are right that the channel length must be set first.

 

This is a right pain and doesn't strike me as 'dynamic'! I've got a lot of upating to do!

 

Cheers,

 

Si.

 

0 Kudos
Message 6 of 9
(4,784 Views)

Hi Brad, me again.

 

I'm running into a similar problem again but this time I thought it wouldn't occur because I wasn't using the calculator. The code is:

 

Call ChnPeakFind("[3]/Time", "[3]/YRate Filt2", "[3]/YR Res X", "[3]/YR Res Y", 1, T1,"Time") 'Setup results channels for Yaw Rate values
chd(2, "[3]/YR Res X") = chd(1, "[3]/COS") + 1
 

 

It seems that referencing the second row of "[3]/YR Res X" isn't allowed because it has a channel length of 1 as defined by ChnPeakFind. Is this the case?

 

Why isn't it dynamic as before?

 

Cheers, Si.

0 Kudos
Message 7 of 9
(4,761 Views)

Hi SI,

 

It wasn't dynamic before, it was static and large enough for your purposes.  You will get the dynamic behavior you expect if you use the new object-oriented approach to channel value reading and writing.

Set XChannel = Data.Root.ChannelGroups(3).Channels("COS")
Set YChannel = Data.Root.ChannelGroups(3).Channels("YR Res X")
YChannel(2) = XChannel(1) + 1

If you continue to use the older ChD() or ChDX() commands, they will continue to be restricted by the ChnLength() property of the channel being used.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 8 of 9
(4,752 Views)

Thanks Brad. Looks like I've got some learning to do. I can't use the new code style yet though because I have to write autosequences that run on both older and newer versions.

 

I'll set the channel length to be of an appropriate size.

 

Cheers,

 

Si.

 

0 Kudos
Message 9 of 9
(4,750 Views)