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))

2 comments:

  1. hello, i m sohail, interested to know more about controlling PIC from vb forms,, is it possible that we can send commands direct form vb form buttons and pic will work as per instructions and operate motors and the receive same as per requirements, my email address sohailimdad@gmail.com

    ReplyDelete
  2. Nice article sir Aynkaran Ramachandiran. How do you switch ON/OFF a PIC output pin (for example RB1) using VB6 and uart or usart. Thank you so much sir. :)

    ReplyDelete

Please give your valuable comments