Table of Contents

Name

PIDmngr - general PID loop manager

Synopsis

PIDmngr <argument list>

Description

The program registers with dbman as PIDmngr.

Arguments

Argument processing is done using Unix long argument syntax.

--mngr <fn>

The pathname to the CONFLIST file from which to obtain the configuration information.

If this is not specified it defaults to "MNGRconf" in the current working directory (i.e. the directory where the program was started).

--mngr_pn <pn>

The program name to use when processing the CONFLIST file.

If this is not specified it defaults to "PIDmngr".

--show_tbl

Print the contents of the CONFLIST table to stderr after it is loaded.

--diag

If the program is started in this mode stdout and stdin are left open and signals are set so the program may be killed by SIGINT.

This argument is useful when setting up the parameters for the PID loop(s) because it makes it very easy to kill and restart the program after changing the config file.

--verbose=<n>

Normally the program does it’s work silently. This sets the level of logging information. The number

If no argument is provided the default level is 1.
0 - work silently

1 - print signon msg, option settings

2 - print signon msg, option settings, loop setup info

--help

Print the help message to stderr and exit.

Parameter scaling information

The PID loops operate internally on input and output values which have been normalized to between -1.0 and 1.0.

Parameters in the configuration file where this type of scaling is necessary use the Preset field in the configuration file as the full scale value for performing the conversion.

For example, using the type 1 filter to control a bending magnet requires a field strength control (comm1), a field reading from a device such as a hall probe (resp1), and a current control (ctl1).

In our example the hall probe controller has a range of +/- 30KG, and the power supply can provide 60A maximum which is capable of exciting the magnet to approximently 15KG.

The field strength control is a virtual parameter (i.e. not associated with hardware) so PhyMin and PhyMax are set as appropriate, in this case 0 to 15KG.

The first problem is to set the configuration so that the cmd and feedback elements are scaled in the same way. That is we want to scale both of them so that most of the positive internal parameter range of 0.0 to 1.0 is used.

Since the magnet is only capable of 15KG maximum it seems this is a likely number to use so we set the Preset fields for comm1 and resp1 to 15000.

The output variable is easy, 60 amperes is the power supply maximum and corresponds to 15KG so we set the Preset field for ctl1 to 60.

Configuration name usage

One Group is assigned for each pid loop to be managed.

Parameters listed as required must be present in the config file for PIDmngr to operate on the group.

Parameters listed as optional are not required and will be ignored or overridden by defaults as appropriate.

Shared filter Configuration names

file1 - required

The type of filter to be used.

The usage of all other parameters is dependent on filter type. See the appropriate filter section below.

Type 1 filter

NOTE: don’t use this filter anymore. Use type 2 instead. Type1 will be removed eventually.

The type1 filter is the classic PID loop. It consists of a proportional, an integral, and a derivative element.

The sampling rate is 1Hz and is presently hardcoded in the program.

Type 1 filter setup configuration name usage

Put "type1" in the file1 Label field to use this filter.

The setup parameters are designed so that each function name is used for a an individual filter block within the PID loop. For example, int1 is assigned to the parameters related to the proportional filter section of the PID loop.

Index fields within the function are assigned to individual filter parameters. Names such as Index0 are used in the manual page for clarity and should be replaced with the integer value in the MNGRconf file, i.e. Index0 is replaced with 0.

All setup parameters may be entered with or without a corresponding database parameter.

If there is no database parameter, i.e. the label and refname fields are set to NULL, the value of the Preset field is used as the value of the parameter.

If there is a database parameter, i.e. the label and refname fields are set to a valid parameter tag name, the value from the AccelNET database is used and the Preset field is ignored.

If a database parameter is used the control key should be set to RSet and the parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for direct update by users and direct update for the owner.

comm1 - required


The command variable.

The control key should be set to RSet.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for direct update by users and direct update for the owner.

See the section "Parameter scaling information" above.

comm2 - optional


Loop enable control.

0.0 - off
1.0 - on

The control key should be set to IncN.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for indirect update by users and unconditional update for the owner.

comm3 - optional


Clear loop parameters.

0.0 - nop
1.0 - clear

The control key should be set to Mom.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for direct update by users and direct update for the owner.

resp1 - optional


The PID loop status.

0.0 - nop
1.0 - tune
2.0 - not_used
3.0 - error

Usually this parameter is named TuneSR in the database.

The control key should be set to RSet.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for no update by users and direct for the owner.

resp2 - optional


The difference between the feedback and the command variable.

Many times this control is named Delta<something> in the database. For example, DeltaG might be used in the case of a PID loop for a bending magnet.

The control key should be set to RSet.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for no update by users and direct for the owner.

PhyMin, PhyMax, SpanMin, and SpanMax should be set to a value large enough to handle the maximum difference between the cmd input (comm1) and the feadback input (read1).

read1 - required


The feedback variable.

Ownership and permissions for the parameter do not matter and should be set as appropriate for the I/O manager obtaining the information from the hardware.

See the section "Parameter scaling information" above.

read2 - optional


Interlock input.

If this parameter is present then the current value is tested against the preset field and if they don’t match the tuning loop is inhibited.

Ownership and permissions for the parameter do not matter and should be set as appropriate for the I/O manager obtaining the information from the hardware.

ctl1 - required


The command output.

The parameter should be writable by whatever task PIDmngr registers as.

See the section "Parameter scaling information" above.

int0 - optional

This group of parameters is global to the filter.
Index0 - deadband

Each time the PID loop is processed the difference between cmd and feedback is calculated (resp2). If the absolute value of the difference is less than the value of deadband the tune status(resp1) is set to "nop" and nothing else is done.

If the difference is greater than deadband then tune status is set to "tune" and a correction is calculated.

This parameter is a positive quantity scaled in database units.

The parameter range is 0.0 to 10000.0.

If this entry is missing from the config file it defaults to 0.1.

Index1 -

This parameter is obsolete.

Index2 - sampling rate

This doesn’t work. The sample rate is fixed at 1Hz.

int1 - optional

This group of parameters applies to the proportional filter.

Index0 - not used

(A proportional filter doesn’t have a frequency control)
Index1 - gain

The parameter range is 0.0 to 1000.0.

If this entry is missing from the config file it defaults to 0.0.

Index2

The parameter is obsolete and no longer in use.

int2 - optional

This group of parameters applies to the derivative filter.

Index0 - frequency

This parameter is scaled in millihertz.

The range is 0.0 to 1000.0.

If this entry is missing from the config file it defaults to 0.1.

Index1 - gain

The parameter range is 0.0 to 1000.0.

If this entry is missing from the config file it defaults to 0.0.

Index2 -

The parameter is obsolete and no longer used.

int3 - optional

This group of parameters applies to the integral filter.

Index0 - frequency

This parameter is scaled in millihertz.

The range is 0.0 to 1000.0.

If this entry is missing from the config file it defaults to 0.1.

Index1 - gain

The parameter range is 0.0 to 1000.0.

If this entry is missing from the config file it defaults to 0.0.

Index2 -

This parameter is obsolete and no longer used.

Type 2 filter setup configuration name usage

Put "type2" in the file1 Label field to use this filter.

The int0 function group is used for parameters related to the operation of the PID loop.

The filter parameters all use int1 as the function name.

Index fields within the function are assigned to the filter parameters. Names such as Index0 are used in the manual page for clarity and should be replaced with the integer value in the MNGRconf file, i.e. Index0 is replaced with 0.

All setup parameters may be entered with or without a corresponding database parameter.

If there is no database parameter, i.e. the label and refname fields are set to NULL, the value of the Preset field is used as the value of the parameter.

If there is a database parameter, i.e. the label and refname fields are set to a valid parameter tag name, the value from the AccelNET database is used and the Preset field is ignored.

If a database parameter is used the control key should be set to RSet and the parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for direct update by users and direct update for the owner.

comm1 - required


The command variable.

The control key should be set to RSet.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for direct update by users and direct update for the owner.

See the section "Parameter scaling information" above.

comm2 - optional


Loop enable control.

0.0 - off
1.0 - on

The control key should be set to IncN.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for indirect update by users and unconditional update for the owner.

comm3 - optional


Clear loop parameters.

0.0 - nop
1.0 - clear

The control key should be set to Mom.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for direct update by users and direct update for the owner.

resp1 - optional


The PID loop status.

0.0 - off
1.0 - in limits
2.0 - tune
3.0 - timeout (and still tuning)
4.0 - not used
5.0 - not used
6.0 - not used
7.0 - error

Usually this parameter is named TuneSR in the database.

The control key should be set to RSet.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for no update by users and direct for the owner.

resp2 - optional


The difference between the feedback and the command variable.

Many times this control is named Delta<something> in the database. For example, DeltaG might be used in the case of a PID loop for a bending magnet.

The control key should be set to RSet.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for no update by users and direct for the owner.

