The Philippine Electronics and Technology Forum
May 30, 2012, 04:51:05 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1] 2 3   Go Down
  Print  
Author Topic: Serial Port Switcher using VB6...  (Read 1353 times)
_Lurker_
Diesel Generator
*

Pogi/Ganda Points: 132
Offline Offline

Gender: Male
Posts: 1387

....


« on: September 06, 2011, 11:07:30 PM »

^^ Tama ba ang title? Grin

Anyway I just want to share this simple vb6 serial port switcher. I test this using a usb-to-serial cable.
I have never tried this on the built-in serial port of a PC. The difference between the two is that
the cable has low -> 0 volts and high -> 5 volts. While the PC's serial port has a low of -9volts and
a high of +9volts, this depends on the PC used.

I don't know if this simple VB6 program may help anyone. But I think this is the simplest way
to interface a circuit to a PC. I might be wrong.



Three buttons could be connected to DTS, CD and CTS. If a high signal is detected, a "true" is displayed
on the appropriate text box. VB.net could sense the RING terminal, but as of now I don't know how to do that
in VB6. It might also be possible to make the RX terminal an input. What I know is the TX pin could be used as an output.

Code:
Private Sub cmdDTR_Click()
If cmdDTR.Caption = "ON" Then
cmdDTR.Caption = "OFF"
MSComm1.DTREnable = True
Exit Sub
End If

If cmdDTR.Caption = "OFF" Then
cmdDTR.Caption = "ON"
MSComm1.DTREnable = False
Exit Sub
End If
End Sub

Private Sub cmdRTS_Click()
If cmdRTS.Caption = "ON" Then
cmdRTS.Caption = "OFF"
MSComm1.RTSEnable = True
Exit Sub
End If

If cmdRTS.Caption = "OFF" Then
cmdRTS.Caption = "ON"
MSComm1.RTSEnable = False
Exit Sub
End If
End Sub

Private Sub cmdExit_Click()
If MSComm1.PortOpen Then MSComm1.PortOpen = False   'makes sure that the com port is close during exit
End
End Sub

Private Sub cmdConnect_Click()
On Error GoTo errorhandler

If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
cmdConnect.Caption = "CONNECT"
Label1.Enabled = True
Text1.Enabled = True
Text2 = ""
Text3 = ""
Text4 = ""
cmdDTR.Enabled = False
cmdRTS.Enabled = False
Exit Sub
End If

If MSComm1.PortOpen = False Then
MSComm1.CommPort = Text1.Text
MSComm1.PortOpen = True
cmdConnect.Caption = "DISCONNECT"
Text1.Enabled = False
Label1.Enabled = False
Text2.Text = MSComm1.DSRHolding
Text3.Text = MSComm1.CDHolding
Text4.Text = MSComm1.CTSHolding
cmdDTR.Enabled = True
cmdRTS.Enabled = True
End If
Exit Sub

errorhandler:
MsgBox "Wrong ComPort number"    ' for now i dont know any other errors
End Sub

Private Sub Form_Load()
With MSComm1
.DTREnable = False
.RTSEnable = False
End With
End Sub

Private Sub MSComm1_OnComm()
Text2.Text = MSComm1.DSRHolding
Text3.Text = MSComm1.CDHolding
Text4.Text = MSComm1.CTSHolding
End Sub

Private Sub Timer1_Timer()
If Form1.Caption = "SERIAL PORT SWITCHER" Then
Form1.Caption = "WWW.ELECRONICSLAB.PH"
Exit Sub
End If
If Form1.Caption = "WWW.ELECRONICSLAB.PH" Then
Form1.Caption = "SERIAL PORT SWITCHER"
Exit Sub
End If
End Sub

A proper series resistor should be used on each terminal.
Logged
The Philippine Electronics and Technology Forum
« on: September 06, 2011, 11:07:30 PM »

 Logged
_Lurker_
Diesel Generator
*

Pogi/Ganda Points: 132
Offline Offline

Gender: Male
Posts: 1387

....


« Reply #1 on: September 06, 2011, 11:18:16 PM »

http://www.easy-share.com/1917978134/serial port switcher.zip
Logged
The Philippine Electronics and Technology Forum
« Reply #1 on: September 06, 2011, 11:18:16 PM »

 Logged
PlCUSER
Diesel Generator
*

Pogi/Ganda Points: 115
Offline Offline

Posts: 1116


« Reply #2 on: September 07, 2011, 03:45:27 PM »

nice post. +1 for sharing.

in addition, you can use the mscomm event "comEvRing" to monitor RI pin. a change status in this pin triggers this event.
below are other mscomm events in VB6:
comEvCD
comEvCTS
comEvDSR
comEvRing
             

