09-08-2008 12:56 PM
Hi All,
I have some problems with "VISA Write" function. Although it works fine in many situations, there are some times that I get "Timeout Error: −1073807339" or "Connection Lost Error: -1073807194". In the latter case I even have to restart the computer. Can anyone help me in this issue?
Here are some supplementary information. I think the last piece of info, describing about EMC considerations is the most important.
1- I am using LV8.2 on WinXP SP2.
2- Recently, I have upgraded to NI-VISA4.4.1. But the newest version did not resolve the problem. (A suggested solution in some threads for -1073807194)
3- I have tried longer Timeouts by using "VISA Configure Serial Port" without any success. (A suggested solution in some threads for -−1073807339)
4- I have also tried defining the Receive/Transmit I/O Buffer size right after Open VISA session function. There were no improvements (A suggested solution in some threads for -1073807194)
5- I have tried both Synchronous and Asynchronous methods in VISA Read and VISA Write. I did not notice any difference for this problem.
6- There is no problem with VISA Read at all (at least, there is no returned error)
About the instrument and structure of the system:
1- It is an RS485 network (2 wire) with three slave nodes, an RS485/USB converter (installed as a COM port), and the PC COM port as the master node of RS485 network.
2- Each slave node uses a microcontroller 8051 with baudrate 57600bps and 9-bit framing style. Therefore I have to write a string, byte-by-byte, setting the proper parity bit for each byte.
3- The longest string to be written is 6 bytes long in each request, which means 6 separate transmitions with the length of one.
4- There are some powerful relays near slave nodes. When I test the program with relays disconnected, EVERYTHING IS OK, but when the relays are powered up to perform the final test, I get either of the aforementioned errors after several switchings of relays. It may seem that some EMC considerations has brought up this problem, but the hardware setting is the last thing to tackle.
In summary, I have two questions:
1- Can you think of any trouble source other than relays' noise?
2- Do you know about any software solution? any programming trick or even using windows dlls or etc.
Regards,
09-08-2008 02:51 PM
09-09-2008 02:58 AM
Before using LV for this job, There was a microcontroller 8051 (as the master node) that could handle the communication with slave nodes without any problem. Therefore, I think the problem returns to VISA itself and maybe using lower level programming could help (in spite of the noisy environment)
The only thing I have found till now is "In Port" and "Out Port" vis. Has anyone had any experience working with these two VIs to establish a 9-bit framing serial connection.
How to define parity-bit for each byte when writing to port using these VIs?
How about defining the baud rate? no. of stop bits and etc.
09-09-2008 05:50 AM
I may be able to help, since I woked before with rs485, give me more detail about the rs485/usb(product number)
and about the 3 slaves, are they are custom or can you give me the product number
Rs485 is a common use interface but I found difficult to mixed different product, the best is to get all from the same supplier
and also have support.
also it could be the relay, did you put a diode on the coil? 1n4001....
what voltage and how o you regulate voltage in you slave devices...
09-09-2008 07:28 AM
Slaves are actually 2 analog input moduls and 1 digital output module. Each of them is driven by a 8051 micro and a domestic company has made them. But their performance is confirmed before. They wait for the master to poll them. Analog input modules return a 17 bytes long string to transfer data to master, while digital output modules are silent and just accept the commands. Their power supply is isolated and they are tested successfully in harsh environment.
The RS485/USB converter is also bought from a domestic company. Not a famous brand, but its performance equals to MOXA. It is also used for connecting SIEMENS PLCs to PC already with complete success. It has no separate power supply, but it has a driver. It is currently installed as a COM port that its baudrate, parity, no. of stop bits, .... are adjustable via Windows Device Manager and also in LabVIEW.
Regarding relays, they are actually energized by smaller relays. There is no intermediate circuit, just wiring. The connectors of smaller relays are in energizing circuit of bigger relays. I can hardly modify hardware settings and I am just to write an LV application!
I should emphsize that, the original system had an ISA board with another 8051 as RS485 master. For many reasons, the owner decided to substitute the master and use a more complex system to be able to implement more efficient control algorithms.
I have attached the code. I only get error in "VISA Write" in "Write-Ser-9bit.vi" when the relays are powered on.
09-09-2008 07:36 AM
you should always put a diode on each relays's coil.
a relay when turn off release energy.
google relay diode.....
09-09-2008 07:37 AM
i am taking a look at your code.
I ll get back to you
you wrote that aplication do work if the relay is not connected?
09-09-2008 07:42 AM - edited 09-09-2008 07:43 AM
Agree with jjc.
SInce you are running 2-wire mode and the issue is in transmision, it sounds like your rs-485 adapter is haveing trouble acquiring control of the bus. When last I looked the control of the bus was hadled using RTS/CTS handshaking signals.
The only things I can suggest (short of breaking an O-scope) are to first check the quality of your ground reference. If the ground drifts due to EMF, the control may not be able to detect the handshaking signal changes.
THe other thing is to try running NI Spy to see if you can get more information about what is happening.
Ben
09-09-2008 07:52 AM
09-09-2008 08:00 AM
One thing that has not been mentioned is both the terminating resistors and bus biasing resistors.
RS-485 in an electrically noisy environment should have these in place to ensure that you get enough current flow to get clean communication. Without the resistors your comm bus is more susceptible to electrical interference.
Here is a good reference for setting up RS-485 busses (http://www.bb-elec.com/bb-elec/literature/tech/485appnote.pdf)
Also, just because the previous microcrontroller worked in this application instance does not mean that your current controller has exactally the same electrical specs and will work. If you were on the fringe edge of the operating envelope a different transeiver may not operate quite as well.
As a minimum, I would implement the terminating resistors. For most applications they are all that is needed unless you are communicating over long distances.