Low-Energy Muon (LEM) Experiment  0.5.1
west6100.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include "midas.h"
#include "west6100.h"
#include "ets_logout.h"
Include dependency graph for west6100.c:

Go to the source code of this file.

Data Structures

struct  W6100_IN_SETTINGS
 stores internal informations within the DD. More...
 
struct  W6100_OUT_SETTINGS
 stores internal informations within the DD. More...
 
struct  W6100_param
 stores internal settings of the running 'West 6100' controller More...
 
struct  W6100_INFO
 This structure contains private variables for the device driver. More...
 

Macros

#define W6100_ETS_LOGOUT_SLEEP   10000
 sleep time (us) between the telnet commands of the ets_logout More...
 
#define W6100_MAX_READBACK_FAILURE   5
 maximum number of readback failures before a reconnect will take place More...
 
#define W6100_TIME_OUT   1000
 time out in msecs for read (rs232) More...
 
#define W6100_SET_PRESSURE   1
 
#define W6100_P   2
 
#define W6100_I   3
 
#define W6100_D   4
 
#define W6100_CTRL_MODE   5
 
#define W6100_NEEDLE_VALVE_POS   6
 
#define W6100_UPPER_OUTPUT_LIMIT   7
 
#define W6100_MAX_ERROR   3
 maximum number of error messages More...
 
#define W6100_DELTA_TIME_ERROR   600
 reset error counter after W6100_DELTA_TIME_ERROR seconds More...
 
#define W6100_READ_ERROR   -1
 read error tag More...
 
#define W6100_INIT_ERROR   -2
 initialize error tag More...
 
#define W6100_OUT_OF_RANGE   -3
 read back pressure out of range tag More...
 
#define W6100_IN_CHANNELS   7
 number of input channels More...
 
#define W6100_OUT_CHANNELS   8
 number of output channels More...
 
#define W6100_IN_SETTINGS_STR   "\Enabled = INT : 1\n\Detailed Messages = INT : 0\n\ETS_IN_USE = INT : 1\n\ODB Offset = INT : 0\n\ODB Output Path = STRING : [64] /Equipment/ModCryo/Variables/Output\n\Input = STRING[7] : \n\[64] W6100 Pressure (mbar)\n\[64] W6100 Set Point Pressure (mbar, readback)\n\[64] W6100 Needle Valve (0=Open, 100=Close)\n\[64] W6100 PID-Gain (P, readback)\n\[64] W6100 PID-Reset (I, readback)\n\[64] W6100 PID-Rate (D, readback)\n\[64] W6100 Controller State\n\"
 initializing string for W6100_IN_SETTINGS More...
 
#define W6100_OUT_SETTINGS_STR   "\Output = STRING[8] : \n\[64] W6100 REMOTE\n\[64] W6100 Set Point Pressure (mbar)\n\[64] W6100 PID-Gain (P)\n\[64] W6100 PID-Reset (I)\n\[64] W6100 PID-Rate (D)\n\[64] W6100 Ctrl-Mode\n\[64] W6100 Needle Valve Pos.\n\[64] W6100 Upper Output Limit\n\"
 initializing string for W6100_OUT_SETTINGS More...
 

Functions

void w6100_error (W6100_INFO *info, char *who, char *msg)
 
float w6100_decode_data (char *code)
 
int w6100_set_cmd (W6100_INFO *info, char *who, char *cmd, char *activate_cmd)
 
int w6100_get_value (W6100_INFO *info, char *who, char *cmd, char *rcv)
 
void w6100_set_pressure (W6100_INFO *info, float value)
 
void w6100_set_gain (W6100_INFO *info, float value)
 
void w6100_set_reset_or_rate (W6100_INFO *info, float value, int tag)
 
void w6100_set_needle_valve_pos (W6100_INFO *info, float value)
 
void w6100_set_manual (W6100_INFO *info)
 
void w6100_forced_update (W6100_INFO *info)
 
void w6100_set_auto (W6100_INFO *info)
 
void w6100_set_self_tuning (W6100_INFO *info)
 
void w6100_set_ctrl (W6100_INFO *info, float value)
 
INT w6100_in_init (HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...))
 
INT w6100_out_init (HNDLE hKey, void **pinfo, INT channels, INT(*bd)(INT cmd,...))
 
INT w6100_exit (W6100_INFO *info)
 
INT w6100_set (W6100_INFO *info, INT channel, float value)
 
INT w6100_get (W6100_INFO *info, INT channel, float *pvalue)
 
INT w6100_in_get_label (W6100_INFO *info, INT channel, char *name)
 
