esrf

Beamline Instrument Software Support
SPEC Macro documentation: [ Macro Index | BCU Home ]

eurotherm2400.mac $Revision: 4.2 $
See other macros in category: Temperature
Description:
    Macros for a the use of a EuroTherm 2400 temperature controller.
Documentation:
    DESCRIPTION
    The macros provide users with an interface between SPEC and a EuroTherm 2400 temperature controller.

    INTERNALS
    You may declare a motor and a counter, even for the same device! The macro motor/counter macros can handle that.
    The temperature setpoint (or any other writable modbus tag) is driven as a (macro) motor, the process value "PV" and other tags can be read as (macro) counter.

    SETUP
    When used through a serial line, this macro motor set is using a macro set called modbus-rtu.mac. The communication with the Eurotherm controller is done using the modbus binary, called RTU, protocol!

    Only one controller is allowed in a Spec session. If need arises, that might be changed. Now declare a motor controller:
    MOTORS    DEVICE                ADDR  <>MODE  NUM             <>TYPE
       YES     E2400                   3          999       Macro Motors
    
    or
    MOTORS    DEVICE                ADDR  <>MODE  NUM             <>TYPE
       YES     E2400   id00/modbus/e2408          999       Macro Motors
    

    If you use a serial line access, please put the index number of your serial line into the ADDR field (alphanum, hit "'" first). Optionally the Modbus instrument address can be added, seperated from the serial line number with blank. If you access your instrument through a Modbus Tango device server, please enter its address. The Modbus instrument address is a property of the server, you can't change it in Spec.

    Then create the macro motor:

    Unit is index num of controller, second is the Modbus TAG address.
    Number: <>Controller           0: MAC_MOT
    Unit/[Module/]Channel                 0/1
    Name                             Eurot SP
    Mnemonic                           m_euro
    Steps per degree/mm                     1
    Sign of user * dial                     1
    Backlash [steps]                        0
    Steady-state rate [Hz]                  1
    Base rate [Hz]                          1
    Acceleration time [msec]                1
    Motor accumulator                       0
    Restrictions <>                      NONE
    
    Dial = accumulator / steps
      High limit                    1000.0000
      Current                          0.0000
      Low limit                        0.0000
    
    User = sign * dial + offset
      Offset                           0.0000
      `High' limit                  1000.0000
      Current                          0.0000
      `Low' limit                      0.0000
    
    The value steps per degree should reflect, if the controller accepts floating point numbers or not (check Modbus tag address 525).
    Then hit 'm' twice. Set the following for your motor:
    Hardware read mode <>        PR + AL + NQ
    


    Now declare a scaler controller:
    SCALERS         DEVICE          ADDR  <>MODE  NUM             <>TYPE
       YES            POLL             1            2     Software Timer
       YES           E2400           3 1          999      Macro Counter
    



    The counter is then configured as :
    Number        Name  Mnemonic  <>Device  Unit  Chan   <>Use As  Scale Factor
         3      T_euro    t_euro   MAC_CNT     0     1    counter             1
         4      europv    europv   MAC_CNT     0   901    counter             1
    



    This reads the Process Value (tag address 1) and places the value in the counter t_euro. One can read tag addresses as IEEE floating point numbers. To read a tag address as floating point number, add 900 to its tag address. To read the PV use 901.
    Other modbus tag addresses are:
    •   1 - Read Process value
    •   2 - Change Setpoint
    • 273 - Select Manual Mode
    •   3 - Change Output Power
    •   5 - Working Set Point
    • 163 - Programmer setpoint
    •  36 - Segment time remaining (secs)
    • 160 - Target setpoint (current segment)
    • 161 - Ramp rate
    •   6 - Proportional band PID1
    •   8 - Integral time PID1
    •   9 - Derivative time PID1
    But please have a look at the documentation, if you have more specific needs: http://wikiserv.esrf.fr/bliss/images/5/52/Series_2000_Modbus_and_Ei-Bisynch_Digital_Communications_Handbook.pdf

    EXAMPLE
    As application example, one could create two separate spec session. The first session would start a previously defined program in the controller and then start a timescan. The timescan updates the process value continuously. A client spec session can now fetch the counter value, using the prop_get() builtin. Assume the counter number 3 reads you Eurotherm:
     16.HOLG> y = prop_get("localhost:spec", "var/S[3]")
     17.HOLG> p y
     y["3"] = 100.3
    
    The same can be accomplished with a simple remote counter :-), but you still have to count to read the instrument!
    Alternatively, one may trigger the read-out when needed by executing the euro_read macro. This macro will write the result to S[3], too.
     remote_async("localhost:spec", "euro_read 3")
    
    If you use a remote counter, then you can even just say euro_read mne.

    If you read your instrument through a Eurotherm2400 Tango device server, you can declare the same instrument in several Spec sessions and just read out the process value in a timescan, while the first session could serve to define new programs in the controller.

    Due to the slow serial line connection, it has to be accounted for the long read out time. For faster handling, it is planned to write a device server, which does a PV polling.

    For your information from the documentation:

    There are four different Holdback types. The choice of type is made by setting a parameter when creating a program, and may be one of the following:
    OFF
    Disables Holdback - therefore no action is taken.
    Lo
    Deviation Low Holdback holds the program back when the process variable deviates below the setpoint by more than the holdback value.
    Hi
    Deviation High Holdback holds the program back when the process variable deviates above the setpoint by more than the holdback value.
    bAnd
    Deviation Band Holdback is a combination of the two. It holds the program back when the process variable deviates either above, or below, the setpoint by more than the holdback value.


    There is a single Holdback Value which applies to the whole program. However, the Holdback type and whether or not it is enabled, can be applied to the program as a whole, or individually in each segment.



    INTERNALS
    Great care has to be taken, when reading selected addresses from the Modbus. Some of the mb addresses are given in 10th. This concerns the values for ramp rate/time and dwell time in segment programming. Also the status values for the remaining segment time in seconds (36) and minutes (63) are return as 10 times of the real value.

    INTERNALS


