05-07-2018 09:27 AM
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
Solved! Go to Solution.
05-07-2018 09:52 AM
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?
05-08-2018 03:16 AM
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
05-08-2018 04:11 AM
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);
} } }
05-08-2018 05:40 AM
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.
05-08-2018 09:01 AM
Hi GerdW,
Thanks for the advice.
Shorten the commands helped a lot, was not necessary to alter the baudrate.
Best Regards
Florian