PhyMin, PhyMax, SpanMin, and SpanMax should be set to a value large enough to handle the maximum difference between the cmd input (comm1) and the feadback input (read1).

read1 - required


The feedback variable.

Ownership and permissions for the parameter do not matter and should be set as appropriate for the I/O manager obtaining the information from the hardware.

See the section "Parameter scaling information" above.

read2 - optional


Interlock inputs.

Two interlock inputs are provided. Index0 is input 1 and Index1 is input 2.

If either of these parameters are present then the current value is tested against the preset field and if they don’t match the tuning loop is inhibited.

Ownership and permissions for the parameter do not matter and should be set as appropriate for the I/O manager obtaining the information from the hardware.

ctl1 - required


The command output.

The parameter should be writable by whatever task PIDmngr registers as.

See the section "Parameter scaling information" above.

int0 - optional

This group of parameters is global to the filter.

Index0 - deadband

Each time the PID loop is processed the difference between cmd and feedback is calculated (resp2). If the absolute value of the difference is less than the value of deadband the tune status(resp1) is set to "nop" and nothing else is done.

If the difference is greater than deadband then tune status is set to "tune" and a correction is calculated.

This parameter is a positive quantity scaled in database units.

The parameter range is 0.0 to 10000.0.

If this entry is missing from the config file it defaults to 0.1.

Index1 - max change

This is obsolete and has been removed from the code.

Index2 - tune timeout time

The amount of time the loop will attempt to tune before setting the TuneSR (resp1) to timeout.

If the timeout value is exceeded the loop will continue to tune but the TuneSR value will indicate a timeout.

Index3 - sampling rate

The amount of time between passes of the pid loop. The value is in seconds.

The parameter range is 1.0 to 60.0.

If this entry is missing from the config file it defaults to 1.0.

int1 - optional

This group of parameters applies to the filters.

Index0 - frequency

This parameter is scaled in millihertz.

It specifies the crossover frequency between the integrator and the differentiator.

The range is 0.0 to 1000.0.

If this entry is missing from the config file it defaults to 0.1.

Index1 - integral gain

The parameter range is 0.0 to 1000.0.

If this entry is missing from the config file it defaults to 0.0.

Index2 - derivative gain

The parameter range is 0.0 to 1000.0.

If this entry is missing from the config file it defaults to 0.0.

int2 - optional


The parameters in this group are used to limit the range of the control parameter.

This can be useful in cases where relationship between the control and the feedback parameter is not monotonic over the entire control range and it is desired to limit the control range to the portion which IS monotonic.

Index0 - minimum value

Index1 - maximum value

Type BM filter setup configuration name usage

Put "type_bm" in the file1 Label field to use this filter.

The int0 function group is used for parameters related to the operation of the PID loop.

The filter parameters all use int1 as the function name.

Index fields within the function are assigned to the filter parameters. Names such as Index0 are used in the manual page for clarity and should be replaced with the integer value in the MNGRconf file, i.e. Index0 is replaced with 0.

All setup parameters may be entered with or without a corresponding database parameter.

If there is no database parameter, i.e. the label and refname fields are set to NULL, the value of the Preset field is used as the value of the parameter.

If there is a database parameter, i.e. the label and refname fields are set to a valid parameter tag name, the value from the AccelNET database is used and the Preset field is ignored.

If a database parameter is used the control key should be set to RSet and the parameter should be by owned whatever task PIDmngr registers as and the permissions should be set for direct update by users and direct update for the owner.

comm1 - required


The command variable.

The control key should be set to RSet.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for direct update by users and direct update for the owner.

See the section "Parameter scaling information" above.

comm2 - optional


Loop enable control.

0.0 - off
1.0 - on

The control key should be set to IncN.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for indirect update by users and unconditional update for the owner.

comm3 - optional


Clear loop parameters.

0.0 - nop
1.0 - clear

The control key should be set to Mom.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for direct update by users and direct update for the owner.

resp1 - optional


The PID loop status.

0.0 - off
1.0 - in limits
2.0 - tune
3.0 - timeout (and still tuning)
4.0 - in limits and sleeping
5.0 - out of limits and sleeping
6.0 - not used
7.0 - error

Usually this parameter is named TuneSR in the database.

The control key should be set to RSet.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for no update by users and direct for the owner.

resp2 - optional


The difference between the feedback and the command variable.

Many times this control is named DeltaG in the database.

The control key should be set to RSet.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for no update by users and direct for the owner.

PhyMin, PhyMax, SpanMin, and SpanMax should be set to a value large enough to handle the maximum difference between the cmd input (comm1) and the feadback input (read1).

