LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Modbus using LV8

Hi Jabili,
 
In the Modbus Slave example steps 0-6 on the outside sequence structure is setting the parameters to communicate with the device.  Step 7 in the sequence is reading the coils and holding registers, then writes to the discrete inputs and input registers.  Step 8&9 is closing all the resources. The Modbus Serial Devices devzone article explains the register tables and addresses in more detail. 
 
gdah,
 
Are you trying to write multiple register values to one space?
Are you trying to write to multiple spaces at one time?
Are you receiving an error code when the program times out?
 
Regards,
Andy L.
Applications Engineer
National Instruments
0 Kudos
Message 11 of 31
(3,481 Views)
thanks for responding , i complted my application modbus commucation on pc . my question is now the same communication can  i do using Labview pda module?? using pda instead of pc?? plz tell me
 
0 Kudos
Message 12 of 31
(3,380 Views)
Hi jabili,
 
Can you explain a bit more about your question regarding the PDA module? Are you trying to setup communication with a PDA through LabVIEW or are you running into a specific problem with the PDA? Are you using serial communication with the PDA? I think with some more information, we can give you some helpful suggestions to get you started. Have you looked at the PDA examples within LabVIEW? If you search the NI Example Finder for PDA, you will find many examples, including one great getting started with PDA example.
 
Carla
 
p.s Just for the future, one great practice is to keep each thread about the same topic. Since this thread is about modbus, this other PDA question would be better in a new thread. When people are trying to search for PDA topics, they might not see this thread since it is in a thread with the title being modbus. That way, you will get more people responding to your comments.
National Instruments
Applications Engineer
0 Kudos
Message 13 of 31
(3,318 Views)
hi thank u for responding, i did an application which is communicate with my device using modbus protocol. I want to run my application on the Pda . my qusetion the pda module weather support the modbus serial communication like as  Pc??
 
0 Kudos
Message 14 of 31
(3,279 Views)
Hi Jabili,
 
Starting with LabVIEW PDA Module version 8.20, support for VISA was introduced, and these functions can be used in a PDA application as in an ordinary desktop application using VISA.
 
