IBM developerWorks
 
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old October 25th, 2004, 02:28 AM
pingping pingping is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Singapore
Posts: 9 pingping User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via MSN to pingping
Serial communication

Hi, dear friend,
Can anybody answer my question? thanks a lot!
I'm doing my school project. It's about to record the
Temperature and the humidity in the greenhouse.
The data is transmitted through RS232, the folowing is
code, but anyway, I can only record one data Temperature,
but how can I record humidity at the same time?
Millions of thanks!



Private Sub Form_Load()

With MSComm1
.CommPort = 1
.Settings = "9600,N,8,1"
.InputMode = comInputModeText
.RThreshold = 1
.InputLen = 0
.PortOpen = True
.RTSEnable = True

End With

End Sub

Private Sub MSComm1_OnComm()

If MSComm1.CommEvent = comEvReceive Then
tmpstr$ = MSComm1.Input
txtTemp.Text = tmpstr$
End If
End sub

Reply With Quote
  #2  
Old October 25th, 2004, 05:24 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 18 h 33 m 48 sec
Reputation Power: 180
Why are you limited to only Temperature? You can send any string you want over a serial line, you can combine Temp and Humidity in some kind of delimited string.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old October 26th, 2004, 01:39 AM
pingping pingping is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Singapore
Posts: 9 pingping User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via MSN to pingping
Smile

Quote:
Originally Posted by Doug G
Why are you limited to only Temperature? You can send any string you want over a serial line, you can combine Temp and Humidity in some kind of delimited string.
Thanks to Dong G!!
Yes, I have tried to do this, following is my code, but I caould not get the correct value. The data is sent in Binary format through 8052 Micro ropcessor. By the way, how can i convert it into decimal format? Thanks a lot! I'm new to VB.




Private Sub MSComm1_OnComm()

If MSComm1.CommEvent = comEvReceive Then
tmpstr$ = MSComm1.Input

Dim tmp%, hum%, scn%
tmp% = Asc(Left(tmpstr$, 1))
hum% = Asc(Mid(tmpstr$, 2, 1))


txtTemp.Text = tmp%
txtHum.Text = hum%

End If




Pingping

Reply With Quote
  #4  
Old October 26th, 2004, 09:39 AM
AnnaChen AnnaChen is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: USA
Posts: 73 AnnaChen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 5 h 58 m 29 sec
Reputation Power: 4
See if this can help:

'SimpleBinaryToString converts binary data (VT_UI1 | VT_ARRAY Or MultiByte string) 'to a string (BSTR) using MultiByte VBS functions
Function SimpleBinaryToString(Binary)
Dim I, S
For I = 1 To LenB(Binary)
S = S & Chr(AscB(MidB(Binary, I, 1)))
Next
SimpleBinaryToString = S
End Function

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Serial communication


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway