From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DASYLab

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I parse an ASCII charater variable that is included in the data string from my device?

Here is the RS232 data from the device.

 

R,2.306 MPa a,0.011 MPa/s,97.000 kPa a”

                               OR

NR,2.306 MPa a,0.011 MPa/s,97.000 kPa a”

 

Channels 0,1, and 2 take care of the 3 numerical values and write them to a file no prob..

 

The R and NR represent the Ready Status of the device, is there a way to write these characters into the same file?

 

 

 

Any help is appreciated, I'm fairly green when it comes to DASYLab.

 

0 Kudos
Message 1 of 9
(6,310 Views)

You could read them as bytes,

Or as strings.

 

Use $1\x2c to store the characters in a Global String. Then, use an Action module to write "ASCII Commentary" to the Text file.

 

The problem with reading them as bytes (either R or N) is the extra character in NR. If you don't know to skip it, it will misalign the rest of the data. 

 

I'm not 100% sure that I could get it to work. 

 

Can you try reading just one channel, a\x2c and see what DASYLab gives you? Anything? You can use the RS232 Monitor to test it out. Feel free to post a screen shot. 

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 9
(6,294 Views)

Here are a couple screen shots of trying to read just the one channel using the a\x2c measurement data format.

 

As shown in the RS232 monitor, it looks like its ignoring the text characters i need, and picking up the values that are already being written to a file in my original worksheet.

 

I also messed around with your suggestion to store it as a global string and use the action module to write it to my txt file.  I'm not too sure I was doing this correctly, how are the RS232 Input, action, and write modules linked to each other in order to get this accomplished?  

I was able to write the string to the header of my file, but thats just a one-time write..

 

Thanks for your reply cj 

 

Data Format.JPG

 

Monitor.JPG

 

 

 

 

0 Kudos
Message 3 of 9
(6,265 Views)

I thought that might happen.

 

To use the $1.... 

 

Replace the format string with 

 

$1\x2c -- should grab the start of the line and put the character into ${STR_1}

 

In the Action module, configure it so that the Receiver is the Write Data module, the Event is Global String Changed, with parameter of 1, and the the Action is Write ASCII comment, with the parameter being the placeholder for the string - ${STR_1}

 

2014-12-19_PrintScreen-0000.png

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
Message 4 of 9
(6,262 Views)

Thanks cj,

 

I think i understand the theory behind using the action module, but how do i "physically" implement it on the worksheet?  What is it connected to, or how do i trigger it?

this is what I have, and it doesn't work lol

 

modules.JPG

0 Kudos
Message 5 of 9
(6,257 Views)

What are the settings in the Action? 

The Event is the trigger... ... try Always, rather than Global String changed, since the string isn't changing. 

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

I will change it to "Always" and give it a try, I am just running a disgnostic on the pressure controller.  Once complete I'll experiment with the action module more. 

 

So, does the action module need to be connected to the RS232 and/or the Write modules??? How do the 3 modules connect on the worksheet, if i leave any of the I/O's open it give me a warning.

 

aaron. 

0 Kudos
Message 7 of 9
(6,250 Views)

All modules that have inputs (on the left of the module icon on the workarea) have to have something connected.

 

The Action module can use incoming data, or other non-data events, for the Action, but it always has to have an input.

 

Connecting it like you did to the RS232 Input was exactly correct for what you want to do. Each time you read a value from the RS232 module, the "Always" event will tell the Action module to do something.  When you wire this way, you can probably use the "Synchronous" setting in the Action module to try to write the string data on the same line as the data. 

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

Thank you for the confirmation cj! 

 

I'll make those changes when i can and post the results

aaron.

0 Kudos
Message 9 of 9
(6,245 Views)