Hi everyone. I'm trying to output the results in the while loop via an AO port. But I could only output the first data in the loop. I don't know where I go wrong.
Any feedback could be helpful.
Attached is my code.
Thanks.
Are you getting any error messages?
What kind of value is being written to the analog output?
I see you calculating a value for center of gravity and dividing it by 2. Then writing that value to the analog output? What is the result of that calculation? If that value is outside the range of 10 to -10, then you will get an error because you are writing a value of CG into a function that expects a value in Volts, and a voltage that is in the range of what it can put out.
I didn't receive any error message.
The result is not divided. I add "sum" and "multiple & sum" just to check the calculating process. The "center of gravity" is what I need.
I cleaned up your VI to get rid of your backwards running wires.
You say you aren't dividing? That is not what I see? Check the notes I placed in the snippet!
Have you done any probes to see what values are on the wire? Specifically the error wire and the double that goes into the DAQmx Write?

And what is the value on that orange wire going to the DAQmx Write?
And to go back to your original question where you said "But I could only output the first data in the loop".
How do you know it is only outputting the first data? What is your evidence that something isn't working right?
I delete the DAQmx Timing and the vi runs well.
I suppose the problem is that the clock could only serve one AO, one AI?