EMERSON PACSystems VersaMax MICRO PLC & NANO PLC. USER MANUAL (2019) - page 38

 

  Index      Manuals     EMERSON PACSystems VersaMax MICRO PLC & NANO PLC. USER MANUAL (2019)

 

Search            copyright infringement  

 

   

 

   

 

Content      ..     36      37      38      39     ..

 

 

 

EMERSON PACSystems VersaMax MICRO PLC & NANO PLC. USER MANUAL (2019) - page 38

 

 

User Manual 

Chapter 26 

GFK-1645M 

Dec 2019 

 

PID Function 

562 

 

Parameter  Low Bit Units  Range 

Description 

Address+5 

Proportional 
Gain -Kp 
(Controller 
gain, Kc, in 
the ISA 
version) 

0.01 CV%/PV% 

0 to 327.67% 

Change in the control variable in CV Counts for a 100 
PV Count change  in the  Error term. A Kp entered as 
450 is displayed as 4.50 and results in a Kp*Error/100 
or 450*Error/100 contribution to the PID Output. Kp 
is generally the first gain set when adjusting a PID loop. 

Address+6 

Derivative 
Gain-Kd 

0.01 seconds 

0 to 327.67 sec  Change in the control variable in CV Counts if the Error 

or PV changes  1 PV Count every  10ms. Entered as a 
time with the low bit indicating 10ms. For example, a 
Kd entered as 120 is displayed as 1.20 Sec and results 
in  a  Kd  *  delta  Error/delta  time  or  120*4/3 
contribution to the PID Output if Error was changing 
by 4 PV Counts every 30ms. Kd can be used to speed 
up  a  slow  loop  response  but  is  very  sensitive  to  PV 
input noise. 

Address+7 

Integral Rate-
Ki 

Repeat/1000 
Sec 

0 to 32.767 
repeat/sec 

Change in the control variable in CV Counts if the Error 
were  a  constant  1  PV  Count.    Displayed  as  0.000 
Repeats/Sec  with  an  implied  decimal  point  of  3.  For 
example,  a  Ki  entered  as  1400  is  displayed  as  1.400 
Repeats/Sec and results in a Ki * Error * dt or 1400 * 
20 * 50/1000 contribution to PID Output for an Error 
of 20 PV Counts and a 50ms PLC sweep time (Sample 
Period of 0).  Ki is usually the second gain set after Kp. 

Address+8 

CV Bias/ 
Output 
Offset  

CV Counts 

-32000 to 
32000 (add to 
integrator 
output) 

Number of CV Counts added to the PID Output before 
the rate and amplitude clamps.  It can be used to set 
non-zero  CV  values  if  only  Kp Proportional  gains  are 
used,  or  for  feed  forward  control  of  this  PID  loop 
output from another control loop. 

Address+9 
Address+10 

CV Upper  
and 
Lower 
Clamps 

CV Counts 

-32000 to 
32000 
(>%Ref+10)  

Number  of  CV  Counts  that  define  the  highest  and 
lowest  value  for  CV.   These values  are  required.  The 
Upper Clamp must have a more positive value than the 
Lower Clamp, or the PID block will not work.  These are 
usually used to define limits based on physical limits 
for  a  CV  output.  They  are  also  used  to  scale  the  Bar 
Graph display for CV. The block has anti-reset windup 
to  modify  the  integrator  value  when  a  CV  clamp  is 
reached. 

User Manual 

Chapter 26 

GFK-1645M 

Dec 2019 

 

PID Function 

563 

 

Parameter  Low Bit Units  Range 

Description 

Address+11  Minimum 

Slew Time   

Seconds/Full 
Travel 

0 (none) to 
32000 sec to 
move 32000 CV 

