From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

want to send data through labVIEW to arduino using visa write and the process and take steps using arduino. A

Solved!
Go to solution
I want to send data through labVIEW to arduino using visa write and the process and take steps using arduino. After that I want arduino to send the necessary outputs via serial port to labVIEW which it should read using visa read and store it in a string. While I am able to individually write or read at a time, I am unable to do it consecutively. I have used advanced read and write vi for the verification of my code but to no avail. The error reads " timeout before execution". Please let me know where I may be going wrong. Also is there a way to write code for hx711 using labVIEW
0 Kudos
Message 1 of 21
(15,640 Views)

Hi,

 

Pl check the below points

1) Although Arduino programming is not officially supported by National Instruments, a third party toolkit exists, called "Labview interface for Arduino Toolkit". Following link provides procedure and softwares required.

https://decibel.ni.com/content/docs/DOC-15971

2) For VISA communication pl search for simple serial example VI in labview and try using this code.

3) For Communication the link  below might help you from Arduino Form.

http://forum.arduino.cc/index.php?topic=252724.0

 

 

 

Regards

M.Kishan ,

-AE team ,NI India.

 

0 Kudos
Message 2 of 21
(15,621 Views)

Hi Ahsial! While the above comment is correct that National Instruments does have a Labview Interface for Arduina (LIFA), there is a newer (shinier) toolkit called LINX! I've personally used Linx and the ease of use is glorious, highly recommend. 

0 Kudos
Message 3 of 21
(15,612 Views)
The aim of my work is to design an interface with labVIEW but the whole of programming is in arduino. For example if I wish to print A when b is pressed or B when a is pressed on the keyboard. But I am unable to print anything and the led of arduino rx and tx glow simultaneously.
0 Kudos
Message 4 of 21
(15,573 Views)

@Ahsial wrote:
While I am able to individually write or read at a time, I am unable to do it consecutively. I have used advanced read and write vi for the verification of my code but to no avail. The error reads " timeout before execution". Please let me know where I may be going wrong.

Please share your code.  That is the only way we can help you debug your issue.

 

 


@Ahsial wrote:
Also is there a way to write code for hx711 using labVIEW

Change your string control to use Hex Display (right click on it).  Then you can type in 0711.  Wire up that string to your VISA Write.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 21
(15,570 Views)

i was trying to debug using these two codes

i have modified the advanced serial read and write (available online)

i testes the code using serial monitor and individually tried the labview code for write and read (by making minor changes in the arduino code).

I get a timeout error on running the vi

// follwoing is the arduino code using which i want to test the serial read and write for now

void serialEvent(){
  while (Serial.available()){
    char inChar=(char)Serial.read();
    
    if (inChar =='a')
    {Serial.println("B\n");
    }
    else if(inChar =='b')
    {Serial.println("A\n");
    }
  }

0 Kudos
Message 6 of 21
(15,560 Views)
Solution
Accepted by topic author Ahsial

1.  You do not need the "\n" on your println() commands.  That command already adds an End Of Line character to the message.

2.  You are getting the error because you have a loop around your Read.  After the first read (well technically the second due to you adding an additional End Of Line character), there is nothing left in the port.  Therefore you will get the timeout.

3.  You really should look into using an Event Structure.  This way you only do the write and read when you press the Write button and you can also use the event structure to make the loop stop.  I also go so far as to close the port inside of the Stop->Value Change event.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 21
(15,555 Views)

thanks for the solution but there still might be a lttle problem somewhere. I am very new to the software so please bear with me here.

the code that i have written runs and doesnt stop  on pressing the stop button. secondly  on runny the vi , the value i write to the buffer doesnt affect the output on the read string at all. It just starts with the first output (on pressing the write button) and then switches to the second output( on pressing the write button again).

 

also if my arduino code were to change to this, would this vi still be effective?

void serialEvent(){
  while (Serial.available()){
    char inChar=(char)Serial.read();
    
    if (inChar =='a')
    {digitalWrite(LeftMotorForward, HIGH);   // turn the Left Motor ie the conveyor ON
  
   delay(10000);
    digitalWrite(LeftMotorForward, LOW);   // wait for  10 seconds
 digitalWrite(RightMotorForward, HIGH);
       delay(2000);
   digitalWrite(RightMotorForward,LOW); 
  Serial.print(scale.getGram(), 1);
  Serial.println(" g");
  delay(200);

Serial.println("B");
    }
    else if(inChar =='b')
    {Serial.println("A");
    }
  }

 


 

0 Kudos
Message 8 of 21
(15,525 Views)
Solution
Accepted by topic author Ahsial

Ahsial wrote:  the code that i have written runs and doesnt stop  on pressing the stop button. 

Make an event case for pressing the stop button.  You really should have the stop button inside of its event case as well.

 

 


Ahsial wrote: the value i write to the buffer doesnt affect the output on the read string at all. It just starts with the first output (on pressing the write button) and then switches to the second output( on pressing the write button again). 

What value did you have in the Write string control?  If you had "ab" then I could see that happening.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 21
(15,517 Views)
I initially had just "a" and then I stopped write and then sent "a" again. The value changed in read indicator
0 Kudos
Message 10 of 21
(15,494 Views)