LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read frames from serial port using MRU protocol

Solved!
Go to solution

Hello,

I have a gas analyser that communicates with the PC via the serial port.

It is the "MRU VarioPlus Industrial".

I attach a PDF that describes the transmission protocol.

I am trying to decode the data that are sent from the analyser, but I cannot make it.

I attach the vi in which I have made some efforts.

Any help is appreciated, at least to get one value from the data stream.

Thank you.

Download All
0 Kudos
Message 1 of 23
(3,674 Views)

Hello,

 

Would you mind attaching a screenshot of your front panel with the the incorrect data and describe what you expect to see instead?

 

Thanks,

National Instruments
Applications Engineer
0 Kudos
Message 2 of 23
(3,640 Views)

Hi Nik,

 

At the moment you are not parsing any of the data. You are reading in the bytes from the port but you dont know if what you are reading is a complete message from the start. You could be reading in 4 messages or half a message, you could be reading from the middle of a message. You need to parse the input data. To do this i would suggest that concatenate the string into a shift register as you receive it. Then have some software parsing this string. To begin with you will need to find the start of message identifier 'MRUj' in your case, once you find this then count out the amound of bytes you are expected to get after this (i believe 40 in total in your case), this will then be a complete message, remove this from the shift register. You will then need to send this complete message to another vi that then does a CRC check and parses the different information out of the string.

 

Rgs,

 

Lucither

 

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 3 of 23
(3,616 Views)

Hi Nik,


First you should check for the 4 byte start of data (MRUi) once you get the correct start message then you can read the next 15 byte data. so now you will be having 19bytes, now parse the 19th byte to get the number of short(X) and long(Y) measurement available in the fourth coming bytes. read the remaining bytes ( X * 16 + Y * 32 + 2 (status bytes) + 2 (check sum bytes) ) and combine all the bytes read to verify the check sum you received.

parse the entrie message as mentioned in the section "Example of an industrial protocol frame" if check sum is correct.

Note : this method is only for the "original sender protocol"

Before try this its better to do the follwing steps.
1. Simulate the data bytes given in the document section "Example of an industrial protocol frame" and parse the data correctly as mention. Once you are succesful with this you can implement the same in the main module.

2. Move the Configure port and close port out of the timed loop, not nessesary to configure the port all the times.

 

Regards

Ganesan Kani

0 Kudos
Message 4 of 23
(3,603 Views)

Thank you all for your responses.

I still do not know the way to manipulate the receiving bits.

 

Here is the Front Panel in which the receiving bytes are represented in a string.

 

FrontPanel_SerialMRU.JPG

 

I also attach the vi in which I have moved the Configure Port outside of the while loop, and I tried to read every single byte in a for loop, using a concatenated string to present them in the Front Panel.

 

Please, show me an example that describes the way to get the useful values out of the data stream that I receive in the serial port.

 

Thank you very much.

0 Kudos
Message 5 of 23
(3,590 Views)

Hi Nik,

 

I have had a little look at what you have been trying to achieve. I will attach a zip file to the bottom. In this it has a file called 'MRU parser tester MAIN', which i used to test a parser i wrote for you and also a file called 'MRU Comms MAIN', which i wrote for you to test. The last vi i cant test as i dont have the MRU hardware. It is just a very basic comms routine that should communicate with the MRU and display its values.

 

just looking at your code i can see several things wrong. To begin with, for example, you are removing the 6 bytes that make up the time/date but you are showing these as a string. These are sent as a string but are 6 bytes that need to be shown as bytes not as a string. You convert the string to a byte array which is correct, then all you need to do to get the data is to index that array, starting at 4, for length 6 (like you do). just show these as numeric bytes. for example december will be shown as a byte of 12, not a string. This goes for all your other data. You need to go through the manual, it tells you in there what the data will need to be. If you cannot follow that then look at the vi's i will send you. All the data is read in as a string. I then parse the data for full messages. I output these messages and CRC check. If it passes i then pass only the useful data part of the message and sort this out into its relevant pieces.

 

Unfortunately i am absolutely sure that the vi's i sent you will not work straight away as i dont have the external hardware to test with. Im pretty sure though that it should be close so have a play and use fault finding skills to work out whats wrong and fix. For example i have tested the CRC routing from what i expect to see but in reality this may be different.

 

Have a play and i hope it helps some.

 

Regards,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 6 of 23
(3,583 Views)

Its hard to see how the data you are seeing on your FP corrosponds to what you are meant to be getting according to the pdf you attached. Another quick point. The loop in which you are concatenating a string doesnt do anything as you are always initialising the array with an empty consant. If you want to show all the data you are getting you need to use an uninitialised shift register and add it into that. You also dont have to convert to byte first then back to string?. You are also using the index to index the array, why dont you just use auto-index instead. What version of LabVIEW do you have?

 

Rgs,

 

Lucither.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 7 of 23
(3,577 Views)

I use the LabVIEW 8.2.1, so could you please post your vi files again ?

Sorry, for not mentioning it before.

I appreciate very much your effort to help me.

I will try it again and post my results.

0 Kudos
Message 8 of 23
(3,569 Views)

I will re-post tomorrow. Just tried but your version does not have the conditional loop of the for loop. This means i will have to re-write a part of it. Where i live it is 21:40 at the moment, i have had quite a lot of brandy's so think it will be best if i do it tomorrow.

 

If you can, can you loop for maybe about 2 seconds of data and write all the data you get in a binary file and attach it. If i can see what you are getting i may be able to help more. In your main string indicator we are not seeing the starting indicator and we should according to your pdf. We are seeing a lot of ascii information though, again non of this corresponds to what we should expect from the pdf you attached.

 

I will look at this again tomorrow for you.

 

Regards,

 

Lucither.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 9 of 23
(3,563 Views)

Hi Again,

 

Just spent 5 mins re-writing the for loops so they are compatible. Hope is ok for you to test. As i said before there are to 'Main' Vi's. The tester vi i used to test the software with what i would expect your hardware to send looking through the pdf you attached. Unfortunately after looking at what you have been receiving im not optimistic about the actual comms vi i sent working as what you seem to be getting does not corrolate with what the pdf is saying.

 

Anyway, whilst im sleeping hopefully you can have a play around and we can have a look at it again some other time.

 

Take care,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 10 of 23
(3,558 Views)