Showing posts with label mscomm. Show all posts
Showing posts with label mscomm. Show all posts

16 Dec 2008

USART communication with Visual Basic 6.0

VB 6.0 is a general tool for communicate with PIC. MSCOMM control can be used to send and receive data to and from PIC. There are two options available in PC side.


1.       Polling method – in this method user continue to read the data out of the MSCOMM buffer, and do the required work with received data. A timer also can be used to check the buffer periodically.


2.      Event driven method – MSCOMM will generate various event depends on the state of it. (I.e. buffer full, pre-set number of data received etc.). in this mode the properties related to each event has to be set correctly to get required functional.


It’s observed that VB’s MSCOMM is good in receiving text characters rather than binary data. It is advised to use string variable to get the buffer. If you need to get binary data (bytes), use this formula to convert text Char to Byte.

X = Asc(Mid(Buffer$, starting_point, 1))