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 also stopped sending anything in the write buffer and continued switching the Boolean write on and off and the values kept changing.
0 Kudos
Message 11 of 21
(4,870 Views)

@Ahsial wrote:

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");
    }
  }

 


 


Looks like you haven't been paying attention to good coding practices for Arduino.

 

Use of delay( );  is BAD.  

 

 

 

 

0 Kudos
Message 12 of 21
(4,860 Views)
For the arduino code modified to above, the labVIEW VI doesn't quiet give the data correctly. What changes should I make to the labVIEW code to incorporate all the delays in serial print due to LEDs and the delay commands.
0 Kudos
Message 13 of 21
(4,830 Views)

@Ahsial wrote:
For the arduino code modified to above, the labVIEW VI doesn't quiet give the data correctly. What changes should I make to the labVIEW code to incorporate all the delays in serial print due to LEDs and the delay commands.

You need to re-write your Arduino code.

 

I haven't looked at your LabVIEW code.

 

 

0 Kudos
Message 14 of 21
(4,820 Views)
i have used delay as I need to make a sequence of the outputs where in they work one after the other. I could use timer but there still would be a specific time after which the serial print is reached at. My current arduino code works fine for my requirement with the serial monitor. But in labVIEW the event case ( uploaded above) does not read the buffer. It was working fine for the simple code (if a then print b and vice versa) and also with the same code with a dealt of 1second. But not for 12 seconds
0 Kudos
Message 15 of 21
(4,807 Views)

You will likely get a timeout error since the timeout for the VISA Read is default 10 seconds.  It is best to have your controller send updates to the PC every second or so to act as a watchdog.



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 16 of 21
(4,803 Views)

@Ahsial wrote:
i have used delay as I need to make a sequence of the outputs where in they work one after the other. I could use timer but there still would be a specific time after which the serial print is reached at. My current arduino code works fine for my requirement with the serial monitor. But in labVIEW the event case ( uploaded above) does not read the buffer. It was working fine for the simple code (if a then print b and vice versa) and also with the same code with a dealt of 1second. But not for 12 seconds

This explanation proves that you are clueless how to properly code in Arduino.

Just as in LabVIEW, it is possible to have state machines in Arduino code.

 

 

 

0 Kudos
Message 17 of 21
(4,778 Views)
Since my arduino code is running as per my requirement with the input on the serial Monitor, my question is focussed at the LabVIEW code 🙂
0 Kudos
Message 18 of 21
(4,772 Views)

Hello everyone

i have a program in Aduino that i read a Serial.print() of that program inside labview over VISA. now i need to write in one or two port of Arduino from labview VISA port in same time in this program.

can someone help me please?

0 Kudos
Message 19 of 21
(3,133 Views)

Hi,

 

how do I send a Boolean value to an Arduino digital port using VISA Write if it only accepts strings? The Boolean value will open/close the valve connected to the digital port of Arduino. 

 

Thank you.

0 Kudos
Message 20 of 21
(2,464 Views)