Jump to content
Sign in to follow this  
Henk H.

Use pointing to filter data from RS-232 input

Recommended Posts

Hello,

this is my first post on this forum, i hope i picked the right category for my question. For a project i am wondering if we could use a V350 that is available here, programmed in Ladder.

For this project, we need to extract a number from data received by the RS-232 input of the V350. This data is sent to the RS-232 input in so called sentences, the pieces of data within the sentence is separated by delimiters (comma, "," in this case). The number we need to extract is somewhere in the middle of these sentences. The number of characters before "our" data varies, so simply picking the x-th to y-th characters from the sentence will not produce the right number. The number of delimiters before our number is always the same. The idea is to use these for extracting the number we need (pick the numbers after the z-th delimiter).

My question is if this is possible with a V350, programmed in Ladder ? If this is possible, where can i find more documentation about doing this ?

I have searched the forum and documentation for answers but i could not find information (i probably overlooked it, i guess). Hope to hear from you, thanks in advance !

Share this post


Link to post
Share on other sites

The answer is definitely yes.

Tool should be used is "FB Protocol"

The way how to do it depends from exact message structure.

If the number of CSV fields is static, you can use parsing feature, build-in inside "FB Protocol".

If the number of CSV fields is unpredictable, then you probably have to receive hole message (but no more than 512 bytes) as a stream and than parse it in a ladder code.

  • Upvote 1

Share this post


Link to post
Share on other sites

Thank you for your fast response !

The project should be used in several installations. The number of CSV fields can differ between the installations but is constant for each installation. The additonal CSV fiels are always added after the field we need (different protocol versions in use, not able to stick to just one). The length of the fields (the number of characters between the comma's) differs, but the total number of charachters is always below 255. The length of the field we need can vary and contain a decimal point. Values can lie between 0 and 99.9 and be positive/negative (negative values do not need to be processed). The goal is to make one program that will be suitable for all installations, regardless of the number of fields.

I have looked up the Visilogic documentation on function blocks and Visilogic Ladder programming.

For your first suggestion i could not figure out if this is suitable for us (with the CSV lines as described above) as it i could not figure out how to use parsing based on the delimiters. We use only the Scan function to read the serial input and don't use the send fuction which contains the control charachter. For the Scan function, i could not find any option to enter a delimiter.

For the second option, i have to use several "find string in string" in cascade in Ladder ? Probably i can use "find in string in string" to pick all CSV fields after the first delimiter (skipping the first field), and repeat this untill i have come to the field i need. Is that a possible solution, or are there any better ways ?

We have to decide if we want to invest time to dive into this, so i'm trying to get a picture of how many effort it will require/if i even could bring this in practice.

Share this post


Link to post
Share on other sites

The sentences are NMEA sentences, the NMEA protocol is used to exchange data between navigational devices on board of (seagoing) ships. These devices could be a GPS, gyrocompass, echosounder etc. We intend to use the sentence that starts with $GPRMC..... This sentence comes from the GPS, among other several sentences.

There are two versions of the $GPRMC sentence:

$GPRMC,135916.14,A,5250.87700,N,00536.88828,E,0004.0,270.0,300512,0.0,W*7A

and

$GPRMC,135906.05,A,5250.87700,N,00536.89012,E,0004.0,270.0,290512,0.0,W,A*1E

The difference between these versions is the addition of an extra field at the end of the sentence/befor the checksum (being after the W and before the *). On some of our installations we have the first, on some the latter.

The number we need to extract is 4.0 in the above sentences, the 8th field. The length of the field containing this number might vary.

We have a supplier that does not succeed in making a program extracting this 4.0. Maybe we can get the program they already made and adapt this so it works with counting delimiters.

Share this post


Link to post
Share on other sites

OK,

NMEA-350 (link from my dropbox) - is a sample code for your task.

I did it in two steps:

1. split ASCII fields and place each value in "RMC Values" data table

NMEA.JPG

2. Convert required field(s) from ASCII to Float. (in this sample only "Speed over ground in knots", but you can do same way any float field)

Of course, there is a lot of room to optimize it.

Adjust settings (COM1, ethernet) for your needs and let me know if it works

Share this post


Link to post
Share on other sites

Great ! Will try it and let you know what the results are.

Unfortunately, my girlfriend was hospitalized last week so i did not have the time te reply/try earlier. She's doing fine now, but i think some days may pass before i have time to continue with the $RMC program.

Anyway, will keep you posted !

Share this post


Link to post
Share on other sites

Yesterday my girlfriend came back home (all went well) and last week i got the program. This afternoon, i made some time to look at the example you gave me.

Took some hours to try and study documentation. If i understand correctly is the file you gave me a "SD block". To incorporate this in the programm (ladder) i have to "write operand vector" containing the complete $GPRMC sentence to the block on the SD card (renamed to block0.udb) and later to "read SD block to operand vector" to have the speed in knots returned ? Is that correct ?

Does the SD block only work from a SD card (or also without) and is there a way to look "inside" it to see what it does ?

Share this post


Link to post
Share on other sites

If the file that you downloaded has an extension .zip, just replace it to .vlp. Than you'll be able to open it in Visilogic

This confusion may come from dropbox.

Share this post


Link to post
Share on other sites

Downloaded the new .vlp file succesfully and opened in Visilogic. Will study how this works.

Unfortunately, we moved for this application to another supplier (using other hard/software) as we need it fast. At least faster i than i could learn Visilogic and make this work.

Nevertheless, will spend some of my own time to see if i can make it work. Will keep you updated !

Share this post


Link to post
Share on other sites
On 5/31/2012 at 9:24 AM, linxchas said:

OK,

NMEA-350 (link from my dropbox) - is a sample code for your task.

I did it in two steps:

1. split ASCII fields and place each value in "RMC Values" data table

NMEA.JPG

2. Convert required field(s) from ASCII to Float. (in this sample only "Speed over ground in knots", but you can do same way any float field)

Of course, there is a lot of room to optimize it.

Adjust settings (COM1, ethernet) for your needs and let me know if it works

Hi, my name is Oscar, I would like that upload the program of NMEA with Unitronic

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...