LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus Bounded Array Not updating

I'm trying to create a Modbus Slave Program to communicate. I followed the following tutorial http://www.ni.com/tutorial/13911/en/ with the exception of setting it up as a Slave and Serial instead of TCP.

 

The tutorial worked great but i could only bind single Modbus variables to a global variable. I read in the help menu in the "Create Bound Variables" and "Using Modbus I/O Servers (DSC Module or Real-Time Module)", Variables that start with "A- Denotes an array". so i created a simple bound variable to the coil range to start. Then i deployed it and i created a simple Vi, to set the coils but while i was testing it the coils would not update and i verified this by reading the bounded variable and i also used the Distrubted System Manager but i could not read any values.

 

I'm using Labview 2018 SP1, RT 2018 SP1, basically everything else is version 18.5. I'm using a 8840 controller in a PXI-1044 chassis, running windows 10 32bit

 

I've attached a couple pictures to hopefully make sense of what i'm trying to do but the unit is stand alone so i had to take them with my phone

Download All
0 Kudos
Message 1 of 8
(2,433 Views)

Hi picky,

 

It is generally better if you can attach your actual LabVIEW code instead of just screenshots. That way, we can actually open the code and see how everything is configured!

 

From your pictures, it looks like the I/O server bound variable name is A000001L1. The 1 after the L denotes the length of the array. So this variable is configured to write to an array of coils, but the array is only length 1. Instead, you would want to create a bound variable for A000001LX where X is the number of coils that you want to write to.

 

There is an example called Modbus Datatype Extension.lvproj in the LabVIEW example finder that you should check out. It has an example of how an array of coils (and other datatypes) should be configured in the project.

 

-Jordan

0 Kudos
Message 2 of 8
(2,397 Views)

I was not able to find the examples you were described. I was able to compile the project into a zip file, i hope i got everything you need. 

 

The machine is stand alone and it does not hook up to the internet or any other systems other then to communicate over RS485. 

 

I was unable to figure out how to make the length of the array longer then 1. i tried using buffers and i tried adding a range of array variables. I also tried initializing the variables but that didn't work. 

 

Note, i initalized the variables in the loop but removing the initalize array from out side the loop had no effect on it.

 

Any help you can provide is appriciated.

0 Kudos
Message 3 of 8
(2,384 Views)

A few things jump out at me after looking at your code.

  1. You have configured a Modbus slave I/O server. This means that you want LabVIEW to be the slave and communicate with another Modbus master device. Is this what you want to do? What is LabVIEW talking to?
  2. Like I mentioned before, you want to create a single bound variable with the correct array length field. For example, let's say I want to write to 10 different coils, starting at coil A000001. I would create a bound variable called A000001L10. The 10 after the L means that I will be writing to coils 1, 2, 3...10.

The example I was referring to should be installed with the DSC Module by default. It should be located at:

 

C:\Program Files (x86)\National Instruments\[your LabVIEW version]\examples\lvdsc\IO Servers\ModbusExtension\Modbus Datatype Extension.lvproj

0 Kudos
Message 4 of 8
(2,376 Views)

1. IMG_0453.jpgIMG_0452.jpgIMG_0451.jpgThey are supposed to be slaves, the master is a PLC, which i'm communicating with the purpose of this is for labview to simulate a piece of equipment.

 

2. I dont think i understand what you mean by increasing the number after L increases the length of the array. I tried to do it but it didn't work, i've attached my second attempt. if you could upload a working version demonstrating it, i would appriciate it.

 

3. i could not find the example you were talking about. i attached screen shots of everything in examples and a screen shot of me searching for Modbus in the examples folder.

0 Kudos
Message 5 of 8
(2,373 Views)

I don't know what those pictures of your Explorer windows are supposed to show.

 

But your latest VI has a variable bound to My Computer\ArrayTest2.lvlib\ModbusSlave1\A1L00000100   That variable name looks quite a bit different from A000001L1 or A000001Lx   listed earlier.

0 Kudos
Message 6 of 8
(2,368 Views)

The pictures of my explorer are suppose that i dont have the example he keeps refering too. I wanted to demonstrate that i dont have lvdsc folder and i don't know if he has any other suggestions on where it might me located.

 

I'm unsure how to create the array with the length i need. When i go to "create Bound Variables" i'm given 2 choices, "add" and "add Range". if i click add for coils, then it 

i click add i get the second picture, if i click add range and i type in 1000 for the number of items i get 1000 variables that all start with the same thing.

 

IMG_0454.jpgIMG_0455.jpgIMG_0456.jpgIMG_0457.jpg

0 Kudos
Message 7 of 8
(2,363 Views)

i finally figured out how to update the length of the array but renaming the variable from "L1" to "L10" for example. I went to test this over modbus serial and the only thing it returned all zeros even when i was able to set it high and read it high.

 

I tried to use the "Distriuted System Manager" but it shows up as no value set.

 

I'm using a PXI 8433/2 RS 485 card connected over a serial cable to each port (connected togeather). I'm currently using Modbus Poll as the master while i'm testing,i know the software i'm using as the master works, i've used it many times in the past.

 

Anyone one got any idea's?

0 Kudos
Message 8 of 8
(2,357 Views)