baka pwd mo ding ishare ung hardware set up mo. para complete package na ang post.
and mas maka relate ung mga mapapadaan. Grin Grin Grin



Logged
The Philippine Electronics and Technology Forum
« Reply #2 on: September 07, 2011, 03:45:27 PM »

 Logged
_Lurker_
Diesel Generator
*

Pogi/Ganda Points: 132
Offline Offline

Gender: Male
Posts: 1387

....


« Reply #3 on: September 07, 2011, 04:08:00 PM »

^^^ Maraming salamat sir sa point at sa payo. "comEvRing" lang pala ang katapat. +1
OK sir gagawa po ako ng schem.. Bagong reformat kasi PC ko, mag iinstall pa ako ng proteus at vb6. Grin
Logged
_Lurker_
Diesel Generator
*

Pogi/Ganda Points: 132
Offline Offline

Gender: Male
Posts: 1387

....


« Reply #4 on: September 07, 2011, 05:16:48 PM »



Ito na po simple hardware. Yung 5 volts doon na kunin sa 5 volts supply sa USB-to-Serial, baklasin nalang yung wire.

Logged
ultrasonic™
Solar Power Satellite
*****

Pogi/Ganda Points: 825
Offline Offline

Gender: Female
Posts: 6548


never be harsh coz everythng is fine


« Reply #5 on: September 07, 2011, 05:39:07 PM »



nice  sharing sis  dummy... hiramin  ko na rin  ito  Grin

Logged

im always walking on the rain so that no one could see me crying
Supremo Mayor Kuya Johnaray
Diesel Generator
*

Pogi/Ganda Points: 198
Offline Offline

Posts: 1459



« Reply #6 on: September 07, 2011, 05:56:39 PM »

+ 1 Nice Grin Grin Grin Thanks for sharing... MOAR MOAR este MORE!
Logged

_Lurker_
Diesel Generator
*

Pogi/Ganda Points: 132
Offline Offline

Gender: Male
Posts: 1387

....


« Reply #7 on: September 07, 2011, 06:17:42 PM »

^^^ Salamat din po. Grin

Nahirapan pa ako magamit ang Ring terminal sir PICUSER. Na detect ko na ang comEvRing pero mahirap ipa labas sa text box ang pag open/close ng switch. Isang beses lang kasi sya mag trigger. At pag na disconnect na yung switch, wala ng commevent.  Undecided
Logged
PlCUSER
Diesel Generator
*

Pogi/Ganda Points: 115
Offline Offline

Posts: 1116


« Reply #8 on: September 07, 2011, 06:58:48 PM »

meron kasi atang hindi tama sa set up mo sir. hehehe.
the proper way to trigger an event on these pins is to pull these pins low. connect mo sa ground ung switch, not sa +5V. in doing so, pwd mo na din alisin ung 1k resistor.

but for good pc interfacing practice, always use an optocoupler. like the PC817.
Logged
_Lurker_
Diesel Generator
*

Pogi/Ganda Points: 132
Offline Offline

Gender: Male
Posts: 1387

....


« Reply #9 on: September 07, 2011, 07:03:50 PM »

Na dagdagan ng isang output.. Grin

