Evaluation


cjd1965

Recommended Posts

Hi

I am evaluation DAQFactory, and want to set up Modbus TCP/IP comms to an advantech 4019 which is an AtoD convertor.

The Adam unit is on ip address 10.73.137.42 and I wish to display the 8 analog values on a screen, and have a test data entry for each analog, plus a fixed test.

Additionally I wish to log the data to an OBDC database (Access or SQL Server)

I have tried setting up comms but it doesnt work for me. I can ping the ADAM and see it with the Advantech software so my network is fine.

Could someone possibly post a basic project here to help me ge started?

Link to comment
Share on other sites

Hi

I have managed to get it working with the QuickMod example. I have saved QuickMod 'As' a new project. How do I embed the IP address so I dont have to enter it each time?

I would have expected to see a list on the RH side showing my device but there is only local device and v memory

Thanks

Link to comment
Share on other sites

I actually do not recommend using QuickMod as a starting point for creating your own application. It has a bit of extra script to allow it to run standalone and be flexible so does not make the best example. However, you should be able to take the settings you found in QuickMod and create your own app from scratch pretty easily. Here are the steps:

1) First, write down the IP, Port, Modbus ID, Function, Type, Tag # and other information from QuickMod that worked for you.

2) Create a new DAQFactory document

3) Go to Quick - Device Configuration, then select New Serial / Ethernet device

4) Click on the New Ethernet (TCP) Client button. Give it a name and enter the IP address and Port info you wrote down from QuickMod, then click OK. If you were doing serial instead of ethernet, you'd click on the New Serial button and enter the appropriate info.

5) Back at the original Ethernet / Serial Device window, enter in a name for your device, say Mod, then check the new ethernet port you created in step 4, and the ModbusTCP or ModbusRTU protocol. Which you choose depends on how your device was configured. If in QuickMod you had "Modbus RTU over Ethernet" checked, you want ModbusRTU. If you had "Modbus TCP over ethernet" you want ModbusTCP

6) Click OK to close that window.

7) Click on CHANNELS: in the workspace. Click Add to add a new channel

8) Give your channel a name. Under Device Type select the name of the device you created in step 5. Under D# put the Modbus ID of your device (its never 0)

9) This is the trickier part: under I/O type select the Function (Read Holding or Read Input probably) and the type of data. If all else fails, do Read Holding S16 as this is the most common type and is generally supported by all devices. If it doesn't work (after going through the rest of these steps), try Read Input S16.

10) Under Chn # put the Tag # you used in QuickMod.

11) Click Apply to start taking data.

The quickest way to check for data is to click on the + next to CHANNELS in the workspace, click on the channel name you just created, then click on the Table tab that appears. You should see data coming in every second.

If you get a Socket Error in the Command Alert window, then you probably have the IP or Port wrong, or you have another copy of DAQFactory or some other software still connected to the device and the device only supports one connection at a time. (if you were doing serial, you'd get an unable to init comm port error indicating that the comm port doesn't exist or is in use by another piece of software)

If you get a Timeout error, then click on the Comm Monitor tab at the bottom of the screen, then right click on it and select the name of your IP port that you created in step 4. If you see nothing, then you have a socket error as just decribed (or you didn't select the port, right click again and make sure your port is selected. The ports are the first items in the popup).

If you see Tx: with a bunch of numbers and characters but no Rx: then you are transmitting but the device is not responding. With Ethernet (but not Serial where transmit still works even if the cable is unplugged), this means that a connection is established, but the device is not responding. This could mean that you are connected to the wrong port or just the wrong device. For example, if you connected to port 80 instead of 502 on a device with a webserver, you'd be able to transmit but wouldn't see a response because port 80 is a web port and doesn't understand the modbus queries.

More likely you have the wrong D#. Double check the ID of your hardware. D# is never 0 as this is a global broadcast ID and not supported by DAQFactory. You could also have an invalid I/O type or channel #, something that isn't supported by your hardware and your hardware is not returning an error and instead just ignoring the query.

If you see Tx and Rx, but still don't have any data in the channel table, take a close look at the Rx. Actually, first, right click on the comm monitor and select "Display all ASCII chars as codes" which is what you want whenever you are working with a binary protocol like Modbus. Now look at the Rx. A correct response will have the same Tx and Rx for the first 4 characters (when I say character I mean \xxx where xxx is the ASCII code for the actual single character transmitted), a slightly different 5th and 6th (or possibly the same, especially the 5th which is usually 00). The 7th character, the ID, should also be the same in Tx and Rx. The 8th character, the modbus function, likewise should be the same. If you did Read Holding it will be 03. If Read Input, it will be 04. If you see \131 or \132 then the device is returning an error, most likely that you specified an invalid function or invalid address. Check your I/O type and Channel #. (if you were doing RTU then the first character should match and be the ID, and the second character should be the function instead of the 8th).

That about covers it. It seems like a lot, but I gave a lot of detail and tried to cover every base. Modbus is a great protocol as it is supported by a wide variety of devices. However, as such it has been tweaked to the extreme to work in various ways which makes it slightly harder to work with. However, once you've done it a little you'll find it pretty easy.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.