Tag Cloud

visual basic projects based on 8051 8051 microcontroller finger print interfacing vb source code for serial port remote controlled clock benq mod 9001 modem with microcontroller tester cable lan with 80c51 temperature controller for thermocouple motor torque keypad interfacing   real time temp sensor using 8051   8051 derivatives   over voltage and under voltage   8051 based microcontroller for mobile devices   quad voltage comparator   sends stop condition   electronic stethoscope   about visual basic   8051 fbus communication   temperature control of the ds1620    

VB Serial Communication


This chapter discusses how Visual Basic can be used to access serial communication functions. Windows hides much of the complexity of serial communications and automatically puts any received characters in a receive buffer and characters sent into a transmission buffer. The receive buffer can be read by the program whenever it has time and the transmit buffer is emptied when it is free to send characters.

Communications control
Visual Basic allows many additional components to be added to the toolbox. The Microsoft Comm component is used to add a serial communication facility.
In order to use the Comms component the files MSCOMM16.OCX (for a 16-bit module) or MSCOMM32.OCX (for a 32-bit module) must be present in the WINDOWSSYSTEM directory. The class name is MSComm. The communications control provides the following two ways for handling communications:

Event-driven. Event-driven communications is the best method of handling serial communication as it frees the computer to do other things. The event can be defined as the reception of a character, a change in CD (carrier detect) or a change in RTS (request to send). The OnComm event can be used to capture these events. and also to detect communications errors.
Polling. CommEvent properties can be tested to determine if an event or an error has occurred. For example, the program can loop waiting for a character to be received. Once it is the character is read from the receive buffer. This method is normally used when the program has time to poll the communications receiver or that a known response is imminent.

Visual Basic uses the standard Windows drivers for the serial communication ports (such as serialui.dll and serial.vxd). The communication control is added to the application for each port. The parameters (such as the bit rate, parity, and so on) can be changed by selecting Control Panel ? System ? Device Manager  ? Ports (COM and LPT)  ? Port Settings. The settings of the communications port (the IRQ and the port address) can be changed by selecting Control Panel ? System  ? Device Manager  ? Ports (COM and LPT)  ? Resources for IRQ and Addresses.