NI Labs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

NI LabVIEW Modbus API Discussion

Thanks Jens

0 Kudos
Message 131 of 529
(1,993 Views)

Hey Smithd

Thanks for the input. Can give me that data model example again for overiding this behaviour. I didnt find the example

Thanks & Regards

Varun garg

0 Kudos
Message 132 of 529
(1,992 Views)

I am also getting error as a master querying slave addresses i.e

Error 538179 occurred at Network Master.lvclass:Shutdown Master.vi

Possible reason(s):

The object used has been invalidated. A method was called on an interface class.

That means you called a function on an un-implemented parent class. Since LabVIEW does not have completely virtual (I think thats the term) functions, we have an implementation for each. That can be confusing if you pass your code through a for loop or conditional disable and labview ends up giving you the default for the data type. If its only happening on close, it may be an internal error. I'll take a look.

The example is post 62 https://decibel.ni.com/content/message/61104#61104

0 Kudos
Message 133 of 529
(1,993 Views)

I'm not seeing anything in the code which would cause that error message during normal operation. Could you post or PM me the modbus-related code?

Thanks,

Daniel

0 Kudos
Message 134 of 529
(1,993 Views)

Hello Smithd

Please find the attached VI for your reference.

Thanks and Regards

Varun Garg

0 Kudos
Message 135 of 529
(1,992 Views)

dexterpoet wrote:

Hi smithd ,

I have just downloaded the latest Modbus VI Library. If you recall from my PM, I want to be able to communicate with an Emerson servo drive using Labview. After much reading, I have been able to identify the registers needed for motion control on the Emerson drive. A few of them for instance are 'Digital input 1 is in the 40821 modbus register for the servo drive, digital input 2 is on the 40822 modubus register' and so on. (Parameters in the drive are prefixed with 4 as all of the drive parameters are mapped to register file 4, which is a Read / Write 16bit register in the servo drive).

The Emerson servo drive supports Modbus RTU. Communication with a laptop and the drive is through a USB serial converter. When connected to my laptop, NIMAX identifies it as ASRL3::INSTR "COM3", is this correct, or does it have to manufacturer specific?

I want to use your library to read and write to these registers, as each represents different types of motion control (run forward, run reverse, jog, etc). My laptop would be the master and the drive as slave. I think it would be better for me to use your library than the Modbus I/O server within Labview as this is my first project with modbus and I do have the Labview DSC module.

Please where and how do I start? Can I please have an example code that explains this type of modbus communication? Even if its just a pointer as to how I can read and write to one register to perform motion. Thanks in advance

Sorry, forgot to reply to this yesterday.

ASRL.... is correct. MAX will assign a windows COM port to a visa name. I forget the "A", but of course SRL is "SeRiaL".

So, for an example to use the code there should be a reasonable one on the palettes--one slave and one master. Everything in it is hardcoded (it serves mostly as a demo), but that should at least give you an idea of how to request data using the API. Once you know how to access a register, its just a matter of writing out the commands you need. I would start simple with something like the example I provided or the simple state machine template and assign a button on the UI to each thing or register you want to access on the device. Once you have a handle on how to control your device manually (ie (1) push init button (2) set motion type (3) read current location (4) set desired position (5) read new location until desired position reached), you can start transitioning that over to a more complete control system and automating that process.

Thanks,
Daniel

0 Kudos
Message 136 of 529
(1,991 Views)

Varun_ECK wrote:

Hello Smithd

Please find the attached VI for your reference.

Thanks and Regards

Varun Garg

1.png

^Pretty common error. The reason that error code exists in the first place is something like this. In my case I had a disable structure around my loop and forgot to wire the reference through. Took me most of a day to figure it out, so I added the error code .

Simple fix in your case is to add a shift register to the modbus master. This is good practice in general (no data copy) and it will prevent invalidation of references if the loop executes 0 times. Same thing for the while loop, although only for the memory reason. Of course, while loops always execute once.

0 Kudos
Message 137 of 529
(1,991 Views)

Hello smithd

Thanks a lot, I have opened the example code, but I have a few questions.

1. I am working with a serial device. From the example in the library, when I change the Modbus VI on the Connect case for the 'New TCP Master' to 'New Serial Master', I get a broken VI, with an error saying 'required input 'unit ID' and 'serial type' is not wired', and when the 'New TCP Slave' is changed to 'New Serial Slave', in addition to the warnings above, I get the error message 'required input 'VISA resource name' is not wired'. What do these mean and what data type is to be wired here?

2. If I want to access a register on the Slave from the Master, which of the VI's should be used?

3. Form your reply, could you please explain the underlined a bit further as I not quite clear. 'I would start simple with something like the example I provided or the simple state machine template and assign a button on the UI to each thing or register you want to access on the device.' Which UI are you refering to?

Thanks

0 Kudos
Message 138 of 529
(1,991 Views)

Hello,

I noticed early in this thread you posted a version for 2011, do you have a current version for 2011?  Or can you make the released version for 2011 instead of 2012?

I have just been tasked with communicating with a DuraPulse GS3-4050 that uses MODBUS (ASCII or RTU).

Bryan

0 Kudos
Message 139 of 529
(1,991 Views)

_Bryan wrote:

Hello,

I noticed early in this thread you posted a version for 2011, do you have a current version for 2011?  Or can you make the released version for 2011 instead of 2012?

I have just been tasked with communicating with a DuraPulse GS3-4050 that uses MODBUS (ASCII or RTU).

Bryan

Hey Bryan,

The last version was just a save for previous of the codebase, and I don't guarantee it will link together properly. I've attached the same here. Because of a silly mistake on my part you will notice a missing VI called "syslog send" or something along those lines. It is not critical to the code and I deleted it from the file heirarchy, but not the project (I don't have 2011 installed). So...you'll probably get a missing vi message, go ahead and ignore it then delete the vi from the utility folder.

Message 140 of 529
(1,991 Views)