06-01-2008 02:51 PM - edited 06-01-2008 02:53 PM
06-01-2008 02:57 PM
06-01-2008 03:19 PM - edited 06-01-2008 03:23 PM
06-01-2008 03:26 PM - edited 06-01-2008 03:30 PM
06-01-2008 03:36 PM - edited 06-01-2008 03:38 PM
Are you sure you aren't getting two data points per serial read? What is that subVI you have in the lower left corner?
You have a couple problems with your code. First, a for loop with a 1 tied to the N terminal really does nothing but run the loop once. You might as well eliminate that whole structure.
Secondly, and most importantly, you have a possible race condition. Why are you using a local variable "Intensidad"? Just wire in the data from there to where the intensidad control is located inside the loop. The race condition is that it's possible the control gets read inside the loop before the serial port updates the local variable. So you could get stale data meaning it could also be duplicated, and also possible that a data point gets lost if the in one iteration the data gets written then the local gets updated, and in the next iteration, the local gets updated first before the data gets written. You would effectively lose the update in the previous loop iteration.
EDIT, I see Mike got his response in quicker. One other tip would be to puts some probes on some wires to see if you can see the duplicated data while the code is running. Then you may be able to tell where it is originating.
06-01-2008 03:37 PM - edited 06-01-2008 03:40 PM
Hello again, and thanks for your reply. The subvi that is wired to the local variable is used to modify the format of the data that the instrument sends to the PC. That part works just fine, the current reading of the instrument is displayed in the string indicator in the front panel. The problem is that when the user presses the button, the case structure is "TRUE" and executes the for loop.( I added the for loop in an attempt to ensure that the data be written only once, but it didn't work.)
What I don't get is that the characters in the string constant are written only once in the datalog each itteration as it should, while the data in the string indicator is duplicated.
I shall try, as you say, to eliminate the local variable and wire the string indicator directly to the array and see what happens. Thank you both for the advice, I really hope that's the problem.
06-01-2008 03:42 PM