LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String parsing problem

Hello everyone, i am a student and as a project i am trying to build a block diagram to acquire some data from the AVL Digas 4000 device. I try parsing the string but datas in the indicator can shift sometimes. When there are 7 datas in the string there are no problems but when there are 8 or 6, or any greater or lower then 7 can cause shifting on the indicators. How can i make them appear on the same indicator even there are less or more data then 7. You can find the pictures and tokens below. I will be very glad if someone can help me 🙂 thank you very much in advance. Have a nice day 🙂

 

410 F means we selected F and F is Standart Petrol measurement

346 RPM

347 Oil Temp

340 CO

343 PPM HC

348 H or P depending on the fuel type ( Hexan or Propane)

341 CO2

344 O2

352 NOx

900 Date

901 Time

902 Puma Status ( i dont know what is this)

 

Thank you very much 🙂

0 Kudos
Message 1 of 10
(4,421 Views)

hi takofako,

a quick note about some terms: singular of data is datum, also use entry or value

 

regarding your problem:

please attach an unparsed return string and state which parts of it are invariant

 

also images of blockdiagrams mostly help nobody, plz attach either snippets or vis, with default values set

(the best way would be to have an example vi, that only has the string parsing part)

 

regards


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 2 of 10
(4,395 Views)

First thing is DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (still not enough emphasis).

 

You have your serial port set up to use a termination character.  So the VISA Read will stop reading when the first of the following occur: 1) the desired number of bytes are read, 2) the termination character is read, 3) a timeout occurs.  So what you really want to do is to just tell the VISA Read to read more bytes than you ever expect in a message.  The read will stop when that termination character is read.  You will now know that you got a full message.


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 10
(4,381 Views)

What is the data tag after 348?  It looks an "H" is in there by mistake. 

 

If you want to leave your code like it is you will probably need to add a wait time between your write and read depending on how fast your instrument responds so you actually get all your data in the read buffer.

 

If you take the "Bytes at Port" out you will need to set your packet size.  Not sure why using this is a big no-no, except for the time is takes to query the serial bus.  But it isn't really needed if the response size is fixed.

Message 4 of 10
(4,363 Views)

JoeWork wrote:

If you take the "Bytes at Port" out you will need to set your packet size.  Not sure why using this is a big no-no, except for the time is takes to query the serial bus.


Because it causes race conditions with your serial bus.  You either have to add in arbitrary long waits (wastes time) or you miss data (even worse).  As I stated before, if you just tell the VISA Read to read more than you ever expect, then the VISA Read will do all of the work for you and stop reading when it reads the termination character.  Now we know we have all of our data and we have it as soon as it comes in.


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 5 of 10
(4,352 Views)

410F     34000.09 3438521  348   H34100.1  34420.6  3451.291 3520003  902-----9000505179011802  15

 

this is one of the data outcomes. The problem isnt that i am not getting all the data (you can see the time stamp with the shifted and non-shifted pictures). I used the original program of the device and there are some datas disappear and then occur on the screen again. I guess this is because i dont connect all of the sensors. It sometimes sends the data like  3xx00 sometimes it doesnt send it at all because it is 00 and not a gas reading i guess. The missing data is 346 which is RPM and it is shown as 34600 and sometimes not at all because i dont connect the sensor. The thing i am wondering is can i make it so the datas are shown on the dedicated indicators even if sometimes the string doesnt contain everydata like 3xx00 because this is what this device does. It even sometimes shows the RPM sometimes doesnt its own program so i am guessing thats the reason why sometimes some datas are missing in the string. I tried to remove property node but visa gives an error when i did that. Visa doesnt work without the property node with DIGAS 4000 i dont know why because it works with AVL 415S. Thank you all so much 🙂

0 Kudos
Message 6 of 10
(4,325 Views)

It seems it is working with %f added but i dont know why. I send the latest vi, which seems working.

0 Kudos
Message 7 of 10
(4,324 Views)

I know you said you are not having any issues with reading the data, but you have some major inefficiencies.

1. Your instrument is using 0x4 as the termination character.  So let's set that with the Configure Serial Port.

2. DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  The Bytes at Port causes weird race conditions between you and your instrument, causing data loss or a lot of wasted time.  In your case, you added 6 seconds to your time just trying to figure out the issue.  So waits are needed.  Just send your request and then just use VISA Read.  Tell VISA Read to read more bytes than you ever expect in a message.  Your example has a little over 100 characters, so let's just go with 500.  So now the VISA Read will read characters until it reads the termination character (0x4) or times out.

 

Now as far as your data is concerned, it looks like it has a channel number as part of the data.  Use that information to populate a cluster (use a shift register and update the value based on the channel number).


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 8 of 10
(4,291 Views)

Thank you for the answer sorry for late reply, i am having my finals this week. Now this is the final version i got to so far. I found the termination character and also i found that:

AVL 4000 in slave mode (only in the standard measurement)

 

In the slave mode, the PC sends a request to the exhaust emission tester. In return, the tester sends a data record with the measured values or a NAK if no data can be sent. The PC confirms the data record with ACK or NAK (the packet is repeated). 

The scope of the data packet depends on the regional version and the type of operation of the exhaust emission tester.

 

 

PC sends  

 

<ENQ>

 

AVL4000 responds with a data block

 

<STX>                                               " Header   n. part

 NNN     xxxxxxxx <ETB>              " 1. Data record

 NNN      xxxxxxxx <ETB>              " 2. Data record

      ......

 NNN     xxxxxxxx <ETB>               " n. Data record

 <PS1><PS2>                                    " 2 byte checksum ASCII '0'..'9'

 <EOT>                                              " End of block

 

PC sends  

 

<ACK>  or  <NAK>

 

so i added visa write with 6 to end. 

Now it seems working without a problem. By the way i couldnt get the brown part with the shift register ( i am sorry i am a mechanical engineering student i am trying to learn visual coding since its easier for me :), so it is hard for me to understand some of the info you gave me, it can be easier for me thank you [ may be it is already easy but since i dont know anything 🙂 ] )

Now i am trying to calculate the mean value. I set the while loop to 1 second so the control i defined as Time is apprx. the time how much and also how many times the loop will work i guess. (it is also the best timing i tried 800-900 ms but it seemed dodgy, it is not able to operate that fast). 

Is there a way to calculate the mean values of these individually. I search youtube and forums but it gives me and error that says the sink is 1D but source is 2D. I am guessing i need to delete 1 array i tried deleting from array module but i couldnt do it :(. 

 

Thank you very much 🙂

Kind regards

0 Kudos
Message 9 of 10
(4,258 Views)

To be specific i want to run the vi for 10 seconds or 20 second sometimes 5 seconds and i want to calculate the mean value after all. I search for it but i mostly found simple mean value calculations which i tried the variations but couldnt get it to work because of that 1D 2D thing. 

 

Thank you 🙂

Kind Regards

0 Kudos
Message 10 of 10
(4,251 Views)