Minimum  number  of  seconds  for  the  CV  output  to 
move from 0 to full travel of 100% or 32000 CV Counts. 
It is an inverse rate limit on how fast the CV output can 
be changed.  
If  positive,  CV  cannot  change  more  than  32000  CV 
Counts  times  Delta  Time  (seconds)  divided  by 
Minimum  Slew  Time.  For  example,  if  the  Sample 
Period is 2.5 seconds and the Minimum Slew Time is 
500  seconds,  CV  cannot  change  more  than 
32000*2.5/500  or  160  CV  Counts  per  PID  solution. 
The integrator value is adjusted if the CV rate limit is 
exceeded. If Minimum Slew Time is 0, there is no CV 
rate limit. Set Minimum Slew Time to 0 while tuning or 
adjusting PID loop gains. 

User Manual 

Chapter 26 

GFK-1645M 

Dec 2019 

 

PID Function 

564 

 

Parameter  Low Bit Units  Range 

Description 

Address+12  Config Word  Low 6 bits used   

The  low  6  bits  of  this  word  are  used  to  modify  six 
default PID settings. The 10 high-order bits should be 
set to 0. 
Bit 0: Error Polarity. Setting this bit to 1 modifies the 
standard PID Error Term from the normal (SP 

 PV) to 

(PV 

 SP), reversing the sign of the feedback term. This 

is for Reverse Acting controls where the CV must go 
down when the PV goes up.  
Bit 1: Output Polarity: Setting this bit to 1 inverts the 
Output  Polarity  so  that  CV  is  the  negative  of  the 
output rather than the normal positive value.  
Bit 2: Setting this bit to 1 removes the setpoint from 
the Derivative calculation.  
Bit  3:  Deadband  Action:  When  this  bit  is  0,  no 
deadband  action  is  chosen.  If  the  error  is  within  the 
deadband limits, the error is to be zero. Otherwise the 
error is not affected by the deadband limit. If  this bit is 
1, the deadband action is chosen. If the error is within 
the deadband limits, the error is forced to be zero. If, 
however, the error is outside the deadband limits, the 
error is reduced by the deadband limit (error = error 

 

deadband limit).  
Bit 4: Anti-reset windup action. When this bit is 0, the 
anti-reset windup action uses a reset back calculation. 
When  the  output  is  clamped,  this  replaces  the 
accumulated Y remainder value with whatever value is 
necessary to produce the clamped output exactly. 
When the  bit is 1,  this replaces  accumulated Y  term 
with  the  value  of  the  Y  term  at  the  start  of  the 
calculation. In this way, the pre-clamp Y value is held 
as long as the output is clamped. 
Bit 5: Enable derivative filtering. When this bit is set to 
0, no filtering is applied to the derivative term. 
When bit 5 is set to 1, a first order filter is applied. This 
limits  the  effects  of  higher  frequency  process 
disturbances on the derivative term. 

User Manual 

Chapter 26 

GFK-1645M 

Dec 2019 

 

PID Function 

565 

 

Parameter  Low Bit Units  Range 

Description 

 

 

 

 

Bit 0 

 Bit 5:  Remember that the bits are set in 

powers of 2.  
To set bit 0, add 1 to the Config Word parameter 
value. 
To set bit 1, add 2. 
To set bit 2, add 4. 
To set bit 3, add 8. 
To set bit 4, add 16. 
To set bit 5, add 32. 
For example, set Config Word to 0 for default PID 
configuration. Add 1 to change the Error Term from 
SP - PV to PV - SP, add 2 to change the Output Polarity 
from CV = PID Output to CV = 

 PID Output, or add 4 

to change Derivative Action from Error rate of change 
to PV rate of change, etc. 

Address+13  Manual 

Command 

CV Counts 

Tracks CV in 
Auto or Sets CV 
in Manual 

Set to the current CV output while the PID block is in 
Automatic  mode.  When  the  block  is  switched  to 
Manual mode, this value is used to set the CV output 
and  the  internal  value  of  the  integrator  within  the 
Upper and Lower Clamp and Slew Time limits. 

Address+14  Control Word  Maintained by 

the PLC, unless 
Bit 1 is set. 

PLC maintained 
unless set 
otherwise: low 
bit sets Override 
if 1. 

If the Override low bit is set to 1, this word and other 
internal SP, PV and CV parameters must be used for 
remote operation of this PID block (see below). This 
allows  remote  operator  interface  devices,  such  as  a 
computer,  to  take  control  away  from  the  PLC 
program. 

