Dobbeljoe Posted March 28, 2022 Share Posted March 28, 2022 After calibrating a displacement sensor it shows that the best results are obtained when splitting the range of the sensor in two parts (range A and range B). In range A, conversion A is the best, in range B, conversion B gives the best results. How can I use two different conversions, based on a button with which I select the range taht I use. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted March 29, 2022 Share Posted March 29, 2022 Use simple boolean math and a flag. So let's say you create a flag called "UseRangeB" that is either 0 for Range A, or 1 for Range B. Use "global UseRangeB = 0" in an autostart sequence to do this. Let's say Range A's conversion is "Value * 2" while Range B's conversion is "Value * 3". The overall Conversion would then be: (Value * 2) * !UseRangeB + (Value * 3) * UseRangeB Quote Link to comment Share on other sites More sharing options...
Dobbeljoe Posted March 30, 2022 Author Share Posted March 30, 2022 Dear Guru, Based on your quick reply (as usual) I created a basic try-out version as attached. Unfortunately I miss something since it does not work as expected. Can you please have a look? Conditional conversion TRYOUT v1.ctl Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted March 30, 2022 Share Posted March 30, 2022 The problem is that you can't have two channels that reference the same I/O point. They are considered the same channel and whether the Conversion is applied is unpredictable because one has a Conversion and the other does not. If you really want to have a raw and converted channel, then you need to create a regular raw channel for the I/O point, then create a Test D/A channel with Timing = 0, and then put code in the Event for the raw reading that stuffs the converted value into the test channel. In this case, you can use iif instead of the boolean math. iif() doesn't work inside a Conversion under the latest version of DAQFactory (something we need to fix...) sensor_output_converted.addvalue(iif(button_state), sensor_output_raw[0] + 10, sensor_output_raw[0] + 50) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.