Home AMX User Forum AMXForums Archive Threads AMX Hardware

Monitor serial port output

Is there a command line function that I could run which would monitor the output of one of the serial ports on an NI-3000? I'm having a hell of a time troubleshooting a serial device that just wont work and it would be useful to see exactly what the NI thinks it is sending that device while the device is actually connected to the serial port.

-Jim

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    If you enable Netlinx Device Notifications in Netlinx Studio you can monitor strings going to/from any comm port. Do a search for "notifications" in the Netlinx Studio help file.
  • DHawthorneDHawthorne Posts: 4,584
    I've found third-party programs to be useful in this. I use SerialWatcher (http://www.pcremotecontrol.com/info.html - in the "other useful software" section), and the test utility Vantage supplies. The advantage of these over using Diagnostics is that you can see what is actually going back and forth without the NetLinx trying to interpret or filter it, including all the unprintable characters, and without truncation of long strings.
  • Joe HebertJoe Hebert Posts: 2,159
    lostboy wrote:
    it would be useful to see exactly what the NI thinks it is sending that device while the device is actually connected to the serial port.
    DHawthorne wrote:
    I've found third-party programs to be useful in this.
    Curious as to how a PC based third-party program such as the one mentioned can monitor the output of an NI-3000 while the NI-3000 is connected to the controlled device. Do you have some sort of adapter that plugs into your PC and T?s into the other two other serially connected devices to listen in?
    DHawthorne wrote:
    The advantage of these over using Diagnostics is that you can see what is actually going back and forth without the NetLinx trying to interpret or filter it, including all the unprintable characters, and without truncation of long strings.

    Diagnostics does indeed do a poor job but Notifications (the one I suggested) does a good job with unprintable characters as it converts them to their 2 digit hex code. It also doesn?t choke on NULLS like Diagnostics does. I?ve used Notifications extensively for troubleshooting and monitoring serial controlled devices and have had good success. But you do need to be careful with how many devices are enabled for Notifications because enough traffic will make Netlinx Studio crash.

    Third-party software is a great help for initial testing of a serial controlled device (it sure beats the heck out of Hyper Terminal) but once you get to the stage of having to monitor traffic between the NI-3000 and the controlled device I?m not sure how it helps. If I?m missing something please let me know.

    One other thing worth mentioning: If you?re sending data but not getting any data back from the device (and you know the baud rate is correct and the cabling is correct) make sure you have CREATE_BUFFER in DEFINE_START, or have a STRING handler present in the DATA_EVENT of the controlled device, or manually do an RXON someplace in your code so that the NI comm port is enabled to receive data.
  • DHawthorneDHawthorne Posts: 4,584
    I don't use them while actually connected to the device. I temporarily switch it to my computer serial port while testing. Often I'll run Hyperterminal on the same port and "mimic" device responses as well. I just missed the part where he said "while connected to the device" :).

    In situations like that, I find it helpful to not have the device connected to isolate my own part of the transaction and make sure it's correct.
  • yuriyuri Posts: 861
    if you are using a serial diagnostic utilty, use Docklight, it's the best :)
  • jneffjneff Posts: 25
    Serial port tester

    Serial port troubleshooting can be tuff sometimes. I verify cable connection using the code below and a 9 pin plug with pins 2-3 shorted as a quick test. This wont tell you if have 2 and 3 are crossed wrong or shorted, but you willl not get result if one of those two pins is shorted to pin 5, your cable length is way too long or there is interference from something else. If the situation is right, relay 1 will turn on and off while the short is in place and you don't need anything more than to look at the led on the front of the contoller to verify it.

    If it is a long run. 50' or more (75' limit?) consider lowering the buad rate, using a RS422 converter and using RS422 on the controllers. I have seen some devices work better than others at the same range. Problems related to cable length usually present themselves with commands and responses getting garbeled over distance. You can use the same code with netlinx diagnostics by connecting to the controller, setting up device notifications, Turn on strings to and from the device (Make sure your system number is the right number, not "0" or it wont work. - IE 5001:1:65535). View the notifications tab. What you send down that cable length should come back exactly the same.

    Another method - Hopefully you can query the device. After setting up notification options, Choose control a device. In the case of com1 on a 3000 with system number 1, send 5001:1:1 something like "'pwr?'" or whatever the protocol manual says. Are you getting the right response back? If you are, maybe your program needs some work.

    Or send a "command" directly to the port like "'GET BAUD'" You should get the baud rate back. Did your baud rate get set correctly at online?

    Here is the code below good luck.

    DEFINE_DEVICE
    serialport1 = 5001: 1:0
    relay = 5001: 8:0

    DEFINE_CONSTANT // create a string as long as you want
    teststring[] = {$03,$95,$00,$00,$00,$98}

    //or teststring = "'I hate troubleshooting RS232 problems!'"

    DEFINE_VARIABLE
    Serial
    send

    DEFINE_START
    serial = 0

    DEFINE_EVENT

    DATA_EVENT[serialport1]
    {
    ONLINE :
    {
    // check any buad rate you want
    SEND_COMMAND DATA.DEVICE,"'SET BAUD 9600,N,8,1 485 DISABLED'"
    SEND_COMMAND DATA.DEVICE,"'HSOFF'"
    }

    STRING :
    {
    IF(FIND_STRING(DATA.TEXT, teststring, 1))
    {
    if( [relay,1] = 0 )
    ON[relay,1]
    else
    OFF[relay, 1]
    }
    }
    }


    DEFINE_PROGRAM

    WAIT 10
    {
    SEND_STRING serialport1, teststring
    }
  • Spire_JeffSpire_Jeff Posts: 1,917
    jneff wrote:
    If it is a long run. 50' or more (75' limit?) consider lowering the buad rate, using a RS422 converter and using RS422 on the controllers.

    The actual max distances can vary drastically depending on the cabling being used. It has been discussed here: http://amxforums.com/showthread.php?t=1663

    If you run at 9600 baud, you should be able to get 500ft on CAT5. ;)

    Jeff
  • jneffjneff Posts: 25
    actual max distance.
    Spire_Jeff wrote:
    The actual max distances can vary drastically depending on the cabling being used. It has been discussed here: http://amxforums.com/showthread.php?t=1663

    If you run at 9600 baud, you should be able to get 500ft on CAT5. ;)

    Jeff

    What I wrote is based upon 18 years of experience with rs232 interfaces. running 500ft of cat5 cable at 9600 is a bad idea. The EIA standard is 50 feet, OR a cable length equal to a capacitance of 2500 pF. UTP CAT-5 cable is typically 17 pF/ft, therefore the EIA standard for that cable would be 147 feet in a perfect environment with perfect equipment. I have seen that same cable fail (garbeled data) at 9600 baud at 50' between a NI-2000 and a MT1065 projector in our engineering physics building. Normally we do not use cat 5 for rs232, but the building design required we used existing cabling and tested the run with a very expensive TDA.

    AMX has set their standard as follows. RS232 - 50 feet, RS422/485 - 4000 feet. Following those standards will save a person a lot of trouble down the road.
  • DHawthorneDHawthorne Posts: 4,584
    Nowadays, if I have a long RS-232 run, I just convert it to Ethernet. The boxes are getting cheap enough that I consider it well worth it. In most cases, I only have to put it on the device end, and just use an IP connection in the NetLinx.
  • JoeJoe Posts: 99
    Not completely relavent to the topic, but I used two different serial port programs for testing communications with equipment. The first and probably most user-friendly is LookRS232, available at www.fcoder.com. The second is Indigo Terminal Emulator from www.shadeblue.com. Both are far better than Hyperterminal and are great for testing RS232 protocols on devices and seeing exactly what comes back to a master. Lately I've had issues with what is documented vs. what is reality.

    Joe
  • mpullinmpullin Posts: 949
    Joe wrote:
    Lately I've had issues with what is documented vs. what is reality.
    Haven't we all?
Sign In or Register to comment.