CAUTION 

If you do not want this to happen, make sure 
the Control Word is set to 0. If the low bit is 0, 
the next 4 bits can be read to track the status 
of  the  PID  input  contacts  as  long  as  the  PID 
Enable contact has power. 

A discrete data structure with the first five bit positions 
in the following  format: 

 

 

 

 

Bit  Word 

Value 

Function  Status or External 

Action if Override bit 
set to 1 

 

 

 

 

Override 

If 0, monitor block 
contacts below. If 1, set 
them externally. 

User Manual 

Chapter 26 

GFK-1645M 

Dec 2019 

 

PID Function 

566 

 

Parameter  Low Bit Units  Range 

Description 

 

 

 

 

Manual 
/Auto 

If 1, block is in Manual 
mode; other numbers  it 
is in Automatic mode.  

 

 

 

 

Enable 

Should normally be 1; 
otherwise block is never 
called. 

 

 

 

 

 8 

UP 
/Raise 

If 1 and Manual (Bit 1) is 
1, CV  is being 
incremented every 
solution.  

 

 

 

 

16 

DN 
/Lower 

If 1 and Manual (Bit 1) is 
1, CV is being 
incremented every 
solution. 

Address+15  Internal SP  

Set and 
maintained by 
the PLC 

Non-
configurable 

Tracks SP in; must be set externally if  
Override = 1. 

Address+16  Internal CV 

 

 

Tracks CV out. 

Address+17  Internal PV 

 

 

Tracks PV in; must be set externally if  
Override bit = 1. 

Address+18  Output 

 

 

Signed  word  value  representing  the  output  of  the 
function  block  before  the  optional  inversion.    If  no 
output inversion is configured and the output polarity 
bit in the control word is set to 0, this value equals the 
CV  output.      If  inversion  is  selected  and  the  output 
polarity bit is set to 1, this value equals the negative of 
the CV output. 

Address+19  Diff Term 

Storage 

 

 

 

Address+20 
Address+21 

Int Term 
Storage 

 

 

Used internally for storage of intermediate values.  Do 
not write to these locations 

Address+22  Slew Term 

Storage  

 

 

 

Address+23 
to 
Address+25 

Clock  

 

 

Internal elapsed time storage (time last PID executed).  
Do not write to these locations 

Address+26  Y Remainder 

Storage  

 

 

Holds  remainder  for  integrator  division  scaling  for  0 
steady state error. 

Address+27 
Address+28 

SP, PV Lower 
and Upper 
Range 

PV Counts 

-32000 to 
32000  

Optional INT values in PV Counts that define high and 
low  display  values.  (Ref  +27  must  be  lower  than 
Ref+28) 

Address+29  
to 
Address+39 

Reserved 

N/A 

Non-
configurable 

29-34 are reserved for internal use; 35-39 are reserved 
for external use.  Do not use these references. 

 

User Manual 

Chapter 26 

GFK-1645M 

Dec 2019 

 

PID Function 

567 

26.4

 

PID Algorithm Selection (PIDISA or PIDIND) 
and Gains 

The  PID  block  can  be  programmed  selecting  either  the  Independent  (PID_IND)  term  or 
standard ISA (PID_ISA) versions of the PID algorithm.  The only difference in the algorithms 
is how the Integral and Derivative gains are defined. 

26.4.1

 

Error Term 

The Independent (PID_IND) term and standard ISA (PID_ISA) versions of the PID algorithm 
both calculate the Error Term as: 

Error Term (in Normal Mode) = 

Set Point (SP) 

 Process Variable (PV) 

Error Term in Reverse-Action Mode  

The Error Term calculation can be changed to Reverse Action mode: 

Error Term (in Reverse Action Mode) = 

Process Variable (PV) 

 Set Point (SP) 

by setting the Error Term (low bit 0 in the Config Word %Ref+12) to 1.   

Effect of the Process Variable on the Control Variable 

