LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

dsc - Modbus TCP - bad writing of data value

I tried to connect to a modbus device trough NI I/O server.

I follows your tutorial (NI-Tutorial-7675 and NI-Tutorial-13911)

I successfully read all the registers I need but when I tried to wrote on it, there is a strange behaviour :

when I write on a UINT16 or an INT16 (for Instance 400018-ProductionDay) the value I tried to write is not the final value (see few example below) :

Written Value --> Value Read

1 --> 508

2 --> 700

100 --> 25660

200 --> -14276

-14276 --> 15466

Please see example in attachement.

 

When I wrote value using another PLC Client (Modbus Pool for instance) I am able to read and write value without problem.

 

I do not believe that it is a bad data type because all the read queries are correct.

 

Could you please help me. Thanks for your support 

 

I used the following developpment :

OS : Windows XP pro SP1 64 bits

Labview 9.0.1 (32 bit) (Professionnal Developpement System)

Module : DSC

 

0 Kudos
Message 1 of 9
(3,199 Views)

It looks like you have some sort of DSC feature, maybe scaling or initial value (?), enabled. When I open it on my machine 400018 doesn't work unless I remove certain features, but it doesn't tell me what features. Check the various configuration tabs and make sure you don't have anything weird enabled which might mess with the value you enter.

0 Kudos
Message 2 of 9
(3,185 Views)

Thanks for your reply. 

 

I have already check configuration tabs but I found nothing to descativate (please see in attachment , I resume the configuation I tested).

 

I also tried to change  Advanced Attribute Setting of the Modbus I/O server (see below) (that is to say the two check option) but nothing works (note that I need to check the fisrt option because otherwise write query do not work not at all)

Modbus I-O serveur - AdvancedAttributeSettings.png

 

I also ask your sale department for an update (I want to tried Labview 2009 64 bit). I am actually waiting for them because this download is not available on your web site.

0 Kudos
Message 3 of 9
(3,175 Views)

Thanks for your reply. 

 

I have already check configuration tabs but I found nothing to descativate (please see in attachment , I resume the configuation I tested).

 

I also tried to change  Advanced Attribute Setting of the Modbus I/O server (see below) (that is to say the two check option) but nothing works (note that I need to check the fisrt option because otherwise write query do not work not at all)

Modbus I-O serveur - AdvancedAttributeSettings.png

 

I also ask your sale department for an update (I want to tried Labview 2009 64 bit). I am actually waiting for them because this download is not available on your web site.

0 Kudos
Message 4 of 9
(3,175 Views)

Interesting, those are the only two things I can think of -- byte ordering, which you've already tried, and the scaling thing which it looks like it isn't enabled.

 

One thing I would double-check is that you've redeployed the configuration after you make any changes by right clicking on the lvlib and selecting deploy all. Shared variables can be tricky sometimes. I'm going to give your code a go on my machine with the 2014 modbus library and see what data I get back.

0 Kudos
Message 5 of 9
(3,150 Views)

So I ran your code on my machine with the 2014 modbus slave and I was able to read values but not write them. It was pretty confusing because when I created a brand new I/O server it works fine. Turns out that advanced option "use function 16 for individual writes" (which is what is being used for your bound variables) sends a malformed modbus packet. Specifcally the byte length is incorrect. This is tracked by corrective action request 400570.

 

Anyway, short version is that I don't have any more ideas for whats going on. My recommendation would be to use Distributed System Manager (it should already be installed on your system). First, expand "localhost' and you should see your library. Right click on it and select "stop process". Then right click on localhost and select "add process". Name it whatever. Right click on <whatever> and select add I/O server. Make a brand new modbus I/O server with the just the defaults (and any address information you might need to change).

(IMPORTANT: When you are finished debugging, please right click on <whatever> and select "remove process" *before* right clicking on your own library and selecting "start process". This will prevent any modbus conflicts between the two libraries)

 

Now that you have a fresh, blank I/O server, expand all the way down and click on "400001-465535". In the right hand pane you should be able to change the bound item from 400001 to 400018 (and hit apply). Then enter a reasonable value and select "set". Confirm that the value is set correctly and report back.

 

0 Kudos
Message 6 of 9
(3,137 Views)

Thanks for your support.

 

For your information, I tested manually to unploy and then to deploy all (see the report file file in attchement). All seems good but it do not work afterward.

 

I wonder why the deployment occurs every time before I launch the main VI (SoloLibraHMI-MAIN.vi) which displays all the data value. Is there any option to disable? Is it possible that there a conflict with all the deployement queries? Do I need to dynamically deploy variable. Do you have any idea or test that I could perform to make it work.. It is too bad that It do not work because it is the only thing I need to finalize my project.... and do not have any other simple way to display and manage the registers  of my modbus TCP device for free.

 

Best regards

0 Kudos
Message 7 of 9
(3,135 Views)

I tried to follow your step but I cannot create a Modbus TCP I/O server... I only have Modbus Serial Option (see picture below)ManualConfiguration_IO_ServerWhatever.png

 

Due to the fact that you identify my issue as the known issue 400570, the only work around I see It see if we could implement Preset Single Register (FC=06) (actually not support on the device I need to write on). I hope It will works... 

 

Thanks for your feedback

 

0 Kudos
Message 8 of 9
(3,123 Views)

You can right click on My Computer and select "Disable Autodeploy Variables" if you don't want that to happen every time, but I wouldn't recommend it necessarily. Really all its doing it checking to make sure the library is deployed and hasn't changed, so disabling autodeploy is usually a bad thing.

 

You can still follow the later steps (open up the I/O server, go to 400001-465535 and manually set the specific register) on your BirdScale#1 library's I/O server, I just thought it would be cleaner to make a new one. You should be able to select Modbus Ethernet from the dropdown, but if you can't then no worries.

 

If that function code 16 is a requirement for your device then unfortunately I think you're out of luck with I/O servers. Its worth noting that we do have standalone libraries which you can use (http://www.ni.com/example/29756/en/ for LV 8.X-2011; https://decibel.ni.com/content/docs/DOC-30140 for 2012 and 2013; included in 2014). They are not as simple as the I/O servers, but they'll get the job done. Important: When using the libraries, values are referenced by address not by register number. That is, what the I/O server calls 400018 is actually the holding register (4xx,xxx) at address 17.

0 Kudos
Message 9 of 9
(3,114 Views)