07-11-2010 02:27 AM
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
Solved! Go to Solution.
07-11-2010 04:39 AM
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 😞
07-11-2010 09:34 AM
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
07-11-2010 11:41 AM
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.
07-11-2010 12:08 PM
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
07-11-2010 12:30 PM
Why not use the Swap Words function?
07-11-2010 03:40 PM
Ravens Fan a écrit :
Why not use the Swap Words function?
because it's two times slover than char reordering. I did some timing.
07-11-2010 04:40 PM - edited 07-11-2010 04:46 PM
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.
07-11-2010 09:04 PM
Of course, you are right. Sorry, I was still refering to the string manipulation.
07-11-2010 09:12 PM
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.