09-16-2016 02:48 PM
I have a vi that:
-locates the USB port that the RS485 communication device is connected
-sends a command to each sensor
-reads a response from each sensor
-performs a calculation on the response
-records the response in a measurement file
I used a flat sequence to poll each sensor. I am trying to figure out a way to modify this vi to increase the sampling rate on the sensors. Currently, it takes 2000ms to poll the 4 sensors and write tot the measurement file. Does anyone have any ideas on how to speed this up programmatically? I am concsidering on buying a USB DAQ device (USB6000) and re-writing the vi. Just wondering if there was some tweek I caould make on the vi.
Thanks!
Solved! Go to Solution.
09-16-2016 03:47 PM - edited 09-16-2016 04:01 PM
A couple suggestions.
If you have a termination character for the read you could do away with the 200ms wait and read until termination character. Also you could try using a producer conumer loop so that you can capture the data in the producer and do the analyze and log in the consumer.
[Edit]: I also dont see a need to clear the port unless there is more information over the port than you expect. And to clean up the code you could put your write and read into a for loop and send it an array of your strings to write.
That could save you a little bit of time.
09-19-2016 09:41 AM
Hi Matt, Thank you for the suggestions. Unfortunately communications are binary protocol and there is no overhead with CR, LR or ACK bytes. I send a Hex read command and receive the temperature back as Hex. I am not too familiar with the producer consumer loop concept, but will read up and try it out. Your suggestion to put the code in a for loop and use an array sounds interesting...I will probably try that first. And there is no other info on the port, so I will remove the clear.
Thanks!
Cheers
09-19-2016 10:56 AM
I see that the name you are looking for should contain NI USB. WHat device are you trying to communicate with? If it is an NI device, why are you not using DAQmx?
09-19-2016 11:03 AM
Hi onjai,
The largest time suck in your app seems to be that 200ms delay you have before the read. Idk the protocal of the info from the device but if you could get rid of that you could save a lot of time. I was suggesting to get rid of that by either increasing your read timeout or reading until a termination character. The producer consumer loop will save a little time, but putting the read write and clear in a for loop was just to help clean up the code.
09-19-2016 11:03 AM
Joe..Communicating with 4 daisy chained Optris control boxes fitted with IR temperature sensors via RS485 communications using a NI cable RS485 to USB. Not sure what the DAQmx would look like, I would have to explore this option further. I am using LabView 2105 Base development and my options are somewhat limited.
09-19-2016 11:08 AM
Hi Matt,
There are no termination characters in the string coming back from the devices, just 2 bytes Hex for temperature value of the head. Will reduce the timeout as that may be the fastest fix
Thanks!
09-19-2016 11:17 AM
I meant put the timeout on the line so the read will either timeout after 200ms or read the 2 bytes. WHichever is faster. Then removes that 200ms wait you have. I attached your vi to show you what i meant. I didnt notice it was an ni device wither so you may want to look into daq functions. They will clean up your code and are very easy to use.
09-21-2016 11:18 AM
Matt,
Thank you. Able to double the sampling rate by removing the 200ms wait in each frame.
I am not sure if I should start another discussion for an error message that the vi throws when it is started??? i.e "Error -1073807343 occured at Visa open..." in
09-21-2016 11:24 AM
Always a good idea to start a new thread for a new question , but, the answer might be in the error code if you havent looked it up yet. I gave you a link to visa error codes.