11-18-2010 06:09 AM
I currently have a requirement to create a time channel in the data portal and subsequently fill it with data. I've shown below how I am currently doing it:
Time_Ch = ChnAlloc("Time channel", 271214 , 1 , , "Time" ,1 ,1) 'Allocate time channel
For intLoop = 1 to 271214
ChD(intLoop,Time_Ch(0)) = CurrDateTimeReal 'Create time value
Next
I understand that the function to create and allocate memory for the time channel is extremely quick. However the time to store data in the channel afterwards is going to be highly dependent on the length I have assigned to the Time_Ch. In my application the length of Time_Ch is variable but could easily be in the order of 271214 or higher. Under such circumstances the time taken to fill Time_Ch is quite considerable. I am wondering whether this is the most appropriate way of doing things or whether there is a more efficient way of creating a time channel and filling it.
Thanks very much for any help.
Regards
Matthew
11-18-2010 07:29 AM
Hi Matthew,
You are correct that there is a more efficient way to do this. I'm a little confused about your "CurrDateTimeReal" assignment-- is this a constant? Most people want a Time channel that counts up linearly in seconds or fractions of a second over the duration of the measurement. But that looks like you would assign the same time value to all the rows of the new Time channel.
If you want to create a "normal" Time channel that increases at a constant rate, you can use the ChnGenTime() function:
ReturnValue = ChnGenTime(TimeChannel, GenTimeUnit, GenTimeXBeg, GenTimeXEnd, GenTimeStep, GenTimeMode, GenTimeNo)
If you really do want a Time channel filled with all the same values, you can use the ChnLinGen() function and simply set the GenXBegin and GenXEnd parameters to be the same value:
ReturnValue = ChnLinGen(TimeChannel, GenXBegin, GenXEnd, XNo, [GenXUnitPreset])
In both cases you can use the Time channel you've already created (which as you say executes quickly) and point the output of these functions to that Time channel by using the Group/Channel syntax of the Time channel you created for the first TimeChannel parameter in either of the above functions.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
11-19-2010 03:10 AM
Hi Brad,
The ChnGenTime function was exactly what I was looking for I think. As I understand my customers requirements they need to create a time channel which increases at a constant rate and therefore this function should fit the purpose.
Thanks in advance.
Matthew