LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to increase sampling rate of multiple sensors through RS485 and writing to measurement file?

Solved!
Go to solution

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!

0 Kudos
Message 1 of 10
(3,575 Views)

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.



-Matt
0 Kudos
Message 2 of 10
(3,554 Views)

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

0 Kudos
Message 3 of 10
(3,494 Views)

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?




Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 4 of 10
(3,486 Views)

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. 



-Matt
0 Kudos
Message 5 of 10
(3,483 Views)

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.

 

0 Kudos
Message 6 of 10
(3,481 Views)

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!

0 Kudos
Message 7 of 10
(3,477 Views)
Solution
Accepted by topic author Onjai

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.



-Matt
Message 8 of 10
(3,475 Views)

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

0 Kudos
Message 9 of 10
(3,406 Views)

Always a good idea to start a new thread for a new question Smiley Very Happy, 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.

 

Visa Error Codes

 



-Matt
0 Kudos
Message 10 of 10
(3,403 Views)