Notes ---- labview and microcontroller serial communications section

        labview as a host computer to record, display, processing the data bits coming from the machine, and may also transmit command signals to the lower computer (microcontroller) through the PC, controlling start and stop of the motor.

        labview and the microcontroller communication protocol is RS-232 protocol, but the internal 51 board has MAX232 chip, the role of MAX232 chip is to convert TTL level microcontroller output to the 232 level PC can receive or 232 PC-output levels into TTL level received by the microcontroller. It requires only one data line communication can be achieved, of course, this is only the hardware, of course, also need software to program, only upper and lower computer communication can be achieved.

Labview program

        labview communication procedures are relied on to achieve the VISA function, as follows,

VISA serial port configuration function

In the front panel labview -> Function -> Instruments IO-> serial -> the VISA serial configuration, as shown:

Including VISA write, read VISA, VISA closed, these functions are common to the communication process several functions, the last to achieve the communication program shown below:

Configured to write from the serial port, the serial port and then read, and then to close the serial port, serial communications to achieve specific process is as follows:

Serial Configuration starts, then detects that the communication test (button) signal is given, the structure of the entry conditions, and the "H" write microcontroller, then the microcontroller detects this signal, transmits the "OK" characters, and "OK" is compared, If so, then the condition is true, the communication is successful, if not the same, the condition is false, the communication failure.

Conditions for the communication state of the state is to create a false local variable, you can select the communication status.

SCM signal sent to the host computer, for example, "H", which needs to be written with lower machine keil software program, the figure above Test 1, Test 2, Test 3, and the communication state is the same 1,2,3 I just used in three places, so creating three variables.

If you have questions please ask.

Released five original articles · won praise 4 · Views 165

Guess you like

Origin blog.csdn.net/ywanju/article/details/105065345