Principle reference of MCU MCU parallel communication

1. Proposal of the problem

Three systems of serial sensors (GPS, pressure and wind direction) and three analog current (4 to 20 mA) interfaces (humidity, temperature and water level) are used in a system. Now it is necessary to summarize these data and upload it to the PC through the serial port, and require each signal data to be received independently in real time.

Principle reference of MCU MCU parallel communication

2. System design

After analysis, we use a 2051 single-chip microcomputer to receive the data of each serial port sensor, and use a multi-channel high-precision ADC to sample the temperature and other signals converted into voltage. The system structure is shown in Figure 1. See Figure 2 for the specific pin connections between the master and slave.

Principle reference of MCU MCU parallel communication

Figure 1 System block diagram

In the system, the 51 MCU acts as the host to control the action of the whole system and initiates each communication. Each piece of 2051 acquires data from the sensor in real time and completes communication under the control of the host. The host and each slave communicate with each other through a parallel port. The master-slave workflow is as follows:

· After the host is powered on, the slave slave address is sent through the P0 port to select a slave and wait for a response.

· Each slave receives the sensor serial data after power-on initialization, and then receives the host address through the P1 port. When the address matches itself, it adjusts the direction of 245 and sends the sensor data to the host by 245. This process is controlled by the handshake line.

· After the slave has sent all the data, change the direction of 245 to receive again, and start receiving the sensor data and the address sent by the host again.

· The host receives all the 2051 data in the same way.

· After the serial port data is received, the host controls the AD conversion and acquires three signals.

· The host aggregates all the data into the specified format and sends it to the PC via 232.

The working flow chart of the master and slave is shown in Figure 3:

Principle reference of MCU MCU parallel communication

Figure 2 Pin connection between master and slave
Principle reference of MCU MCU parallel communication

Figure 3 master and slave work flow chart

The main program codes are as follows, the host is:

......

Sbit adc_busy=P3^2;

Sbit adc_hben=P3^3;

Sbit hand1=P2^0;//GPS

Sbit hand2=P2^1;//PRESSURE

Sbit hand3=P2^2;//WIND

Sbit hand4=P2^3;//BAK1

Uchar idata gps[96];

Uchar idata pressure[9];

Uchar idata wind[26];

Uchar idata tem[6];

Uchar idata hum[6];

Uchar idata water_tem[7];

......

P1=0x01;

For(i=0;i"96;i++){

While(hand1!=0);

Gps[i]=P1;

While(hand1==0);

}

Sendbyte2pc('#');

Sendbyte2pc('#');

Sendbyte2pc('1');

Sendbyte2pc(' ');

Sendbyte2pc(' ');

Send2pc(gps,96);

......

The slave is:

......

Sbit dir=P3^2;

Sbit en=P3^3;

Sbit hand=P3^4;

......

Loop:

RI = 0; i = 0;

While(!RI);//wait for receiving ready

If (SBUF!=0x40)//data head

Goto loop;

Data_str[i]=0x40;i++;

RI=0;

While(!RI);//wait for receiving ready

If (SBUF!=0x40)//data head

Goto loop;

Data_str[i]=0x40;i++;

Do{

RI=0;

While(!RI);

Data_str[i]=SBUF;

i++;

}

While(i!=96);

Dir=0;en=0;//enable data receiving P1=0xff;

For(i=0;i"100;i++){

If(P1==0x01)

Goto send;

}

En=1;

Goto loop;

Send:

For(i=0;i"96;i++){

Dir=1;

P1=data_str[i];

Hand=0;

For(j=0;j"5;j++){;}

Hand=1;

}

En=1; dir=0;

Goto loop;

......

3. Conclusion

The parallel communication method proposed in this paper has the characteristics of simple and clear circuit structure and easy implementation of the program, which has proved feasible in practice. In the debugging process, you can use the serial port assistant and other software to receive data to verify the reliability of communication.

VOZOL Alien 2 Vape

This is a special vozol Alien 2 electronic cigarette product series. We sell Vozol Vape, vozol vape Pen, vozol vape 3000 Puffs, and other vozol vapes.

We are specialized electronic cigarette manufacturers from China, Vapes For Smoking, Vape Pen Kits suppliers/factory, wholesale high-quality

products of Modern E-Cigarette R & D and manufacturing, we have the perfect after-sales service and technical support. Look forward to

your cooperation!

vozol alien 2 vape kit,vozol alien 2 vape pen, vozol alien 2 e-cigarette, vozol alien 2 vape 600 puffs,vozol alien 2 disposable vape

Ningbo Autrends International Trade Co.,Ltd. , https://www.vapee-cigarettes.com