Graph Computed Virtual Channel


Recommended Posts

I personally prefer just creating a Test channel (with timing 0).  Then, use AddValue() on that channel to stuff my calculated data into it.  Graphing it then is no different then graphing anything else.

So, if you had a test channel called "calcedValue" and you wanted to stuff some calculation in there based on a channel called "myChannel", you might go to the Event for myChannel and put:

calcedValue.addValue(myChannel[0] * 10)

Sometimes it can get tricky with the time stamp, so I often force it:

calcedValue.addValue(insertTime(myChannel[0] * 10), systime(), 1)

 

 

Link to comment
Share on other sites

I had already switched to a Test Channel, as you advised.  Attempting to drive from a sequence to generate the data to exercise control over the value stream.

Will attach .ctl file, but be aware I'm still debugging a C1099 error (in line 5 of DataSource).

Frankly, I'm loathe to send you the code I'm supposed to be developing, but up against a looming test session on many product samples.

This TestBed was intended to provide a known-data driver to work out why the MaxPersistent code is malfunctioning in our primary testing tool, but I'm suffering from cascading ignorance ...

TestBed.ctl

Link to comment
Share on other sites

Hi Guru...referencing the Test device above led me to a question.  Is it possible to rename the device to something like "Internal".  The reason I'm asking is that "Test" to me is more like a temp channel for testing purposes and is not a permanent channel..  To me it would be better to name is something like "Internal" or something that indicates that it's a permanent channel.

Can it be renamed?

Thanks...John

Link to comment
Share on other sites

The problem with line #5 is parenthesis location.  I'm sorry I didn't see it in your other posts.  InsertTime() takes three parameters.  You have only one inside the inner (), and then two additional parameters, systime() and 1, inside the outer ().  The inner () is for InsertTime, and the outer () is for AddValue().  Its giving you an operator error because you provided too many parameters to AddValue.

And John: yes, you can rename it if you want.  Just go into testDevice.dds and change the "Test" in the line that reads:

D,0,Test,TestDevice.dll,O

to whatever you want.  Don't change anything else on that line.  Note that this could cause incompatibilities with other DAQFactory applications, etc.  We named it "Test" because originally it was designed for creating test applications without any real hardware.  But, it became useful as a place to stuff data.  And come to think of it, rather than renaming it, you might consider just copying testDevice.dds to say internalDevice.dds and then make the change I recommended, but also changing the 0 to something bigger, like 1000.  Don't change TestDevice.dll, just let both dds files point to the same dll.  Then you'll have two different devices, one named "Test" and one named "Internal" or whatever you want.  They will act the same way because internally they are the same driver.

Note that any time I use a Test device and stuff data in it, you can use any other device you want from the drop down.  As long as the Timing is set to 0 and you never do read() or readGroup() or myChannel = then the driver is never called.  I often do this if I'm using "Test" type channels with real hardware, say, for a calculated value from a real channel.  But for this forum, I try and stay consistent and recommend "Test"

Link to comment
Share on other sites

Presumably none of the attempts I've made to display the Test Channel on the Graph Component in the attached .CTL have succeeded because the Test Channel Timing is set to 0, which is necessitated by the method used to fill it with computed values?

Should Test.Event be used in some way to drive a Graph Trace?

TestBed.ctl

Link to comment
Share on other sites

Actually, they probably failed because your sequence didn't work and so no data was being added to the channel.  Once I fixed the parenthesis issue and ran your sequence, the graph you have on the page started showing a trend.  This is because you used insertTime() to put a time stamp on each data point being added.  Graph's don't care how the data was generated, they just need an X and a Y, or in the case of a trend graph, a Y and corresponding Time, which you created with insertTime(), and truthfully would be created anyway just with AddValue() because a regular channel HAS to have time associated with all values.  The problem is that depending on the math, you can create a situation with addValue() where the time stamp remains the same, and that can't really be graphed, or at least would result in a vertical line.

Timing is just an easy way to tell DAQFactory to query a channel every so often.  

Link to comment
Share on other sites

Hey Guru...duplicated TestDevice.dds and created a internal.dds with the changes you directed.  Works great!!!

One additional question...Under the I/O Type, I see standard data types like string, but not some of the other data types such as int, float, and Boolean.  What I/O type should I use for these types?

John

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.