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: 

modbus writing to registers via PID controller

Solved!
Go to solution

Hi,

 

Can you please help... I'm new here

 

I'm trying to use a read register, send the value through a PID vi, then write it to a register.

 

I've attached an example using a temperature controller.

 

I get errors every time I try to connect using bundles, clusters, etc.

 

My hardware and comms are all good, I have values and gauges all reading ok, but it seems I cannot work out how to manipulate the data via a PID vi.

 

Your help is very much appreciated.

 

Thank you

0 Kudos
Message 1 of 2
(2,928 Views)
Solution
Accepted by topic author ST4000

1.  Rearrange your functions so that your Data Read occurs before your Data Write.  So you can go 1 2 3 4.  Right now your code executes step 3 before step 1 and impossible to know where steps 2 and 4 should go.

 

2.  Your Write register has an input called register where your value goes.  It is a U16 input.  Your PID provides a DBL.  You need to read the manual for the device to figure out how to encode the PID output's floating point number into an integer.  It may be a simple as multiplying by a scaling factor and rounding it to an integer.

 

3.  Your Modbus Read is for multiple registers. You will get a 1-D array of readings, but it will only be 1 element.  You can use Index Array, then bundle it with the setpoiint wire to feed into the multi-needle gauge.  Since you data will be a U16 integer, you may need to do some scaling to convert from an integer to whatever however it represents the temperature.

 

 

 

 

4.  Don't forget you need to wire your process value into the PID function.

 

 

 

Message 2 of 2
(2,900 Views)