VERY simple question about sending data

Hi,

I am trying to figure out how to get my VB program to send 5 volts through any output (serial, parallel, or USB) so I can trigger an external switch...That's it...nothing else...its so simple I can't find a direct answer to the question!

In case its relevant, the computers are new Dell dimensions and I use VB 6.0

Any help would be greatly appreciated,
Carl Lejuez
Assistant Professor of Psychology
University of Maryland - College Park


Comments

  • : Hi,
    :
    : I am trying to figure out how to get my VB program to send 5 volts through any output (serial, parallel, or USB) so I can trigger an external switch...That's it...nothing else...its so simple I can't find a direct answer to the question!
    :
    : In case its relevant, the computers are new Dell dimensions and I use VB 6.0
    :
    : Any help would be greatly appreciated,
    : Carl Lejuez
    : Assistant Professor of Psychology
    : University of Maryland - College Park
    :
    :

    With a very simple answer. VB can't do it. VB just doesn't have the low-level ability to do communication for the most part. It can do some work with COM/LPT ports, but there's not much control. I've never heard of sending a specific voltage, so I don't know if you'll find that ability or not. You can find a dll on the net that can handle the I/O for you. If nothing else, try looking for inpout.dll. That would seem to be a logical name to call it...

  • You can do it with APIs, VB is not powerful enough. As for the voltage, you can only send a legacy +5V TTL signal (I think ~1.5mA), nothing else.
    Good luck,
    _____________________________
    [size=1][b][grey]Cold[/grey][blue]Shine[/blue][/b]
    http://www16.brinkster.com/rafonline[/size]


  • : Hi,
    :
    : I am trying to figure out how to get my VB program to send 5 volts through any output (serial, parallel, or USB) so I can trigger an external switch...That's it...nothing else...its so simple I can't find a direct answer to the question!
    :
    : In case its relevant, the computers are new Dell dimensions and I use VB 6.0
    :
    : Any help would be greatly appreciated,
    : Carl Lejuez
    : Assistant Professor of Psychology
    : University of Maryland - College Park
    :
    :

    Jeez! These guys are so negative!

    Just use the MSCOMM control to turn on and off the RS-232 control signals. You can use either (or both if you want to contol two signals):

    MSComm1.DTREnable = vbTrue|vbFalse or
    MSComm1.RTSEnable = vbTrue|vbFalse

    to set/reset the Data Terminal Ready and/or Request to Send signals.

    Each of these will give you RS-232 level voltages, so they'll be a bit more than 5 volts. The output signal level usually swings between +12v and -12v.

    Don't try to draw much current from these - they are not meant to turn on big power relays! They are acually very low-current, so you will have to hang something else on the output to handle the necessary current for whatever you want to do. They can handle enough current to light up an LED, though.

    If you need inputs, there are four available: Carrier Detect (CD), Clear To Send (CTS), Data Set Ready (DSR), and Ring Indicator (RI). Some of these you can just test directly like this:

    If MSComm1.CDHolding = True Then... or

    If MSComm1.CTSHolding = True Then... or

    If MSComm1.DSRHolding = True Then...


    Or, you can use an event to check for these and for RI. That looks like this:

    [code]
    Private Sub MSComm_OnComm ()
    Select Case MSComm1.CommEvent
    ' Handle each event or error by placing
    ' code below each case statement

    Case comEvCD ' Change in the CD line.
    Case comEvCTS ' Change in the CTS line.
    Case comEvDSR ' Change in the DSR line.
    Case comEvRing ' Change in the Ring Indicator

    End Select
    End Sub
    [/code]


    The same thing could be done with the parallel port as well, though it's a bit more complicated and would prety much require external hardware. You could have eight outputs, which would give logic-level signals of +5 volts, which could then be used to control devices with the addition of some hardware to sink the current. Of course, you'd have to properly set the ready and acknowledge bits in your external hardware in order to keep the parallel port happily working.

    And how to control those signals? Just send a character to the printer output in VB. The character would be chosen based on the bit pattern it turns on and off. Depending on the application, you could send a string of characters to keep the signal on, or your external device would latch the outputs until reset.

    Anyway, try the serial port way. It's quick and easy.

    I couldn't give you the pin numbers for the serial port, because I wasn't sure whether you had a 9-pin or 25-pin serial port. I'd assume a 9-pin, since that's mostly what's being used today, but who knows.

    Just re-post if you have any more questions.

    Melissa


  • : Jeez! These guys are so negative!

    I said that VB can't do it and a third-party component would be needed. MSComm is such a third-party component. I just didn't know that MSComm would be capable of this.

  • : : Jeez! These guys are so negative!
    :
    : I said that VB can't do it and a third-party component would be needed. MSComm is such a third-party component. I just didn't know that MSComm would be capable of this.
    :

    Hey I was just jokin'! I thought I was safe in not putting a smiley face after it, since you are the guru of all the gurus around here. Sorry guys.

    I always consider whatever comes in the box to be part of the product, unless it is trialware, or something obvious like Crystal. I didn't know that someone else wrote MS Comm.

    Anyway, my suggestion is an unconventional use of those features, so I wouldn't expect anyone to pick up on it unless they have a twisted mind like me.


    Melissa


  • : Hey I was just jokin'! I thought I was safe in not putting a smiley face after it, since you are the guru of all the gurus around here. Sorry guys.
    :
    You have to take one little thing into account. You pointed out that I was wrong and why. I don't get offended by that. The smily was not needed for me, you're right. I was a bit tired when I posted. Just use a little leeway when reading my posts if I sound upset. Chances are great that I'm not, I'm just tired and cranky.

    : I always consider whatever comes in the box to be part of the product, unless it is trialware, or something obvious like Crystal. I didn't know that someone else wrote MS Comm.
    :
    My use of "third-party component" was a bit loose in my post, Microsoft did write MS Comm. My thinking is a little different. I consider everything included in the mandatory components to be part of the product. Everything else in the box is an add-on-able (new word? ) component, but not part of it. So when I say "third-party component", I probably actually mean "an add-on-able component" whether it's third-party or not.

    : Anyway, my suggestion is an unconventional use of those features, so I wouldn't expect anyone to pick up on it unless they have a twisted mind like me.
    :
    Twisted? I like twisted! Are you married? Seriously, I often use unconventional methods to find something. Wanna know how to find out if you are in the IDE or are compiled? Make use of uncompilable statements!:
    [code]
    Public Function InIDE() As Boolean

    On Error Resume Next
    Debug.Print 1 / 0 'Not compiled, so no error in exe
    InIDE = (Err.Number <> 0)

    End Function
    [/code]
    Later,
    KDL

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories