Use Open to connect to serial port

  • Hi
    I use this sub to control my Serial instrument and it is working ok


    Code
    1. Sub Set_Up()
    2. Open "COM8:2400,N,8,1,X" For Binary Access Read Write As #1
    3. Cmnd = Chr(27) + Chr(2) + "0B" + Chr(13)
    4. Put #1, , Cmnd
    5. Close #1
    6. End Sub


    The problem is when I turn on my PC and run this micro fothe first time it is not working
    The I have to open another software like hyper terminal of patty to just open and close the com port once I don’t need to send any command
    Then after that the micro works ok
    What can I do to fix the problem
    Thanks

  • Re: Use Open to connect to serial port


    Quote from pike;746299

    HI iliagod57
    welcome to the forum
    what is the device and the expected result?



    Hi mate
    it is a simple RS232 connected thermometer that if you send 0B to it it will return XX.XXX as an integer which is the temperature and it is working no prob
    as I mentioned the problem is the first time excel wants to communicate and open the port there is nothing happening
    the instrument has been connected to PC true RS232-USB adapter and the OS is windows 8
    I wonder if there is any command that I have to send at the beginning to kind of clear the pathway or not ?


    thanks

  • Re: Use Open to connect to serial port


    iliagod57
    try this


    the code is in sheet one will populate the combo box with connected comports


    it all depends on the data transfer. is it a stream where it sends a signal to received data .. ? does the instrument has a transfer data button? .. or are you just reading a file?

  • Re: Use Open to connect to serial port


    Hi
    TNX for the code but unfortunately it did not work !!!
    it is not a stream and there is no file the instrument is HART SCIENTIFIC 1502A (or Fluke 1502A) you can find the cod and all the information in the manual
    I think it has nothing to do with the instrument cuz I can connect to it with any other com connectors like Windows HyperTerminal
    I did use a Carroll Touch 232LT circuit breaker and I know when I run the micro on this line:


  • Re: Use Open to connect to serial port


    sorry I did not notice that hope this one is better thanks

  • Re: Use Open to connect to serial port


    Hi iliagod57,


    try the attached workbook
    check the combo box to see which coms ports are connected, change to yellow cells to the correct values and then start the down load
    have a play around and let me know exactly what happen or did not happen

  • Re: Use Open to connect to serial port


    Quote from pike;746601

    Hi iliagod57,


    try the attached workbook
    check the combo box to see which coms ports are connected, change to yellow cells to the correct values and then start the down load
    have a play around and let me know exactly what happen or did not happen




    Thanks mate
    it is working, I need to test it more at the moment, but it is cool, I need to find out how the code works and how I should feed my code to it
    the com selection is not working it is not show any thing.
    I can not use it to download
    but again when i open and close the port with this one you send me after that my code is working
    i have to find out what you did to open and clear the pathway for the comport
    again I appreciate the time you put to answer me

  • Re: Use Open to connect to serial port


    Quote from pike;747012

    let me know what help you need .. does the white drop down list the connected coms ports?


    Hi me again
    I was wondering if it is possible to do the same thing true the network connection
    Same instrument with same commands all I need to do is send it to the IP address
    do you know what will be the format of command?

  • Re: Use Open to connect to serial port


    Quote from Kristian;783855

    Connect to more than one serial port using Excel Serial Comms Class test II.xlsm


    Hi.
    I succeded to use the Excel Serial Comms Class test II.xlsm to connect to one instrument. Is it possible to use this Excel to connect to 2 or more instrument of the same type?


    Regards
    Kristian



    i come across this and works well for getting data from my scale but have a few questions if someone might can help me


    1) I need help getting so that when i send the Capture command( AKA Hit the print button ) that it will let me chose which cell that number goes into and not jsut on the next line


    2) how i can regex and have it auto take out the Ibs so its just the number itself


    Sorry for thread digging figured it would be worth the shot for some help ;)

  • Re: Use Open to connect to serial port


    You should post a question in the forum but

    Code
    1. If Not .Data = vbNullString Then
    2. lngRow = lngRow + 1
    3. Cells(lngRow, 1).Value = replace(.Data,"Ibs","") ' change the cell location in the cells function Cells(row,column) and use replace function to remove the Ibs
    4. Range("L7").Value = "Transfer"
    5. End If

  • Dear Kristan
    Is it possible to use this Excel to connect to 2 or more instrument of the same type?
    pls help me !