LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

USB VISA Problem

Solved!
Go to solution

Hi, 

I am trying to read and write simultaneously data from VISA via USB from STM32F103C programmed via Arduino IDE.

So my problem : Everything is ok for reading but when I am sending data to STM  it has kind of random delay, about few seconds. What to do I was looking for solution but did not found anything good enough for me. Write is for real-time control so it can't have any significant delay.



VI and code below.

Nightfall_1-1583415013370.png

 



Nightfall_0-1583414971135.png

 

0 Kudos
Message 1 of 4
(2,205 Views)

My first thought is that it is an issue with the termination character.  But I saw that you are doing a WriteLn in the Arduino code, and you have the termination character there.

 

But then looking at how you have the code to read the data from the serial port in the Arduino code, I think that it is a termination character issue but with the LabVIEW to Arduino direction.  Or more specifically a timeout problem.  It looks like you are only sending 1 byte to it.  But I don't know enough about the text code to know if you are telling it how many bytes to read.  Is it 1?,  just what is in the buffer?  Is the code not advancing beyond the Serial Read until it hits its timeout value?

 

If the timeout value is a few seconds, then you will have a variable length of time for the Arduino to read the message and for it to then proceed with what it has and move onto the next line.

0 Kudos
Message 2 of 4
(2,186 Views)
Solution
Accepted by topic author Nightfall

Its starts blowing my mind 
Firstly I tried just control(Visa Write only) and it worked.
But ... there is line in code below Serial2.print(a); which i used second serial line in STM with other device to check if it reciving correct number and it started crashing(error: 1073807360) above number 10 .... god knows why and in that line was println for printing in new line so i decided to write it without new line... remember that this part of code did not have anything to do with labview ..
but it started worked again... so back on the track
It is working separately. 

Nightfall_0-1583420829733.png

Nightfall_1-1583420890190.png

 

 

0 Kudos
Message 3 of 4
(2,159 Views)
Solution
Accepted by topic author Nightfall

Solution !!!
In VI sending just when needed.
In code if not recive anything Serial.read return -1 so if -1 do not update.

Nightfall_1-1583424129225.png

 

Nightfall_0-1583424094764.png

 

0 Kudos
Message 4 of 4
(2,147 Views)