05-07-2016 10:51 AM
Hi everyone,
I have a really, really odd bug. I have a LabVIEW VI which changes the voltage of a channel on a power supply unit. I have a start voltage and a stop voltage and use a while loop to increment the device. E.g. if I want to scan from 1.2 V to 2.2 V in 0.2 V incremements the program will end when "Current Voltage" = "Stop Voltage". And this works fine!
However, when I start -3 V and want to stop at say -0.8 (again in 0.2 V incremements) the program does not stop when "Current Voltage" = "Stop Voltage". I have checked with the probe near what should be the end of the run and -0.8 V is going in both of the "Equal-to" comaprison operator inputs, but this deson't trigger a true result.
This is very strange to me. Espeically as if I go from -0.8 V to -2 V but decrement by -0.2 V the program stops correctly!!
I am very puzzled!!
Cheers!
Solved! Go to Solution.
05-07-2016 11:01 AM
05-07-2016 11:03 AM
Ahhh, okay!! I did try searching the forum for a similar problem but couldn't find a similar problem. If you know of a relevant thread could you point me to it? Thanks!
05-07-2016 11:10 AM
05-07-2016 11:10 AM
Would I be correct in thinking that I should use one of the conversion fucntions like "fixed point precision"?
Cheers
05-07-2016 11:14 AM
For anyone who stumbles across this post:
Thanks to Mike for the pointer!
05-07-2016 11:39 AM
@quantisedpenguin wrote:Would I be correct in thinking that I should use one of the conversion fucntions like "fixed point precision"?
No. Just use the In Range And Coerce to look for a range. Since you are going in steps of 0.2V, check to see if you are in the range of your final voltage +-0.05V. So if your final voltage is 2, look for the value to be in the range of 1.95 and 2.05.
05-07-2016 11:53 AM
Thanks for the help. what is the best way to make this robust for any current voltage and any stop? The voltage supply is only capable of 1 mV precission so I should use somethink like Range and coerce with input of (Stop voltage + 0.0001) for upper limit and (Stop voltage - 0.0001 for lower limit)?
I attach what I think the solution should be!
Cheers!
05-07-2016 01:07 PM - edited 05-07-2016 01:07 PM
You should do something more like this.
05-07-2016 01:31 PM
The problem with these solutions is the fact that they won't do any good if e.g. the voltage changes very rapidly and one pont is still below, but the next point is already above the termination condition. (These things can happen in the presence of poorly chosen inputs (e.g. increment of 0.3, stop at 1), noise or hardware malfunction.) For example if you are ramping up from zero volts and want to stop at 2V, but the successive measurements are 0.4V, 1,2V, 1.9V, 2.2V, ....1000V, it will never stop and possibly fry the device. Ramping up, you need to stop at ~equal or larger, and ramping down, you need to stop at ~equal or smaller. Make it bulletproof!
Looking at your question, it seems that your issue does not involve any measurement and is purely mathematical. The correct solution would be to reformulate the problem and calculate the number of steps instead. The number of voltage steps can be calculated from first principles form your inputs and since it is an integer, there are no resolution issues to deal with. You could even pre-calculate all voltages as an array (look e.g. at "ramp pattern.vi"), then you can simply autoindex on a FOR loop and there is not even a need to inspect any termination conditions ever.