Results 1 to 7 of 7
  1. #1
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Serial comms (Excel 2K)

    We have developed a product that we need to make basic communication with (RS232) via a serial port. Assuming running Excel 2K on either W98 or W2K, is this a relatively straighforward thing to achieve?

    We can communicate OK using an old laptop with W3.1 & Terminal, but want to drag this into the 21st century.
    Currently, we send a 2 character string and get a 16 string reply. Once I've got the data into Excel I'll be OK to manipulate it, it's getting the communication protocol going that I'm totally at sea on.

    Anyone able to assist?

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Serial comms (Excel 2K)

    There exists a COMM (not to be confused with COM) control
    that will do every RS232 thing you might need. I think it's part
    of VB5 + and it's called MSCOMM.

    But you may be able to accomplish serial I/O simply using the
    VBA native Open command.

    Put this in a loop and bust out when needed.
    Open COM1: for Input as #1
    Input #1, bla bla bla
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Serial comms (Excel 2K)

    Thanks, Kevin, but notalotajoy.
    <pre>Open "COM1:" For Output As #1
    Write #1, "DD"
    Close #1
    Open "COM1:" For Input As #1
    Input #1, A$
    Close #1
    </pre>


    I found I had to put COM1: in quotes or it errored on me.
    I need to send "DD" to the equipment as a signal to Dump Data - whether this is working or not I don't know.
    As soon as it get's to the Input line, Excel hangs and I have to EndTask to get out (Ctrl_Brk does nothing).
    <img src=/S/sad.gif border=0 alt=sad width=15 height=15>
    Mu ultimate aim is to give the end user a stepping stone to access data on the equipment. We may develop something more sophisticated later, but at the moment, if we can dump the incoming data onto a spreadsheet so it can be printed out, I'll be happy.
    If I need to go the VB route, am I going to be able to produce something I can freely ship out, much as I could a spreadsheet?
    I've got VB4 lurking somewhere, if I need to upgrade I will. It may seem excessive to buy the software for what seems a trifling thing, but the job can stand the cost.

    Any more advice / pointers gratefully received.

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Serial comms (Excel 2K)

    Leif,

    It's my understanding that com ports need to establish a "handshaking" protocol before any data transmits or received. I'm no expert on this, however.

    Try this at a command prompt to get some port info:

    mode comX: (where X is the com port number).

    DTR data terminal ready
    CTS clear to send
    RTS ready to send
    DSR data set ready

    Each of these commands has a corresponding ASCII code. The transmit side needs to indicate RTS and the receive side needs to indicate CTS.

    The most important aspect of serial communications is the baud rate, stop bits and parity. Make sure both RS232 ports are set the same and try your code again. How are these 2 ports connected, BTW? Null modem cable?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Serial comms (Excel 2K)

    Thanks for that - I will go and play.
    I've also come across a distributable DLL that may do the job - I'll post it if it does the job.

  6. #6
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Serial comms (Excel 2K)

    Well, I eventually got round to sorting this using dll's available from MarshallSoft - $105.00 but so simple to use, even I managed it.

    If anyone is interested, they do a neat range of " Email, FTP, and serial communications library (component) software for Windows " - all available as free trial-ware.

  7. #7
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Serial comms (Excel 2K)

    Lief,

    Thanks for this reference. My further testing revealed that (on Win2k) the serial ports are not directly accessible (Open COM2 for Input, etc.).

    So the library approach using the API is the way to go.

    I was hoping to find the Windows API functions and use them without having to reference YAL (yet another library). Nothing on my first fishing trip.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •