From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with read/write to MODBUS RTU registers in Labview 8.0

I’m trying to write and read the registers in G3800xx016. controlling temperatures and lightning.  Please look at the attached pdf file for this unit..

I have used Lookout for about three years, and it works fine.. Now I want to expand my system and try to use Labview 8.0

My temperature register start adress is 100 Hex  (256 dec) I read from Register with Function code 03.

This register have values from 0-255 witch mean in labview for me as unsigned byte U8

I read my temperature from the register like this: eks.: 40257 lets say value=5

 

Slave    FC       Start Adress     Byte     Value               CRC

01        03        0100                02        0005                7847   

This is the status received from the Modbus tester when I use null-modem connection..

I receive the same value if I use Modscan32

I have used null-modem cable to read out the values.

 

I have also PIR detectors that control movements and light of and on, and I read these starts at 40017.1

 

01   03     0010     02    

The register to switch on and of heating and lights starts at 404097.1  FC16  

Values mention here is read from Lookout 5.0  

 

I have tried examples and read for weeks about this, but everything stops when I try to use Labview 8.0    I can’t read any values from my Master unit, neither write to it, or read any values in Modbus testers when I use null-modem cable.. I have tried different baud rates in my serial connection and it works perfect in Lookout, but Not Labview..

I have even bought DSC module, but I can’t write to either com ports or Modbus testers..

 

Please anybody… is there anybody that can give me help with this??

Start address for for PIR detectors is 40017.1 (FC03)  and for writing bits for on of to light and heatsystem is 404097.1 (FC16)

 

I would be very happy for any idea that can give me some positive results…  Look at the attached pdf file.

Thanks.. and very best regards from

Benjii…

 

0 Kudos
Message 1 of 31
(7,936 Views)

Have you downloaded the NI modbus library??

http://sine.ni.com/nips/cds/view/p/lang/en/nid/201711

Also try my modbus serial query.llb in reply 10 of this thread.

http://forums.ni.com/ni/board/message?board.id=170&message.id=200988&requireLogin=False

0 Kudos
Message 2 of 31
(7,917 Views)
Hi... and thanks for your answer..
Yes, I have downloaded the NI Modbus drivers.. I have downloaded that one + a lot of other things about Modbus..
I have also tried communication between lokout and labview true null-modem cable.. and it works..
I have tried several Modbus examples and I communicate with most of them with null-modem cable.
I write to the right registers as well, cause I use Modbus scanner to read the information..
 
I have used the same settings for serial communication as my Master device use, bust still I can't get any response..
There was an error message in one of my example from the Modbus INIT module.. Maybe I should try to set up a new connection using VISA ??
Maybe the problem is to INIT my serial port? I have tried restarting my computer after closing my system..  But still, I have the same problem..
 
I hope you can give me any idea...
Thanks again..  by the way.. is it possible to write and read directly to serial port with the DSC module??  If so.. how?? 
 
Very best regards..
Benjii..
0 Kudos
Message 3 of 31
(7,894 Views)

I had a difficult time with modbus in the past but always got it working with labview.  The biggest problem I have encountered with that the settings for the serial port are often not correct.  Make sure that device and the serial init function are matching in baud (very important often the cause of troubles), start bits , stop bits, parity.... I would start very simple, open visa followed by a init serial command (set all settings explicitly to match your device), send a visa write, wait (1 second for now) then issue a serial read.  The string to write and read can be selected to be hex strings and the value send can be the example from the device manual.  This will be the simplist verification of a correct communication protocol.  I have never had any luck with generic modbus drivers but I have easily written several using visa.  Good luck.

 

Paul 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 4 of 31
(7,886 Views)

One other stumbling block I had in the past.  Often a device comes with its own application for communicating with the device.  Make sure this is not opened since it will grab your com port and labview/visa will not be able to use it for communications.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 31
(7,881 Views)
Thanks a lot Paul..
I will go to work in the night and try, cause I can't shut down the system in the days....
Yes maybe VISA init will do a better job, cause I see that VISA use both DATA bits and  STOP bits..
I will take a snap shot of my error messages so it will be better to understand..
 
Thanks again..  I would be grateful to ask you some more questions if I don't have any luck with this..
Very best regards...
Benjii..
 
0 Kudos
Message 6 of 31
(7,880 Views)
Might require a reinstall or upgrade of VISA if it isn't working properly.
0 Kudos
Message 7 of 31
(7,879 Views)

Hi again Paul...

You wrote me this.:

""One other stumbling block I had in the past.  Often a device comes with its own application for communicating with the device.  Make sure this is not opened since it will grab your com port and labview/visa will not be able to use it for communications.""

I think this is what happens here.. cause when I tried to view what is going on on the com port, I always get the message:  The com port is already open.. and I can't communicate, even if I have restarted my computer. So my problem here will be how to find the application that controle this, and to deactivate it..  I will try..  but if you have any idea, I would be happy to have this answer as well....  I use Lookout 5.1.. and maybe there is an application there that controle and lock the com port... I don't know..

Thanks again..  rgards from Benjii...

0 Kudos
Message 8 of 31
(7,876 Views)
That has nailed me in the past. If visa open is not getting the resource then some other application has locked it.  I am not sure how to know who has it though.  The task bar might give you a clue. 
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 9 of 31
(7,865 Views)

Hi again Paul...

I didn't understand exactly what you meant about any application that was open, but it's obvious to me now..

There is no application that use the com port after I shut down the system, I removed Lookout from the startup section in my computer.. So when I have restarted my computer it should be ok.. But still.. I can remember that the message was: com port is already open.. Maybe it was because the comport was connected to my Mastergenerator, and that I have to reconnect it to release the com port.. I will try.. I learn a lot of this... but it's very time demanding.. but I never give up.. Smiley Mad

Thanks again Paul... Benjii..

0 Kudos
Message 10 of 31
(7,865 Views)