INT w6100_out_get_label (W6100_INFO *info, INT channel, char *name)
 
INT w6100_in (INT cmd,...)
 
INT w6100_out (INT cmd,...)
 

Variables

W6100_INFOinfo
 global info structure, in/out-init routines need the same structure More...
 

Macro Definition Documentation

#define W6100_CTRL_MODE   5

Definition at line 37 of file west6100.c.

#define W6100_D   4

Definition at line 36 of file west6100.c.

Referenced by w6100_forced_update().

#define W6100_DELTA_TIME_ERROR   600

reset error counter after W6100_DELTA_TIME_ERROR seconds

Definition at line 44 of file west6100.c.

Referenced by w6100_error(), and w6100_get().

#define W6100_ETS_LOGOUT_SLEEP   10000

sleep time (us) between the telnet commands of the ets_logout

Definition at line 24 of file west6100.c.

Referenced by w6100_get().

#define W6100_I   3

Definition at line 35 of file west6100.c.

Referenced by w6100_forced_update().

#define W6100_IN_CHANNELS   7

number of input channels

Definition at line 50 of file west6100.c.

Referenced by w6100_in_init().

#define W6100_IN_SETTINGS_STR   "\Enabled = INT : 1\n\Detailed Messages = INT : 0\n\ETS_IN_USE = INT : 1\n\ODB Offset = INT : 0\n\ODB Output Path = STRING : [64] /Equipment/ModCryo/Variables/Output\n\Input = STRING[7] : \n\[64] W6100 Pressure (mbar)\n\[64] W6100 Set Point Pressure (mbar, readback)\n\[64] W6100 Needle Valve (0=Open, 100=Close)\n\[64] W6100 PID-Gain (P, readback)\n\[64] W6100 PID-Reset (I, readback)\n\[64] W6100 PID-Rate (D, readback)\n\[64] W6100 Controller State\n\"

initializing string for W6100_IN_SETTINGS

Definition at line 69 of file west6100.c.

Referenced by w6100_in_init().

#define W6100_INIT_ERROR   -2

initialize error tag

Definition at line 47 of file west6100.c.

Referenced by w6100_get().

#define W6100_MAX_ERROR   3

maximum number of error messages

Definition at line 43 of file west6100.c.

Referenced by w6100_error(), and w6100_get().

#define W6100_MAX_READBACK_FAILURE   5

maximum number of readback failures before a reconnect will take place

Definition at line 27 of file west6100.c.

Referenced by w6100_get().

#define W6100_NEEDLE_VALVE_POS   6

Definition at line 38 of file west6100.c.

#define W6100_OUT_CHANNELS   8

number of output channels

Definition at line 51 of file west6100.c.

Referenced by w6100_out_init().

#define W6100_OUT_OF_RANGE   -3

read back pressure out of range tag

Definition at line 48 of file west6100.c.

Referenced by w6100_get().

#define W6100_OUT_SETTINGS_STR   "\Output = STRING[8] : \n\[64] W6100 REMOTE\n\[64] W6100 Set Point Pressure (mbar)\n\[64] W6100 PID-Gain (P)\n\[64] W6100 PID-Reset (I)\n\[64] W6100 PID-Rate (D)\n\[64] W6100 Ctrl-Mode\n\[64] W6100 Needle Valve Pos.\n\[64] W6100 Upper Output Limit\n\"

initializing string for W6100_OUT_SETTINGS

Definition at line 86 of file west6100.c.

Referenced by w6100_out_init().

#define W6100_P   2

Definition at line 34 of file west6100.c.

Referenced by w6100_forced_update().

#define W6100_READ_ERROR   -1

read error tag

Definition at line 46 of file west6100.c.

Referenced by w6100_decode_data(), and w6100_get().

#define W6100_SET_PRESSURE   1

Definition at line 33 of file west6100.c.

Referenced by w6100_forced_update().

#define W6100_TIME_OUT   1000

time out in msecs for read (rs232)

Definition at line 30 of file west6100.c.

Referenced by w6100_get_value(), and w6100_set_cmd().

#define W6100_UPPER_OUTPUT_LIMIT   7

Definition at line 39 of file west6100.c.

Function Documentation

float w6100_decode_data ( char *  code)

Decodes the return string from the 'West 6100' controller.

Return:

  • value of the coded string
  • W6100_OUT_OF_RANGE if an error was detected
Parameters
codestring from the 'West 6100' controller which has to be decoded.

Definition at line 162 of file west6100.c.

References W6100_READ_ERROR.

