07-15-2024 08:19 AM
I'm reading data using Visa read(say 10 bytes) in the LabVIEW Real-time and need to log the data for post analysis. To maintain the determinism i decided to move the data to low priority loop. The Problem is that Visa read function gives out as string data type. So that not able to use the RT FIFO with string data type. Can anyone tell me solution for this without loosing the data.
My idea is to convert the string to byte array and move the array using RT FIFO.
Solved! Go to Solution.
07-15-2024 08:23 AM
Hi Manik,
@Manik981211 wrote:
So that not able to use the RT FIFO with string data type. Can anyone tell me solution for this without loosing the data.
My idea is to convert the string to byte array and move the array using RT FIFO.
Have you tried your idea?
Where are you stuck?
07-15-2024 09:33 AM
Without the testing device, I'm developing the code in RT now. I have to maintain the loop rate at 100Hz(10ms) and let say the device gives 10 bytes(hex format) of data which means character of 20 bytes. If i use use string to byte array then each time array size writing to FIFO is also 20.
In future i need to connect more than 20 devices to test independently and run parallelly. I'm worrying about the memory optimization and chances of FIFO overflow. So that i like to know the efficient way to move the string output from Visa Read to the low priority loop.
07-15-2024 09:59 AM
What is the bus this communication is done over? Does the device constantly send data or do you have to request it? Assuming RS-232, what is the baud rate?
07-15-2024 12:02 PM
This is done using RS 485 bus and the baud rate is 115200.The data is continuously coming at a rate of 50 to 100Hz.
07-15-2024 01:39 PM - edited 07-15-2024 01:40 PM
@Manik981211 wrote:
This is done using RS 485 bus and the baud rate is 115200.The data is continuously coming at a rate of 50 to 100Hz.
The good news is that it looks like your baud rate is fast enough to get your data rate. I have ran into instruments that did not meet the requirement. My nightmare scenario had a device output at 100Hz, but the message takes 13ms to output.
Given this information, I would have the loop do a VISA Read to get the message and convert the data. This loop should have no waits in it as the VISA Read waiting for the message will limit the loop rate. And there should be plenty of time to convert the string data into the float, cluster, or whatever data is in the message and then use a standard queue to pass the data to another loop for further processing.
07-16-2024 04:44 AM
If i use the standard queue to pass the data to another loop then it will affect the Deterministic of my priority loop rate. So that case how to move the string data type to low priority loop.
07-16-2024 06:19 AM - edited 07-16-2024 06:22 AM
@Manik981211 wrote:
If i use the standard queue to pass the data to another loop then it will affect the Deterministic of my priority loop rate. So that case how to move the string data type to low priority loop.
Considering the data rate you are working in, you are most likely busy with premature optimization at this point! You should have more than enough time to parse the incoming data string into a more suitable numeric representation such as a numeric, an array of numerics or a cluster containing multiple different elements and pass that on to the processing loop through a queue. Converting string data to numerics can cost performance but your serial port is almost always the actual limiting factor here and your CPU runs many circles around the loop waiting for enough data to convert into a numeric representations.
We are not using 8-bit CPUs running at 4 MHz anymore nowadays. Those could get overrun by a 115kBaud serial link but not a 1GHz 64-bit CPU.