Object, send a string like "123,456H" from a Labview VI to an Arduino Uno board and have the Arduino Uno board return the string "All fields received 123,456". The problem is no results are being returned when Labview sends this string.
When Arduino's Serial Monitor is used to send the string "123.456H" the correct results are returned. The Free Serial Port Monitor shows that the same string is being sent from the Labview VI and the Arduino Serial Monitor to the Arduino Uno board . And the Free Serial Port Monitor shows no data is returned when Labview is used. The Arduino Uno board acts like it is not reading the "123,456H string when Labview is used.
Hence my question is why doesn't the Arduino Uno board respond when Labview is used? What additional things should I do to trouble shoot this problem?
Here is the sketch used with both Labview and Arduino’s Serial Monitor.
- SerialReceiveMultipleFields with textFinder
- This code expects a message in the format: 12,-345H
const int NUMBER_OF_FIELDS = 2; // how many comma seperated fields we expect
int values[NUMBER_OF_FIELDS]; // array holding values for all the fields
Serial.begin(9600); // Initialize serial port to send and receive at 9600 baud
int fieldIndex = 0; // the current field being received
while(fieldIndex < NUMBER_OF_FIELDS)
values[fieldIndex++] = finder.getValue();
Serial.println(“All fields received:”);
for(fieldIndex=0; fieldIndex < NUMBER_OF_FIELDS; fieldIndex++)
You may find this helpful:
No, the Gammon article on using serial communications did not help.
Any other suggestions?
Try doing the loop-back test to make sure LabVIEW really is sending what you told it to. You'll need to write some more labview code (I don't think you can use the serial monitor because only one thing can connect to the serial port at a time) to just read the port and display it (but that's easy)
I performed the loop back test with both Arduino's Serial Monitor and a Labview Basic Serial Write and Read VI. Both the Serial Monitor and Labview were able to read the transmitted string.
Any additional suggestions on why an Arduino Uno won't respond when Labview is used. But will respond when the Serial Monitor is used and the same string is sent to an Arduino Uno board?
Show us a picture of the labview code.
Attached is a copy of Basic Serial Write and Read.VI. This VI is an example that is included with most versions of Labview and was used during the loop back test.
Basic Serial Write and Read.vi (26.2 KB)
Well I’m not sure about other people, but I don’t have a copy of labview on my computer so I can’t help unless you post a picture.
Attached are two files showing the Basic Serial Write and Read Vi Block Diagram. One is a PNG file that gives an overall view of the block diagram. The other is a PDF file that may be used to provide a close up view of a parts of the block diagram.
ScreenHunter_07 Oct. 07 17.04.pdf (173 KB)
Sorry for the stupid question, but did you double check the serial port settings in both Arduino and LabView ? Maybe there's a mismatch there...
Before I ran into this problem of Arduino not being able to read a string sent from Labview I was able to read a string sent from Arduino to Labview. Both setups use the same 9600 bits per second, no parity and 8 data bits parameters. The Labview read test was conducted with a simple sketch that only transmitted data from Arduino. Hence I am convinced the serial port settings match.
So... you send a string to the Arduino, wait for some time, then read the string back. Is this correct ?
Maybe you need to increase the delay between send and receive, to give the Arduino enough time to send back its response...
my 1 cent...
A time delay between receive and send is not required to be added to the sketch. When testing the response using the sketch I posted previously and the Arduino Serial Monitor the expected response is returned almost immediately.
Some success at last.
I am now able to use Labview to send and receive messages from an Arduino Leonardo board. Whereas I was using an Arduino Uno board when I initiated this thread.
Although both the Uno and Leonardo boards use the same Usbser.sys driver they use different .ini files. The Uno .ini version is not compatible with Labview. Whereas the Leonardo .ini version is compatible with Labview. The Leonardo .ini version meets the "Communication Device Class (CDC) subclass Abstract Control Model (ACM)" specification.
I came across the following that explains why an Arduino Uno board would not respond when a command was sent from a Labview VI. Source
"It is worth noting that the example above will not work on a windows machine; the arduino serial device takes some time to load, and when a serial connection is established it resets the arduino.
Any write() commands issued before the device initialised will be lost. A robust server side script will read from the serial port until the arduino declares itself ready, and then issue write commands. Alternatively It is possible to work around this issue by simply placing a ‘time.sleep(2)’ call between the serial connection and the write call. "
My problem was caused by my VI immediately sending a command after establishing a connection. By adding a delay between establishing a connection and sending a command an Arduino Uno board would return the correct response.