In Normal mode, the Control Variable (CV) responds to changes in the Process Variable (PV) 
by moving in the same direction. In Reverse-Action mode, when the Process Variable goes 
up, the Control Variable goes down.  

26.4.2

 

Derivative Term 

The Derivative term is the time rate of change of the Error term in the interval since the last 
PID solution. 

Derivative = 

Error / Delta time (dt) =  (Error 

 previous Error) / Delta time (dt) 

where 

Delta time (dt) =  Current PLC elapsed time - PLC elapsed time at previous PID solution. 

In  Normal  Mode  (without  Reverse-Action  mode),  this  is  equal  to  the  change  in  the  Error 
term. 

(Error 

 previous Error) =  (SP 

 PV) 

 (previous SP 

 previous PV)  

(previous PV 

 PV) 

 (previous SP 

 SP)  

However, when the Reverse-Action mode bit (bit 0) in the Config Word is set, the sign of the 
change in the Error term is reversed. 

(Error 

 previous Error) =  (PV 

 SP) 

 (previous PV 

 previous SP) 

(PV 

 previous PV) 

 (SP 

 previous SP) 

The change in the Error term depends on changes in both the Set Point and the Process 
Variable.  If the Set Point is constant, the difference between SP and the previous SP is zero 

User Manual 

Chapter 26 

GFK-1645M 

Dec 2019 

 

PID Function 

568 

and has no effect on the output.  However, Set Point changes can cause large changes in the 
Derivative term and in the output.   

Removing Set Point Changes from the Derivative Calculation 

Loop  stability  can  be  improved  by  eliminating  the  effect  of  Set  Point  changes  on  the 
Derivative term.  Set the third bit (bit 2) of the Config Word to 1 to calculate the derivative 
based only on the change in PV.  

For bit 2 set in normal mode (bit 0 = 0),  

(Error 

 previous Error) =  (previous PV 

 PV), 

and with bit 2 set in Reverse-Action mode (bit 0 = 1),  

(Error 

 previous Error) =  (PV 

 previous PV). 

26.4.3

 

Delta Time 

The dt (or Delta Time) is determined by subtracting the last PID solution clock time for this 
block from the current PLC elapsed time clock. 

dt = 

Current PLC Elapsed Time clock - PLC Elapsed Time Clock at Last PID 
solution 

Derivative =  (Error - previous Error)/dt  or 
 

(PV - previous PV)/dt if 3rd bit of Config Word set to 1 

The Independent term PID (PID_IND) algorithm calculates the output as: 

PID Output =  Kp * Error  +   Ki * Error * dt  +  Kd * Derivative  +  CV Bias 

The standard ISA (PID_ISA) algorithm has a different form: 

PID Output =  Kc * (Error  +   Error * dt/Ti  +  Td * Derivative)  +  CV Bias 

where Kc is the controller gain, and Ti is the Integral time and Td is the Derivative time. The 
advantage  of  ISA  is  that  adjusting  the  Kc  changes  the  contribution  for  the  integral  and 
derivative terms as well as the proportional one, which may make loop tuning easier. If you 
have PID gains in terms or Ti and Td, use 

Kp =  Kc  Ki = Kc/Ti  and  Kd = Kc/Td 

to convert them to use as PID User Parameter inputs. 

The CV Bias term above is an additive term separate from the PID components. It may be 
required if you are using only Proportional Kp gain and you want the CV to be a non-zero 
value when the PV equals the SP and the Error is 0. In this case, set the CV Bias to the desired 
CV when the PV is at the SP. CV Bias can also be used for feed forward control where another 
PID loop or control algorithm is used to adjust the CV output of this PID loop. 

If an Integral Ki gain is used, the CV Bias would normally be 0 as the integrator acts as an 
automatic bias. Just start up in Manual mode and use the Manual Command word (%Ref+13) 
to set the integrator to the desired CV, then switch to Automatic mode. This also works if Ki 

User Manual 

Chapter 26 

GFK-1645M 

Dec 2019 

 

PID Function 

569 

is 0, except the integrator will not be adjusted based on the Error after going into Automatic 
mode. 

26.4.4

 

