Jump to content

[LVTN] Plasmionique Modbus Master


Recommended Posts

18 hours ago, Porter said:

For #3, check the "MB_Master Simple Serial.vi" example located in "<LabVIEW>\examples\Plasmionique\MB Master\" or search for it in the Example Finder.

Thanks a lot.

I am gonna check what you said and I will post here the solution if I fix it.

Thanks again.

Link to post
Share on other sites
  • 2 weeks later...
  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

View File Plasmionique Modbus Master This package contains the Plasmionique Modbus Master library for LabVIEW. It supports RTU, ASCII and TCP modes with th

OK. I've worked it out. Modbus Master now has a dynamic dispatch accessor for ADU and Session Valid. I'm going to make an example for a TCP/Serial device this weekend and post an update.

I like that you decided to simplify the RTU serial read...I was stubborn and wanted to follow the spec, I think that was a mistake. Serial APIs have come too far since RTU was created.   The visa lo

Posted Images

On 2/2/2017 at 5:57 PM, Porter said:

For #3, check the "MB_Master Simple Serial.vi" example located in "<LabVIEW>\examples\Plasmionique\MB Master\" or search for it in the Example Finder.

Yes! That simple!! Thanks!!

I have another question.

In my application I have to read constantly a few variables from PLC (coils, registers...). For example if a coil is 1, then an event occurs in my application (in an event structure).

Sometimes as I said in #1 some variables are not read.

So what is the best way to do a poll? Just one while reading every variables (coils and registers) each 10ms for example and then pass the information in local variables to anothers whiles?

Thanks a lot!

Link to post
Share on other sites

10ms seems like a very short polling period for a serial device. 100ms is more realistic. Of course it depends on baud rate, number of transactions, FIFO buffer settings etc... But yes, you can just poll the PLC in one loop (as shown in the simple serial example), then put the data into a queue or user event to pass it to other loops. I would recommend looking into the producer/consumer design pattern.

Link to post
Share on other sites
  • 11 months later...

Hi,

