Serial USB - Read - Write - LabView - Baud Rate

Hi! The 18,01,12 I wrote the next post in MBED Forum.

Quote:

I have a very serious problem and it took me at least 3 weeks thinking about a possible solution, but I didn´t find it yet. I am developing a HMI (Human Machine Interface) in LabView. The problem is that I need to send data from my MBED to LabView (with a Serial Interface, connecting USBTX and USBRX pins, so routing Serial Port over USB Port) with high speeds, without no successful. I try to run this simple program in my MBED, and read the data in LabView:

#include "mbed.h"

Serial pc(USBTX, USBRX);

int main() {
    
    char letter;
    
    pc.baud(921600);
    
    letter = 0;
        
    while(1) 
    {   
        letter = letter +1;
        pc.printf("%c\n", letter);
    }
}

Talking about the LabView code, I only put the "mbed read VI" (reading the Line String), whose information appears in the next link: http://mbed.org/cookbook/Interfacing-with-LabVIEW (below "Serial Communication").

I test the C++ code, reading what MBED was sending me, with TERA TERM at 921600 bauds, and it worked. So, I think that the problem is in LabView, but I don´t know where.

I am not saying that my application don´t run in LabView. It´s false. It starts running, and after 5 seconds LabView stop receiving data and hang up. What´s the problem ? Could anybody help me ? Best Regards.

Nobody have answered me yet, and I found the solution. That´s why I am posting this note. Now, the solution:

Quote:

As I said in the post above, I used the block that MBED offer users to read and write data, via serial port. But these blocks have one mistake, if you put it in a loop.

Normally, applications require readings every step in a loop. So, in this cases, if the baud rate selected is not very high, it works perfectly, but the problem appears (in my case) if I increase the baud rate over 38400 bauds. Why????? Because the ports can´t be configured once each step. That´s why my program broke and LabView hang up.

I would like to upload the blocks that I used in my LabView program, but I only can upload C++ programs from my compiler. So, I will just say the way to design your LabView program correctly:

Quote:

You only need tree blocks:

- Configuration block: in this block you have to put the "VISA Configure Serial Port" block (offered by LabView), with which you will be able to configure the Baud Rate and other communication parameters. Furthermore, another block that you need is the "VISA Set I/O Buffer Size Function" block, that will be useful if you need an in/out buffer to receive or to send the data.

- Read block: in this block you only have to put the "VISA Read Function" block and configure it.

- Write block: in this block you only have to put the "VISA Write Function" block and configure it.

Only the "Configuration block" has to be out of any loop. A good way to program would be starting putting the "Configuration block" at the start of your LabView design, and then the loop with every Read or Write block inside.

That´s all. Best regards and enjoy your MBED !!


Please log in to post comments.