Referenced by w6100_get(), and w6100_in_init().

void w6100_error ( W6100_INFO info,
char *  who,
char *  msg 
)

error limiting routine. It works the following way: error messages are reported up to a maximal number of errors per time frame. If there are more error messages, they will be suppressed and only with the next time frame, errors are reported again.

Parameters
infois a pointer to the DD specific info structure
whois the calling routine
msgis the error message

Definition at line 139 of file west6100.c.

References W6100_INFO::errorcount, W6100_INFO::lasterrtime, W6100_DELTA_TIME_ERROR, and W6100_MAX_ERROR.

Referenced by w6100_get_value(), and w6100_set_cmd().

INT w6100_exit ( W6100_INFO info)

terminates the bus driver and free's the memory allocated for the info structure W6100_INFO.

Return: FE_SUCCESS

Parameters
infois a pointer to the DD specific info structure

Definition at line 818 of file west6100.c.

References W6100_INFO::bd, W6100_INFO::bd_info, W6100_IN_SETTINGS::enabled, and W6100_INFO::w6100_in_settings.

Referenced by w6100_in().

void w6100_forced_update ( W6100_INFO info)

Forces an update of the input settings according to the output settings. Needed if one switches to PID control.

Parameters
infois a pointer to the DD specific info structure

Definition at line 470 of file west6100.c.

References W6100_IN_SETTINGS::detailed_msg, hDB, W6100_IN_SETTINGS::odb_offset, W6100_IN_SETTINGS::odb_output, W6100_D, W6100_I, W6100_INFO::w6100_in_settings, W6100_P, w6100_set_gain(), W6100_SET_PRESSURE, w6100_set_pressure(), and w6100_set_reset_or_rate().

Referenced by w6100_set_auto().

int w6100_get_value ( W6100_INFO info,
char *  who,
char *  cmd,
char *  rcv 
)

Gets a specific value from the 'West 6100' controller.

Return:

  • 0, if any error was found
  • 1, if everthing went smooth
Parameters
infois a pointer to the DD specific info structure
whothe calling subroutine name
cmdthe request command
rcvthe answer of controller

Definition at line 282 of file west6100.c.

References w6100_error(), and W6100_TIME_OUT.

Referenced by w6100_get(), w6100_in_init(), w6100_set_auto(), w6100_set_ctrl(), w6100_set_manual(), and w6100_set_self_tuning().

INT w6100_in ( INT  cmd,
  ... 
)

The 'West 6100' controller is used to control the He flow of the Moderation cryostat 'Moddy'. A needle valve, controlled by pressurized air (Bosch ?xyz?) is regulating the LHe flow through the capillary to the cold finger heat exchanger. A absolute pressure gauge (Keller PAA-23S/80549.55) at He pumping exhaust is used as a feedback to regulate the He flow.

Input:

  • Channel 0: He pressure at the exhaust line measured by the Keller pressure gauge
  • Channel 1: Set point pressure in (mbar). This is a readback from the 'West 6100' for monitoring reasons
  • Channel 2: Needle valve position reading; 0=open, 100=close
  • Channel 3: PID-Gain (P, readback)
  • Channel 4: PID-Reset (I, readback)
  • Channel 5: PID-Rate (D, readback)

Output:

  • Channel 0: Remote switch; 0=output settings disabled; 1=remote variables activated
  • Channel 1: Set point pressure in (mbar). This is the pressure at the He exhaust line measured by the Keller pressure gauge
  • Channel 2: PID-Gain (P); allowed values between 0.0% and 999.9% of ouput power range
  • Channel 3: PID-Reset (I); allowed values between 1sec and 99min 59sec. The value entered has to be understood as xx.yy, whereas xx = min-value and yy = sec-value, e.g. 2.23 = 2min 23sec
  • Channel 4: PID-Rate (D); allowed values between 0sec and 99min 59sec. Coding as for PID-Reset
  • Channel 5: Ctrl-Mode (manual=0; auto=1; self-tuning=2); this is a tag used to change between the 'manual mode', the 'auto mode' (PID controlled) and the 'self-tuning facility'. In the 'auto mode' and the 'self-tuning mode', the ouput needle valve position (Channel 6) is going to be ignored. In 'manual mode', one only sets the position of the needle valve and the set point pressure is going to be ignored.
  • Channel 6: Needle valve position ranges between 0 and 100, whereas 0=fully open and 100=fully closed

The 'West 6100' controller comes with a RS485 interface. We use an RS485<->RS232 converter to integrate the controller in our MIDAS slowcontroll system which is RS232 based controlled via a RS232 terminal server.

