LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Master-slave 2-wire communication with Temperature Controller via Modbus RTU (USB-485) protocol.

Hello amigos:

 

I need to enable a master-slave communication between my PC and my Temperature Controller (TC) (TM-005 from TOHO).  The TM-005 is able to communicate with other devices via an RS-485 connection, using either Modbus (ASCII) or Modbus (RTU) in half duplex (i.e. two wire communication). 

 

I've been trying to communicate with this device for almost a week without any success at ALL. I have already thoroughly studied the modbus related documentation and have some experience with LV but I don't seem to get any data from the slave.  This is why I'll try to explain with a LOT of detail every connection and step I've done... if any of you guys has an idea of what could be wrong please tell me! I'm drowning here!

 

SOFTWARE RELATED

1. Instaled NI-Serial

2. Downloaded modbus library (for LV 8.2) from ni website, and installed it.  (btw I use LV8.2, to avoid any compatibility problems)

3. Connected the USB-485

4. The USB-485 appears in VISA.

5.  I changed the settings in the device manager to "two wire auto"

6.  I double checked in the MAX that no mismatch was occurring between Windows port Settings and LV port settings.

 

HARDWARE RELATED

1. I programmed the communication settiings in my TC to be exactly the same as in WXP and LV serial parameters (i.e. baudrate, parity, stop bits, etc)

2. I  don't need any bias resistors since the cable's length which enables the connection between the TC and the PC is no longer than 50cm and I also have enabled the internal resistor in the RS-485 port.

3. I made the connections to the TC as Picture 1

 

Note: I've only connected pin 8 to 4 (in the RS485 port) to pin A (in the TC)--- and--- pin 9 to 5 (in the RS485 port) to pin B (in the TC).  I didn't made any GND or Shield connections. ALSO when I saw the USB-device properties in the MAX there's a parameter called "isolation" which "tells whether the interface is isolated" and has a value of "0".  Is this OK??

 

After double checking all this settings, I made this small program (Picture 2) to read the holding registers of the TC, but seem to get nothing!

 I'll continue my battle with modbus and let you know if I get to solve the problem, in the meantime, any suggestions are welcome

 

Antonio

Download All
0 Kudos
Message 1 of 12
(7,867 Views)
Add an error output indicator to the bottom output on the write/read block. Then give us the info on what error code comes up. Does the temperature controller come with a sample program that you can use to verify the wiring is good??
0 Kudos
Message 2 of 12
(7,818 Views)

Hi unclebump:

 

Thanks for the reply.  I tryed again to communicate with a program which has already proven to work with the TOHO TC's, but with a USB-485 converter from another brand (not NI)

 

As I run the code, the following error appears:

"VISA Read in MB Serial Receive.vi:2->MB Serial Master Query.vi:1->TOHO Modbus_v8_0.vi"

 

I'm starting to think that something went wrong while installing the drivers or something, even though I can seel my device in MAX andDevice Manager!

 

Any suggestions?

Antonio
0 Kudos
Message 3 of 12
(7,785 Views)
It could still be a wiring issue. After rebooting, see if you can find a non labview program to talk to the device. Sometimes when labview programs have been run, they do not release the serial port resources when finished.  Once you know the wiring to the device is good, then work on the labview program.
0 Kudos
Message 4 of 12
(7,783 Views)

Hello

b.t.w.

 

It is possible to program the USB-485 converter I spoke from (from the other brand, not from NI), to automatically work as a 2-wire device...

This means that instead of manually connecting pins (4-8) and (5-9) from the outside, an internal connection is somehow done by SW.

i.e. we just take TWO terminals from the DB9 connector, instead of taking 4 and manually connect them from the outside..

 

Is it the same for the single USB-485 cable from NI?

 

Thanx

 

0 Kudos
Message 5 of 12
(7,781 Views)
Not sure. I've never used the NI USB-485 hardware.
0 Kudos
Message 6 of 12
(7,779 Views)

Antonio,

 

 

Your vi shows that you have set Parity = None.  According to the MODBUS Protocol standard, when parity is not used, you must add a second stop bit.  In other words, an ASCII MODBUS frame will always include a total of 10 bits.  A RTU frame differs only in that it includes 8 data bits and a total of 11 data bits per frame.

1 Start Bit

7 Data Bits

Either 1 Parity Bit and 1 Stop Bit or 2 Stop Bits. 

 

 

If you look at the block diagram for the MB Serial Init.vi, you will notice that it it always setting the Serial Settings:Stop Bit = 1.0  I don't think this is correct. 

 

The NI-USB-485 converter will support 2-wire mode.  I use it all the time and it works well.

Message Edited by centerbolt on 01-22-2009 08:14 AM
0 Kudos
Message 7 of 12
(7,763 Views)

Hi centerbolt,

 

I had this old computer with TONS od LV toolkits, modules, PCI's, DAQ Cards, etc, etc.  I also have this brand new PC.  On the new computer, I installed LV from scrap, then I installed the Serial files from my original CD, then I pluged in my USB-485/1, then I installed the modbus library.    I don't think that any other program is using or accesing the 485 port.  In fact, the NI USB-485/1 is the only communications port appearing in the Device Manager (as COM 3) and is the only HW from NI installed as well.

 

I changed the settings (in LV (MAX and VISA) and in my TC's) to the following:

RTU,19200,8,n,2 =(MODE: RTU) (BAUDRATE: 19200) (DATA BITS: 😎 (PARITY: None)(STOP BITS: 2)

I also changed the "stop bits" inside "MB Serial Init.vi" to be "2.0".


Then, the same error comes out which is focalized in the "VISA Read" block, inside the "MB Serial Init" VI.

(ERROR CODE: -1073807298).

I get the same error in my program and in the new program that was proven to work with the same TC model, but with a different USB-485 HW.

 

I'm missing either a VISA parameter or a connection is wrong!  I double-checked the connections and everthing seems to be right

 

Any ideas?

0 Kudos
Message 8 of 12
(7,736 Views)

centerbolt,

 

You said you use the USB-485 in 2-Wire mode without problems..

How did you connected the HW? Is it like my drawing in the first post?

Where did you connected PIN 1 (GND) from the DB9 connector?

(My TC's only have terminals A and B for external communications.....but no GND :smileysad:

 

Cheers

0 Kudos
Message 9 of 12
(7,724 Views)

antonio,

 

I said I had used the National Instruments NI-USB-485 adapter in 2-wire mode.  Not exactly sure which adapter you are using?

 

The error you reported makes me think that your COM port is hung.  Your vi opens the port but does not close it.  You need to use the VISA close.vi to release the com resource.  Take a look at the block diagram for MB Serial Example Master.vi    If you look at the last frame of the stacked sequence you will see that the last thing this vi does is close the VISA session.

 

 

0 Kudos
Message 10 of 12
(7,721 Views)