02-16-2020 03:09 PM
Hello Everyone!
I am making a Labview based software to control different loads. In this system i am using Arduino as a Micro controller. I am Facing a problem to send multiple data to arduino from labview, e.g, i want to send four different numeric values from different fields and then i want these values in arduino also stored in different variables. At a time i want to read data from arduino as well. In Short i want to send and receive multiple data from arduino to Labview and Labview to Arduino. Thanks in advance. Waiting for experts help.
Solved! Go to Solution.
02-16-2020 03:17 PM
02-16-2020 11:14 PM - edited 02-16-2020 11:16 PM
Hi GerdW, First of all thanks for your reply. Basically i am dealing with PID library of arduino. My arduino code is working perfectly. In this code i change the values of P, I, and D. These values are stored in specific variables. The problem is this i want to set these variable values from Labview to Arduino. In short I am making a software to control PID values from the Labview to Arduino. I am using VISA Write Module in Labview to send data to Arduino. Please tell me how to receive these individual values from Labview and to store these values in arduino different variables. For example i create four different numeric control and i send data like 3 from first numeric, 6 from second, 10 from third and 12 from fourth and i want these values to store in different variables in arduino, like "int a=3" "int b=6" "int c=10" "int d=12".
Best regards,
02-16-2020 11:21 PM
Write a string to the Arduino using the serial port like "3,6,10,12LF" where LF is the linefeed character. Then have the Arduino code to a readln on the serial port and break it down into 4 values based on the comma locations.
02-16-2020 11:25 PM
RavensFan Thanks for reply. Actually i am almost new to Labview, that's why i am not understanding what are you telling me the solution. Can you please attach a example VI and Code end also.
02-17-2020 12:24 AM
Presumably you are currently sending something to the Arduino using the VISA Write node you mentioned.
If this is working, you're probably using something like Serial.read to get single characters - and you can use code like the example here https://forum.arduino.cc/index.php?topic=288234.0 to get a "line" of characters by checking if the character that was read is equal to e.g. a line feed character.
Then, send your values to the Arduino with the last character each time (the termination character) being Line Feed constant.
On the Arduino, parse the string (char buffer) into tokens using something like strtok, then parse as needed.
Since you know the number of elements, you can probably write simple (but brittle) code by just assigning each block to a specific variable based on its position in the string (i.e. a = first token, b = second token, ...).
02-17-2020 08:28 AM
Cbutcher thanks for reply. Your providing information seems good. I will try your methods then I will discuss further here 🙂