RS232: 4800 baud, 7 data bits, 1 stop bit, even parity bit, CTS/RTS, termination character: '*' send/receive

Definition at line 1058 of file west6100.c.

References hKey, info, w6100_exit(), w6100_get(), w6100_in_get_label(), and w6100_in_init().

INT w6100_in_get_label ( W6100_INFO info,
INT  channel,
char *  name 
)

at startup, after initialization of the DD, this routine allows to write default names of the channels into the ODB.

Return: FE_SUCCESS

Parameters
infois a pointer to the DD specific info structure
channelof the name to be set
namepointer to the ODB name

Definition at line 1034 of file west6100.c.

References W6100_IN_SETTINGS::name, and W6100_INFO::w6100_in_settings.

Referenced by w6100_in().

INT w6100_in_init ( HNDLE  hKey,
void **  pinfo,
INT  channels,
INT(*)(INT cmd,...)  bd 
)

Initializes the W6100 device driver, i.e. generates all the necessary structures in the ODB if necessary, initializes the bus driver and the W6100 controller.

Return:

  • FE_SUCCESS if everything went smooth
  • FE_ERR_ODB otherwise
Parameters
hKeyis the device driver handle given from the class driver
pinfois needed to store the internal info structure
channelsis the number of channels of the device (from the class driver)
bdis a pointer to the bus driver

Definition at line 639 of file west6100.c.

References W6100_INFO::bd, W6100_INFO::bd_connected, W6100_INFO::bd_info, W6100_param::ctrl, W6100_IN_SETTINGS::enabled, W6100_INFO::errorcount, W6100_INFO::first_bd_error, hDB, W6100_param::high_limit, hKey, W6100_INFO::hkey, info, W6100_INFO::last_reconnect, W6100_INFO::lasterrtime, W6100_param::low_limit, W6100_INFO::num_channels_in, W6100_INFO::param, W6100_INFO::readback_failure, W6100_INFO::remote, W6100_INFO::startup_error, w6100_decode_data(), w6100_get_value(), W6100_IN_CHANNELS, W6100_INFO::w6100_in_settings, and W6100_IN_SETTINGS_STR.

Referenced by w6100_in().

INT w6100_out ( INT  cmd,
  ... 
)

west6100 LHe flow controller device driver (DD) for Moddy (moderation cryostate). It is handling the communication between the 'West 6100' controller and midas.

w6100_out is the part, which handles the communication LS330<-MIDAS

Definition at line 1108 of file west6100.c.

References hKey, info, w6100_out_get_label(), w6100_out_init(), and w6100_set().

INT w6100_out_get_label ( W6100_INFO info,
INT  channel,
char *  name 
)

at startup, after initialization of the DD, this routine allows to write default names of the channels into the ODB.

Return: FE_SUCCESS

Parameters
infois a pointer to the DD specific info structure
channelof the name to be set
namepointer to the ODB name

Definition at line 1051 of file west6100.c.

References W6100_OUT_SETTINGS::name, and W6100_INFO::w6100_out_settings.

Referenced by w6100_out().

INT w6100_out_init ( HNDLE  hKey,
void **  pinfo,
INT  channels,
INT(*)(INT cmd,...)  bd 
)

Initializes the W6100 device driver, i.e. generates all the necessary structures in the ODB if necessary.

Return:

  • FE_SUCCESS if everything went smooth
  • FE_ERR_ODB otherwise
Parameters
hKeyis the device driver handle given from the class driver
pinfois needed to store the internal info structure
channelsis the number of channels of the device (from the class driver)
bdis a pointer to the bus driver

Definition at line 777 of file west6100.c.

References hDB, info, W6100_INFO::num_channels_out, W6100_INFO::startup_error, W6100_OUT_CHANNELS, W6100_INFO::w6100_out_settings, and W6100_OUT_SETTINGS_STR.

Referenced by w6100_out().

INT w6100_set ( W6100_INFO info,
INT  channel,
float  value 
)

sets the values of the W6100, if the device is remote.

Return: FE_SUCCESS

Parameters
infois a pointer to the DD specific info structure
channelto be set
valueto be sent to the W6100

Definition at line 840 of file west6100.c.

References W6100_INFO::bd_connected, W6100_param::ctrl, W6100_IN_SETTINGS::enabled, W6100_INFO::first_bd_error, W6100_param::needle_valve_pos, W6100_INFO::param, W6100_INFO::remote, W6100_INFO::startup_error, W6100_INFO::w6100_in_settings, w6100_set_cmd(), w6100_set_ctrl(), w6100_set_gain(), w6100_set_needle_valve_pos(), w6100_set_pressure(), and w6100_set_reset_or_rate().

