1. Overview
In modern measurement and control systems, we often use the development and control mode of the host computer and the slave computer. The slave computer is mainly used to collect data, which can be realized through embedded controllers, single-chip microcomputer controllers, PLCs, etc. The host computer is mainly a graphical interface, which is used to display the collected data in real time, analyze and process the data, and control the slave computer at the same time. The host computer can be realized through various high-level languages, such as VB, Delphi, etc., as well as NI's graphical virtual instrument software development environment LabVIEW. Since LabVIEW uses a graphical programming method, whether you have programming experience or not, you can quickly and efficiently design the user interface, realize communication with the control hardware, and perform data analysis and processing. Today, LabVIEW has penetrated into various fields of industrial measurement, and at the same time it also plays a huge role in embedded, FPGA, DSP, real-time control and other fields.
2. Functions implemented in this example
First, use the microcontroller STC89C54 to send "Hello, LabVIEW" through the serial port, and LabVIEW will send the microcontroller to the data for display. Through this example, you can understand the serial communication design of LabVIEW.
3. Hardware design and software design of the lower computer
(1) Hardware design
The hardware circuit design of the microcontroller serial port communication is relatively simple, mainly including the microcontroller STC89C54 minimum system, MAX232 and a nine-pin serial port.
(2) Software Design
The design source code is as follows:
#include
#define uchar unsigned char
#define uint unsigned int
void SendStr(unsigned char *s); //send
String
void DelayMs (uint xms) //delay sub-function
{
uint i,j;
for(i=xms;i>0;i-)
for(j=110;j>0;j-);
}
void InitUART(void) //Serial port initialization
{
SCON=0×50; //SCON: mode
1,8-bitUART,receive enabled
TMOD|=0×20; //TMOD:timer 1,mode
2,8-bit reinstall
TH1=0xFD; // TH1: reload value 9600 waves
Crystal Oscillator: 11.0592MHz
TR1=1; //TR1: timer 1 is turned on
EA=1; //Open the general interrupt
}
void main(void)
{
initUART();
while(1)
{
SendStr("Hello! LabVIEW!");
DelayMs(240);
DelayMs(240);
}
}
void SendByte(unsigned char dat)
{
SBUF=dat;
while(!TI);
TI=0;
}
void SendStr(unsigned char *s)
{
while(*s!=\'\\0')//\\0 indicates the end of the string
Flag, // detect whether the string ends
{
SendByte(*s);
s++;
}[page]
4. Host computer LabVIEW front panel and program flowchart
(1) Introduction to related functions
When doing LabVIEW serial communication, you must first install the VISA driver, which can be downloaded from the Internet. LabVIEW's operations on the serial port are mainly read and write operations. This example mainly receives data, that is, read operations. Here we first introduce the controls and functions related to this example.
①VISA resource name
Under the "New" control tab, under the "I/O" sub-tab, there is a "VISA Resource Name" control. After installing the VISA driver and connecting to the hardware, the corresponding COM ports can be listed under this control, and you can select the appropriate COM port.
②VISA configures the serial port function
This function is located in the "Instrument I/O"
The sub-tabs are mainly used to configure the serial port parameters, including baud rate, data bits, parity check, etc.
③VISA read and VISA close functions
The VISA Read function reads a specified number of bytes from the device or interface specified by the VISA resource name and returns the data to the read buffer. The VISA Close function closes the device session handle or event object specified by the VISA resource name.
(2) Program flowchart design
The program flowchart design is shown in Figure 1.
5. Testing
After connecting the hardware, power on, download the program, and run labVIEW, we can see that the string "Hello! LavVIEW" sent by the microcontroller is received in the read buffer, as shown in Figure 2.
6. Summary
The host computer is designed using LabVIEW, which has a beautiful interface and is easy to implement. It can be easily used in various measurement and monitoring systems.
Previous article:Design and production of a simple digital voltmeter
Next article:Research on single chip intelligent lighting dimming system
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- 【Qinheng Trial】8. FlashROM
- The Agilent oscilloscope cannot be started and keeps stopping at the self-test position. What should I do?
- DSP digital anti-noise module for airborne communication equipment
- ESP32-C3 development board for 9.9 yuan with free shipping
- Design method of high-speed graphics frame storage using DSP+FPGA architecture
- Why can the defined pointer be used as an array?
- Have you ever used the YU4215 chip, SMD SO-8 package?
- Pingtouge RISC-V Development Board--STEP2--Intelligent Voltage and Current Acquisition Controller Design Preparation Part 1
- max30102 MCU selection
- Switch Mode Power Supply Board Layout Example