04-14-2009 03:25 AM
hello,
I am trying to communicate with a device using Modbus.
In this the PC is master and the device whose registers i am going to read will be a slave device.
I have LabVIEW MODBUS Library installed on my PC as the hardware architecture will be on RS 485.
Now, suppose i want to access the register 400025 and upto 400125 of the device. I have gone through the MB master query (poly).vi.
In this vi i have to give the starting address as 400024 (as one should be decremented from actual register number) and on the quantity input i must give the difference between the starting and end register. MODBUS vi's will do rest of the task like LRC Calculation, putting the data into the MODBUS Frame etc.
My question is am i correct?
Please correct me if i am wrong.
Thanks & Regards,
Samriddh Sarbalhi
04-14-2009 12:24 PM
I am not familiar with Labview modbus but i think you are right.
First try to access a single register, then multiple registers.
There are a few threads about modbus.
Do a little search.
If you still have problems re-post
04-14-2009 12:48 PM
Give the starting address as 24. The initial 4 is already assumed based on the command code you are giving.
Also, make sure your serial settings such as baud rate, parity, stop bits are all correct and that you are using the correct slave address.
04-14-2009 11:27 PM
hi Ravens,
The point where i am struck is that see there are different kinds of registers available which can be accessed using MODBUS Interface.
It might be possible that any other register not only the holding register, any input register or read coils register may have the same address 24.
In that case how the MODBUS interface and Slave device will come to know that what kind of register (mean holding, input etc) has been called by using address 24.
I think i had made my point clear to you.
Please tell me in this regard.
Thanks & Regards,
Samriddh Sarbalhi
04-15-2009 12:07 AM
Hi Ravens,
One more question, see i am using MODBUS Library vi's amoung which there is a particular vi called " MB Serial Master Query (poly).vi
It is a polymorphic vi and i can select or configure it to certain tasks like read write coils, registers etc.
Can i use the same vi for master and for slave purpose?
If yes then how?
Since i had not received the slave hardware, i want to create a MODBUS Similator by my own so that i will become familier with MODBUS vi's and commands.
How can i do this?
Can you give me an example code except available in LabVIEW help.
Thanks & Regards,
Samriddh Sarbalhi
04-15-2009 12:08 AM
samriddh wrote:hi Ravens,
The point where i am struck is that see there are different kinds of registers available which can be accessed using MODBUS Interface.
It might be possible that any other register not only the holding register, any input register or read coils register may have the same address 24.
In that case how the MODBUS interface and Slave device will come to know that what kind of register (mean holding, input etc) has been called by using address 24.
I think i had made my point clear to you.
Please tell me in this regard.
Thanks & Regards,
Samriddh Sarbalhi
It knows based on what command code you use.
Command code 3 is used to address the 40000 series registers.
Command code 4 is used to address the 30000 series registers. (Seems backwards, but that is just the way it is..
So if you use command code 3 and ask for address 24, the modbus device will look at address 40025
If you use command code 4 and ask for address 24, the modbus device will look at address 30025.
Some devices might have a 30025 address and a 40025 address. Other devices might not allow that. But they will all know which address to look at based on the command code used.
(Similarly for read/write coils vs. read discrete inputs.)
Start working with the VI's and the device. You may still run into some problems and have questions, but ultimately you'll learn as you go.
04-15-2009 12:22 AM
I hadn't seen a (poly) version of the VI before. Did you download the library from here? http://sine.ni.com/devzone/cda/epd/p/id/4756
It looks like NI just recently updated the library and added polymorphic VI's do it. I can't comment on it because it is so new, I haven't had a chance to download this version and play with it yet. With the original MB Serial Master Query, you selected an Enum that determined which command you were using and it was a part of the command, start address, # of registers, and data and boolean cluster.
You can't use the Master VI as a slave. NI placed other VI's in that library to act as slaves.
The best help would be to download this new library and get it installed in your Function palette. Then open up the examples and see how NI uses the subVI's.
04-15-2009 04:00 AM
Hi Ravens,
Yes i had downloaded the library from this link.
I seems that you had not viewed the polymorphic MODBUS vi's.
The following attachment will make you clear on this.
One just have to place the vi on the block diagram and to select the function this vi should do on the foot of the vi.
Rest all is done automatically.
Can you name me any vi which is availabe and can be used as slave.
Thanks & Regards,
Samriddh Sarbalhi
04-15-2009 09:24 AM
samriddh wrote:Hi Ravens,
Yes i had downloaded the library from this link.
I seems that you had not viewed the polymorphic MODBUS vi's.
No. When I tried downloading the VI's I kept getting stuck at some dialog box about saving different instances of the VI. So I never really looked at it. Right now, I have several projects going on using the original library. I will have to decide at what point of time I may want to stop using what I have and update my code to use this newer library.
The following attachment will make you clear on this.
One just have to place the vi on the block diagram and to select the function this vi should do on the foot of the vi.
Rest all is done automatically.
Can you name me any vi which is availabe and can be used as slave.
There are two in the library called MB Serial Slave Example and MB Serial Slave Demon. Take a look at them.
Thanks & Regards,
Samriddh Sarbalhi
04-16-2009 07:02 AM
Hello Ravens,
I want to set a register on the salve with a value " -55 " .
How can i send this value on MODBUS.
See, i don not have any idea regarding this.
Please guide me.
Thanks & Regards,
Samriddh Sarbalhi