DASYLab

cancel
Showing results for 
Search instead for 
Did you mean: 

Analysing RS-232 ascii data

Solved!
Go to solution

I have a need to compare incoming RS-232 ascii data to tables or arrays for accuracy. I can generate the data using the RS-232 module but I'm not sure what to do with the incoming data. The commands and the incoming data vary. The data comes in to a string variable. Becuase it varies with the command I'm not sure how to compare it to a lookup table etc.

 

JLW

0 Kudos
Message 1 of 11
(8,375 Views)

Is it all string data? Or is it numeric data?

 

If it's string data, then DASYLab is probably not the best tool to use. 

 

If numeric, I'm wondering why you are using strings? 

 

I have to find a serial port and a loopback connector... I'll run the worksheet with it, and see if I can understand more.

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
Message 2 of 11
(8,374 Views)

Its all string data so far from the serial port. I was thinking of using the strVal command in the expression area to retrieve a number. Or I could try to parse the number out of the serial data coming back from the port. You probably no the parsing commands to retrieve the numeric data from the ascii returns.

 

Where is the info to learn how to parse the incoming data? Have not found that yet. All I need to do is compare either the string data or numeric data (better) to a know value or range of values (pass/fail) and I'm done.

0 Kudos
Message 3 of 11
(8,366 Views)

I'm just so excited about this solution that I'm posting it.

 

There are two ways, one is to only parse the incoming strings for the Current values. That left you feeling like it wasn't a complete solution. 

 

Your current application sends out a series of command strings, and then copies the device responses to Global Strings... 2 or more for each command sent. 

 

All of the lines that have data include the phrase "Current = " before the number and <space>( after it. Because this is well defined, and you can bracked the number, you can extract the value from the string.

 

You can define a global variable to parse the string to find the number using the Define Global String-->Definition function.

 

strval (substr ( ${STR_3}, strind (  ${STR_3}, "Current = ")+10,strind (  ${STR_3}, " (") -${VAR_1}-3 ) )

 

 

To find the help for this, get into the definition dialog for the global variable, click the String Functions button at the bottom and click the Help button in that dialog.

 

See the attached... 

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
0 Kudos
Message 4 of 11
(8,354 Views)

To find the relevant help for the RS232 module, put the mouse cursor into the Measurement Data Format field in the dialog box -- then click Help.

You'll see the help for that parameter.

 

PrintScreen-0031.jpg

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
Message 5 of 11
(8,353 Views)

I get an operator error when I try to paste this command

0 Kudos
Message 6 of 11
(8,342 Views)
Solution
Accepted by topic author wheels1950

There is an error in my formula... it relies on a variable that isn't really defined.

 

So,

 

strval (substr ( ${STR_3}, strind (  ${STR_3}, "Current = ")+10,strind (  ${STR_3}, " (") -strind (  ${STR_3}, "Current = ")+10 ) )

 

the syntax is:

 

substr ( string, start, length)

 

strind ( string, search string) -- gives you a number that is the start of the search string, so you need to add to it to advance to the end of the search string

 

strval (string) - turns a string into a number

 

So, to deconstruct the formula

 

Find the location of the number, in this case, it's immediately after "Current = ", so search for that string, and add 10 to advance beyond it.

Find the location of the following parenthesis, search for "("

Compute the length of the number by subtracting the position of the parenthesis from the position of the start of the number

 

xxxxxxx Current = 42.0 (ampsx10)<CR>

 

             ^              ^      ^

             A             B     C

 

A is strind (  ${STR_3}, "Current = ")

 

B = A + 10, or strind (  ${STR_3}, "Current = ")+10

 

C = strind (  ${STR_3}, " (")


length of B = C- B, or C-A+10

 

So, using this notation, the above formula is

 

STRVAL ( SUBSTR ( STRING, A+10, C-A+10) )

 


Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
Message 7 of 11
(8,320 Views)

way to go!!

Message 8 of 11
(8,317 Views)

dear friend,i am working on a project where i have a gwinstek GDM-396 multimeter to be conneted to an RS 232 port.

watever voltage is recorded from the multimeter should be trasmitted on a waveform chart in labview. i have written a labview program but i am always getting a 0 output.i have already set the parameters(parity,baud rate...) of the multimeter in the labview also. i am quite new to labview. help me please to get that output voltage in labview.

please find attached my program.i am using labview 7.0.

thanks

0 Kudos
Message 9 of 11
(8,024 Views)

Wok,

 

Here is a list of the third party drivers that National Instruments provides:

 

http://search.ni.com/nisearch/app/main/p/bot/no/ap/tech/lang/en/pg/1/sn/ssnav:idr/q/instek/

 

Hopefully that will help. I didn’t see a driver specifically for the GDM-396 but it’s possible that one of the other drivers might work. You’ll need to know the specific commands that are used with the GDM-396 in order to operate with the meter. I would suspect that those commands are in the user manual that you received with the meter or could be found near the product page.

(http://www.gwinstek.com/en/product/productdetail.aspx?pid=39&mid=80&id=204)

 

These commands are written to your VISA Write “write buffer”. You could create a control on the front panel to operate between these commands.

Blake C.
Applications Engineer
National Instruments
www.ni.com/support
0 Kudos
Message 10 of 11
(8,007 Views)