Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Digital Output Line Via RS-232 1

Status
Not open for further replies.

jsaliers

Programmer
Jan 23, 2003
129
US
Don't know if this is possible, but we'll give it a try. I need to output a cycling digital signal across a RS-232 line. That is, when the program starts, the line will be 0(V). After 285 minutes, the line will go to +5(V). Then after 30 minutes, the line will go to 0(V), then after 68 minutes, the line will go to +5(V). After 97 minutes, this cycle will repeat. Each cycle is 8 hours. This will go on for 35 cycles. I can set up the time loops and waiting. However, I don't know how to write a continuous 0(V) or +5(V) signal to the transmission line of the RS-232 cable. General info: pin 3 is TxD, pin 5 is Gnd, no need for RxD.

If you have any ideas, please let me know. Thanks in advance.

Jon
 
Well, I found out some new information about this. It is possible to make a request. When the request is made, one of the pins on the serial port will be set (positive voltage). It then waits until a response is given, or until the request bit is deset. In this way, I can set the request property of the serial port to set a positive voltage, and deset the request property of the serial port to set no voltage. This leads to another question. Does anybody know which property this is, or how to set/deset it?

Thanks in advance.

Jon
 
Use the DTR pin on the com port instead of TXD. You can set it high or low at will from VB.

As note, COM ports are + or - 12VDC, not 5V. If you need 5V and can't adapt the COM port to your needs, then you could use the parallel port. There's threads on here on how to control it.

Robert
 
Just want to check, is it okay to use the RTS pin instead of the DTR pin?

The 5(V) is not all that important. I just need to make sure that I have two distinct voltage levels. Thanks a ton!

Jon
 
Alright, I am having an issue, and I am not sure why. Here is my code. I have excluded the other stuff going on because it should not affect it.

Dim MSComm1 As MSComm

Private Sub btnStartCycle_Click()

With MSComm1
.CommPort = 1
.Settings = "9600,N,8,1"
.PortOpen = True
End With

....

MSComm1.RTSEnable = True
'Wait for certain time period.
MSComm1.RTSEnable = False

End Sub

The basic idea is that I set a pin on the serial port high, wait, then set it low. However, when I run my app, I get an error in the With block on the ".CommPort = 1" command. It says, 'Object variable or with block variable not set.' When I debug, and put the mouse over the line "With MSComm1", it shows "MSComm1 = Nothing". Any ideas on what I am doing...or not doing? I tried to add a "Set MSComm1 = New MSComm" line, but it did not have the MSComm object in the selection list.

Any help is much appreciated! Thanks in advance.

Jon

 
First off you can declare MSCOMM1 as

Dim MSComm1 As New MSComm

Then if that doesn't work you need to make sure that in your project references you have included a reference to the relevant file that contains the MSCOMM object.



Mark

The key to immortality is to make a big impression in this life!!
 
When I make the declaration, after New, the MSComm object does not appear in the list. When I type it in and run it, I get, "Compile Error. Invalid use of New keyword." I went through the entire reference list, and couldn't find a single one that referred to MSComm. Any ideas?

Jon
 
Never mind, I figured it out. I forgot to put the MSComm component on my UI. Way to pay attention to detail, eh? Thanks for all the help.

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top