Jump to content

Modbus communication problem


Recommended Posts

Hello everyone.


 


I'm currently trying to establish a communication between a Superflow SF1020 bench and Labview thought a Modbus protocol and I'm meeting a few troubles...


 


First of all, the device can be seen by MAX properly only when i just rebooted the computer. At this moment, I can open the VISA panel and see on his attributes that "Is Port Connected" has an "Invalid Property Value" on his current value. 


 


At this point, I tried some examples found on modbus library or on topics given by labview community and It always starts the same way : I just have to choose "Com 1" for the visa ressource name before the system detect the instrument and so I can finally choose "ASRL1::INSTR". At this moment, MAX can only see that the interface name is "unknown". As the device is "reserved" by the program, I can understand that it is not usable anymore, but as I'm not an expert, I prefer to explain all the details, in case it could help.


 


Among all the examples I found, most of them end the same way, with the famous visa read error -1073807298 that I've never succeed in overpassing it, even with the help of many older topics :


http://digital.ni.com/public.nsf/allkb/0C2ABA463217342686256E2E006DF187


http://digital.ni.com/public.nsf/allkb/60DDFED7EFEFE7188625705700750821


and I just quoted the official solutions ...


 


Besides, I also tried to do a Modbus I/O server to see if there was any piece of informations that was transfered by the bench and there was none. As a result, the attribute "CommFail" was on true state...


 


As I'm not used to Modbus protocol or serial instruments, I'm not even sure if the communication was well set or if my problems come from the SF1020 or my lack of modbus communication knowledges. In that way, if any of you know how to solve my problems or at least one of them, help will be warmly welcomed 16x16_smiley-happy.gif


post-54596-0-58751300-1460035830.png

TESTPERSO.vi

Link to comment

Honestly, I only know a few things about how Modbus works, and so I've tried many examples given by Labview (in the usual modbus libraby) or that I've found on the community FAQ, and most of them gave me the same -1073807298 result.. If you have an idea of example that should fit to my situation, please tell me because I'm currently doubting about the functions that I have to use.

 

Is this topic dealing with what you meant ? :

http://digital.ni.com/public.nsf/websearch/0C2ABA463217342686256E2E006DF187?OpenDocument

Link to comment

The best way to debug would be if the mfg'r provided a test software and you get that working first (without labview open) that will verify your hardware layer.  Then move to LabVIEW and software layer.  99% sure its not the "functions" you are using. 

 

If you don't have access to the mfg's software, start at the hardware level and read the OEM manual (i couldn't find it on line):

Is the interface RS-232, RS-485, or RS-422?

Does your USB to Serial converter support the hardware layer above?

If its RS-232 to you have the TX and RX lines swapped incorrectly?  

Are you sure the COM port is assigned to COM1? Plug and unplug the converter and see if COM1 disappears from windows?

 

Moving to the software layer

What does the manual say the default COM settings are?

Baud Rate = ?

Parity = ?

Data Bits=?

Stop Bits= ?

 

What is the default Modbus device address?

 

Based on your screenshot, it looks like you are trying to read from a starting address of 0.  Usually the address is a higher number.  Do you have the address list from the mfg?

Link to comment

Thank you Mr Bean :)

 

That's the way I tried it. I first installed the OEM software on another computer and was able to send and receive a few informations so I know the hardware communication can be set. I haven't tried it on this computer but since there's no drivers issue, I guess it wasn't necessary. I'll do it again since it doesn't take a lot of time.

 

I must agree with you on that point, their support is very poor, and their manual isn't so much detailed. In fact, the OEM manual only show us the usual Windows device manager window to give us some information about the default com setting : 

bit per sec (baud) : 9600

data bits : 8

parity : none

stop bits : 1

flow control : none

 

The link between the bench and the computer is made by an USB  A to B cable, given by the OEM, but thanks to the OEM manual, I know it is also possible to command it with RS-232.

I know the com port is well assigned because i changed it on the Windows device manager and it can be seen/unseen when I turn ON/OFF the device. However, I have a problem with VISA resource name, as you can see it on the picture attached. Maybe it is the cause of my problem, but as it the first time I'm having so much issues to establish a device communication, I don't have so much experience with that.

 

I've attached the OEM documents to control the bench with protocol Modbus so that you can see informations about it, but I already have tried both parameters (from adress 0 and adress 40000) and the same dead-end. Same thing happened with modbus adress device, because the default one is adress 35 (and I tried it with this adress) but as I can change the adress on the bench front panel, I swaped it to adress 1. 

 

I've also attached 3 differents VI that I used trying to establish communication, so that you can tell me if the global architecture is correct.

 

Thank you for your time  

 

Modbus Example.vi