Independent Term Algorithm (PIDIND)  

The following diagram shows how the PID algorithms work: 

Figure 379 

 

The ISA Algorithm (PIDISA) is similar except the Kp gain is factored out of Ki and Kd so that 
the integral gain is Kp * Ki and derivative gain is Kp * Kd. The Error sign,  DerivAction and 
Polarity are set by bits in the Config Word user parameter. 

CV Amplitude and Rate Limits 

The block does not send the calculated PID Output directly to CV.  Both PID algorithms can 
impose amplitude and rate of change limits on the output Control Variable. The maximum 
rate  of  change  is  determined  by  dividing  the  maximum  100%  CV  value  (32000)  by  the 
Minimum Slew Time, if specified as greater than 0. For example, if the Minimum Slew Time 
is 100 seconds, the rate limit will be 320 CV counts per second. If the dt solution time was 
50 ms, the new CV output cannot change more than 320*50/1000 or 16 CV counts from 
the previous CV output. 

The CV output is then compared to the CV Upper and CV Lower Clamp values. If either limit 
is exceeded, the CV output is set to the clamped value. If either rate or amplitude limits are 
exceeded modifying CV, the internal integrator value is adjusted to match the limited value 
to avoid reset windup.  

Finally,  the  block  checks  the  Output  Polarity  (2nd  bit  of  the  Config  Word  %Ref+12)  and 
changes the sign of the output if the bit is 1. 

CV =  Clamped PID Output or  
 

- Clamped PID Output if Output Polarity bit set 

If the block is in Automatic mode, the final CV is placed in the Manual Command %Ref+13. 
If  the  block  is  in  Manual  mode,  the  PID  equation  is  skipped  as  CV  is  set  by  the  Manual 
Command,  but  all  the  rate  and  amplitude  limits  are  still  checked.  That  means  that  the 
Manual Command cannot change the output above the CV Upper Clamp or below the CV 
Lower Clamps and the output cannot change faster than the Minimum Slew Time allowed.  

 

 

 

User Manual 

Chapter 26 

GFK-1645M 

Dec 2019 

 

PID Function 

570 

26.4.5

 

Sample Period and PID Block Scheduling 

The PID block is a digital implementation of an analog control function, so the dt sample 
time in the PID Output equation is not the infinitesimally small sample time available with 
analog controls. The majority of processes being controlled can be approximated as a gain 
with a first or second order lag, possibly with a pure time delay. The PID block sets a CV 
output to the process and uses the process feedback PV to determine an Error to adjust the 
next CV output. A key process parameter is the total time constant, which is how fast does 
the  PV  respond  when  the  CV  is  changed.  As  discussed  in  the  Setting  Loop  Gains  section 
below, the total time constant, Tp+Tc, for a first order system is the time required for PV to 
reach 63% of its final value when CV is stepped. The PID block will not be able to control a 
process unless its Sample Period is well under half the total time constant. Larger Sample 
Periods will make it unstable. 

The Sample Period should be no bigger than the total time constant divided by 10 (or down 
to 5, worst case). For example, if PV seems to reach about 2/3 of its final value in 2 seconds, 
the Sample Period should be less than 0.2 seconds, or 0.4 seconds worst case. On the other 
hand, the Sample Period should not be too small, such as less than the total time constant 
divided by 1000, or the Ki * Error * dt term for the PID integrator will round down to 0. For 
example, a very slow process that takes 10 hours or 36000 seconds to reach the 63% level 
should have a Sample Period of 40 seconds or longer. 

Unless the process is very fast, it is not usually necessary to use a Sample Period of 0 to solve 
the PID algorithm every PID sweep. If many PID loops are used with a Sample Period greater 
than the sweep time, there may be wide variations in PLC sweep time if many loops end up 
solving the algorithm at the same time. The simple solution is to sequence a one or more 1 
bits through an array of bits set to 0 that is being used to enable power flow to individual PID 
blocks. 

 

 

 

User Manual 

Chapter 26 

GFK-1645M 

Dec 2019 

 

PID Function 

571 

26.5

 

