07-06-2010 09:13 AM
Hallo,
zur kleinen Info vorab, ich arbeite noch nicht sehr lange mit LabView 😉
Ich habe folgendes Problem:
Beim Ansteuern einer TLS habe ich eine Wellenlängen Abfrage eingebaut. Diese befindet sich in einer While-Schleife. Das Programm springt aus der While-Schleife raus, wenn die aktuelle Wellenlänge gleich der Stop-Wellenlänge meines Sweeps entspricht.
So weit so gut. Nur leider funktioniert das nur für manche Sweep-Bereiche. Bei den meisten jedoch bleibt das Programm in der While-Schleife einfach hängen. Da mir nicht bewusst war, warum, habe ich einfach mal zwei Anzeigeelemente für die beiden Wellenlängen (Ist-und Stopwellenlänge) eingebaut. Diese habe ich dann so konfiguriert, dass sie mir etliche Nachkommastellen anzeigen und schon hatte ich den Fehler gefunden.
Die beiden Double-Variablen unterscheiden sich Tatsächlich in der 22/23. Nachkommastelle.
Nun meine Frage: Wie lässt sich des Problem beheben? Gibts so eine Art "Rundungsfunktion" für Double-Variablen? Ich könnte theoretisch die Abweichung von der Stopwellenlänge abziehen, aber die Abweichung ist für jeden Wellenlängenbereich unterschiedlich. Daher funktioniert auch das nicht 😞
Ich bin für alle Ideen und Hilfen sehr dankbar!
Viele Grüße
07-06-2010 12:02 PM
Please attach your LabVIEW code. Your chances for help will be better.
07-06-2010 12:12 PM - edited 07-06-2010 12:12 PM
You can calculate the number of iterations (N) from x0 and dx, assuming equal wavelength spacing.
Now use a FOR loop. 😄
07-06-2010 12:19 PM - edited 07-06-2010 12:28 PM
Hallo Photonics,
as this is an English-speaking forum you should try to ask in English for the next time... (For a German forum you could use this link!)
It also helps a lot when you attach your VI!
General answer:
Floating point numbers are prone to rounding errors - that's what you saw when showing 20+ digits of the number. This is inherent to those numbers and no problem of LabVIEW. You will find a lot of similar threads on exactly the same topic in the forum. To avoid such problems you should never ever compare floating point numbers for equality! Possible solution: Always compare using ">=" or "<=" or use the InRange function to check for an interval of numbers.
Here's another thread on the same topic!
07-07-2010 05:29 AM
Hey, thank you for the useful help 😉 and sorry, I thought this is a mixed forum.
07-07-2010 05:56 AM
Didn't even notice the OP was in german until you pointed it out.....
Guess that qualifies me for "fluent" right?