06-19-2012 02:30 PM
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
Solved! Go to Solution.
06-19-2012 05:55 PM
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.
06-20-2012 01:49 PM
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.
06-22-2012 01:09 PM
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...
06-22-2012 01:12 PM
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.
06-25-2012 12:27 PM
I get an operator error when I try to paste this command
07-03-2012 09:30 AM
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) )
07-03-2012 01:01 PM
way to go!!
12-01-2012 03:29 AM
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
12-03-2012 06:07 PM
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.