_Lurker_
Diesel Generator
Pogi/Ganda Points: 132
Offline
Gender: 
Posts: 1387
....
|
 |
« on: September 06, 2011, 11:07:30 PM » |
|
^^ Tama ba ang title?  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. 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
Gender: 
Posts: 1387
....
|
 |
« Reply #1 on: September 06, 2011, 11:18:16 PM » |
|
|
|
|
|
|
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
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. 
|
|
|
|
|
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
Gender: 
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. 
|
|
|
|
|
Logged
|
|
|
|
_Lurker_
Diesel Generator
Pogi/Ganda Points: 132
Offline
Gender: 
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
Gender: 
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 
|
|
|
|
|
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
Posts: 1459
|
 |
« Reply #6 on: September 07, 2011, 05:56:39 PM » |
|
+ 1 Nice  Thanks for sharing... MOAR MOAR este MORE!
|
|
|
|
|
Logged
|
|
|
|
_Lurker_
Diesel Generator
Pogi/Ganda Points: 132
Offline
Gender: 
Posts: 1387
....
|
 |
« Reply #7 on: September 07, 2011, 06:17:42 PM » |
|
^^^ Salamat din po.  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. 
|
|
|
|
|
Logged
|
|
|
|
PlCUSER
Diesel Generator
Pogi/Ganda Points: 115
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
Gender: 
Posts: 1387
....
|
 |
« Reply #9 on: September 07, 2011, 07:03:50 PM » |
|
|
|
|
|
|
Logged
|
|
|
|
Hotguy
Diesel Generator
Pogi/Ganda Points: 49
Offline
Gender: 
Posts: 1642
|
 |
« Reply #10 on: September 07, 2011, 07:05:03 PM » |
|
|
|
|
|
|
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
Gender: 
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
Gender: 
Posts: 1387
....
|
 |
« Reply #12 on: September 07, 2011, 08:45:14 PM » |
|
|
|
|
|
|
Logged
|
|
|
|
Hotguy
Diesel Generator
Pogi/Ganda Points: 49
Offline
Gender: 
Posts: 1642
|
 |
« Reply #13 on: September 07, 2011, 10:10:25 PM » |
|
nyc.. i like that 
|
|
|
|
|
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
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  pero thnx po tlga d2 O:D
|
|
|
|
|
Logged
|
|
|
|
Lhean
CR2032 Battery

Pogi/Ganda Points: 1
Offline
Gender: 
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
Gender: 
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
Posts: 4648
C#<-->Android<-->Java
|
 |
« Reply #17 on: September 08, 2011, 02:25:56 AM » |
|
gamitan mo ng diodes to multiplex those three inputs.. para maging 7 inputs  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! Kaizer Killer EX Pre-Alpha
|
|
|
_Lurker_
Diesel Generator
Pogi/Ganda Points: 132
Offline
Gender: 
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
Posts: 4648
C#<-->Android<-->Java
|
 |
« Reply #19 on: September 09, 2011, 12:12:33 AM » |
|
^ kung gagamitin mo lahat ng combination.. malamang di na  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! Kaizer Killer EX Pre-Alpha
|
|
|
|
The Philippine Electronics and Technology Forum
|
|
|
|
|
|
Logged
|
|
|
|
|