Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 1 month ago.
LabVIEW and mbed serial interface problem
// LabVIEW and mbed serial interface test #include "mbed.h" #define samplePeriod 40 // 40 ms #define sampleRate 25 // 25 Hz Serial pc (USBTX, USBRX); int main() { pc.baud (19200); Timer timerPeriod; timerPeriod.start(); while (1) { timerPeriod.reset(); pc.printf("%f,%f,%f,%d\n", 0.333333, 0.555555, 0.777777, sampleRate); while (timerPeriod.read_ms() < samplePeriod); } }
When the arguments in the printf statement in the above program are received in LabVIEW on the Array of String and Array of Number interfaces of the mbed-read.vi, the first argument is quite often very strange. The value could, for example, be 70.333.333. The last three arguments are always received correctly on the mbed-read.vi interface.
Any ideas on how to solve the problem?
Best regards Henrik Larsen
2 Answers
11 years, 1 month ago.
A pragmatic solution would be just to add a dummy character before your numeric values, and just ignore it on the labview side.
To actually investigate to problem:
1) Ensure that the serial port settings are the same on both sides. Not just the baud rate, but the # of data bits and stop bits and the parity setting.
2) Try slower and faster baud rates and see if the problem persists
3) Download a serial port monitor program for the PC side. These programs "sniff" the serial traffic and let you see what bytes are being seen at the serial port.
Not sure what you mean by "mbed-read.vi interface", but if this is some other client and it gets the data OK, that seems to indicate that the problem is not on the mbed side, it's on the labview side.
Thanks Dave. I have once again checked my data communication setting; they are correct and the test program runs fine with TeraTerm. By mbed-read.vi I refer to the LavbVIEW serial communication described in http://mbed.org/cookbook/Interfacing-with-LabVIEW. I think you are wright, the problem relates most likely LabVIEW or more specifically to either the unit mbed-read or the unit Serial Port VISA. Henrik
posted by 16 Oct 2013Ah - "vi" as in "virtual instrument" in the LabVIEW parlance. You should download a serial port monitor program and use it to look at what bytes are really going across the wire.
I believe I have used this one: http://www.serial-port-monitor.com
But people also recommend this one: http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx
This will tell you which side of the system is making the mistake.
posted by 16 Oct 201311 years, 1 month ago.
I would try, 0%3.3f for the first variable, forcing out an extra zero as text, also, I always add \n\r, so it works in most terminal programs.
as a test replace the first result with text..
"0.3333, %3.3f. .........
hope this helps,
Ceri