03-08-2016 10:11 AM
03-08-2016 07:30 PM
@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.
03-12-2016 07:42 AM
03-12-2016 06:43 PM
@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.
03-13-2016 05:45 AM
03-13-2016 07:31 AM
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.
03-14-2016 09:38 AM
@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.
03-14-2016 11:10 AM
07-07-2018 04:51 PM
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?
01-20-2021 09:46 PM
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.