LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus RTU - Problem with 2 stop bits

That modbus library doesn't seem to set the stop bits.  And I'm not sure how easily it will be to set the stop bits because some implementation is hidden on the class wire, and modifying it may be hard because the files are part of a library.

 

I'm thinking that if it isn't explicitly letting you set the number of stop bits to 2, or at least I can't see it in the level of subVI's that it lets you look into.  If it doesn't set it, it might be using whatever value for stop bit is set in MAX, or set in Windows control panel  I would try to go into MAX and see if you can change the serial settings to 2 stop bits in there and try again.

 

The older library is the one I used to use and it doesn't involve classes. http://www.ni.com/example/29756/en/  Instead of using its MB Init, I just used VISA Serial Configure.  You might be able to use VISA Serial Configure to set the parameters ahead of using the "New Serial Master" VI with the purple header.  I don't know how that will interact with the class.

 

MODBUSTEST_BD

0 Kudos
Message 11 of 15
(1,428 Views)

@Ben_Manthey wrote:

What brand and model of USB to 485 converter are you using?

Is it this Micro Flex? If it is I've encounter the same problem.

I tried a USB to RS-232 converter and it works just like using it not. It does not change anything. The parameters should be correct. The VI works fine with the Carel controllers. I have a RS-485 to RS-232 converter.

 

Thanks arteiltle, i didn´t know that. Thought that could be code i don´t want there.

 


@RavensFan wrote:

That modbus library doesn't seem to set the stop bits.  And I'm not sure how easily it will be to set the stop bits because some implementation is hidden on the class wire, and modifying it may be hard because the files are part of a library.

 

The older library is the one I used to use and it doesn't involve classes. http://www.ni.com/example/29756/en/  Instead of using its MB Init, I just used VISA Serial Configure.  You might be able to use VISA Serial Configure to set the parameters ahead of using the "New Serial Master" VI with the purple header.  I don't know how that will interact with the class.

 


I tried your solution and it works again with the Carel controllers. But not with the I/O modules. I also prefer the older library.

 

I really don´t know what to do know. Can i just use two different parameter sets on the one modbus line? I know i should´nt but does this cause problems? I would use two different VISA configs with different parities and stop bits for the I/O modules and for the Carel Controllers.

0 Kudos
Message 12 of 15
(1,382 Views)

@RavensFan wrote:

 

I'm thinking that if it isn't explicitly letting you set the number of stop bits to 2, or at least I can't see it in the level of subVI's that it lets you look into.  If it doesn't set it, it might be using whatever value for stop bit is set in MAX, or set in Windows control panel  I would try to go into MAX and see if you can change the serial settings to 2 stop bits in there and try again.

 

The older library is the one I used to use and it doesn't involve classes. http://www.ni.com/example/29756/en/  Instead of using its MB Init, I just used VISA Serial Configure.  You might be able to use VISA Serial Configure to set the parameters ahead of using the "New Serial Master" VI with the purple header.  I don't know how that will interact with the class.

 

 


It is working for the Carel controllers with those settings, but again not for the I/O modules. I also prefer the older NI modbus library but wanted to test the other ones.

 

Thanks arteitle i didn´t know that. I thought that those are maybe signals which should´nt be there.

 

Iam not using a USB converter. Iam using a RS-232 to RS-485 converter. But i tried an USB converter and nothing changed. I can communicate with the Carel controllers but not with the I/O modules via Labview (just with the other program..).

 

I don´t know what to do now. Is it possible to use one Modbus line with two sets of parameters? One for the controllers and one for the I/O modules. I know that only one parameter set should be used, but would it cause problems? I would change the parity and the number of stop bits in the two parameter sets.

0 Kudos
Message 13 of 15
(1,401 Views)

So when you set the serial line to use 8 data 2 stop, it is now working for the controllers.  Correct?  In message 1 you said for the controller you were told 19200-8-N-2

 

You said the module has adjustable parameters.  Are you unable to adjust the modules to the same 19200-8-N-2?

If you can't set both things to the same parameters, then I think this manufacturer has some poorly designed equipment.

 

If their software is working, then some way or another they managed to get both the controllers and the modules working with the same parameters.

 

You can try to open and close the port and change the parameters when talking to each item.  It seems unwieldy but you'll have to try it out.

1.  Set port to 19200-8-n-2

2.  Write a command, wait for response.

3.  Get response.

4.  Close port.

5.  Set port to 19200-8-even-1  (??  I think you had said that in an earlier message.)

6.  Write a command, wait for response.

7.  Get response.

8.  Close port.

9.  Repeat at #1.

 

It is also possible you don't need to close the port, just reconfigure.  As long as the devices are well behaved and don't talk when they aren't supposed to, and don't replay back if they get a malformed message (because the message will be garbage to the other device who you are not talking to at the time.), and the devices don't lock up because they see bad messages on their end.  It just might work.  But if there software is able to work through that mess, then some way there is a way for you to do it to.

 

What has the manufacturer actually said about there devices having different serial parameters, and the one controller not being changeable?

 

You can try using a tool like a port sniffer to run while there software is running to see if you can pick up the transitions they have while they talk to each system.

0 Kudos
Message 14 of 15
(1,391 Views)

Sorry for the two posts. Somehow i couldn´t see my first reply.

 

I have tried your solution to try different settings and they work without closing the port. I think i will do it with the two settings. The devices shouldn´t talk without my request so i think it will work fine.

 

The manufacturer of the I/O modules said it should work with all settings and don´t know why it is not working for me. The controllers have hard coded settings i think. Only the baud rate is changeable.

 

Thank you for your help!

0 Kudos
Message 15 of 15
(1,374 Views)