Note: You must install the VISA driver on the PDA in order to use VISA. Select Start»All Programs»National Instruments»VISA»Windows Mobile and CE Driver Installation.
Aashish M
CEO
TransferFi
www.transferfi.com
0 Kudos
Message 15 of 31
(2,845 Views)
Hi, I felt like this forum almost hit exactly what I'm trying to achieve.  I am not in any way proficient or efficient at LV.  Just Basics.  I am trying to save an entire Holding Register of an NI device into a config file using modbus TCP.   Basically, I am hoping to store the entire Holding Register values table in a configuration file that I can then initialize into the device upon start up.  I am using NI Compact Vision Systems with VBAI to inspect products, but before you attack me for not being in Machine Vision Forums you should know that I am using LV 8.0.1 to change attributes on the fly using the Modbus TCP stuff.  I have successfully gotten to the point where I can run the device across the network and change the measurement limits for the given properties of a part being inspected via MB Ethernet Master Query.vi , however, whenever the device that holds the Modbus registers is powered down, the values that were written to the Holding Register are cleared--the registers are stored in the RAM of the device.  How can I save every Holding Register address (0000-FFFE) into an initiation or configuration file in one step, then write the entire contents to my NI CVS device's Holding Register as soon as the vi is run?  I can do it individually, one address at a time, but can't seem to figure out how to do the entire register.  Would I select Write to Multiple Registers, then enter hex 0000 starting address, qty = 65535, then link an ini file that I could use help on creating properly as well, to data portion?  Additionally, how do I save the entire Holding Register back into the ini file upon exiting the vi?  My guess is I am missing more Modbus library components that would help do this for me.  Either way, I'm scraping by trying to figure it out.  Any help would be much appreciated.  Thank you for your time.
0 Kudos
Message 16 of 31
(2,430 Views)
Modbus commands are usually limited to around 100-125 registers per read/write. It is device dependent. You can save the entire block of addresses to a file, read the file back, but you will need to write a block of 100 to the device at a time. What modbus function codes does the device support?? You should be able to use a read or write multiple holding registers command in a loop. Wire in data array chunks to send to the device.
0 Kudos
Message 17 of 31
(2,419 Views)
Thanks for the fast response.  The amount sent at a time is fine.  The device is a National Instruments Compact Vision System 1456.  Basically, this device is used for visual inspections via IEEE1394 firewire cameras.  It uses LV real-time engine with the option of strictly running LV or what they call VBAI (which is a software NI made that uses a bunch of vi's that you jsut select and enter values, no wiring); VBAI is what we use since it is incredibly simpler and faster to program.  I have multiple CVS devices.  Each device contains atleast 12 different inspection programs that visually measure features and stores those measurements within it's own memory.  Using Modbus Slave steps in NI VBAI, I can read/write to 4 registers--Input Register, Discrete Registers, Coil Register and Holding Register that are on each CVS.  Each program on the CVS device has individual steps, ie. count pixels in a given area.  I then have a step in NI Vision Builder for Automated Inspection that reads/writes to local modbus registers...I am not certain which ones, I could migrate it to LV8.0.1 to see exactly which, it appears to have no issues with the Modbus 1.1 library ethernet queries.  I'm almost positive I run any pertinent vi in this device as a step in any of it's programs.  I was hoping I could make a simple vi that would read an ini file and initialize the holding register with this file.  Problem is, I don't know how to write an ini file with this data.  So, I'll have the modbus write the "count pixels" value to an input register, then read Holding Addresses 0 and 1.  Then, as long as the input register is within the two holding register values, I pass the inspection.  Trouble is, it is compared with 0 and 0 after repowering--which occurs daily.  I have written each program to place each inspection step measurement into it's own Input address thinking I could store this value into the register permanently.  So, the device is already set up to call only like 80-100 register values and does so successfully.  I just don't know how to store those values to a table that I can have the device and my PC access as needed.  They all clear to 0 when powered down.  Come to think of it I need the device to load these values on it's own...which I can run vi's on....ugh.  So, yeah, good questions.  Well, I'd like to atleast be able to use my PC to store these values first, then I think I can figure out how to implement it on the device.  So, do you know how to write all the current values of an entire Holding register to an ini file then retrieve it and write into the register?  I don't know how to pull all the values out of the register and into an ini file nor put back into the Modbus register via an ini file.  I am thinking I just need to use the MB Registers Manager.vi, and write the Word Out /word In terminals to ini files?  Doesn't seem right though since I need a Word In and WOrd Out rather than just one or the other.  I just want to be able to have a table of the Holding Register values stored on my Host PC that can be recalled when the vi is turned on.  I think I'm rambling and getting confused.  Thanks again for your time.

Message Edited by scott_7723 on 03-26-2008 09:28 AM

Message Edited by scott_7723 on 03-26-2008 09:32 AM
0 Kudos
Message 18 of 31
(2,409 Views)
It looks like MB Registers Manager is just an Action Engine VI to keep track of Modbus register values within LabVIEW.  While it may be useful in your application, I don't think it is necessary.  I've never used it myself.
 
I would use the MB Serial Master Query.  You use function code 3 to Read Holding Registers and function code 16 Write Multiple Registers to pass values between LabVIEW and your device.  The only other thing you should need would be the config file I/O portion.  Search the forums and the examples in LabVIEW for this topic.  You should find multiple ways of doing this.  The easiest would just involve iterating through the array that is returned from the Read Registers and writing out the values to a text file.  In reverse, you'd read the text file and build an array of values that you woud pass into the Write Multiple Registers.
0 Kudos
Message 19 of 31
(2,402 Views)
Thanks.  Well, for some reason I thought I had to stick with only vi's that had ethernet in the name.  I was just assuming that all the serial ones dealt with a serial cable...guess not.  Thank you for your input.  Yeah, the config files were the other half of my problem, but I'll keep looking on the forums for more on that.  Thanks.
0 Kudos
Message 20 of 31
(2,395 Views)