LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial read parse problem

Solved!
Go to solution

Good morning,

 

I trying to use VISA to talk to an IPS power supply.

The communication now works perfectly but I’m struggling to parse the data in a suitable format.

I require just the voltage output but it seems to be interspersed with zeros.

Any suggestion as to how I overcome this issue.

 

Thanks  

Front panel output.JPG

VI image.JPG

0 Kudos
Message 1 of 8
(2,034 Views)
Solution
Accepted by topic author Simon-lee

Hello, Simon-lee.  I see that you got @crossrulz, the Forum's expert on all things Serial, to help you with the VISA side of communication with the IPS-603.  What might (?) now be happening is that you are getting responses back, but maybe are parsing the returning data incorrectly.

 

Here's my suggestion:  Make a copy of your Volt-Read program.  Delete the While Loop (so you only do one read), and delete everything below the Error Line (no parsing).  Attach a String Indicator to the Read Buffer Output, set its "Appearance" Property to "Backslash Code" (so we can see \13 and \10, if present), and run the Program.  Expand the String Indicator so we can see the entire String.  Note that if it doesn't "look like a String", you might need to connect a "String to Byte Array" function to the Read Buffer output and display (perhaps in Hex) the resulting Byte Array.

 

One other thing to try is to see if things work better if you use <LF> (0x10) instead of <CR> (0x13) as the VISA termination character.

 

Sometimes just seeing how the data actually look can be a great help!  Since it is either going to be a readable (I hope) String or a short list (50 elements, at most) of U8s, you can even attach a "picture" (I know, I usually cry when pictures are attached) and I'll be happy ...

 

Bob Schor

 

Could you take the output of your VISA Read (of 50 characters) and save it as a String Indicator?  Set the "Appearance" Property of this Indicator to "Backslash Codes" (so we can see \13 and \10, if they are present) and can see all the other characters in the String.  For the purposes 

Message 2 of 8
(2,020 Views)

Do you have a link to the manual?  We need a lot more information on how the messages and replies are formatted in order to give any real advice.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 8
(1,990 Views)

Hi Bob Schor,

 

Thank you for you interest, Yes @crossrulz was a massive help. 

I have added some addition snips - one with the original termination character - and a second with no termination.

On you second suggestion of subsituting <LF> for <CR> I returned to my original vi and made the change. Hey presto it works, I really happy it works. I have also added some additional HEX and \ codes if that might explain why. 

I can now keep my project moving and a bit shout out to you and crossrulz, your help and advice is much appreciated.

 

Regards

0 Kudos
Message 4 of 8
(1,986 Views)

Hi Crossrulz,

 

I have attached the manual , I had a responce fron Bob Schor and acting on his suggestion I repaced the <CR> with <LF> and that appears to work. I.m not sure why as your solution was correct to the printed manual but I have a working solution. I would like to thank you for all of your advice and support.

 

Regards

0 Kudos
Message 5 of 8
(1,981 Views)

String%20to%20byte%20array%20with%20no%20ternination%20and%20HEX

I find it weird there are two Carriage Returns.  It is like the supply is terminating the response with just a Carriage Return (which is why I previously told you to use that as the termination character) and then appending a Carriage Return and a Line Feed to complete the message.  Therefore, you should be using the Line Feed as the termination character.

 

EDIT:  From the Manual

"The power supply has 25 commands available. Every command is end up with (ASCII 0Dh or ACSCII 0D 0A acceptable). The return message of the power supply is CR/LF (ASCII 0D 0A)."


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 8
(1,979 Views)

@crossrulz wrote:

String%20to%20byte%20array%20with%20no%20ternination%20and%20HEX

I find it weird there are two Carriage Returns.  It is like the supply is terminating the response with just a Carriage Return (which is why I previously told you to use that as the termination character) and then appending a Carriage Return and a Line Feed to complete the message.  Therefore, you should be using the Line Feed as the termination character.

 

EDIT:  From the Manual

"The power supply has 25 commands available. Every command is end up with (ASCII 0Dh or ACSCII 0D 0A acceptable). The return message of the power supply is CR/LF (ASCII 0D 0A)."


Whenever I see weird stuff like this, it makes me think that the communication was originally intended to be used with a terminal program, and someone made a hasty adaptation (or sometimes even NO adaptation) to automate it.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 7 of 8
(1,963 Views)

Hi Crossrulz,

I've punched in some of the commands with the following outputs.

V\r  = V23.28\r\r\n

L\r =  V23.28A0.000W000.0U60I2.11P127F000010\r\r\n

V\r =  V23.28\r\r\n

A\r =  A0.000\r\r\n

W\r = W000.0\r\r\n

U\r = U60\r\r\n

F\r = F000010\r\r\n

 

All have that odd double \r - I guess its just one of those undocumented idiosyncrasys. It was a cheap unit and its quite slow responding (baud rate is only 2400) so you get what you pay for. On the plus side I can talk to it now, thanks to you and others on this forum. 

0 Kudos
Message 8 of 8
(1,923 Views)