Channel data correction

Recommended Posts

No. Once its in the Channel's history it can't be changed. You can, however, change it before it gets there if you use a sequence for polling and stuff the value into the channel using mychannel.addvalue(). You also could modify it before it gets put into the History using a Conversion.

Link to comment
Share on other sites

  • 1 month later...

I have a similar question.

Basically I have a pressure transducer (1-5V) that should be reading 0.00PSIG when there's no pressure in the line, but actually fluctuates between -0.5 and about 1.5 PSIG (after conversion).

I have a lot of additional calculations and conversions linked to this pressure which subsequently all fluctuate on-screen (or in some cases display errors, as there's an exponential conversion applied to it, and when the channel becomes negative, the component can't be evaluated).

So I when I know the pressure in the line should be zero, I want to set the channel (that's close, but not exactly 0.000) to exactly 0.000.

I want to do something simple in the "event" for that channel, like:


if(CA_Pressure[0] < 2)

CA_Pressure[0] = 0



It kinda works for a DtoA test channel I made, but if you look in the "Table" tab for that channel, it displays the initial value (e.g. -0.23), and then about 130 consecutive "0".

When saving to a log file, it luckily shows 0, but -0.23 is still logged in the channel's history as it appears from the Channel's table.

(1) I haven't tried this with the actual channel just yet, as I'm prototyping at home and not at work with the Labjack hooked-up, but does the above make sense? Should it work with constantly-coming-in data from the U6 Labjack?

(2) I have a conversion applied to this channel (i.e. I want the pressure 0-200PSIG and not the voltage 1-5V), so when you put script in an "event" section of a channel, does it apply to the pre- or post-converted data??

Thanks in advance,


Link to comment
Share on other sites

Actually what you have will just create an infinite loop and crash DAQFactory. This is because the event gets called whenever you change the channel, which includes when you do CA_Pressure[0] = 0 (which, by the way, is not the proper notation. It should just be CA_Pressure = 0.

Ignoring that, it won't work the same with an input channel because you can't do myChannel = 0 for an input, only an output. You instead have to use myChannel.addvalue(0) to stuff the value into the channel. However, again, you'll have an infinite loop.

So first to answer your questions, then the actual solution:

1) as I guess I just explained, no it won't work. It would work if you set a different channel to 0 or the actual value, but as you'll see below, there is a better way

2) the event occurs post-conversion. You have no access to preconverted data except in a logging set marked to log preconverted data.

Now the solution: use a conversion. This sort of logic can be done in a single expression, using either iif() or boolean math. iif() is probably clearer:

iif(value < 2, 0, value)

Link to comment
Share on other sites

Awesome! Will go try it, but thinking through the math of the "inline if" I'm sure it will.

Again, I'm sorry for so many easy questions, but I'm pretty good at C++, it's just with DAQFactory I never have any idea where the script should go, there's so many options (events, sequences, V_channels, screen component expressions, conversions (as I've just found out!) etc etc!

Thanks again! :D


Link to comment
Share on other sites

  • 5 weeks later...

Okay, so the above solution you proposed putting an inline-if statement in a conversion "iif(value < 2, 0, value)" does indeed work... however, I'm now out of channels, and this operation requires 2 channels (1 is the initial raw signal, the second channel contains the conversion to set the output to zero if below a set point).

Is there anyway this same logic can be applied, but only using a single channel?

Going back to the original post and your response, it sounds like this can only be done with the "myChannel.addvalue()" sequence.

I have not done any sequencing yet, so please give me a quick tutorial on how I can get a raw signal, apply a conversion to it (for example taking it from Volts to a pressure), then apply some Boolean (if it's below a threshold set it to zero), and the stuff it in a channel, using only ONE channel.

And how is this script/sequence called?



Link to comment
Share on other sites

I have DAQFactory Lite and not the money to upgrade again currently.

It doesn't seem to work though. I have a channel named "CA_Pressure_Raw", it's D to A from a Labjack U6.

I have the following Conversion applied to it (that attempts to combine both the volts to pressure and the Boolean), named "Dwyer_0_to_200PSIG"

" iif(value < 1.1 , 0 , value*50 - 50)"

All this does however is display the volts coming in, for example 1.09, and not either "0.00" or the converted pressure e.g. "45PSIG".

Link to comment
Share on other sites


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