LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String Output

Well, the Portmon log speaks volumes. Your insistence on using those old wrappers for the serial functions instead of using the VISA functions causes unnecessary serial port initializations, and having the serial port initialization as the first step in your main while loop is also causing that. Here is what I saw at a high-level in terms of sequence of events:

 

  • serial port initialization
  • serial port initialization
  • serial port write 1B 02 41
  • serial port initialization
  • serial port initialization
  • serial port write 53 49 0D 0A
  • wait a while
  • serial port write 1B 02 42
  • serial port reading a response
  • serial port write 1B 02 44
  • serial port initialization
  • serial port initialization
  • serial port write 53 49 0D 0A
  • serial port initialization
  • serial port initialization
  • serial port write 53 49 0D 0A
  • wait a while
  • serial port reading a response
  • serial port write 1B 02 44
  • serial port initialization
  • serial port initialization
  • serial port write 53 49 0D 0A
  • serial port initialization
  • serial port intialization
  • .... (you get the picture)


As far as what's actually coming over the serial port with a read ... I saw six sections in the log file which were serial port captures. I wrote a simple VI (see attachment) to convert the Portmon capture text to ASCII. As you can see from the result of running the VI I attached, none of the captures match what you have shown us so far as what you're supposed to get over the serial port. Now, this could be that Portmon missed some characters (doubtful), or you're not getting what you think you're supposed to be getting, or at least not in the nice little format that you've been showing so far.

You can eliminate the possibility of Portmon having missed some characters by logging the serial port read directly in LabVIEW, as I was doing with the "String Output Capture" VI I uploaded previously. You could do the same thing with the RC1. However, as I've mentioned before, your RC1 VI seems to be based on the assumption that you are reading a full line of text with each Read operation. This is simply not true, and the Portmon log proves it. If you look at the sections where the reads occur, you will see that 0D (a carriage return) does not always occur at the end of the particular read operation. Sometimes it's in the middle, and sometimes it's not even there. In your RC1 VI you are stopping the loop if (a) you've done 11 read operations; or (b) the concatenated string is exactly 77 characters after the "{" character. Neither of these conditions makes any sense. The first condition is unlikely to ever be met, so you would always (practically 99.9999% of the time) default to the "stop after performing a Read 11 times). What's so special about 11? Do you think that corresponds to 11 lines? If so, that is a fundamental mistake. This does not work the same way HyperTerminal does.

 

On a more fundamental level, I'm beginning to question your serial port interface. The actual characters received don't make any sense - there's no pattern to them, and I find it difficult to believe that whatever you're interfacing to would send such haphazard data. I wonder if you might have noise issues on the line. 

Message 51 of 59
(1,396 Views)

Hi Smercurio,

  Thanks for your detailed analysis of portmon data.  Infact the VIs which I uploaded (main VI and RCI.VI) had been used to process the data string from old version of insturment. Now we bought a new version of instrument and the data string format is different from old version.  The major difference in the newversion data out is presence of carriage retuns before, after and sometimes at middle of string which is need to be extracted.  This hold true with your portmon analysis too.  Except this there is no change in the format of the requried string (highlighted as red in my previous posts) on comparsion with the old version.  So I decided to keep the old version VI and trying to extract the required string by making changes in formatting the new version string read out.

 

The setup of the number of lines as 11 and string length as 77 are meant for old version alone.

 

In your understanding could you suggest any way to extract the string by modifying the old VI?

 

Thanks

 

Senthil

 

 

0 Kudos
Message 52 of 59
(1,381 Views)

Hi Smercurio,

  I tried using 'spread sheet to array.vi' to process the string read out. Now it is working. I could able to get the array with string data read out (check the attached VI). Sorry this has been suggested by you and Va dave initially at start of my problem. unfortunately I could not able to arrive this solution at that time.  Ok. Now my quetion is how could able to seperate my required string out of array?

 

I could not use index array as you know we are not aware of the consistency of data out.  Also sometimes due to presence of return carriage on mid of stirng data out, the string could be divided in to two portions and seperated in two consecutive cells of array. Is there any way to sort the particular cells containing the string and concanate to a single required string.

 

Thanks

Senthil

0 Kudos
Message 53 of 59
(1,369 Views)

To be honest, I don't know what that is trying to accomplish, since there are no spaces in the data that you're reading. Frankly I've given up trying to understand your code since you only seem to listen to part of what we say anyway. For instance, your RC1 VI is still set up to stop after 11 reads, even though I've told you many times that a read operation is NOT the same as reading a full line in this case. 

 

Fundamentally, if you want to read based on lines then you need to change the way the serial port initialization is done. You have to use the NEW serial port initialization which allows you to set the character that VISA Read should use to end a read operation. You can set enable termination to True, and set the termination character to be 0D (carriage return). This means that VISA will keep reading until it sees a carriage return. This will eliminate the need to checking for the available bytes at the port. It also means that you HAVE TO CHANGE TO USE THE VISA FUNCTIONS DIRECTLY. If you don't, then the "Serial Port Write" VI will reinitialize the port and potentially change your configuration. 

0 Kudos
Message 54 of 59
(1,356 Views)

Hi Smercurio,

  Sorry. i dont know much about VISA functions. I have modified the existing 'Initalize serial port.vi' to 'Configure serial port.vi' including your suggested settings. Please check the attachment if it is ok. What modificiations do I need to make in sub-VI (i.e. RC1.vi).

 

Thanks

Senthil

Download All
0 Kudos
Message 55 of 59
(1,341 Views)

Hi Smercurio,

  Also suggest me a way to extract the required data string from the array of strings (in RC1.vi).

 

Thanks

 

Senthil

0 Kudos
Message 56 of 59
(1,335 Views)
I have no idea what to change it to! The Portmon log you captured shows no pattern - at least nothing that matches what you've shown, so I seriously doubt you are correctly interpreting what you're supposed to be getting over the serial port. You've said before you don't get carriage returns in the middle of a sequence of digits, yet your previous samples clearly indicate you do, and the Portmon log shows that as well. You said that the length of 77 was for the previous version of the "widget" that you're talking to. What is it now? Is that what the documentation says? Have you verified your serial port settings against the documentation of the device you're talking to?
0 Kudos
Message 57 of 59
(1,319 Views)

hi

 how can i read a data from string.my output string looks like.:

for example

{<V01/DST62/SRC01/PT08/DT01><C04/R01/A00><P120.002.001/R001/C001><2000>}:{<V01/DST62/SRC01/PT08/DT01><C01/R01/A07><P120.003.001/R001/C001><6>}u and so on.But i need only the value  2000 and 6.i have to analyse more than 20 such output string.how can i read these value in my front panal? Thank u.

 

Thakur

0 Kudos
Message 58 of 59
(895 Views)

@tadhika wrote:

hi

 how can i read a data from string.my output string looks like.:

for example

{<V01/DST62/SRC01/PT08/DT01><C04/R01/A00><P120.002.001/R001/C001><2000>}:{<V01/DST62/SRC01/PT08/DT01><C01/R01/A07><P120.003.001/R001/C001><6>}u and so on.But i need only the value  2000 and 6.i have to analyse more than 20 such output string.how can i read these value in my front panal? Thank u.

 

Thakur


Please do not hijack this thread. You are asking an unrelated question. Create your own thread with your request. You will need to provide more details to provide a solution. Such as: how do the contents of the string change? What parts are always fixed. Do not provide an answer here. As I said, start your own thread and provide the additional details.

0 Kudos
Message 59 of 59
(893 Views)