11-28-2014 07:28 PM - edited 11-28-2014 07:35 PM
Hi guys, I'm having a problem most of the times when intiating a VI that communicates with Arduino through Serial port and reads and sends data at a baud rate of 9600 kb/s.
Almost every ocasion I have to push the reset button until it starts communicatin at a normal continous rate, and sometimes the communication either stops or gives me a BSOD in windows
Also heres the Arduino code I'm using:
http://codeviewer.org/view/code:4804
Is this normal? or how can I deal with this serial communication erros I'm having.
11-28-2014 07:49 PM
You are not handling any errors in the segment of LV code shown in your image.
You proceed with the VISA Write even if a read error occurred.
What kinds of errors do you get? Where in the code do the errors occur?
Do you have any control over which program starts first? I did not look at the Arduino code - and probably would not understand it if I did. Does it start sending data after the reset? How long does it take to get started? Is the first message always complete? Does it send the termination character the LV code expects (line feed)?
Lynn
11-28-2014 07:57 PM - edited 11-28-2014 08:00 PM
The Arduino Program starts first, it sends data throught the Serial port when it starts and reads when theres anything available through it, I finish my lines with Serial.println(); in Arduino, and when I reset the Arduino it starts sending data. Normally after to o r three resets it starts communicating continously.
11-28-2014 08:14 PM
12-05-2014 08:59 AM
Sorry for the late response, Why is it better to have sequence structures instead of local variables? , Furthermore how reliable is Serial communication if I want to build an automated system, because that's my main concern with my Labview and Arduino Code.
12-05-2014 10:04 AM
12-05-2014 10:27 AM
Serial communication between Arduino and LabVIEW is very reliable. You need to look at your sketch first and verify it's doing what you want. As was mentioned above, Arduino's IDE has that Serial Monitor that allows you to receive and send as you please in order to verify Arduino code. Now, in order to verify and debug the messages you think you are sending on the serial port to the Arduino, you should use NI Visa. You can establish connection and send whatever it is you wish to send to verify your commands are being interpreted correctly. From there, I'd also look into Arduino's serial library. I wish I knew the answer to this for sure, but it's possible Arduino is look for an "End of Line" which I do not see being sent in your LabVIEW. I'd definitely look into that. And then of course, everything everyone else said about Local Variables and sequence structures. Local Variables are not as big of deal as some are making it to be. Your application is small and would not be negatively affected by the use of multiple local variables. That being said, it isn't good practice due to potential race conditions and blah blah blah. Your code could easily be re-written in a state machine format.