LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Configuring/reading multiple signal types from one module via serial port

Thanks for your suggestions, Ravens Fan.  They were very useful!

Ravens Fan wrote:
 
Instead of using a wait statement and reading the bytes at port and only reading that many, it would be better to get rid of the wait, read a sufficiently large number of bytes into the VISA Read statement and let the termination character of carriage return be what returns the data from the VISA read function.

If I get rid of the wait statements and 'reading the bytes at port', do I need to add anything else in between the VISA write and reads, or do I just wire them together?  It seems, however, that when I remove the wait statements, I get frequent spiking in all measurements being read from module 4.  Therefore, I'm hesitant to remove them completely.
 
Any ideas?
 
Thanks again!
0 Kudos
Message 11 of 17
(954 Views)
I think you can eliminate the waits.
 
If you say you want to read 1000 bytes with the termination character enabled, it will hold at the read statement until the 1000 bytes are received, or the termination character is received, or the timeout on the serial port is reached (which would return an error).  I think if you use a wait statement and it's not long enough, you may get incomplete data which would explain spurious spikes.  If you use it and it is too long, then you are waiting unnecessarily.  If you don't use a wait at all in your current configuration of get bytes at port, it will get the bytes at port immediately after the write which would almost certainly be an incomplete message would give a lot odd data spikes.
 
You may want to reduce the serial timeout from it's default of 10,000 milliseconds.  Also, move the configure port and close port to before and after the loop, repectively.  Take a look at all of the serial port examples in the example finder to see different ways the serial port can be used through programming.
0 Kudos
Message 12 of 17
(951 Views)

Have you tried a low wait time, such as 2 to 5 ms? 

Sorry.. I didn't read the entire thread, but I did find that on some instruments, small wait time is needed between the write and read transactions. Some as high as 10 ms. 

For some instruments that are slow to respond (1990's vintage), I typically prepare a reading loop which stores everything in a shift register until I finished reading the serial transaction. Then pass the values for processing.  If it is continuously running, I then use the producer - consumer loops and feed the consumer loop at intervals though a Queue.

RayR 

0 Kudos
Message 13 of 17
(950 Views)
Thanks for all of your suggestions and help, everyone!  I think I have my program doing what I want now, thanks to all of you!  I really appreciate your responses!
0 Kudos
Message 14 of 17
(926 Views)

Hello,

I have the same issue. Can you tell me how did you fixe your program please?

 

 

0 Kudos
Message 15 of 17
(643 Views)

Hi sam,

 

you have the same problem with the very same hardware and software like someone 11 years ago?

(Do you really expect answers from "you" after that long time?)

 

It would be helpful if you create your own thread with explaining the exact problem!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 16 of 17
(640 Views)

Hello GredW,

 

Thank you for your message. I created my own thread. it will be a please if you can take a look.

https://forums.ni.com/t5/LabVIEW/Multi-signals-acquisition-from-the-same-serial-port/td-p/3882310

 

Thank you.

Best regards.

0 Kudos
Message 17 of 17
(623 Views)