Macros:
    e2400_debug
    Usage: e2400_debug
    toggle debug mode for the present macros.

    euro_read
    Usage: euro_read mne
    read PV (process value) from the counter with mnemonic mne. Allows to trigger a read-out without counting. Value is returned, i.e. x = euro_read euro01

    euro2400status
    Usage: euro2400status <manual_setpoint> [unit=<unit>]
    Gives information about the status of the controller. Not to confuse with europrogstatus, which gives information about a program execution in the controller. This one reads the status bytes on a controller and puts them out in human readable form. Saves you to rtfm. The bits of the fast status read (tag 75) are as follows:
     0 Alarm 1 State ( 0 = Safe, 1 = Alarm )
    1 Alarm 2 State ( 0 = Safe, 1 = Alarm )
    2 Alarm 3 State ( 0 = Safe, 1 = Alarm )
    3 Alarm 4 State ( 0 = Safe, 1 = Alarm )
    4 Manual Mode ( 0 = Auto, 1 = Manual )
    5 Sensor Break ( 0 = Good PV, 1 = Sensor Broken )
    6 Loop Break ( 0 = Good closed loop, 1 = Open Loop )
    7 Heater Fail ( 0 = No Fault, 1 = Load fault detected )
    8 Tune Active ( 0 = Auto Tune disabled, 1 = Auto Tune active)
    9 Ramp/Program Complete ( 0 = Running/Reset, 1 = Complete )
    10 PV out of range ( 0 = PV within table range, 1 = PV out of table range )
    11 DC control module fault (0= Good,. 1= BAD)
    12 Programmer Segment Synchronise (0= Waiting, 1 = Running)
    13 Remote input sensor break (0 = Good, 1 = Bad)
    After reflexion, Ill give you all that is there :-), 74 to 77

    euro2400saveprogram
    Usage: euro2400saveprogram program_number [file_name] <unit=[0|1|2|..] or mne=some-counter-or-motor>
    Save the program with number program_number. Optional argument is the filename. Files are saved in ~blissadm/local/spec/userconf.

    euro2400restoreprogram
    Usage: euro2400restoreprogram [file_name] [program number] <unit=[0|1|2|..] or mne=some-counter-or-motor>
    Restore a program previously saved. Only and optional argument is the filename. Files are restored from ~blissadm/local/spec/userconf.


    euro2400showpid
    Usage: euro2400showpid <unit=[0|1|2|..] or mne=some-counter-or-motor>
    Show the PID values for unit


    euro2400configuration
    Usage: euro2400configuration <unit=[0|1|2|..] or mne=some-counter-or-motor>
    Please run without arguments to find out about the possible actions. Put controller into configuration mode and set one of several special cells. The following values influence the macros considerably. They can be set from the computer to make the user experience less painful.
    Note: no spaces are allowed around the `=` signs!
    Note: the decimal display will only be valid, if the Resolution is set to 0 (full)!!!
    Decimal places displayed (mb address 525)
    0: nnnn
    1: nnn.n
    2: nn.nn
Resolution (mb address 12550)
0: Full
1: Integer
Low Range Limit (mb address 11)
High Range Limit (mb address 12)
Instrument Units (mb address 516)
0: oC
1: oF
2: oK
3: None

euro2400parameters
Usage: euro2400parameters <unit=[0|1|2|..] or mne=some-counter-or-motor>
Please run without arguments to find out about the possible actions. Set one of several special cells. The following values influence the macros considerably. They can be set from the computer to make the user experience less painful.
Note: no spaces are allowed around the `=` signs!


eurowaitformove
Usage: eurowaitformove <mne>
toggle behaviour for motor mne to wait for the end of a move, if a simple mv command is using a ramp rate.

europrogreset
Usage: europrogreset <manual_setpoint> <unit=[0|1|2|..] or mne=some-counter-or-motor> [noninteractive]
Forces a reset of running program (if any) and sends a new setpoint to the eurotherm.
Without argument, the macro will set the last used setpoint.
With "unit=1" unit declared as 1 will be reset. No blanks please. With option "noninteractive", no questions asked.

europrogstatus
Usage: europrogstatus <unit=[0|1|2|..] or mne=some-counter-or-motor>
Gives a status of the program execution in the Eurotherm

europroghold
Usage: europroghold <unit=[0|1|2|..] or mne=some-counter-or-motor>
Forces the running program into hold mode. Please consult docmentation for the exact meaning of that state.

europrogholdback
Usage: europrogholdback <unit=[0|1|2|..] or mne=some-counter-or-motor>
Forces the running program into holdback mode.

Holdback (from the documentation)

As the setpoint ramps up, or down (or dwells), the measured value may lag behind, or deviate from, the setpoint by an undesirable amount. Holdback is available to freeze the program at its current state, should this occur. The action of Holdback is the same as a deviation alarm. It can be enabled, or disabled. Holdback has two parameters - a value and a type. If the error from the setpoint exceeds the set "holdback" value, then the Holdback feature, if enabled, will automatically freeze the program at its current point and flash the HOLD light. When the error comes within the holdback value, the program will resume normal running.

europrogcomplete
Usage: europrogcomplete <unit=[0|1|2|..] or mne=some-counter-or-motor>
Forces the running program to complete.

europrogrun
Usage: europrogrun <unit=[0|1|2|..] or mne=some-counter-or-motor>
Executes the defined program.

europrogskipsegment
Usage: europrogskipsegment <unit=[0|1|2|..] or mne=some-counter-or-motor>
Ends the current segment.

europrog
Usage: europrog <unit=[0|1|2|..] or mne=some-counter-or-motor> <run|reset|hold|holdback|complete|skip|status> <argument>]
Macro that runs an interactive loop. It allows to define programs inside the controller, read them, read the status, reset the controller. The command run can have an additional argument containing the program number.


