11-30-2022 11:25 PM - edited 11-30-2022 11:29 PM
I'm trying to send commands from Labview to Arduino.
The following VI and Arduino program are working perfectly.
I just want to know why do I have to connect a Read vi after the Write vi in the labview program?
When I run the program with the Write function only, the Arduino does receive data (can tell it by the Tx blinks on the Arduino board) but doesn't perform like how it should, which means it isn't decoding the data properly.
Secondly, why do I have to not connect the Close Visa function? If I connect that, the program won't run, it's giving an error at the Close vi.
Solved! Go to Solution.
12-01-2022 12:59 AM
Hi sarwat,
@sarwatsarfaraz wrote:
The following VI and Arduino program are working perfectly.
Secondly, why do I have to not connect the Close Visa function? If I connect that, the program won't run, it's giving an error at the Close vi.
I don't think it works "perfectly", due to several misconceptions…
What's the point of the event structure? Why is there an empty timeout event?
You open the serial port in every iteration, but you never close it. That sounds wrong…
Open the port once before the loop, close it once after the loop!
(Which error do you get when you close the port? Please provide all needed information for us!)
@sarwatsarfaraz wrote:
When I run the program with the Write function only, the Arduino does receive data (can tell it by the Tx blinks on the Arduino board) but doesn't perform like how it should, which means it isn't decoding the data properly.
That should be a problem in your Arduino code…
Does it wait for a TermChar, which you forgot to send?
12-01-2022 09:35 AM
I need to see your Arduino code.
DON'T USE RAR my company does not allow that to be installed so I can't open it.
Arduino code is just text copy and paste it into your post.
12-14-2022 11:51 PM - edited 12-15-2022 12:20 AM
Hi. This is my updated vi, have deleted the event structure
Here is my Arduino code:
char x;
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
x = Serial.read();
Serial.println(x);
}
if (x=='a') {
digitalWrite (13, HIGH);
}
if (x=='b') {
digitalWrite (13, LOW);
}
}
12-14-2022 11:54 PM - edited 12-14-2022 11:55 PM
This is the error when i connect the Close function:
The error window never closes, it keeps popping up so I have to end Labview through Task Manager end task
12-15-2022 01:26 AM
Hello,
there are some mistakes in your design.
As we can see, your error message says, that the VISA resource is not valid while writing to the port, but opening is OK. The reason could be the Serial Monitor. What happens, if you close the Arduino IDE?
12-15-2022 03:42 AM
I just placed the configure port and VISA select outside the while loop, it's working now.
Btw, why should i feed the VISA wire via a shift register into the loop? It's working without this but still curious.
12-15-2022 05:55 AM
You are right, it's not absolutely necessary.