12-04-2007 01:34 PM
12-04-2007 02:03 PM
I would recommend starting off with the example VIs included with LabVIEW. Try using the Basic Serial Write and Read VI with known commands, this will verify that you device is working properly. Once you establish communication with your device, incorporate your own code to automate commands.
Also, it would be helpful if you can elaborate on "it doesn't work". Can you explain whats happending, are you getting any error codes? A useful tool for debugging serial communication is NI-Spy. NI-Spy captures VISA calls to the serial bus as well as status and error codes. You can find NI-Spy at Start>>Programs>>National Instruments>>NI-Spy on a Windows machine. Check out this KnowledgeBase for more information on NI-Spy.
Ted
12-04-2007 02:08 PM
well, i have setup the program to send out as a message format to this system. if this system have receive a valid message, it will display it.
since i didnt see the message display from the other system. i'm sure that i did something wrong in my end of the program.
so, i'm stuck right in the middle. i did use, a basic write to start my application. then it didn't send out a valid message as well. so, i just kept of modifying the program.
12-04-2007 02:54 PM
12-04-2007 02:57 PM
12-05-2007 02:06 PM
12-06-2007 05:43 PM
12-06-2007 06:37 PM
First bit of advice is to fix the code you posted as PNT was talking about in message 5. Your use of local variables will cause race conditions. In all likelihood, a copy of the local variable will be used to calculate a piece of string before the local variable gets written to. It will either be the default value, or a stale value from a previous iteraiton of the loop. Get rid of all the local variables in that event structure and pass the data from one area of the code to another by way of wires.
I see in the top right you have a constant set for big endian. But the document mentions that the words are little endian. I'm not even sure why you are using the flatten to string function there anyway. You are passing in a string. I think between that and the big-endian/little endian, you are completely scrambling things in ways you don't want to, or possibly doing nothing at all.
Start from the beginning, just build the strings using the available functions to see if they are being built the way the document calls for. Nothing fancy, just concatenate. Do not use the build array that you have coming out of the HDR function array that does nothing. (A few other spots as well.) Be careful of your naming conventions. You have MSB LSB as well as msb and lsb. That could confuse you as to where those values are supposed to go.
Also odd is your checksums where you are operating on each byte individually. The document looks like the checksums operate on words at a time. By operating on bytes at a time, you may miss have the least significant byte roll over into the MSB when doing the summing of U16 values.
There are a lot of code problems here that would best be solved by scrapping all of your code and starting again.
12-07-2007 07:31 AM
12-07-2007 12:50 PM