I am have a issue with this library. I will try to setup a modbus TCP Master and start communication with a slave device which uses a MBAP header. Is it possible to use this library for these application and how implementing it? Every try to start a communication stops with an error message :(

Many thanks in advance

Ingo    

Link to post
Share on other sites

The Modbus TCP Master uses the MBAP header.

I will need more information in order to help you.

What error message is produced when communication stops?

Please post example code that reproduces the error.

Please try the attached code. Fill in the correct IP address, port number, slave ID, holding register address before running it. Post a screenshot of the output

MB TCP Read Holding Register Test.vi

Link to post
Share on other sites
  • 1 month later...

This project is now available on GitHub: https://github.com/rfporter/Modbus-Master

If you want to make modifications to the modbus master library, I suggest that you pull the source code from that repo.

To build your own release, you just need to build the "Source Distribution" then build a VIP package using "MB Master.vipb" with VI Package Manager 2014.

  • Like 1
Link to post
Share on other sites
  • 2 months later...

I was thinking, an useful addition to the cool Modbus Comm Tester would be a section for Read Device Identification. Probably fitting nicely the 7th rectangle on the FP is the difficult part of it; the extension of the code, which is elegantly written, seems trivial. What do you think about?

Edited by ensegre
  • Like 1
Link to post
Share on other sites
  • 3 weeks later...

I have implemented transaction IDs for Modbus TCP in the "Transaction ID fix" branch here: https://github.com/rfporter/Modbus-Master/tree/Transaction-ID-Fix

Could use some feedback.

Here is a vip if you would like to take it for a spin: mb_master-1.3.2.4.vip

Edited by Porter
Link to post
Share on other sites
  • 2 weeks later...
  • 3 weeks later...

Hopefully a real quick question:

I just started using this library, I got referred over here from the NI forums as this Modbus Library solved an issue that another MB library I was using had. That being said, I have not really taken a dive under the hood to figured out my problem. I was curious if anyone knew a quick fix before I started looking into it.

When I try to build an application through the application builder that is using this MB library I get an error telling me that it can't build a broken VI without attaching the block diagram (which does fix the issue). It pointed me towards the "Read Session Valid.vi" as the issue. When I looked at that vi I can see a broken arrow with the error pointing towards the "unbundle by name". Can anyone verify that this block diagram is correct? I double checked I had the newest version of the library and still get this issue.

 

Thanks!

MB Library.PNG

Link to post
Share on other sites
5 hours ago, Masony said:

When I try to build an application through the application builder that is using this MB library I get an error telling me that it can't build a broken VI without attaching the block diagram (which does fix the issue). It pointed me towards the "Read Session Valid.vi" as the issue. When I looked at that vi I can see a broken arrow with the error pointing towards the "unbundle by name". Can anyone verify that this block diagram is correct? I double checked I had the newest version of the library and still get this issue.

This is fixed in the latest version (v1.3.3.1) here: 

 

Edited by Porter
Link to post
Share on other sites
  • 2 months later...

@Porter I'm trying to use Plasmionique Modbus ver 1.3.1.4 with Labview 2014 over serial and i keep running into a CRC error. it's not properly calculating the CRC.

For example:

The Master sends: 01 04 00 00 00 01 31 CA

and the builtin simple slave responds with 01 04 00 00 00 01 31 instead of the correct message 01 04 03 00 00 B9 30

i've this with the Plasmionique Master example and with the third party Modbus Poll program. and both report a CRC error.

Any help would be appriciated.

Link to post
Share on other sites

Have you ever thought of creating a Slave Library? Your ablity to use visa locking to allow multiple masters to write over 1 comm port would be in valuable to doing the same to allow multiple slaves to read and write over the same serial port.

Link to post
Share on other sites
  • 5 months later...

Thanks for the easy to use Libary.

As I have a combined measurement, a NI-DAQ-Device and the DUT, that sends its internal parameters via Modbus, I would like to set a sample rate for the MODBUS data and to synchronize both systems

The Baudrate is at the moment at 230400, but data are flowing in with samplerate arround 1sec.

 

 

Link to post
Share on other sites

How much data are you transferring? For example, if you are reading 1000 input registers, one register at a time, then you can't expect to get a sample rate of 100ms.

Screenshots or sample code would be useful if you are looking for help.

Are you using the Modbus Comm Tester?

Link to post
Share on other sites
13 hours ago, Porter said:

How much data are you transferring? For example, if you are reading 1000 input registers, one register at a time, then you can't expect to get a sample rate of 100ms.

=> The maximum registers I had were about 50. I do not want to have a fast sample rate as I have slow changing processes, but I like to synchronize (have the same samplerate)  the data derived from Modbus with my DAQ data. 

Screenshots or sample code would be useful if you are looking for help.

=> is attached

Are you using the Modbus Comm Tester?

=> no

 

I have attached the VI that I use tu read the registers. 

 

Modbus Read Waveform.vi

Link to post
Share on other sites

If you are reading single register values at 1Hz, sample rate doesn't look to me a limiting factor. The modbus packet size might be some 20bytes [Mike correct me], at 230kbaud they are moved through in a ms. The jitter in the synchronization, rather, might be, but that depends on what you can afford or tolerate. You have to keep in mind that both DAQ and Modbus are in principle asynchronous measurements. You can write a program which pushes a modbus command into the computer UART and a start acquisition command to the DAQ. Depending on how you write the program and on the realtiming of the target you run onto, you can approach a simultaneous firing of the commands, but still you don't know the latency of execution of them. The bottom line is normally that if you want sampling to be tightly synchronized, you have to do that by hardware triggering. In reading the results, you may afford delays.

Link to post
Share on other sites
  • 2 months later...

I just ran into an issue where a VFD with option modules would kick back "Illegal Data Address" when attempting to read/write Holding Registers. Upon discussion with the manufacturer it was found that the unit ID for the various option modules is different than the VFD itself (255).

I changed the Unit ID constant in the "Create TCP Session" vi and it fixed the issue, as well as using a property node to change the Unit ID after creating the TCP Session. Would you consider changing the constant to a control with the default being 255?

Keep up the great work, I use this library daily and it has been a life saver.

Thanks!

Edited by Masony
  • Like 1
Link to post
Share on other sites
  • 4 weeks later...
  • 3 weeks later...
On 6/27/2019 at 10:33 AM, Porter said:

@Masony, something like this?

Capture.PNG

Hey, sorry about the late reply I guess email notifications weren't working. Anyways I see that you pushed out an update and that was exactly what I was thinking. Thanks so much for the quick response.

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.

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.

  • Similar Content

    • By govindsankarmr
      Hi, 
      I am looking for a paid or free course online for LabVIEW instrument control that covers topic like  communication protocols, RS232. GPIB etc. Can anyone suggest a good one. Thank You.
      Govind
    • By Porter
      This package contains the Plasmionique Modbus Master library for LabVIEW.
      It supports RTU, ASCII and TCP modes with the following function codes:
      0x01 - Read Coils
      0x02 - Read Discrete Inputs
      0x03 - Read Holding Registers
      0x04 - Read Input Registers
      0x05 - Write Single Coil
      0x06 - Write Single Register
      0x07 - Read Exception Status
      0x0F - Write Multiple Coils
      0x10 - Write Multiple Registers
      0x16 - Mask Write Register
      0x17 - Read/Write Multiple Registers
      0x2B/0x0E - Read Device Identification
      Other features include:
      - Sharing a COM port across multiple Modbus sessions using VISA locks (10 second timeout).
      - Sharing a Modbus session across multiple communication loops.
      - TCP transaction ID handling to ensure that requests and responses are matched up correctly in case responses are received out of order.
      - Modbus Comm Tester, available through the "Tools->Plasmionique" menu, for testing communication with a slave device without writing any code. 
      - Detailed help document available through the "Help->Plasmionique" menu.
      Examples are included in "<LabVIEW>\examples\Plasmionique\MB Master\":
      MB_Master Comm Tester.vi: Demonstrates usage of API to open/close connection and communicate with a Modbus slave device. MB_Master Multiple Sessions.vi: Demonstrates usage of API to open concurrent Modbus sessions. MB_Master Simple Serial.vi: Demonstrates polling of a single input register over serial line. Download a copy of the user guide here: MB_Master - User Guide.pdf
      Note that Version 1.3.4 of this library has been certified compatible with LabVIEW and has been released on the LabVIEW Tools Network: http://sine.ni.com/nips/cds/view/p/lang/en/nid/214230
      The most recent version of this library will always be released on LAVA first before going through NI's certification process.
      ***This project is now available on GitHub: https://github.com/rfporter/Modbus-Master
    • By Porter
      NI Labs Modbus API is now on GitHub!
      Password protection of VIs has been removed.
      https://github.com/NISystemsEngineering/LabVIEW-Modbus-API
    • By szewczak
      I wanted to cross post metux's discovery here asap, and have a separate discussion.
      Metux's original post:
      The recent Linux driver package introduces a CRITICAL security vulnerability:
       
      http://www.ni.com/download/ni-linux-device-drivers-2018/7664/en/
       
      It adds additional yum/zypper repos, but explicitly disabling package signing and using unencrypted HTTP transport. That way, it's pretty trivial to completely takeover the affected systems, by injecting malicious packages.
       
       
      DO NOT INSTALL THIS BROKEN SOFTWARE - IT IS DANGEROUS !
       
      CERT and BSI are already notified.
       
       
       
       
       
    • By ensegre
      This is a DSC module question: has anybody here experience with building standalone executables which include shared variables bound to DSC modbus i/o servers? I have an issue with deployment, possibly related to licensing. I posted on the dark side, but haven't got feedback yet.
      https://forums.ni.com/t5/LabVIEW/shared-variable-bound-to-Modbus-i-o-not-working-in-deployed/td-p/3809801
      TIA, Enrico



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.