[IMG=http://img192.imageshack.us/img192/9431/hardware2.jpg][/IMG]

Uploaded with ImageShack.us

http://www.easy-share.com/1917998828/serial port switcher.zip
Logged
Hotguy
Diesel Generator
*

Pogi/Ganda Points: 49
Offline Offline

Gender: Male
Posts: 1642



« Reply #10 on: September 07, 2011, 07:05:03 PM »

Pasub..  Smiley Thanks sir pulang kabayo sa pagshare...Dadagdagan ko pa ng 1 point if madagdagan pa ng info Grin Grin Grin
Logged

God give us the grace to accept with serenity the things that cannot be changed, courage to change the things which should be changed and the wisdom to distinguish the one from the other [Reinhold Niebuhr]
_Lurker_
Diesel Generator
*

Pogi/Ganda Points: 132
Offline Offline

Gender: Male
Posts: 1387

....


« Reply #11 on: September 07, 2011, 07:09:28 PM »

meron kasi atang hindi tama sa set up mo sir. hehehe.
the proper way to trigger an event on these pins is to pull these pins low. connect mo sa ground ung switch, not sa +5V. in doing so, pwd mo na din alisin ung 1k resistor.

but for good pc interfacing practice, always use an optocoupler. like the PC817.

OK sir try ko modify yung circuit.. Maraming salamat po. Teka bakit hindi lalabas ang image sa taas?
Logged
_Lurker_
Diesel Generator
*

Pogi/Ganda Points: 132
Offline Offline

Gender: Male
Posts: 1387

....


« Reply #12 on: September 07, 2011, 08:45:14 PM »

Repost ko lang po..




http://www.easy-share.com/1917998828/serial_port_switcher.zip
Logged
Hotguy
Diesel Generator
*

Pogi/Ganda Points: 49
Offline Offline

Gender: Male
Posts: 1642



« Reply #13 on: September 07, 2011, 10:10:25 PM »

nyc.. i like that Smiley
Logged

God give us the grace to accept with serenity the things that cannot be changed, courage to change the things which should be changed and the wisdom to distinguish the one from the other [Reinhold Niebuhr]
Phthonos
Size AAA Battery
***

Pogi/Ganda Points: 0
Offline Offline

Posts: 54


« Reply #14 on: September 08, 2011, 12:24:31 AM »

super thnx po tlga master dummy_c! sna po mgwa nio ung 4 switches if possible Cheesy
pero thnx po tlga d2 O:D
Logged
Lhean
CR2032 Battery
**

Pogi/Ganda Points: 1
Offline Offline

Gender: Male
Posts: 12


LHEANELECTRONICS


« Reply #15 on: September 08, 2011, 12:37:58 AM »

panu po kung ang need ko 4 switch...
Logged

HYDRO AC GENERATOR

>Xecixz<
Lhean
CR2032 Battery
**

Pogi/Ganda Points: 1
Offline Offline

Gender: Male
Posts: 12


LHEANELECTRONICS


« Reply #16 on: September 08, 2011, 12:38:47 AM »

panu po kung 4 switch ang need kong ikabit...
Logged

HYDRO AC GENERATOR

>Xecixz<
Kaizer03
Nuclear Reactor
****

Pogi/Ganda Points: 220
Offline Offline

Posts: 4648


C#<-->Android<-->Java


WWW
« Reply #17 on: September 08, 2011, 02:25:56 AM »

gamitan mo ng diodes to multiplex those three inputs.. para maging 7 inputs Wink

001
010
100
011
110
101
111

same thing with output=)
Logged

Lend a hand for those who are in need!=)

Stop Hijacking!=) More Technical Posts!=)
DataSheets are enough to answer your questions! Wink

Kaizer Killer EX Pre-Alpha
_Lurker_
Diesel Generator
*

Pogi/Ganda Points: 132
Offline Offline

Gender: Male
Posts: 1387

....


« Reply #18 on: September 09, 2011, 12:08:28 AM »

^^^ Sir kaizer salamat po. But what if dalawa or tatlo na switch sabay sabayin na i-pendot sir? Pwede pa rin kaya? Salamat po.
Logged
Kaizer03
Nuclear Reactor
****

Pogi/Ganda Points: 220
Offline Offline

Posts: 4648


C#<-->Android<-->Java


WWW
« Reply #19 on: September 09, 2011, 12:12:33 AM »

^

kung gagamitin mo lahat ng combination.. malamang di na Cheesy kasi may dodoble... pero kung 4 lang gagamitin mo..make it sure na walang kaparehas na combination yung pedeng magkasabay na button =)
Logged

Lend a hand for those who are in need!=)

Stop Hijacking!=) More Technical Posts!=)
DataSheets are enough to answer your questions! Wink

Kaizer Killer EX Pre-Alpha
The Philippine Electronics and Technology Forum
   

 Logged
Pages: [1] 2 3   Go Up
  Print  
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Serial Port (PC) and Serial Cable loopback
General Digital Design
Winterburn 6 1539 Last post May 21, 2008, 10:57:16 PM
by maldihtah13
HELP: Using USB-serial port in ZDS II
Zilog Microcontrollers
fuzzy_logic 6 1353 Last post April 30, 2009, 09:24:36 PM
by Donopot
multi serial port?
Computer Interfacing and Digital Communications
erraticmind 14 1673 Last post June 03, 2009, 08:20:37 AM
by 7_SeVeN_7
rf tranceiver that can connect to serial port and usb port « 1 2 »
Announcement and Promotions
be_he_he 31 3166 Last post August 17, 2009, 01:56:39 PM
by be_he_he
Serial or Parallel port interfacing (using usb to parallel or serial converter)
Computer Interfacing and Digital Communications
janmike 8 553 Last post May 10, 2011, 09:00:43 PM
by Arvie
mga sis help po sa serial port
Computer Repair (Computer Technicians Forum)
charles jericho 0 148 Last post December 02, 2011, 03:26:35 PM
by charles jericho
Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!