Academic Hardware Products (myDAQ, myRIO)

cancel
Showing results for 
Search instead for 
Did you mean: 

modbus

Dear All

I have a modbus master in my block diagram with the following specifications:

BoudRate: 115200

Type: RTU

I want to know if the modbus Write and Read blocks themselves take care about the silence time (3.5Char at the end of the frame) or not? If not how could I do that? and how do I compute the appropriate delay time?

 

Thanks in Advance

Regards

V.S

 

0 Kudos
Message 1 of 8
(6,498 Views)

V.S.,

 

Are you using the Modbus Library, Modbus API, or the functions that come with LabVIEW 2014 in the Real-Time and DSC module?  Because the silent time is a part of the RTU ADU I would be surprised if you had to do anything extra but it might depend on what Modbus functions you are using.

Matt J | National Instruments | CLA
0 Kudos
Message 2 of 8
(6,469 Views)

Dear Jacobson

I am using Modbus library. As you see in the following attached image if I set the "Wait" after each Read operation equal to zero, it cause an error when I run the program.

I should set a value for this "Wait"s depending on the number of "Holding Registers" I read in the previous frame. for example when I am reading one Holding Register in the previous frame I have to wait for 5mS and when I read 10 Holding Registers I have to wait 10mS.

Is it because of the silent time? if not what is the reason of this problem?

 

 

Beat Regards

V.S

0 Kudos
Message 3 of 8
(6,455 Views)

V.S.

 

To be honest, I have no idea.

 

The Modbus Library is example code though so you should be able to look inside to see if it is.  If I were to guess I would say that the silent time is not the direct cause.  I say this because the Modbus RTU ADU consists of Silence - Address - PDU - CRC - Silence.  I would not think that the number of Holding Registers read would effect the the silence time linearly.  There is still a very good chance that you are correct though

 

I would be interested to see if this 5ms/register wait holds up for larger and larger reads.

Matt J | National Instruments | CLA
0 Kudos
Message 4 of 8
(6,444 Views)

Dear Friend

I have attached a simple VI. Please check it. What do you thing is the problem of this code. another confusing thing about this VI is that when I run it in "Highlight" mode it sometimes runs without error while in "non highlight" mode it cause an error.

You can see the Error in the attachment.

it would be appreciated if you help me to solve this problem.

 

Regards

V.S

0 Kudos
Message 5 of 8
(6,433 Views)

V.S.

 

I'm having trouble reproducing your error, but there are a few best practices that could improve the code you have.

 

1. It is usually best to create a new serial master once before your main while loop.

2.Similarly, it is usually best practice to close your references after you are completed.

3. Unless you are running FPGA code, you should almost never have a false constant wired to a stop if true loop condition.

Matt J | National Instruments | CLA
Message 6 of 8
(6,425 Views)

Dear Matt J

Thanks for the information. I have done the two first suggestion you offeredm, but I do not understand the reason of the third one. could you explain more?

Moreover the problem still has not been solved.

 

Regards

V.S

0 Kudos
Message 7 of 8
(6,402 Views)

V.S.

 

If you have a false constant wired to your stop condition in a while loop, your program will run forever.  This means that if you want to stop your program you have to click abort.  Using abort usually works for smaller programs but it is a bit like stopping your car by running it into a concrete wall.  This works perfectly well if your only concern is stopping as fast as possible but there might be significant consequences.

Matt J | National Instruments | CLA
Message 8 of 8
(6,399 Views)