Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't read each iteration value of for loop

Solved!
Go to solution

Hiiii...

 

I'm developing a front end which reads the values from serial port and dispaly it on frontpanel.

 

The data is of 16 channels value which is in string form. I have seperated that string to read individual channel's data but at the end of for loop i can read only one channel data for one iteration and also I have to store each iteration value to a text file.

 

I'm new to labview. Please help. I have LabVIEW 8.0.

 

Attached herewith is my application code.

 

 

0 Kudos
Message 1 of 15
(4,362 Views)

The 1 time for loop will only run once only giving you ONLY one of your results.

 

BadForLoop.png

 

I am not to sure what you were trying to do with this.

Were you tying to write single lines of text to your file? Look at "Write To Spreadsheet File" fuction.

Omar
0 Kudos
Message 2 of 15
(4,354 Views)

Hey I got the solution..Smiley Very Happy

 

I used case structure to store 16 different values at different location. Using for loop i can't store seperate values so, i got confuse.

 

Thaaaaank Youuuuuuu,

 

Regards,

Manisha

 

0 Kudos
Message 3 of 15
(4,337 Views)
Solution
Accepted by topic author Man_Can

That sounds pretty inefficient. Why do you use a case structure? Why don't you post your code.


As for the original code, were you trying to run this using the Run Continuously button? I ask because I don't see an overall loop, so it wasn't clear if this was intended to run as a simple subVI or "on-demand". If it's meant to run continuously until you stop, DO NOT USE THE RUN CONTINUOUSLY BUTTON. Use a while loop in your VI. Be sure to place the initialization and close outside of the loop - you do not need to initialize and close the serial port each time you loop around.

0 Kudos
Message 4 of 15
(4,328 Views)

Thanks for your reply.

 

As I have already mention m new to labview, every time m chaging my code as i found new functions.

 

Sorry, but m not getting you. Everytime when I open my code I have to enter the data as well as 16 paths for serial communication. Can I store that permenatly? Is there any way to used that 16 channels value directly on frontpanel of second VI? I have developed two VI, one for serial communication & data writing into file and other is for reading that values n displaying it. M posting you both the VI. I have to read temperature values, its setpoint, hysteresis & depending on that i have to work on alarm conditions. The frontend is incomplete m working on it.

 

Please do the needful.

 

Thank you,

Manisha

Download All
0 Kudos
Message 5 of 15
(4,320 Views)

Your approach is quite flawed. You do not need to write data to file just to have the data read in another VI. There are other mechanisms for that, such as queues. I'm not sure what you are intending to do with that "Front End" VI. How large of a monitor are you expecting people to have?

 

I would suggest looking at the producer-consumer architecture. The producer loop can read the data from the serial port and put the data into a queue. The consumer loop can simply read the data from the queue and update the indicators. I would suggest considering using a 1D array or 2D array for your data since you are basically talking about data from 16 channels. The link for the producer-consumer architecture is supposed to be this: http://zone.ni.com/devzone/cda/tut/p/id/3023. However, at the time I'm writing this the link is broken. You can create the basic pattern from LabVIEW using the templates (File -> New ...). 

0 Kudos
Message 6 of 15
(4,313 Views)

Hey I saw that Producer/Consumer architecture but m not getting, how it can be use in my code. 

 

M facing one more problem in serial communication that, I have enabled the End Read On Termination Char, In continuous run mode the string is not displayed on read string. After passing one character m getting string of 64 char, that string is displayed only for some seconds. I have to read that data continuously in order to display it.

 

How can I pass end of read char to store that string? 

Thank you for your reply.

 

Regards,

Manisha

0 Kudos
Message 7 of 15
(4,294 Views)

Hellooo to all,

 

Guys pls give me some solutions I have to complete my code asap.Smiley Sad.

 

Now i want to pass one number, that indicates the enabled channels say if i pass 6 number then 6 channels are enabled n that many channels are displayed i.e. Channels 1 to 6 are enabled.  How can i do this? Maximum no of channels can be enabled are 16. 

 

Please help me out with this n my previous post.

 

Thank you,

 

Manisha

0 Kudos
Message 8 of 15
(4,273 Views)

Do not use Continuous Run mode.

 

Put the parts of your code which need to repeat inside a loop. This likekly will be mostly the Read case structure. If you know how many times it will run use a for loop.  If the number of iterations is unknown in advance, use a while loop.  In either type of loop use a shift register to pass data from one iteration to another.

 

Lynn

0 Kudos
Message 9 of 15
(4,268 Views)

Thanks for ur reply Johnsold.

 

That problem is solved. Now m facing another problem that serial communication timeout is 10 sec & my device gives me output in 5 sec, but still I can't read values in this 10 sec. Why is it so?? How do I can check that timeout is 10 sec.?

 

M posting my final code please lemme know any improvement in that & m still not getting how can I take that out put to other VI using queue?? The Front End VI is still not complete. I have to take data from RTD Scanner VI n display it on Frontpannel.

 

Thanks,

Manisha

Download All
0 Kudos
Message 10 of 15
(4,255 Views)