paulneal Posted September 20, 2010 Share Posted September 20, 2010 Is it possible to change a logged value within a channel's history? i.e if temp[12] = 234 is it possible to change that to 324? cheers Paul Link to comment Share on other sites More sharing options...
AzeoTech Posted September 21, 2010 Share Posted September 21, 2010 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 More sharing options...
dmdodd Posted October 23, 2010 Share Posted October 23, 2010 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 endif " 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, Dan Link to comment Share on other sites More sharing options...
AzeoTech Posted October 23, 2010 Share Posted October 23, 2010 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 More sharing options...
dmdodd Posted October 25, 2010 Share Posted October 25, 2010 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! Dan Link to comment Share on other sites More sharing options...
AzeoTech Posted October 25, 2010 Share Posted October 25, 2010 I understand. If you are a C++ programmer (as I am), its often best to do most everything in script (sequences). Most of the other stuff is there to make it easier for the non-programmer. I'd avoid V channels. Link to comment Share on other sites More sharing options...
dmdodd Posted November 23, 2010 Share Posted November 23, 2010 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? Thanks, Dan Link to comment Share on other sites More sharing options...
AzeoTech Posted November 23, 2010 Share Posted November 23, 2010 Actually, that expression can be used directly as a Conversion and applied directly to one channel. If you need more than that, I recommend simply upgrading so you have more channels. Link to comment Share on other sites More sharing options...
dmdodd Posted November 23, 2010 Share Posted November 23, 2010 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 More sharing options...
dmdodd Posted November 23, 2010 Share Posted November 23, 2010 Oops, I meant the channel is A to D, sampling every 0.1 seconds. Link to comment Share on other sites More sharing options...
AzeoTech Posted November 23, 2010 Share Posted November 23, 2010 Use boolean math instead: (value * 50 - 50) * (value >= 1.1) Link to comment Share on other sites More sharing options...
dmdodd Posted November 24, 2010 Share Posted November 24, 2010 Awesome! Worked perfectly. Didn't think we could do that with channels. Can we use "V.Channels" in conversions also?? Link to comment Share on other sites More sharing options...
AzeoTech Posted November 24, 2010 Share Posted November 24, 2010 You can reference a V channel from a conversion, yes. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.