LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DSC - Write Trace - Bit Array or Logical

Hi,

we are trying to write digital signals to a citadel database. The polymorphic function "Write Trace.vi" has the types logical and bit array.

First of all I have created a new database and tried to write 10 digital signals of type boolean to the database. Unfortunately I get an error: "SPW_WriteBool.vi:2". I only can write the data into the citadel database if I convert the boolean to 0 and 1 values and write them via the numeric type. But this causes an overhead of factor 32.

Is there a sample vi of using the "Write Trace.vi" function of type Logical or Bit Array. I've noticed that the trace which I have created is a analog one of type double. In another database of our company I've found a discrete trace of type double. Is this the problem?

Kind Regards
Joachim
0 Kudos
Message 1 of 11
(8,016 Views)
I am unable to reproduce the issue that you describe. We do not ship an example that writes a logical or bit array trace, but I've attached a screenshot of a simple VI that writes a single channel of a digital waveform to a trace. If that doesn't help, please post the numeric error code that is being returned by the Write Trace VI, and, if possible, a screenshot of your VI.

Thanks,

--J.D.
0 Kudos
Message 2 of 11
(8,010 Views)
Hi,

Many thanks for your reply. I've used the wrong type in the "Open Trace.vi" function. Our application is very storage intensiv. We have 32 digital channels which are logged round the clock with 4kHz. That means that we have to save as much storage as possible.

In the attached vi I generate boolean-arrays with 20000 values. I execute that loop 500 times. This 1.000.000.000 values need 20 files in the filesystem. When I calculate the needed storage of each value the result is an int16 --> 1.000.000.000 * 2 / 1024 /1024 ~ 19 MB. Is my calculation wrong? Can't I store more digital values in an int16?

Kind Regards,

--
Joachim
Message 3 of 11
(7,991 Views)
Each write operation stores both the digital value and a timestamp. The uncompressed size of the LabVIEW timestamp is 16 bytes, so 2 bytes per point is a reasonably good compression rate. I can see why you are concerned, however. Even if we only required 1 bit per value, your application would generate more than 1Gb of data per day.

You can set the precision of the stored timestamp using the "trace attributes" input of the Open Trace VI. The default precision is 1ms. If you don't require that precision, setting a higher value will save you a byte here or there. Running your example with a precision of 1s saved approximately 4kb over the length of the run.

I don't know how the data in your application is formatted, but you might also consider using a writer of type Variant and logging your values as arrays. Using your example, but logging 500 arrays of 20,000 values each, approximately 1 byte is required for each value. This method will not provide individual timestamps for each value (you will get a timestamp for each array), and will require you to write your own code for retrieving and displaying the data, but it is considerably faster with a smaller disk footprint.
0 Kudos
Message 4 of 11
(7,981 Views)
I just realized how to do better. I should have thought of this in the first place. You application has 32 channels. If you pack those 32-bits into a U32 value, you can log the data using the bit array type. Using your example, I get around 5 bytes per 32-channel value, or around 1/6 of a byte per single-channel value.
0 Kudos
Message 5 of 11
(7,980 Views)
Thanks a lot for your reply.

When I pack 32 digital signals into an U32 I can't view the result with the MAX-Studio, isn't it? It would be ok if I can programmatically "decode" the data with the "Read Trace.vi" function, but how? There is a shared variable necessary, but why?

Enclosed is a screenshot of my VI.

Kind Regards,

--
Joachim
0 Kudos
Message 6 of 11
(7,975 Views)
Unfortunately, you will not be able to view the data using MAX with any of my suggested packing schemes.

The "shared variable name" input to the Read Trace VI could also be called "trace name". You only need to provide a URL string for the trace in the format:

  "\\localhost\process\trace"

Where "process" and "trace" match the Process Name and Trace Name inputs to the Open Trace VI.
0 Kudos
Message 7 of 11
(7,971 Views)
Many thanks for your help. MAX would be a nice and easy way to view the data, by the way, I try to view them with the Mixed Signal Graph. I am very new to LabVIEW and I am fighting now in correct reading of my data. I have 32 digital channels - each value of them is packed in an U32. When making a loop of my example 2 times for each channel should contain 2 values. But how can I program that the first boolean of the U32 is part of digital channel 1 - second boolean is part of digital channel 2 and so on? I've read that I can only transpose 2D arrays. Enclosed I've programmed the visualization of 2 digital channels containing 32 datapoints. But the result should be 32 channels with 2 datapoints.

Kind Regards,

--
Joachim


0 Kudos
Message 8 of 11
(7,964 Views)
The attached diagram should do what you want. My example returns the first 100 points in the trace.

When you drop the Convert to Dynamic Data node, be sure to select 2D array of scalars - columns are channels.
0 Kudos
Message 9 of 11
(7,950 Views)
Thanks a lot for your help. That's it. I've thought a little bit to circumstantial.

Kind Regards,

-- 
Joachim
0 Kudos
Message 10 of 11
(7,944 Views)