FieldPoint Family

cancel
Showing results for 
Search instead for 
Did you mean: 

How to change input range, update rate, ect. using Measurement Studio .NET and C# for a cFP-AI-118 on a cFP-1808?

I am trying to write a generic program that can change the input range, update rate, scale factors, ect., of a cFP-AI-118 module on a cFP-1808 controller. I am writing the program for a customer who does not want to make changes in MAX.
0 Kudos
Message 1 of 8
(8,694 Views)

Hi Willy,

 

Yes that's definitely possible. What you're talking about is programmatically editing I/O Module attributes. In MAX under Remote Systems, you can browse in your module to where you can see the module's channels and "Create Item" for a certain attribute, such as thermocouple type, etc. Doing so will add a new tag to your FieldPoint target under Data Neighborhood. You should then hit Save in MAX to save the IAK file and then re-add the FieldPoint target in your project so you have the most up-to-date IAK file when programming in LabVIEW.

 

Pretty straightforward there. Here's where things get tricky. In LabVIEW Real-Time, you'll want first create an I/O Point Constant and select Browse... Assuming you created the item in MAX, saved the file, and replaced your FP target with a new FP target in your project, you should see the new item you created in the list. Since that item represents an attribute, you'll just wire that constant into the standard FP Write (Polymorphic) VI and then wire in the new value for that attribute. Once you get here, you'll need to go into MAX again, click on the custom item that you created, and see what values are supported for writing to that item.

 

If you have any questions just let me know. Hope this helps!

 

Regards,

Dan Richards
Certified LabVIEW Developer
0 Kudos
Message 2 of 8
(8,673 Views)
I'm sure that would work great in LabView, but I'm programming in C# with Measurement Studio. And since I'm using a cFP1808, I won't be downloading any (real-time) code to the controller.
0 Kudos
Message 3 of 8
(8,665 Views)
After doing some online research, I found and downloaded nmodbus, which allows me to change the channel input range and filter attributes. I also found that I can change the update rate and deadband by specifying these values in the datasocket URL (for example by adding "?updaterate=100&deadband=10" at the end of the URL). I have not found a way to change the scaling factors or to enable/disable scaling programatically.
0 Kudos
Message 4 of 8
(8,659 Views)

Hi Willy,

 

My bad not reading that initial post carefully. I've been digging around on this for the past few days. I think the right way to make this work is going to be by using MAX to manually create those tags. If you absolutely cannot do that, there may be a way to do that with the MS API. I know that in LabVIEW you can create tags programmatically, but I'm not sure if you can do that in a way that accesses module attributes.

 

Again, the best way is to create the tags in MAX and then use the simple FP Read or Write functions to change the values. MAX will also tell you what the accepted values are for writing to I/O attribute tags, and will ensure that the attribute you think your changing is the same as the attribute you are changing.

 

I don't have the VS 2003/MS 7.0/FP driver combination installed yet, so it could take a bit more time to get specific information. Does what I wrote give you enough to go on?

 

Regards,

Dan Richards
Certified LabVIEW Developer
0 Kudos
Message 5 of 8
(8,624 Views)

I've found a way around using nmodbus to write to the address space of the IO modules that I am using. I need to be able to not use MAX so that my code can be used for more than one application.

 

Willy

0 Kudos
Message 6 of 8
(8,540 Views)

Hi Willy,

 

That's interesting. Are you able to change the attribute values (range, rate, etc.) using Modbus? I think others might benefit from that information if you'd care to share. Otherwise, I hope you're good to go. Let me know if you'd like me to look into anything for you.

 

Thanks,

Dan Richards
Certified LabVIEW Developer
0 Kudos
Message 7 of 8
(8,525 Views)

Sorry for taking so long to respond. Here is what I've learned.

 

You can specify the update rate and deadband by adding them to the datasocket url, such as:

 

opc://localhost/National Instruments.OPCFieldPoint/FP @ 196_168_0_1\\cFP-AI-118 @1\\Channel 0?updaterate=100&deadband=10

 

You can also get/set the attributes, such as the input range and filter, using modbusNModbus can be downloaded at http://nmodbus.com/. Here is an example of what I did to get the attributes. The code assumes that ipAddress, slotNumber and channelNumber are passed in as arguments, and that a cFP-AI-118 is being addressed.

 

             // Declare local variables.
            TcpClient client;
            ModbusIpMaster master;
            ushort attributeAddress;
            ushort[] attributeValue;

            // Set module range and filter attributes via modbus.
            client = new TcpClient(ipAddress, 502);
            master = ModbusIpMaster.CreateTcp(client);
            // Get attribute address.
            attributeAddress = (ushort)(10000 + (slotNumber * 1000) + (8 * channelNumber));
            // Get compact fieldpoint module attributes.
            attributeValue = master.ReadHoldingRegisters(attributeAddress, 1);
            // Close connection and return attributes.
            client.Close();
            return BitConverter.GetBytes((ushort)attributeValue[0]);

 

The code to set the attributes is simular. Just replace

 

            // Get compact fieldpoint module attributes.
            attributeValue = master.ReadHoldingRegisters(attributeAddress, 1);

 

with

 

            // Get attribute values and address (attributes is a byte array).
            attributeValue = BitConverter.ToUInt16(attributes, 0);
            // Update compact fieldpoint module attributes.
            master.WriteSingleRegister(attributeAddress, attributeValue);

 

All code segments written in C#. To determine the attributes which cFP or FP module has, refer to "FieldPoint Modbus Help" file that is installed with the fieldpoint drivers.

 

Good luck and have fun!

Message 8 of 8
(8,379 Views)