LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sequencing While loops

In the code below, I want to make the second while loop lag behind the first while loop by one iteration. 

 

This is a simplified version of my requirement. My actual requirement is to control two Modbus slaves one after the other.  I tried all methods within a single loop, but whichever one I try i end up with the same issue  : When only one slave is controlled i can run my loop at 50ms speed neat. But the moment I invoke the second slave the loop timing starts lagging and settles around 100ms or so.  And each packet of my Modbus message is not more than 7ms and I account for this.  Still I have the issue. So now I am trying to send commands from two loops which will be sequenced properly. 

 

2-WhileLoops.png

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 5
(856 Views)

Hi Moga,

 


@MogaRaghu wrote:

So now I am trying to send commands from two loops which will be sequenced properly. 


Why not use just one loop and sequence the Modbus communication within this loop (using DATAFLOW)?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(830 Views)

Using two loops should have the same performance of one loop, only more difficult.

I would focus on why you see the time lag. What interface are you using? Ethernet, I guess.

Can you show us the code where you try to poll both slaves in one loop? Maybe there is something wrong there.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 5
(816 Views)

@pincpanter

 

This topic has already been discussed : https://forums.ni.com/t5/LabVIEW/VFD-Modbus-Control-1-works-2-Does-not/td-p/4180794

 

But just after that the company went into a slowdown due to pandemic and the project was on hold.  Now they are reviving. And I am back to square 1. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 4 of 5
(792 Views)

So the loop does not hang any more? 100 ms does not seem a bad performance to me, why you need to speed up further?

What's the maximum speed you can reach polling a single device (i.e. putting no delay between successive commands)? Do the response times jitter or not?

Remember that the packet sending time is not so important, more relevant is the time taken by the device to manage the command and send back an answer. You have no control over this time. For example, if a device manages commands every 50 ms, it's possible to have a timing interaction when you poll two slaves. For example, you may receive an answer from the first device just after the beginning of the "deafness" interval of the second device. This would mean you need to wait for further 50 ms to get an answer.

Also, why you clear the input buffer after sending a command? Is it needed to clean the command echo over RS-485?

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 5 of 5
(777 Views)