Referenced by w6100_out().

void w6100_set_auto ( W6100_INFO info)

sets the 'West 6100' controller auto mode, i.e. PID controlled.

Parameters
infois a pointer to the DD specific info structure

Definition at line 517 of file west6100.c.

References w6100_forced_update(), w6100_get_value(), and w6100_set_cmd().

Referenced by w6100_set_ctrl().

int w6100_set_cmd ( W6100_INFO info,
char *  who,
char *  cmd,
char *  activate_cmd 
)

Sets a command of the 'West 6100' controller and activates it. The controller works the following way: send a command. If the controller understands this command, it replys with a specific acknowledgment, without actually executing it. Therefore one needs to send in a next step an activation command in order to get the command executed.

Return:

  • 0, if any communication error was taking place
  • 1, if everything went smooth
Parameters
infois a pointer to the DD specific info structure
whowhich subroutine is sending the command
cmdthe command sent to the controller
activate_cmdthe activation code, in order to get the command executed

Definition at line 235 of file west6100.c.

References w6100_error(), and W6100_TIME_OUT.

Referenced by w6100_set(), w6100_set_auto(), w6100_set_gain(), w6100_set_manual(), w6100_set_needle_valve_pos(), w6100_set_pressure(), w6100_set_reset_or_rate(), and w6100_set_self_tuning().

void w6100_set_ctrl ( W6100_INFO info,
float  value 
)

sets the control mode of the 'West 6100' controller.

Parameters
infois a pointer to the DD specific info structure
valuectrl mode value. 0=Auto, i.e. PID controlled, 1=Manual, 2=Self-Tuning

Definition at line 577 of file west6100.c.

References W6100_param::ctrl, W6100_INFO::param, w6100_get_value(), w6100_set_auto(), w6100_set_manual(), and w6100_set_self_tuning().

Referenced by w6100_set().

void w6100_set_gain ( W6100_INFO info,
float  value 
)

set the 'gain' (P) of the 'West 6100' controller.

Parameters
infois a pointer to the DD specific info structure
valuedemand gain (P) value to be set

Definition at line 348 of file west6100.c.

References w6100_set_cmd().

Referenced by w6100_forced_update(), and w6100_set().

void w6100_set_manual ( W6100_INFO info)

sets the 'West 6100' controller into manual mode.

Parameters
infois a pointer to the DD specific info structure

Definition at line 439 of file west6100.c.

References W6100_param::needle_valve_pos, W6100_INFO::param, w6100_get_value(), w6100_set_cmd(), and w6100_set_needle_valve_pos().

Referenced by w6100_set_ctrl().

void w6100_set_needle_valve_pos ( W6100_INFO info,
float  value 
)

sets the needle valve position of moddy. This routine is only called if the controller is set to the manual mode.

Parameters
infois a pointer to the DD specific info structure
valuedemand needle value pos

Definition at line 418 of file west6100.c.

References w6100_set_cmd().

Referenced by w6100_set(), and w6100_set_manual().

void w6100_set_pressure ( W6100_INFO info,
float  value 
)

set the 'set point', which is the demand pressure at the He exhaust of Moddy. The routine checks, if the demand value is in the allowed range, i.e. between the low and the high limit.

Parameters
infois a pointer to the DD specific info structure
valuedemand pressure value to be set

Definition at line 325 of file west6100.c.

References W6100_param::high_limit, W6100_param::low_limit, W6100_INFO::param, and w6100_set_cmd().

Referenced by w6100_forced_update(), and w6100_set().

void w6100_set_reset_or_rate ( W6100_INFO info,
float  value,
int  tag 
)

set 'reset' (I) or 'rate' (D) of the 'West 6100' controller.

Parameters
infois a pointer to the DD specific info structure
valuedemand reset/rate value to be set
tag0=reset, 1=rate

Definition at line 370 of file west6100.c.

References w6100_set_cmd().

Referenced by w6100_forced_update(), and w6100_set().

void w6100_set_self_tuning ( W6100_INFO info)

sets the 'West 6100' controller into self-tuning mode.

Parameters
infois a pointer to the DD specific info structure

Definition at line 549 of file west6100.c.

References w6100_get_value(), and w6100_set_cmd().

Referenced by w6100_set_ctrl().

Variable Documentation

W6100_INFO* info

global info structure, in/out-init routines need the same structure

global info structure, in/out-init routines need the same structure

Definition at line 126 of file west6100.c.