LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Digital Signal from Labfew/LINX to Arduino

Solved!
Go to solution

Hi everyone,

I want so send a digital signal (0v or 5V) from LabVIEW/Linx  to my arduino because I need to use the interrupt pin from my Arduino for faster comunication.
I tryed via serial communication but I can not affort to wait in the programm till I reach the line where the Aruino reads the serial input.

If anyone has an Idea, pleas let me know.

 

Kind regards

Florian

0 Kudos
Message 1 of 6
(4,320 Views)

Hi Florian,

 

I tryed via serial communication but I can not affort to wait in the programm till I reach the line where the Aruino reads the serial input.

When using LINX, then you have to use serial communication and so you have to wait until the Arduino "reaches the line"…

 

Which "line" are you waiting for?

What have you tried so far?

Where are you stuck?

Mind to attach a VI?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(4,313 Views)

Hi GerdW,

thanks for your reply.

I want to send a signal from my PC to alter something in the Arduino Programm while its running.

The Arduino programm is cycling in main loop while performing different tasks on after another till it reachs the lline: 
if (Serial.available() > 0) {
    Input = Serial.readString();
...........

 

The Response is to slow beacause the Arduino needs to long to process the other tasks in the main loop.
(For example it reaches the line only every 0.5 sec)
My idea was to use the interrupt pin. 
I could use an second Arduino which just waits for serial signals and set one pin HIGH which is attachet to the interrupt pin of the first Arduino.

But i hope there is a more elegant solutiuon.

 

Best regards

Florian

 

0 Kudos
Message 3 of 6
(4,278 Views)

Hi GerdW,


I just figured out that the problem is not that the main loop takes so long. 

I tested the response in a really basic program and figured out that my serial comunication itself is verry slow.

When I press the buttun "Signal Simulation" it takes over a secont to set output pin HIGH and light an test LED.
Is there any way to do faster communication?

I attached the vi,  Ardunio Skript below.

 

Greeting Florian

 

String Input = "";
const int output = 10;
void setup() {
  pinMode(output, OUTPUT);
  digitalWrite(output, LOW);
  // put your setup code here, to run once:
  Serial.begin(9600);
  delay(10);
  Serial.print("ready");
}
void loop() {
    if (Serial.available() > 0) {
    Input = Serial.readString();
    if (Input == "SignalLow") {
      digitalWrite(output, LOW);
    }
    if (Input == "SignalHigh") {
      digitalWrite(output, HIGH);
    }   }  }

0 Kudos
Message 4 of 6
(4,273 Views)
Solution
Accepted by topic author FloMaye

Hi Florian,

 

your VI looks quite ok - you should have used AutoCleanup once before posting the VI…

 

With 9600baud you need ~10ms to transfer your commands "SignalHigh"/"SignalLow" (about 1ms per byte). When it comes to speed you might think about using a different baudrate (like 57600baud) and to shorten your commands (like "S1"/"S0", respectively).

On the other hand I wouldn't expect (or cannot explain) your code to need ~1s to execute those commands.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(4,267 Views)

Hi GerdW,

 

Thanks for the advice.
Shorten the commands helped a lot, was not necessary to alter the baudrate.

 

Best Regards
Florian

0 Kudos
Message 6 of 6
(4,256 Views)