LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Medibus Protocol VISA help wanted!!

Hi All,

 

I am new in LabView.  I am under to pump to finish by college work to implement MEDIBUS protocol for medical devices used by Drager in Labview. If anyone has ever done it,  plese help!

 

I can take serial data , port its output, save in file or turn it in graphs. However, medibus implements the comples ASCII hex 2 byte checksum , CR and SOH in every data. I simply cannot truncate last three bytes of checksum data and SOH  byte and save it. Also, it needs initialization and commands with 2 byte checksum of LSB in ascii hex with CR and ESC at front. Can anyone please help me?

 

Truncating 3 bytes at end, one byte at beginning while receiving and adding checksum, adding extra byte and beginning and end is driving me crazy. Please ideas, any inputs will be highly apreciated. 

 

 

Sasha

0 Kudos
Message 1 of 17
(5,086 Views)

You need to read the documentation for the serial protocol to figure out how to generate/check the checksum - there are a number of different ways of calculating a checksum (e.g. CRC-16, simple XOR etc.). It's like someone sending you a whole page of text without telling you what language it's written in!

 

If you can find the page of documentation on the Medibus protocol that gives the details of the checksum it should tell you what you need to do to the bytes to calculate the checksum. Normally it involves performing some logic/shifting on the data bytes (e.g. XOR) which can easily be done in LabVIEW.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 2 of 17
(5,061 Views)

Correct ! The protocol documentation says the 2 byte checksum is the ( hex sum each byte converted to ASCII )  LSB of all the preceding bytes. Being a beginner in labview, my problem is - Truncate these serial read bytes -  last 3 bytes and one first byte.  And also to add one extra byte and add three bytes while writing the command. Both the read and write are in Hex format and they can vary in length of upto 3000 bytes. Any help in truncating/ adding bytes at specific locations ? 


@Sam_Sharp wrote:

You need to read the documentation for the serial protocol to figure out how to generate/check the checksum - there are a number of different ways of calculating a checksum (e.g. CRC-16, simple XOR etc.). It's like someone sending you a whole page of text without telling you what language it's written in!

 

If you can find the page of documentation on the Medibus protocol that gives the details of the checksum it should tell you what you need to do to the bytes to calculate the checksum. Normally it involves performing some logic/shifting on the data bytes (e.g. XOR) which can easily be done in LabVIEW.


 

0 Kudos
Message 3 of 17
(5,052 Views)

these are the receive and transmit protocol i need help to implement in labview. Being a beginner it seems like a mountain.

Download All
0 Kudos
Message 4 of 17
(5,044 Views)

Ok, so you read a string from the serial port...first you need to split that into the different messages (by finding the start/end of each message). You then need to convert that into bytes using the string to U8 array function. This will give you an array of bytes and you can use the array functions to separate the command/data/checksum.

 

The checksum in this case is just adding all of the U8 bytes up to the checksum and discarding everything except the least significant byte (e.g. the overflow bytes when it goes above 255). I think you then prepend that with either the ASCII ESC or SOH character to get your two byte checksum.

 

There might be some examples included in the documentation to give you a sample message so you can check if you've calculated the correct checksum.


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 5 of 17
(5,037 Views)

Thank you, very close! Probably would have been enough if I had been in Labview for while. I am thinking now..  count lenth(l)  of message and ignore bytes in positions --   l to l-3 and 1 . 

I would implement this easy in C but in labview still a challange. 

Also, do we happen to know how can I type ASCII non printable characters like SOH, ESC  etc in labview. In VISA I tried with usual Alt + ascii codes, does not seem to work. The binary type section is blocked out.

 

 

0 Kudos
Message 6 of 17
(5,018 Views)

Right click on a string or numeric control and do visible items -> radix/display style. That will allow you to change the display format of the number/string to be in '\' or HEX codes display or to display a number in hex format. I don't think there's a way to display items as the ASCII 'descriptions' but at least you can display them as HEX/decimal codes.

 

For the array manipulation - in the array palette you have lots of useful functions like index array (note you can drag it down to index out multiple items), array size and array subset.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 7 of 17
(5,007 Views)

The more I think I got it close, the far it seems to get away from me. So, this is what I should be able to do.

 

1. WRITE    -----    Write 5 to 200 bytes of hex code including ascii ESC first byte and lascii CR last byte with 2 bytes lsb checksum   ( obtained by adding all the previous byte including 1B ) converted to ascii ( 1B and 0D) .  Example for a 5 byte write command  -    1B 22 33 44 0D

2. READ  ---    Incoming Hex Serial  Data going to array ( whose length to be determined by checking  0x0D  ). 

3 .Convert the hex data in arrays to ASCII .

4. Graph the hex data .

 

 

Any insights? Any chances of example VI files for reference? Appreciate your help.

0 Kudos
Message 8 of 17
(4,997 Views)
As embarrassing as it might seem to you, you need to post your code.  By this, I do not mean a picture of your code, but the code, itself, either the VI as an attachment, or create a Snippet (if you know what this is) and show us that.  In turn, we can (a) see what you are attempting to do, (b) point out simple mistakes or misunderstandings, and (c) describe (or show) better ways to do what you show.
 
Bob Schor
0 Kudos
Message 9 of 17
(4,967 Views)

Hello,

I am an university student working with Labview on trying to implement MEDIBUS protocol to communicate with Draeger equipement. I have been searching everywhere for MEDIBUS protocol/ documentation and it seems all you guys have one. 
Where can I get one? is there a place to download it or buy it?

Because of this I'm not even able to get serial data out or anything.

 

Any information will be much appreciated

 

Thanks in advance. 

KT

0 Kudos
Message 10 of 17
(4,727 Views)