How to use computer serial port to realize automatic control

1. Serial port exploration

The serial port is one of the main external interfaces of the computer. There are many devices connected through the nine-pin serial port, such as serial mouse, MODEM, handwriting board, etc. The schematic diagram of the 9-pin serial port is shown in the figure, and the definition of each pin is as follows:

How to use computer serial port to realize automatic control

In the initial state, pin 4 is at a low level. When the serial port is opened, pin 4 is at a high level. When the serial port is closed, pin 4 returns to a low level. Therefore, the high and low levels of pin 4 can be used to control the power of other appliances.

Since the output current of each pin of the serial port is very small, it is not enough to drive the relay to work, so you need to take 5V power from the USB port of the computer (the 5v power supply current of the USB port can reach 500mA, which can drive the 5v relay to work normally). .

The 4 pins of the computer serial port are connected to the base of Tl through Rl to control the turning on and off of Tl, so as to control whether the relay Jl is engaged.

Tl adopts NPN type 9013, the resistance value of Rl is generally between l ~ lOkΩ, other components can be according to the parameters in the figure, after this circuit is welded, generally it can work normally without debugging.

How to use computer serial port to realize automatic control

Second, use VB to achieve serial control

Select the "Project" menu in the Visual BasIC 6.0 integrated development environment, then click the "Parts" menu item, select the "MicroSOFt Comm Control 6.0" option in the pop-up "Parts" dialog box, after confirmation, the toolbox will appear " "MSComm" tool, add the control "MSComml" on the form as shown below.

How to use computer serial port to realize automatic control
How to use computer serial port to realize automatic control

In this way, VB language programming and interface design are adopted in the host computer, and the serial port can be used to achieve automatic control conveniently with the clever use of the serial port.

Dc And Ac Motor Ceiling Fan

Dc Motor Fan,Smart Ceiling Fans,Ac Motor Fan Ceiling,Dc And Ac Motor Ceiling Fan

Jiangmen MagicPower Electrical Appliances Co.,Ltd. , https://www.magicpowerfan.com