12-03-2019 03:01 PM - edited 12-03-2019 03:01 PM
Greetings everyone.
I have a program for interpolation of a monochromator step motor calibration table. The program takes the value of wavelength next to which monochromator at is and number of steps needed to reach that value. And then makes a subtable with interpolated values of wavelengths and steps to make multiple measurements for photoconductivity spectrum with delta being an interval between interpolated values of wavelengths. In the end of program I have an indicator for next value of wavelength which I move to at the next iteration of interpolation in the main program. Also in that program I made a check for initial wavelength value of current measurement iteration being higher than the one measurement has to stop, the latter I set manually.
And so getting to the problem. During the test experiments of obtaining photoconductivity spectrum I noticed that the measurement stops not at the wavelength value I set but at the next one. So I decided to check the condition satisfaction I mentioned above. It was found out that somehow after being moved to the required value it is not equal to one I set, e.g. 270 =/= 270. I moved to the interpolation program and modified it to test the same without executing the main program (Block diagram on the screen). And so the error keeps happening whether I play with representation (DBL, I32 and so on) or try to write nonsignificant zeros into the check control or anything else. Everything is correct only if delta = 1.
And so I do not know how to get rid of the problem. I know I can evade it for instance by setting a previous wavelength value to what I want to stop at, but I want to make a qualitative program without having to keep that in mind every time. So I am open to every solutions.
Solved! Go to Solution.
12-03-2019 05:27 PM
The diagram shown is to messy to really tell what's going on from a picture alone. We prefer the actual VI and some typical data. Also set all controls to reasonable defaults before saving. Also tell us what result you expect.
Again, please attach your VI!
12-04-2019 01:45 AM - edited 12-04-2019 01:46 AM
Hi Nodrael,
@Nodrael wrote:
It was found out that somehow after being moved to the required value it is not equal to one I set, e.g. 270 =/= 270.
NEVER compare floating point numbers for equality! (Learn about IEEE754/854 definitions, rounding rules and accuracy of floating point numbers…)
One more item: that "initial wavelength" local is not needed: use more wire!
12-04-2019 03:23 AM
Hi, altenbach
Here is my program. In this case the "wavelength to" value has to be equal to next to "initial wavelength" value in the calibration table. Also there is a part of the table I use for testing and compiling.
12-04-2019 03:34 AM
12-04-2019 04:09 AM
12-04-2019 11:12 AM
The answers to all my questions are simple numbers, not long confusing paragraphs. 😉
Given the current file:
If you don't initialize the shift register, it's initial value will be the last value from the previous run. It will only be zero after the first loading and after recompile.
If all values are integers, why is all your code orange???
What do the values in the second column represent?
You are making a lot of assumptions about the initial data, e.g. that the initial wavelength actually exists in the file, that all data in the file are integers, and that the spacing between wavelength in the file is exactly one. What should happen if any of those assumptions are not true?
There are better and simpler ways to interpolate.
12-04-2019 11:29 AM
Your problem descriptions is still very unclear.
Here is a quick draft that might give you some ideas how to simplify. You still need to deal with the exceptions mentioned.
12-04-2019 11:48 AM
As I mentioned above the program itself works fine. The problem occurs only when it's needed to compare the value contained in "wavelength to" indicator with the preset one. If you try to create a double numeric control and write there, for instance, 359, it will not be equal to 359 in the indicator. That was the original problem.
12-04-2019 11:54 AM
You cannot compare floating point numbers for equality.
https://floating-point-gui.de/errors/comparison/