LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI VISA UART desn't send data out in event structure

I am having a problem getting a visa instances to send a string. I have two visa instances. The first is started by a button that is connected to a case structure (True/False). I am communicating with a µC and it works in both ways with the first instance.  

chili023_0-1643128563954.png

 

I recently tried to add an additional button that should also send a string over UART to the same µC. However nothing is coming out of the com port. The instance is started by a change value in a button.

The indicator for "bytes send" shows 8 bytes send as requested, but the µC is not receiving anything. What am I missing?

chili023_1-1643129102434.png

 

0 Kudos
Message 1 of 7
(1,697 Views)

Hi chili,

 


@chili023 wrote:

The indicator for "bytes send" shows 8 bytes send as requested, but the µC is not receiving anything. What am I missing?


You missed to attach your VI(s), we cannot edit/debug/run images with LabVIEW…

 

IMHO it makes no sense to clear VISA buffers immediatly after VISAWrite: by calling VISAWrite you just put your data into the COM port buffers! It is up to the COM port driver to actually send the data in the buffer over the communication bus - which will take some time, form µs to ms, depending on baudrate and data length. But you clear the buffer within ns…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(1,677 Views)

On top of what Gerd said, don't open a VISA Session, Initialize the serial port and then close the VISA session every single time you read or write to the port. 

 

  1. Open VISA session and configure the serial port at the beginning of your program
  2. Pass the VISA Session around your loop using Shift Registers
  3. Reuse the same VISA session throughout your program
  4. Close the VISA session at the end of your program
========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 7
(1,672 Views)

Hi Gerd

Thank you for your input. You are right. when I delete the CLR and CLOSE of the VISA The message is send.

I will add some delays or a flat sequence.

 

On second thought I will add a Response from the µC.

 

Thank you so much. Have a great day!

0 Kudos
Message 4 of 7
(1,669 Views)

@chili023 wrote:

Hi Gerd

Thank you for your input. You are right. when I delete the CLR and CLOSE of the VISA The message is send.

I will add some delays or a flat sequence.

 

On second thought I will add a Response from the µC.

 

Thank you so much. Have a great day!


I would not recommend either of your proposed "fixes". Adding delays to make things work is generally a sign of a poor application design. As suggested, open your VISA session once at the start and continue to use it throughout your application. Only close it at the end of the application or when you are finished with the specific device. For example, if you are using VISA to communicate with your device under test you would open the session at the beginning of the test and close it when the test completes.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 5 of 7
(1,658 Views)

Hi chili,

 


@chili023 wrote:

I will add some delays


Oh no!

 


@chili023 wrote:

I will add … a flat sequence.


Oh no, no!

Both options are just bandaids to cover the problem!

 

Learn about proper dataflow (to avoid flat sequences) and about proper implementation of communication protocols!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 7
(1,656 Views)

Hello and thank you for all the replies.

I will do some digging and chang my programm according to your suggestions.

I will present my solution here.

 

Thanks so far

0 Kudos
Message 7 of 7
(1,653 Views)