Searching \ for '[EE]:Visual Basic serial interface' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/io/serials.htm?key=serial
Search entire site for: 'Visual Basic serial interface'.

Exact match. Not showing close matches.
PICList Thread
'[EE]:Visual Basic serial interface'
2001\04\01@194420 by john

flavicon
face
Hi,
Im using a 16C71 to send data through a serial port to my PC (analog
readings) and I want to use VB 6.0 to graphically represent the data.
Any help would be appreciated.  Thank you.

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\04\01@214418 by Dave Dilatush

picon face
john <.....rempetisKILLspamspam@spam@SYMPATICO.CA> wrote...

>Im using a 16C71 to send data through a serial port to my PC (analog
>readings) and I want to use VB 6.0 to graphically represent the data.
>Any help would be appreciated.  Thank you.

You might find Richard Grier's book helpful:

Visual Basic Programmer's Guide to Serial Communications, 2nd Ed.
ISBN 10890422-25-8
Mabry Publishing, 1999

http://www.mabry.com/bookpub.htm

HTH...

Dave

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2001\04\01@214638 by myke predko

flavicon
face
Hi John,

I see this request often enough that I feel like I should write a little set
of directions for doing this.  In terms of a "quick" version of doing this
in VB 6.0, you should follow the steps:

1.  To add the "MSComm" to the Form Toolbar, Click on "Projects" and then
"Components".  Click on the square box to "Microsoft Comm Control 6.0"
followed by "Apply" and then "Close".  This will put the (invisible) Comm
Control (a "telephone") on the toolbar.

2.  Click on and place the telephone control onto your Form.  This control
is invisible, so you can put it anywhere.  The control will come up as
"MSComm1".

3.  Set your initial operating parameters.  For working with most
applications, I set the following properties for the MSComm control:
CommPort - "COM#" Serial Port Number to be used
InputLen = 0 - This means that if you use the "OnComm" event, you will be
flagged after each character input
InputMode = 1 - "comInputModeBinary" to read in full binary data.
Settings = "((#)#)###,n,8,1" where "((#)#)###" is the data speed you are
communicating with the PICmicro

4.  Add the following subroutines to your application:

Private Sub SerPortOpen(OnOff As Integer)
'  Open the Serial Port if "OnOff" is <> 0
'  Else, Close the Serial Port

   If (OnOff = 0) Then
       MSComm1.PortOpen = False
   Else
       MSComm1.PortOpen = True
   End If

End Sub

Private Sub SerPortSend(Data As String)
'  Send the "Data" string out of the Serial Port

   MSComm1.Output = Data

End Sub

Private Function SerPortRead() As String
'  Poll the Serial Port and if something is available return it,
'  Else, return a Null String

   SerPortRead = ""

   If (MSComm1.InBufferCount <> 0) Then
       SerPortRead = MSComm1.Input
   End If

End Function

These are about the most basic subroutines you can have for serial
interfacing in VB.  I recommend that in your "Form_Load" subroutine, put in
the line:

   call SerPortOpen(1)            '  Open the Serial Port

and, at the end of the application, always put in:

   call SerPortOpen(0)            '  Close the Serial Port

5.  You can use SerPortRead and SerPortSend in your application to send and
receive data to the PICmicro one byte at a time.

6.  The other MSComm properties (namely "DTREnable", "Handshaking",
"InBufferSize", "NullDiscard", "OutBufferSize", "RThreshold", "RTSEnable"
and "SThreshold") can be changed as required.


Comments?

myke
{Original Message removed}

2001\04\02@002515 by patmurphy

flavicon
face
Myke,
I am no expert, but I have recently written some VB code
with MSCOMM using the Binary mode, and I have both Jan
Axelson's book (Serial Port Complete) and Richard Grier's
book (Visual Basic Programmer's Guide to Serial Communications)
- and I have at a couple of your books too, I might add! :-)
Anyway, I'd just like to point out that working with MSCOMM
in binary mode means both the input and output bytes are stored
in variants that contain byte arrays.

Please correct me if I am wrong, but it looks like in your
example the mode is actually text, not binary.

InputMode can be a 1 or 0, with 0 being comInputModeText,
and 1 comInputModeBinary. So if you want to work with binary,
I think you would just use the constant comInputModeBinary.

You would also store your output data in an array and then
give the array to MSCOMM like this, perhaps:
 Dim aOutput(0 to 1) as Byte
 Dim Buffer as Variant
 aOutput(0) = &H14 'A byte to send
 aOutput(1) = &H15 'A second byte
 Buffer = aOutput
 MSComm1.Output = Buffer

To receive data, you would then do a similar setup:
 Dim aInput(0 to 1) as Byte
 Dim Buffer as Variant
 Buffer = MSComm1.Input
 aInput() = Buffer

I like using binary because then I can check the InBufferCount
value to determine when to read the input buffer.