Determining the Process Characteristics 

The PID loop gains, Kp, Ki and Kd, are determined by the characteristics of the process being 
controlled. Two key questions when setting up a PID loop are:  

1.

 

How big is the change in PV when we change CV by a fixed amount, or what is the 
open loop gain?  

2.

 

How  fast  does  the  system  respond,  or  how  quickly  does  PV  change  after  the  CV 
output is stepped?  

Many processes can be approximated by a process gain, first or second order lag and a pure 
time delay. In the frequency domain, the transfer function for a first order lag system with a 
pure time delay is:  

PV(s)/CV(s) = G(s) = K * e **(-Tp s)/(1 + Tc s) 

Plotting a step response at time t0 in the time domain provides an open loop  unit reaction 
curve: 

Figure 380 

 

The following process model parameters can be determined from the PV unit reaction 
curve: 

Process open loop gain = final change in PV/change in CV at time t0  
(Note no subscript on K) 

Tp 

Process or pipeline time delay or dead time after t0 before the process output  
PV starts moving 

Tc 

First order Process time constant, time required after Tp for PV to reach 63.2% 
of the final PV 

Usually the quickest way to measure these parameters is by putting the PID block in Manual 
mode and making a small step in CV output, by changing the Manual Command %Ref+13, 
and plotting the PV response over time. For slow processes, this can be done manually, but 
for faster processes a chart recorder or computer graphic data logging package will help. 
The CV step size should be large enough to cause an observable change in PV, but not so 
large that it disrupts the process being measured. A good size may be from 2 to 10% of the 
difference between the CV Upper and CV Lower Clamp values. 

 

 

 

User Manual 

Chapter 26 

GFK-1645M 

Dec 2019 

 

PID Function 

572 

26.6

 

Setting Parameters Including Tuning Loop 
Gains 

As all PID parameters are totally dependent on the process being controlled, there are no 
predetermined values that will work; however, it is usually simple to find acceptable loop 
gain. 

1.

 

Set all the User Parameters to 0, then set the CV Upper and CV Lower Clamps to the 
highest and lowest CV expected. Set the Sample Period to the estimated process 
time constant (above)/10 to 100. 

2.

 

Put block in Manual mode and set Manual Command (%Ref+13) at different values 
to check if CV can be moved to Upper and Lower Clamp. Record PV value at some 
CV point and load it into SP. 

3.

 

Set  a  small  gain,  such  as  100  *  Maximum  CV/Maximum  PV,  into  Kp  and  turn  off 
Manual  mode.  Step  SP  by  2  to  10%  of  the  Maximum  PV  range  and  observe  PV 
response. Increase Kp if PV step response is too slow or reduce Kp if PV overshoots 
and oscillates without reaching a steady value. 

4.

 

Once a Kp is found, start increasing Ki to get overshooting that dampens out to a 
steady value in 2 to 3 cycles. This may require reducing Kp. Also try different step 
sizes and CV operating points. 

5.

 

After suitable Kp and Ki gains are found, try adding Kd to get quicker responses to 
input changes providing it doesn't cause oscillations. Kd is often not needed and will 
not work with noisy PV. 

6.

 

Check  gains  over  different  SP  operating  points  and  add  Deadband  and  Minimum 
Slew Time if needed. Some Reverse Acting processes may need setting Config Word 
Error Sign or Polarity bits. 

 

 

 

User Manual 

Chapter 26 

GFK-1645M 

Dec 2019 

 

PID Function 

573 

26.6.1

 

Setting Loop Gains Using the  Ziegler and Nichols Tuning 
Approach 

Once the three process model parameters, K, Tp and Tc, are determined, they can be used 
to estimate initial PID loop gains. The following approach provides good response to system 
disturbances with gains producing an amplitude ratio of 1/4. The amplitude ratio is the ratio 
of the second peak over the first peak in the closed loop response. 

1.

 

Calculate the Reaction rate: 
 

R = K/Tc 

2.

 

For Proportional control only, calculate Kp as: 
 

Kp = 1/(R * Tp) = Tc/(K * Tp) 

 