Internal Macros:
    __e2400_put
    Usage: __e2400_put(unit, fwaddr, value)


    __e2400_blockput
    Usage: __e2400_blockput(unit, fwaddr, num, data)


    __e2400_get
    Usage: __e2400_get(unit, fwaddr, num, data)


    __e2400_put_serial
    Usage: __e2400_put_serial (node, fwaddr, value)
    Called by spec

    __e2400_blockput_serial
    Usage: __e2400_blockput_serial (node, fwaddr, value)
    Called by spec

    __e2400_get_serial
    Usage: __e2400_get_serial (fwaddr, fwaddr, num, data)
    Called by spec

    __e2400_put_tango
    Usage: __e2400_put_tango (fwaddr, value)
    (server, fwaddr, value) Called by spec

    __e2400_blockput_tango
    Usage: __e2400_blockput_tango (server, fwaddr, nwords, data)
    Called by spec

    __e2400_get_tango
    Usage: __e2400_get_tango (server, fwaddr, num, data)
    Called by spec.<BR>data is ushort array

    __euro_rfloat
    Usage: __euro_rfloat(unit, val)


    __euro_wfloat
    Usage: __euro_wfloat(unit, val)


    E2400_config
    Usage: E2400_config (mne, type, unit, mod, chan)
    Called by spec

    E2400_cmd
    Usage: E2400_cmd(mne, cmd, p1, p2, p3)
    Called by spec

    E2400_par
    Usage: E2400_par(num, key, action, p1, p2)
    Called by spec with different keys to handle motor_par(mot,"key",new_value) actions.

    __euro__float
    Usage: __euro__float (<data>)
    Converts 4 byte size values into IEEE floating point value and returns it.
    The 2408 can be put into a floating point mode (read cell 12550) which then displays values with variable number of floating point numbers. To avoid getting in trouble with that, the protocol allows to read 4 bytes from adresses over 0x8000. Thus, the cell 2 reads from
    2 x 2 + 8000h = 8004h = 32772 decimal.


    __europrog_save_as_scan
    Usage: __europrog_save_as_scan (starttemp, memarr, nosubprg)
    Save eurotherm 2400 program from array `memarr` into the SPEC datafile.

    __e2400_simple
    Usage: __e2400_simple


    _europrog_show_values
    Usage: _europrog_show_values (memarr, unit)
    this is a special macro for europrog shows the values in a eurotherm program, just the values without conversion.

    euro2400menu
    Usage: euro2400menu <unit=[0|1|2|..] or mne=some-counter-or-motor>
    Set various parameters in the controller. Only possible for unit number 0 in this spec session.

    _euro_set_serial_parameters
    Usage: _euro_set_serial_parameters (mne)
    Setting serial line parameters

    _euro_search_bisync
    Usage: _euro_search_bisync(serialline, enda)


    _europrog_cmd
    Usage: _europrog_cmd (unit, state)
    this is a special macro for europrog Sends a program control command to a Eurotherm 2400 series instrument.

    _europrog_status
    Usage: _europrog_status (unit)
    this is a special macro for europrog Reads the status of a program on a Eurotherm 2400 series instrument. This macro has been adapted from the former one in temperature.mac. There seems to be more testing necessary!

    _europrog_show
    Usage: _europrog_show (label, starttemp, memarr, nosubprg, unit)
    this is a special macro for europrog Reads a program from a Eurotherm 2400 series instrument.

    _europrog_edit
    Usage: _europrog_edit (memarr, label, unit)
    this is a special macro for europrog Edit a program Adress calculation is base address 8192 plus number of program (skip 0) times 17*8

    _europrog_read
    Usage: _europrog_read (unit, euro_program_number)
    this is a special macro for europrog Reads a program from a Eurotherm 2400 series instrument.

    _europrog_write
    Usage: _europrog_write (unit, memarr, program_number)
    this is a special macro for europrog Writes a program on a Eurotherm 2400 series instrument. Adress calculation is base address 8192 plus number of program (skip 0) times 17*8

    writing a program has to be done in a selective manner. One can`t just write a block of modbus adresses. Each segment type has arguments, which can be written other

    _europrog_value_too_high
    Usage: _europrog_value_too_high(unit, astr, value)


    _europrog_print_error
    Usage: _europrog_print_error(str)


    _europrog_print_so
    Usage: _europrog_print_so(str, width)


    europrog_editfield
    Usage: europrog_editfield (str, width, xpos, ypos)
    this is a special macro for europrog Edit a field

    europrog_multiplechoice
    Usage: europrog_multiplechoice (choice, charr, width, xpos, ypos)
    this is a special macro for europrog Edit a field

    __eurotherm_wrapper
    Usage: __eurotherm_wrapper


    euro_main
    Usage: euro_main ()
    This macro function runs a loop to provide interactive communication to an eurotherm device.
    It reads keyboard input and executes the wished command.

    _euro_mne2unit
    Usage: _euro_mne2unit


    _euro_mne_test
    Usage: _euro_mne_test


    _euro_2400_test_function
    Usage: _euro_2400_test_function(cmd)


    testattempt_eurotherm2400
    Usage: testattempt_eurotherm2400


Filename: eurotherm2400.mac
Author: H. Witsch, BLISS - ESRF, derived from the macros in temperature.mac, $Revision: 4.2 $, $Date: 2018/05/22 09:40:35 $
Last mod.: 22/05/2018 11:40 by witsch