As far as displaying the analog data graphically, have you
looked at S-Plot Pro? <http://www.selmaware.com/s-plot>
I haven't used it myself. I'd be curious to hear what
solution you come up with for graphically displaying your
data.

HTH,
Patrick Murphy
James Valley Colony
Box 324
Elie, MB R0H 0H0



myke predko wrote:
<snip!>
> 3.  Set your initial operating parameters.  For working with most
> applications, I set the following properties for the MSComm control:
> CommPort - "COM#" Serial Port Number to be used
> InputLen = 0 - This means that if you use the "OnComm" event, you will be
> flagged after each character input
> InputMode = 1 - "comInputModeBinary" to read in full binary data.
<snip!>
> Private Sub SerPortSend(Data As String)
> '  Send the "Data" string out of the Serial Port
>
>     MSComm1.Output = Data
>
> End Sub
<snip!>
{Quote hidden}

<snip!>
> Comments?
>
> myke
> {Original Message removed}

2001\04\02@221822 by Brian Kraut

picon face
I can't find the control on the VB 6.0 learning edition.  I believe it is not
included on the learning edition.  Correct?  What is the price on the full
version with the comm control?  I can't find it in any computer stores here.

myke predko wrote:

{Quote hidden}

> {Original Message removed}

2001\04\02@223314 by shane

flavicon
face
> I can't find the control on the VB 6.0 learning edition.  I believe it is not
> included on the learning edition.  Correct?  What is the price on the full
> version with the comm control?  I can't find it in any computer stores here.

It is included in the learning edition.

Right click on the component bar, and select 'components'.  Select 'microsoft comm control 6.0' and the little telephone 'mscomm'
button will appear on the component bar.

Cheers,
Shane.

> {Original Message removed}

2001\04\02@225010 by patmurphy

flavicon
face
Brian,
I don't have the learning edition, but I've heard it wasn't included.
However, you can download one at:

 <http://ourworld.compuserve.com/homepages/richard_grier/xmcomm.htm>

He has two, one for straight VB and a second for VBA.

HTH,
Patrick Murphy
James Valley Colony

Brian Kraut wrote:
{Quote hidden}

> > {Original Message removed}

2001\04\03@090118 by myke predko

flavicon
face
Sorry, I missed the destination address of the "reply" - here is my reply to
Patrick.

> I am no expert, but I have recently written some VB code
> with MSCOMM using the Binary mode, and I have both Jan
> Axelson's book (Serial Port Complete) and Richard Grier's
> book (Visual Basic Programmer's Guide to Serial Communications)
> - and I have at a couple of your books too, I might add! :-)
> Anyway, I'd just like to point out that working with MSCOMM
> in binary mode means both the input and output bytes are stored
> in variants that contain byte arrays.
>
> Please correct me if I am wrong, but it looks like in your
> example the mode is actually text, not binary.

Yes - because I find a text string easier to work with than a byte array.

Sorry, I should have put that in the original email.

{Quote hidden}

The difference with Text is that you can append data to a String and not
worry about the variable conversions that you have to do with the binary
data.  The "InputBufferCount" works for both Binary and Text data.

> As far as displaying the analog data graphically, have you
> looked at S-Plot Pro? <http://www.selmaware.com/s-plot>
> I haven't used it myself. I'd be curious to hear what
> solution you come up with for graphically displaying your
> data.

No I haven't see this.  I'm disappointed that there aren't any PICmicro
examples I can try out.

If I am going to display analog data graphically, I generally use a
PictureBox along with an algorithmically calculated "Line" parameter to
display the data.  It's quite fast and very easy to do.

myke

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\04\03@091643 by Alan B. Pearce

face picon face
>Yes - because I find a text string easier to work with than a byte array.

this is fine provided the it really is a text string. I have had problems doing
this in transfers (OK it was not across a serial interface) because assumptions
were made about text - specifically CR and LF, and as I was transferring a BMP
file it fouled up with short transfers.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\04\03@210559 by Alejandro Lavarello

picon face
I have used MSCOMM in the  text-based form.(Only printable ASCII characters).
It works OK, and allows me to develop a PIC application using
a simple terminal emulator (the Windows' Hyperterminal ).

Text allows you to type manually commands, binary not :).

Text-based is not suitable for fast transfers
because waste in bandwidth, but is excellent for master/slave systems.

If you need to send numeric values, these values can
be converted to two-character hexadecimal ( d'225' --> FF ).
Another useful thing is to send data in fixed length strings.

Regards!
         Alejandro.

At 14:14 03/04/01 +0100, you wrote:
>>Yes - because I find a text string easier to work with than a byte array.
>
>this is fine provided the it really is a text string. I have had problems
doing
>this in transfers (OK it was not across a serial interface) because
assumptions
>were made about text - specifically CR and LF, and as I was transferring a
BMP
>file it fouled up with short transfers.
>
>--
>http://www.piclist.com hint: The list server can filter out subtopics
>(like ads or off topics) for you. See http://www.piclist.com/#topics
>
>
>

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...