For Proportional and Integral control, use: 

 

 

 

Kp = 0.9/(R * Tp) = 0.9 * Tc/(K * Tp)  

 

 

Ki = 0.3 * Kp/Tp 

 

For Proportional, Integral and Derivative control, use: 
 

 

Kp = G/(R * Tp)  where G is from 1.2 to 2.0 

 

 

Ki = 0.5 * Kp/Tp 

 

 

Kd = 0.5 * Kp * Tp 

3.

 

Check that the Sample Period is in the range 
 

(Tp + Tc)/10 to (Tp + Tc)/1000 

26.6.2

 

The Ideal Tuning Method 

The “Ideal Tuning" procedure provides the 

best response to SP changes, delayed only by the 

Tp process delay or dead time. 

 

 

Kp = 2 * Tc/(3 * K * Tp) 

 

 

Ki = Tc 

 

 

Kd = Ki/4 

 

if Derivative term is used 

Once initial gains are determined, convert them to integers. Calculate the Process gain K as 
a change in input PV Counts divided by the output step change in CV Counts and not in 
process PV or CV engineering units. Specify all times in seconds. Once Kp, Ki and Kd are 
determined,  Kp and Kd can be multiplied by 100 and entered as integer while Ki can be 
multiplied by 1000 and entered into the User Parameter %RefArray. 

 

 

 

User Manual 

Chapter 26 

GFK-1645M 

Dec 2019 

 

PID Function 

574 

26.7

 

Sample PID Call 

The following PID example has a sample period of 100Ms, a Kp gain of .4.00 and a Ki gain of 
1.500. The set point is stored in %R0001, the control variable output in %AQ0002, and the 
process variable is returned in %AI0003. CV Upper and CV Lower Clamps must be set, in this 
case to 20000 and 4000, and an optional small Deadband of +5 and -5 has been included. 
The 40-word RefArray starts in %R0100. Normally User Parameters are set in the RefArray, 
but  %M0006  can  be  set  to  reinitialize  the  14  words  starting  at  %R0102  (%Ref+2)  from 
constants stored in logic (a useful technique). 

Figure 381 

 

The block can be switched to Manual mode with %M1 so that the Manual Command, %R113, 
can be adjusted. Bits %M4 or %M5 can be used to increase or decrease %R113 and the PID 
CV and integrator by 1 every 100 ms solution. For faster manual operation, bits %M2 and 
%M3 can be used to add or subtract the value in %R2 to/from %R113 every PLC sweep. The 
%T1 output is on when the PID is OK.

User Manual 

Chapter 27 

GFK-1645M 

Dec 2019 

 

Reading and Writing Data in Flash Memory 

575 

Chapter 27:

 

Reading and Writing Data in 
Flash Memory 

For Release 3.0 and later VersaMax Micro PLCs, two Service Request commands can be used 
to read or write flash memory during run time: 

 

SVCREQ 52: Reads from Flash Memory into Reference Memory 

 

SVCREQ 53: Writes from Reference Memory into Flash Memory 

Chapter 22: gives details of using use these Service Request commands in the application 
program. 

This  chapter  describes  the  Logic-driven  Write  to  Flash  feature,  and  gives  application 
program examples. 

27.1

 

Logic-Driven Write to Flash 

For a VersaMax Micro PLC, one of the configuration choices is whether the CPU will read the 
initial  values  from  flash  or  RAM  at  power-up.  If  RAM  is  the  choice,  the  CPU  will  read  the 
reference tables data from its RAM memory at power-up. 

If “Read from flash” is the configured choice, the CPU will read 

previously stored reference 

tables from flash memory at power-up. In addition, Release 3.0 and later VersaMax Micro 
PLCs (which includes all 20-, 40-, and 64-Point Micro PLCs) will also read from flash all data 

that has been stored to flash using Service Request 53. This feature is called “Logic

-drive 

write to flash”.

 

The  logic-driven  flash  data  area  is  cleared  using  the  programmer.  When  storing  an 

application to the PLC, if “Write All To Flash” is configured, all data that has been written to 

