ni.com is currently undergoing scheduled maintenance.
Some services may be unavailable at this time. Please contact us for help or try again later.
06-10-2022 07:24 AM
Hello
I try to read serial data (UART @ 57600baud) with a while loop. Therefore the while loop is triggered each time when receiving a char ">" to take a timestamp. The timestamp is written to an array.
Interestingly I see a pattern which somehow indicates that the loop or windows interrupts the reading.
Question:
- How can I improve or speed up the serial reading to get more constant timestamp?
thanks
The char ">" comes in 10Hz +/-2% (verified) but when plotting the timestamp array I see following:
Solved! Go to Solution.
06-10-2022 07:41 AM - edited 06-10-2022 08:03 AM
@Norick17 wrote:
Question:
- How can I improve or speed up the serial reading to get more constant timestamp?
What problem are you trying to solve?
Serial communication is designed for communication, not for time-keeping. Also, you will probably want to avoid "Bytes At Port". Check out https://labviewwiki.org/wiki/VIWeek_2020/Proper_way_to_communicate_over_serial
06-10-2022 07:47 AM
Take a look at Proper way to communicate over serial
"Do not use Bytes at port!!!!" is the first thing he says.
06-10-2022 07:51 AM
06-10-2022 08:22 AM
I try to solve the problem that the lower values (every 4th) should be much higher.
I measured with a scope the reading and all readings are around 10.4-10.5Hz without any values below 10 Hz like I measure it in LV with the while loop. Now I try to solve it with a different vi in order to have a more accurate reading.
06-10-2022 08:41 AM
@Norick17 wrote:
I try to solve the problem that the lower values (every 4th) should be much higher.
Yes. That is why I asked. I suspect that there is an https://en.wikipedia.org/wiki/XY_problem here. There are more problems to that approach you are on than just Bytes at Port. I strongly believe that you will be more satisfied with the feedback once you tell us why you are trying to get 10Hz readings from your serial port.
06-10-2022 08:51 AM
Serial reading is not appropriate for precise timing. Remark however that the average frequency is about 10.05 as expected.
Thus not only the lower values are wrong, but the higher are (less) wrong too.
06-10-2022 08:55 AM
@thols wrote:
Take a look at Proper way to communicate over serial
"Do not use Bytes at port!!!!" is the first thing he says.
ok - and leave the number of bytes open?
06-10-2022 09:06 AM
@Norick17 ha scritto:
@thols wrote:
Take a look at Proper way to communicate over serial
"Do not use Bytes at port!!!!" is the first thing he says.
ok - and leave the number of bytes open?
No, wire a large number, greater than any expected message size. And leave the property node outside the loop. Once it's enough.
06-10-2022 09:18 AM
@LLindenbauer wrote:
@Norick17 wrote:
I try to solve the problem that the lower values (every 4th) should be much higher.
Yes. That is why I asked. I suspect that there is an https://en.wikipedia.org/wiki/XY_problem here. There are more problems to that approach you are on than just Bytes at Port. I strongly believe that you will be more satisfied with the feedback once you tell us why you are trying to get 10Hz readings from your serial port.
You are asking about "why" but this is absolutely irrelevant for my problem (question), because I need to know the timestamp between the "<" chars. It does not matter if it is 1, 3 or 10Hz.. The question is HOW I can improve my vi to solve the problem.