LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

rs485

 i have tried every possible things, it's not working. i dont know what's wrong with my program. please help. .
0 Kudos
Message 11 of 34
(2,754 Views)

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

Ted H
Applications Engineering
National Instruments
Message 12 of 34
(2,753 Views)

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.

0 Kudos
Message 13 of 34
(2,752 Views)
Are you using the 2 or 4 wire setup for your 485?
0 Kudos
Message 14 of 34
(2,743 Views)
2 wires; half duplex.
0 Kudos
Message 15 of 34
(2,740 Views)
You're problem is probably coming from the fact that you aren't sending the right commands to the device.  What are you trying to communicate with?  Do you have a programming manual?
 
Additionaly, like I said before, any associated error codes would be really helpful.  Run NI-Spy and see what VISA calls are throwing errors.  To make things simpler, do this trouble shooting with the VISA basic serial write and read vi.
Ted H
Applications Engineering
National Instruments
0 Kudos
Message 16 of 34
(2,712 Views)
my programing manual is in the first page, so as my labview program.
i tried to use ni-spy, but it seems ok to send. i'm not quite sure what i'm looking for as an error.
the other system won't shoot out error, if you're not sending the right message. it won't respond back.
thats how i know that my program is not right. can someone please look at the program manual as well as the program, and tell me what am i doing wrong. thanks.
0 Kudos
Message 17 of 34
(2,692 Views)

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.Smiley Wink

0 Kudos
Message 18 of 34
(2,687 Views)
ok thanks, i'll give that a try.so, you're saying; make a 6words of constant number and then convert them into a normal hex string? as for the checksum, wire them up by using the constant word that i was using before.
0 Kudos
Message 19 of 34
(2,675 Views)
tried it with the constant number, still not working. 
0 Kudos
Message 20 of 34
(2,658 Views)