Serial Port Mscomm

The purpose of this article is to demonstrate how you can perform serial port communication in the VBA (Visual Basic Applications – script editor included in any typical Microsoft Excel distribution) but without using the MSComm control or any other third party add-on or ActiveX. To communicate with the ADR boards using Visual Basic, the MsComm control must be utilized to allow serial data transfer via a serial port ( Com1-Com4). MSComm is a custom control shipped with VB4.0 and VB5.0 and must be loaded using the Tools menu. Form1 of a sample program controlling an ADR112 is shown below.

I have a Visual Basic 6 program which connects with a BS2 stamp using the serial port on the Board of Education. The VB6 program uses the MSCOMM control and the OnComm event. I know that pins 6 and 7 on the BOE are connected to handle automatic serial port selection in the stamp editor.

Why does data send to the BS2 from the VB6 program get returned to the VB6 program OnComm/CommEvent (comEvReceive)? This occurs even if there is no power to the BS2 (unless the serial cable is disconnected). I thought it might be the two capacitors on the ATN (serial pin 4) line, but that doesn't seem to be the case. Here are the MSCOMM properties MSComm1.CommPort = 1 MSComm1.DTREnable = False MSComm1.EOFEnable = False MSComm1.Handshaking = comNone MSComm1.InBufferSize = 1024 'Setting the InputLen property to 0 causes the 'Communications control to read the entire contents 'of the receive buffer when the Input property is used MSComm1.InputLen = 1 MSComm1.InputMode = comInputModeText MSComm1.NullDiscard = False MSComm1.ParityReplace = '?'

Hematology atlas images. Explores the pathogenesis, clinical, morphologic, and investigational aspects of blood disease with extensive coverage of the pathologic anatomy of common clinical entities. Provides quick and easy reference of key diagnostic issues in a comprehensive yet concise format.

MSComm1.RThreshold = 1 MSComm1.RTSEnable = False MSComm1.SThreshold = 1 MSComm1.Settings = '9600,n,8,1' Thanks for any insight. The reason for this is that the level-shifter on the BS2 module 'borrows' power from the RS-232 connection, so everything gets echoed back.

Port

This is easy to filter, or it can be used (as the compiler does) to make sure that a byte sent to the BASIC Stamp actually got there (you know that since it got echoed). -- Jon Williams -- Applications Engineer, Parallax -- Dallas Office Original Message From: Ron Czapala [noparse][[/noparse]mailto:] Sent: Thursday, April 15, 2004 3:37 PM To: Subject: [noparse][[/noparse]basicstamps] VB6 / MSCOMM control - serial comm echo I have a Visual Basic 6 program which connects with a BS2 stamp using the serial port on the Board of Education. The VB6 program uses the MSCOMM control and the OnComm event.

I know that pins 6 and 7 on the BOE are connected to handle automatic serial port selection in the stamp editor. Why does data send to the BS2 from the VB6 program get returned to the VB6 program OnComm/CommEvent (comEvReceive)? This occurs even if there is no power to the BS2 (unless the serial cable is disconnected). I thought it might be the two capacitors on the ATN (serial pin 4) line, but that doesn't seem to be the case. Here are the MSCOMM properties MSComm1.CommPort = 1 MSComm1.DTREnable = False MSComm1.EOFEnable = False MSComm1.Handshaking = comNone MSComm1.InBufferSize = 1024 'Setting the InputLen property to 0 causes the 'Communications control to read the entire contents 'of the receive buffer when the Input property is used MSComm1.InputLen = 1 MSComm1.InputMode = comInputModeText MSComm1.NullDiscard = False MSComm1.ParityReplace = '?' MSComm1.RThreshold = 1 MSComm1.RTSEnable = False MSComm1.SThreshold = 1 MSComm1.Settings = '9600,n,8,1' Thanks for any insight.

I wondered whether the BS2 was drawing power from the PC serial port. That explains why it worked with no power applied. I'm not sure what the 'level shifter' is but I assume it is in the PIC controller and that there is no way to disable the echo in PBasic. Thanks for your help!

- Ron --- In, 'Jon Williams' wrote: > The reason for this is that the level-shifter on the BS2 module > 'borrows' power from the RS-232 connection, so everything gets echoed > back. This is easy to filter, or it can be used (as the compiler does) > to make sure that a byte sent to the BASIC Stamp actually got there (you > know that since it got echoed). > > -- Jon Williams > -- Applications Engineer, Parallax > -- Dallas Office > > > Original Message > From: Ron Czapala [noparse][[/noparse]mailto:rczapala@y.] > Sent: Thursday, April 15, 2004 3:37 PM > To: > Subject: [noparse][[/noparse]basicstamps] VB6 / MSCOMM control - serial comm echo > > > I have a Visual Basic 6 program which connects with a BS2 stamp > using the serial port on the Board of Education.