06-26-2011 10:10 AM
Hi, I am using Labview to read and write continuous data from a couple of sensors. I am able to read the data continuously (inside a while loop), I would also like to change the value going to my PIC almost on each iteration (depending on the input read from the sensors), but it seems that the value does not change with the iteration automatically. If I do it manually , stopping and changing the value every time, it works but if I would like to run it continuously it doesnt ( I tried it just by using a random number to see if it would change it on the pic). Attached is the file I am using, I am currently applying the "advanced serial vi" and just did small modification to graph values and to save them but as you can see there is a constant *M9/n" rto change the value going to my pic. My first approach would be to move inside the VISA close, so then the value updates, is that feasible?
06-26-2011 10:40 AM
The reason nothing is changing in writing out of the serial port is because you have a constant going to the VISA Write. You even said so yourself in your own message. So what do you expect to happen differently on each iteration? Moving the VISA close inside the loop isn't going to do anything differently, except possibly slow down your code, or cause you to lose any data that might arrive from your device.
You have a string control called "string to write" that is not connected to anything.
What are your really trying to write to the device? What are you trying to change?
One other possibility is that you have *m9/n in the constant. Is that what you really want to write on every iteration without changing? Is the /n supposed to be the line feed character? You have your constant set on normal display which means you are sending 2 characters, a slash and an "n". If you want to send a new line character, you need to change your constant to /codes display and enter the /n there.
06-26-2011 10:54 AM
Hi , many thanks for the reply. Yes I know I have a constant , that was the example of how my system works. The problem is when I change that constant to lest say a control. The *M0\n has to oscillate between 0-255 , 9 was just a random number. Anyway the problem is taht when I start to run my vi and I would like to change that value from *M0\n to *M37\n (or whatever) my pic is not taking the number. I used the constant bvecause if I stop the program change the constant and run it again it works but not if I want to change it during operation. (I can check if that value is changing because the PIC reads that value and change the output everytime I change it, and it works perfectly on the hyperterminal). I am sorry if I was not clear. I have also set the write string to /codes display so I dont think that is the problem. I attach the new file with the control option. I know my program will become slow if I move the close VISA inside, that's why I am wondering if there would be another solution. I hope to be clearer this time.
06-26-2011 11:19 AM
Are you saying you want to programmatically change the number that is in the string that you write out of the serial port? Then you need to program it that way.
See the attached. (I also cleaned up the code since there were a lot of hidden wires.)
I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
06-26-2011 11:26 AM
Awesome, I will try this tomorrow at the lab. Many thanks for all!
06-27-2011 04:15 AM
Hi , I tried the program you sent me but it doesnt seem that the pic is receiving any new information. I tried again with the hyperterminal and I am able to change it, is tehre any chance there is another solution? Attached are the output data that I get from hyperterminal and the one from labview. On the labview sile that you sent I only added an indicator of what goes to the VISA write. Many thanks again.
06-27-2011 09:08 AM
You'll have to explain what the problem is. With the screenshots you showed, the LabVIEW results look pretty much like your hyperterminal results.
06-27-2011 10:12 AM
The number at the end of the row on the labview output does not change with each iterarion, meaning that it is not sending back the information to the pic (it remains in zero).
06-27-2011 12:20 PM
It repeats at 0, a lot of times on your hyperterminal screenshot. It also has repeats of the values 10 and 60.
Do any of the other values changed on your LV screen?
I have no idea what any of the numbers are supposed to mean or what your Pic does. I'm afraid I can't be of anymore help.
06-27-2011 02:42 PM
The value at the row on the terminal was changed manually to those values (10, 60), I was expecting to change that value on LV screen as well. As I have teh code on labview (as you send it to me) the value should change from 1 to 256 on each iteration and therefore the last number of the row on LV but it doesnt and it just remains on zero. Many thanks for the help anyway =).