serial communication
serial communication
serial communication
serial communication
serial communication
serial communication serial communication serial communication serial communication serial communication serial communication serial communication serial communication
serial communication serial communication
serial communication
Go Back  Xtreme Visual Basic Talk > > > serial communication


Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2010, 11:37 AM
zk123 zk123 is offline
Newcomer
 
Join Date: Apr 2010
Posts: 1
Exclamation serial communication


Hi..

I am new here..

I am doing a program that can monitor and control lights (LED as output), fans, doors(switches as input) and windows(switches as input) of a REAL TIME miniature house.
It has 16 inputs and 16 outputs. I use IC 8051.

I have to connect VB to rs-232 (serial communication) and I'm using MSComm.

It is real time system, thus everytime the program is loaded, it has to check all the input whether it is 1 or 0.

For the output, i have to send the output from VB6 (computer) to the hardware.


Below is the coding to check the input status. If the input=1, then the shape in my program will turn the color.

Quote:
Private Sub Form_Load()
mscomm1.CommPort = 1 'control is using COM1
mscomm1.Settings = "9600,n,8,1" 'set up the port parameters
mscomm1.RThreshold = 1 'set the oncomm event to trigger whenever data arrives
mscomm1.PortOpen = true 'open the port

Dim hwinput, substr As String

MSComm1.PortOpen = True
MSComm1.Output = "IN0?"
MSComm1.Output = "IN1?"
MSComm1.Output = "IN2?"
MSComm1.Output = "IN3?"
MSComm1.Output = "IN4?"
MSComm1.Output = "IN5?"
MSComm1.Output = "IN6?"
MSComm1.Output = "IN7?"
MSComm1.Output = "IN8?"
MSComm1.Output = "IN9?"
MSComm1.Output = "IN10?"
MSComm1.Output = "IN11?"
MSComm1.Output = "IN12?"
MSComm1.Output = "IN13?"
MSComm1.Output = "IN14?"
MSComm1.Output = "IN15?"


Do
dummy = doevent()
Loop Until MSComm1.InBufferCount >= 5

hwinput = MSComm1.Input
substr = Mid(hwinput, 5, 1)

If substr = "1" Then
Shape11.FillColor = &H80FF&
ElseIf substr = "0"
Shape11.FillColor = &H00FFFFC0&
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub

Is the coding true? I get nothing when I do the testing....

please help me.

TQ in advance
Reply With Quote
  #2  
Old 05-21-2010, 03:45 PM
Cerian Knight's Avatar
Cerian Knightserial communication Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,199
Default

If you are not using OnComm then set RThreshold = 0. By 'get nothing' do you mean that you are stuck in the loop and .InBufferCount never reaches 5? To test your serial port, you can wire Tx and Rx together to create a loopback plug and anything you send out should show up in the buffer.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
serial communication
serial communication
serial communication serial communication
serial communication
serial communication
serial communication serial communication serial communication serial communication serial communication serial communication serial communication
serial communication
serial communication
 
serial communication
serial communication
 
-->