post-54596-0-83872700-1460126878.png

TEST.vi

TESTPERSO.vi

FlowCom Modbus commands.pdf

Link to comment

Your code looks Ok.  Have you tried using a serial sniffer (such as device monitoring studio) while the OEM software is running?  This will give you a clearer idea of how it communicates if you are able to make the OEM software work.

 

It looks like you have a bunch of duplicate COM ports left open, probably a result of not stopping the program gracefully.  You can modify or use the attached VI to close these duplicate ports.  (There may be a better version out there to do this but I can't find it right now) But I don't think thats the root cause of your problem.

 

 

Also, try starting at address 1 (instead of address 0)

VISA Close All.vi

Edited by bbean
Link to comment

For convenience, I'd recommend trying the MB_Serial_Master Comm Tester (attached). You can try with different serial port settings and register addresses. Once you find the winning combination you can put it in your code.

 

To use:

- Run the VI

- Set the Communication Settngs: COM1 or COM3 or COM4 (whichever is connected to the instrument), Baud Rate 9600 or 19200, Address 1, Mode RTU, Stop Bits 1.0, Flow Control None, Parity None

- Click Open Port (The LED should turn green)

- Set starting address of Holding Registers to 0 (also try 1), quantity 1

- Click Read Registers

 

If this produces an error, the serial port will be closed automatically.

MB_Serial_Master Comm Tester.vi

Edited by Porter
Link to comment

Honestly, I only know a few things about how Modbus works, and so I've tried many examples given by Labview (in the usual modbus libraby) or that I've found on the community FAQ, and most of them gave me the same -1073807298 result.. If you have an idea of example that should fit to my situation, please tell me because I'm currently doubting about the functions that I have to use.

 

Is this topic dealing with what you meant ? :

http://digital.ni.com/public.nsf/websearch/0C2ABA463217342686256E2E006DF187?OpenDocument

Yes, that's the one I was referring to. Specifically, the part that relates:

 

This issue can be caused because some third party devices do not implement all serial settings on their USB-Serial adapters. To avoid the problem, do not use the VISA Configure Serial Port VI in your program. Instead use a VISA property node to set only the supported properties.

To determine which properties are unsupported by your USB-Serial adapter, use a VISA property node, and set the properties one at a time to see which properties cause the I/O error to be thrown.

 

The error message is all about serial. I looked in the Modbus serial init and saw all the properties being set. Try just setting one at a time to see what is throwing the error.

  • Like 1
Link to comment

Thank you all for your answers.

Could you please send me another version of the VIs please, because I can't run them with Labview2012.

 

I'm currently trying to use a serial sniffer while executing the OEM software, but I'm now having troubles using it, since their software can't even set a proper communication. I have asked the manufacturer if there was something special to do to make it work but it seems like the main problem comes from the bench...

 

Once this step is made, I'll focus on Labview and possible defecting parameters

Link to comment

Hi everyone, 

 

After two attempts of running the OEM software on two differents computer (maybe the communication problem could have come from drivers conflict), I am now thinking that the problem comes from the USB cable and so I will try the serial bus with the following cable (http://uk.rs-online.com/web/p/kvm-mixed-cable-assemblies/6877819/) as soon as the OEM contact send me the pinout of the serial connector, and so I'll be able to use a serial sniffer..

 

Thanks to porter, I've been able to use the Comtester and the communication seems to be OK but it ends with -1073807298 when I try to read registers (I've attached screen shots).

A good thing is that Tim_S must be right about parameters set because I've tried a VI given by a support and so it shows that the previous error is no more a prob...

 

Please tell me if I made a mistake in understanding the situation or if I missed something.

 

Thank you :)

post-54596-0-39485600-1460562539.png

post-54596-0-17673900-1460562540.png

Link to comment

The main difference that I see is that the I/O buffer sizes are set to 4096 before the first VISA write. I suspect that they are doing this because of the problem described here: http://digital.ni.com/public.nsf/allkb/60DDFED7EFEFE7188625705700750821

 

You can add "VISA Set I/O Buffer Size" to the "Open Serial Session.vi" of the Modbus Serial Comm Tester (located in the init case).

post-40255-0-80057000-1460606797.png

 

I imagine that this would have a negative impact on performance so you should increase the timeout to 1000ms.

 

Also it looks like they use function code 4 to read address zero. So you should try using "Read Input Registers" to read register zero.

 

  • Like 1
Link to comment

Error code -8101 means that the Slave ID of the RX message doesn't match that of the RX message.

Error code -8102 means that the CRC of the RX message is invalid.

 

I'd suggest using a different USB to serial converter. Otherwise, you could try increasing the number of retries.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...

Important Information

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