flash using Service Request 53 is automatically deleted. The data area can also be cleared by 
using the flash-EEPROM tab and selecting Write All Data to Flash. This option is not available 
during Run mode due to the time required to erase flash. 

27.1.1

 

Data Quantities 

For 20-, 40-, or 64-point Micro PLCs, the flash memory used for the Logic-driven write to 
flash feature has a total size of 8192 bytes. Of this, 8 bytes are reserved and cannot be used. 
So the maximum available capacity is 8184 bytes.  For 14, 23, and 28-point Micro PLCs, the 
Logic-driven user flash memory is 64kB (65536 bytes) and the maximum available capacity 
is 65528 after 8 bytes are reserved. 

Each execution of Service Request 52 or 53 can transfer: 

 

1 to 10 words of %R, %AI, or %AQ reference data plus 6 bytes of command data. That 
means a 1-word write to flash requires 8 bytes of flash memory, while a 10-word 
write to flash requires 26 bytes of flash memory ((10 words X 2 bytes per word) + 6 
bytes of command data). 

User Manual 

Chapter 27 

GFK-1645M 

Dec 2019 

 

Reading and Writing Data in Flash Memory 

576 

 

1 to 10 bytes of %I, %Q, %M, %T, or %G reference data plus 6 bytes of command data. 
A 1-byte write to flash requires 7 bytes of flash memory, while a 10-byte write to 
flash occupies 16 bytes of flash memory. 

Therefore, because each request requires 6 bytes of command data, the most efficient use 
of flash is by transferring data in 10-word increments. 

27.1.2

 

If Flash Memory Becomes Full 

If  Service  Request  53  attempts  to  write  more  data  to  flash  memory  than  the  maximum 
available, a fault is logged in the PLC Fault Table. 

Fault Group   

APPLICATION_FLT 

22 

Fault Action   

DIAGNOSTIC 

 

Error Code 

 

USERFLASH_FULL 

204 

Error Message  

Logic Driven Userflash Full 

If a Logic Driven Userflash Full fault is logged in the PLC Fault Table, the PLC must be power 
cycled. 

After  power-cycling  the  PLC,  if  another  Logic  Driven  Userflash  Full  fault  is  logged,  the 
contents of flash memory must be completely erase

d by downloading new logic with ‘Write 

All To Flash’ selected during download to PLC. After power

-cycling the PLC, data can again 

be stored in flash until the Logic Driven Userflash Full 

“fault

 is logged again. 

The same configuration and application program must be stored on RAM and PLC flash to 

use this feature. It should not be done with configuration stored with ‘Read from flash’ set 

and  ladder  program  on  RAM.  If  the  program  on  RAM  calls  Service  Request  53  to  store 
reference memory on flash, then the PLC is power-cycled, if the configuration says to read 
data from flash, the data will be read but the application program may not be the same one 
that called Service Request 53. 

27.1.3

 

Important Note 

Service request 53 (Logic driven write to flash) should be performed with caution after an 
operation is performed that makes the application in RAM not equal to the application in 
flash. The following are few such operations: 

 

Word for word change or Run Mode store 

 

Stop mode store of logic to RAM only 

 

Logic and Registers stored to Flash during Stop mode store, but CPU is configured 
to read Logic from RAM and Registers from Flash on power up. 

Such operations may  make  the data  stored by  Service request 53 incompatible with the 
application in flash and hence need to be used carefully. 

 

 

 

User Manual 

Chapter 27 

GFK-1645M 

Dec 2019 

 

Reading and Writing Data in Flash Memory 

577 

Example 1: Writing Data to Flash Memory 

This example writes 10 continuous bytes from PLC references %G0001 through %G0080 into 
flash memory. In this example, the segment selector (56) is for byte access and so are the 
offsets and lengths. 

Figure 382 

 

Example 2: Reading Data from Flash Memory 

This example reads the same 10 continuous bytes from %G0001 through %G0080 from 
flash into %G reference memory into the PLC. 

Figure 383 

 

 

 

 

 

 

 

 

 

 

Content      ..     36      37      38      39     ..