06-30-2015 12:20 AM
Hello Ni Forums
This is my first post on this forum and I have been using labview for about 8 months now
I have a problem regarding writing data to modbus registers through an i/o server set as a modbus slave for my 9074 hardware.After I have completed building project and deploying the variables and following instructions from here , it yields no result but a line zeros. I have the Ni DSM open and modbus master setup to see whether the data is actually being read/written from the respective sides which both yield the same line of zeros as well. What I am actually trying to write to is an array of single precision floating data. The registers are structured from ranges F40000-F46534 for 10 elements or have them for range AF40001L1-AF46534L1 of item AF40001L10 where it is an array of length 10. (Referenced ranges here)
I know 1 thing for sure, the modbus connection works and is ready for data requests, I tested this through NI DSM and manually set data for and my master received them .
System and Project specifications
Windows 7 OS
Labview Full Development System 2011
No Labview DSC module but I am using the real time module as referenced by one of the documents
This project is a real time application with fpga mode (not scan interface mode)
The master and slave are the same subnet and network
Modbus Connection Type: TCP
9074 compact rio 8 slots
9234 module x3
9221 module x1
9472 module x1
Shared Variable Engine service running on windows os and rtos system
Used this guide to learn about the modbus protocol as I searched all over the internet to learn about modbus
I already having Modbus IO Server software installed on the crio through ni max version 1.8 for NI RIO 4.0
attached file(s)
Image of Crio software specifications
Image of the Data being written into variable in rt block diagram
Short Version of the problem: Why is the io variable not being written into with properly converted data?
Solved! Go to Solution.
06-30-2015 04:49 PM
mzamstl
In a lot of cases, issues with Modbus track back to configuration settings.
Perhaps you can clarify a few points for me:
-In your setup, what is the Modbus master?
-Do you have any third party hardware or software in the Modbus network?
-Where are you seeing the line of zeros? As data read by the cRIO slave?
One debugging technique that might be helpful is to try doing a smaller example first. Can you read one register holding an integer? If you’re able to do this, it establishes that you have bidirectional communication, which is a large step.
06-30-2015 04:58 PM - edited 06-30-2015 05:07 PM
My master , I have 2 right now one I made with labview
and the other is some 3rd party software named fenix
I am currently using the labview master to atleast trying to get the data to be read
and once that happens I ll try the 3rd party one
My crio is the slave and it is writing to the specified registers
I dont have any other slaves or masters in the network
I am expecting floating point data to be written into holding register
Regards mzamstl
07-01-2015 09:44 AM
I'd make a function which just does the modbus write by itself, and make sure you check for errors. No need to complicate things with additional code (did you check errors in that screenshot? Are you sure the data isnt all zeros?)
I'd also make sure your modbus I/O server only has one element referencing a given holding register.
Once its deployed you can manually set register values through DSM (when you select a range, you can change the register you're writing to). You can also view errors in one of the IO server subfolders.
07-02-2015 11:49 AM - edited 07-02-2015 12:08 PM
The data can have zeros but not all of them will be zeros and I have another program (on local computer for database storage)that is recieving the same data through TCP and they are not zeros.
If a machine is running and is active then the data that will be collected should not be zero , it should infact be some analog value > 0.
I will look into the function you described
How do you view the errors in the IO server subfolders ?
Is it the modbus register called error status that returns an error code if so that value is currently 0
Regards mzamstl
07-03-2015 06:00 PM - edited 07-03-2015 06:05 PM
I tried your function idea, if i interpreted what you said correctly then the image of the code should reflect that.
I input a 2 in the holding register address 1(400002) from the master and expected a 4 to be written into address 3(400004) because of 2 + 2, but it didn't write it which resulted in a 0.
regards mzamstl
07-06-2015 11:50 AM
Ok, yeah, thats what I was suggesting. As for the error info, if you look at the bottom of your DSM picture you see a commfail bit and an error code, but it looks like those are OK.
The only thing I can think of is that DSM (or some other function) is writing to a range of values which includes 400004. I'd suggest switching it from a 4- range to a 3- range. 3s are input only (from the master's point of view) so you can be sure the master isn't stomping on the data. Once you've verified that, I'd look at DSM and any other code running to ensure t hat you're not accidentally writing 0s to the same reg.
07-08-2015 04:54 PM - edited 07-08-2015 04:55 PM
So this ended up working out
The small vi started to write to the register after
I configured the master to have more retries
and then give the slave more time to respond.
Then it started working
and realized i made tiny mistakes about the vi running
I was able to implement this in my large application
and now it works
screen shot of my large application through ni dsm and the trend proves it.