LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus read

Solved!
Go to solution

I am trying to read three holding registers of a Modbus slave unit from inside of a timed loop. The timed loop is configured to run at 250ms interval in the original application and hence I will not be able to wait till the read is completed. Hence I am reading each  register one by one allowing a 250ms gap in between each read.

 

I just want to know if the VI as I have coded will do the job ?? ( Reading one register in a  VI with Timed loop is working fine )  I am particularly keen to know if the way I have opened the VISA reference and using it is correct.

 

Thanks 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 10
(4,257 Views)

No need to chain three case structures containing exactly the same code. Instead, you could create a short array containing the adresses to be read, and index it accordingly, using the result of a single Q&R operation.

 

Also, I usually use a different re-order code (see picture). However, I did some timing and although more compact, my solution is surprisingly 2 times slower 😞

 

18565i0838E710F10DFD28

Chilly Charly    (aka CC)
Message 2 of 10
(4,247 Views)

Hi CC,

 

Agreed there was NO need to repeat structures as I did. But when you are struggling with a code snippet and do not know why it does not behave as it should I guess it is good to KISS 😉

 

The conversion as you did is simple but it does run a tad bit slow. I am already fighting for time and hence chose the fastest means.

 

But since you did not remark anytrhing about the way I handled VISA,  I guess it is oK ?

 

Thanks

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 10
(4,235 Views)

 


Raghunathan a écrit :

 

The conversion as you did is simple but it does run a tad bit slow. I am already fighting for time and hence chose the fastest means.

 

But since you did not remark anytrhing about the way I handled VISA,  I guess it is oK ?


the decoding step takes less than 10 microseconds, so I don't believe it will have any impact on the overall performance 😉

Waiting for the bytes transmission is orders of magnitude longer, leaving time for parallel processing.

Nothing wrong with VISA as far as I can see.

 

Chilly Charly    (aka CC)
0 Kudos
Message 4 of 10
(4,227 Views)

Hi CC,

 

Thanks for the input confirming that the way the VISA is handled is OK.

 

With regard to the "slower " execution of the conversion with Split and Join number functions, the remark was to point the relative merits.

 

Thanks

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

Why not use the Swap Words function?

0 Kudos
Message 6 of 10
(4,212 Views)

 


Ravens Fan a écrit :

Why not use the Swap Words function?


because it's two times slover than char reordering. I did some timing.

 

Chilly Charly    (aka CC)
0 Kudos
Message 7 of 10
(4,205 Views)

My calculations show that the swap words doing it in about 2/3 the time.  About 14 msec per million as opposed to 21 msec per million for the split/join method.  Sometimes about the same.

 

Though either way the calculation is very fast.

 

0 Kudos
Message 8 of 10
(4,196 Views)

Of course, you are right. Sorry, I was still refering to the string manipulation.

Chilly Charly    (aka CC)
0 Kudos
Message 9 of 10
(4,180 Views)
Solution
Accepted by MogaRaghu

Hi Ravens and CC,

 

Thanks for your interesting alternatives in handling the data conversion. Of course in this case the maximum time is taken by the write - read to  the Modbus and  thus this conversion timing is not too critical.

 

But of course compared to the original way of stripping - reorganizing and concaneting the alternatives are very elegant.

 

thanks again.

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 10 of 10
(4,172 Views)