resp3 - optional


The countdown timer variable.

Many times this control is named CntDown in the database.

The control key should be set to RSet.

The parameter should be owned by whatever task PIDmngr registers as and the permissions should be set for no update by users and direct for the owner.

PhyMin, PhyMax, SpanMin, and SpanMax should be set to a value large enough to handle the maximum timer value entered into the int0 index3 parameter.

read1 - required


The feedback variable.

Ownership and permissions for the parameter do not matter and should be set as appropriate for the I/O manager obtaining the information from the hardware.

See the section "Parameter scaling information" above.

read2 - optional


Interlock inputs.

Two interlock inputs are provided. Index0 is input 1 and Index1 is input 2.

If this parameter is present then the current value is tested against the preset field and if they don’t match the tuning loop is inhibited.

Ownership and permissions for the parameter do not matter and should be set as appropriate for the I/O manager obtaining the information from the hardware.

ctl1 - required


The command output.

The parameter should be writable by whatever task PIDmngr registers as.

See the section "Parameter scaling information" above.

ctl2 - optional


A list of parameter values to send to the dbman whenever the loop is enabled or if the field strength is changed while the loop is enabled.

The Preset field is used for the value to send to the database.

The index numbers do not need to be consecutive. This makes it easy if you wish to comment one out in the CONFLIST file.

The purpose for which this was implemented is to clear the interlock bypass for the Faraday cup in front of the particle detector in the AMS systems. The problem here is trying to prevent the user from accidently putting the 13C or 12C beam on the detector and cooking it.

int0 - optional

This group of parameters is global to the filter.

Index0 - deadband

Each time the PID loop is processed the difference between cmd and feedback is calculated (resp2). If the absolute value of the difference is less than the value of deadband the tune status(resp1) is set to "nop" and nothing else is done.

If the difference is greater than deadband then tune status is set to "tune" and a correction is calculated.

This parameter is a positive quantity scaled in database units.

The parameter range is 0.0 to 10000.0.

If this entry is missing from the config file it defaults to 0.1.

Index1 - sleep deadband

The deadband value to use when the loop is sleeping.

This takes care of situations where the BM needs to be tuned as precisely as possible but after the loop goes to sleep the BM may be allowed to be inside of a larger deadband without the tune status read, i.e. resp1 indicating "out of limits and sleeping".

If this parameter is not present the deadband_sleep value is set to the same value as the tuning deadband.

Index2 - tune timeout time

The amount of time the loop will attempt to tune before setting the TuneSR (resp1) to timeout.

If the timeout value is exceeded the loop will continue to tune but the TuneSR value will indicate a timeout.

Index3 - sleep countdown time

The amount of time to wait before the loop goes to sleep after going in limit.

Index4 - sampling rate

The amount of time between passes of the pid loop. The value is in seconds.

The parameter range is 1.0 to 60.0.

If this entry is missing from the config file it defaults to 1.0.

Index5 - feedback mode

If this parameter is present and the value is 1 then the absolute value of the feedback input is used.

This is meant to be used with switching magnets where the power supply has a polarity switch and the current control is always positive.

Index6 - wakeup countdown time

The amount of time to wait before waking up the loop if it drifts out of limit while sleeping.

int1 - optional

This group of parameters applies to the filters.

Index0 - frequency

This parameter is scaled in millihertz.

It specifies the crossover frequency between the integrator and the differentiator.

The range is 0.0 to 1000.0.

If this entry is missing from the config file it defaults to 0.1.

Index1 - integral gain

The parameter range is 0.0 to 1000.0.

If this entry is missing from the config file it defaults to 0.0.

Index2 - derivative gain

The parameter range is 0.0 to 1000.0.

If this entry is missing from the config file it defaults to 0.0.

Examples

Notes

If a kill -1 is sent to the process, PIDmngr will dump it’s internal state information to stderr. This was added to help diagnose problems with the pid loop.

The type1 filter is on it’s way to obsolesence so don’t use it.

The type2 filter will eventually become the type1 filter.

The difference between them are:

The proportional filter has been eliminated because it doesn’t make sense to have a proportional filter since the integrator is already DC coupled because of the integrator.

The type1 filter has independent frequency controls for each filter section. The type2 filter has one frequency control to specify the frequency at which control moves from the integrator to the differentiator.

The MNGRconf setup parameters have been rearranged to simplify them.

See Also

Manual page revision

$Id: PIDmngr.8,v 1.14 2008/02/25 14:41:10 kitchen Exp $


Table of Contents