Home
Extending Forth in a Camac Controlled Muon Channel
Contents
1. R gt M THEN DROP THEN gt _A C V n1 n2 convert amps to counts AMP IF _DAF 1 CASE SWAP FSA M DROP ELSE FSA R ENDS THEN _SDAC _DAF DDUP U gt IF SWAP THEN DROP _DAC WT1 SET _DAF DDUP U gt IF SWAP THEN DROP DUP TO SP DAE WT1 FS Vn show full scale in number of bits 1 CASE 16 ELSE 4095 CASE 12 ELSE 1023 CASE 1 ELSE ENDS 2 R 100 100 R V n1 p n2 add p percent amp DIFF OVER IF OVER 100 ROT R ELSE SWAP DROP THEN n1 n2 p PSHD AMP IF E Ampsx10 header for ps status table ELSE THEN DAC ADC CR s percent off CR STATUS AD TO HAD DAC RD1 TO DA DG DUP IF RD1 ELSE NODIGI THEN pretend ok if no digi ID SP C A 6 U R REMOTE IF SP DA XDIFF DUP IF 6 R ELSE THEN ELSE Local THEN OK IF ON IF DA _DAF ADF M DROP M DROP AD ZDIFF DUP IF 6 R ELSE THEN ELSE uU off THEN ELSE intlk THEN CR DROP CTRL V controlbit DG IF DG WT1 ELSE DROP No remote ON OFF RESET for ID THEN PSHL header for configuration table at a d bits digi d a bits amps CR PS write an entry of the configuration table TAB ADC NA TAB ADF FS TAB DG NA TAB DAC NA TAB DAF FS _FSA 10 8 R PS ID CR Extending Forth in a Camac Controlled Muon Channel 17 PS V lt config n par s gt PS lt name gt define a power supply CREATE PAR ALLOCATE V and initialize param s 10 TO FSA BIT 1 TO DAF NA
2. The Forth application routines were developed in three weeks took seven pages and allowed full control and diagnostics Adaptation of the C program took a month This involved adding a few pages to the existing fifty and some restructuring necessitated by porting to a different operating system and compiler This package was not meant for diagnostics It features a channel definition language and a level of user interface not addressed by the other programs The efforts in the different languages varied widely in scope They were not undertaken to study the comparative merits of programming languages but rather to do a specific job with the tools at hand This paper describes the Forth program used for channel tuning and hardware diagnostics On several occasions modifications or extensions of the Forth language were introduced to make the code more readable Choice of Language Clearly if the task is simple enough the choice of programming language is less important and a simple language like Basic can be very effective Journal of Forth Application and Research Volume 3 Number 4 3 4 The Journal of Forth Application and Research Volume 3 Number 4 Forth excels in flexibility and speed of implementation but it lacks the wide acceptance and standardization of C The choice between Fortran and Forth on technical grounds can be quite clear Fortran for math Forth for control Include the programming language C and the arguments are less ev
3. FLag to get ADC rather than DAC setting VAR AMP Flag to work in AMPS rather than COUNTS VAR AD Temporary store for a d VAR DA u d a VAR FUN Function to be performed VAR SW ON Extend use of TO variables QVAR SW OFF VAR SW RESET FUN SW SCAC Scale by PCT percent FUN SW R Initialize setpoints by reading actual DAC setting FUN SW Show DAC ADC and Status FUN SW PC Show parameters FUN SW RDC V Load setpoint value from next word in input stream FUN SW WR V Write ID and DAC value to output stream FUN SW Revert to standard mode V for TO TO ON OFF and RESET SC TO PCT SCAC ADC 1 TO ADC DAC TO ADC AMPS 1 TO AMP COUNTS TO AMP PNT PAR pointer to the parameter list of a power supply D XY col and row for display _ SP Value of set point _ _FSA Full scale amps x 10 _ _DAF DAC s full scale 4095 for 12 65535 for 16 bits _ DAC DAC s camac address _ DG V DIGI s camac address ignored if not there _ ADF ADC s full scale _ ADC ADC s camac address set bit for ch 16 31 ID PAR pfa nfa 8 ID Show name of beam line element _AD V n read 1 of 32 subbaddresses _ADC DUP 1 AND IF 1 RD2 ELSE RD1 THEN The Journal of Forth Application and Research Volume 3 Number 4 16 _C A V n1 n2 convert counts to amps if required AMP IF FSA M ADC IF ADF ELSE _DAF THEN 1 CASE 32767 D SWAP ELSE DUP gt R 2 D
4. List the specified file FLOAD lt filespec gt Load i e start interpreting the specified file LIST an List the file whose n char filespec starts at a LOAD an Load a file e g CAMAC LOAD gt FILE lt filespec gt Create a file and direct standard output to it gt TER Redirect standard output to the terminal TER c Get a keyboard input character zero if none Extending Forth in a Camac Controlled Muon Channel 11 R abc r Return rounded result of a b c BIT n 7 v Raise 2 to the power n CON n CON lt name gt Define a direct code constant can t be changed ESC lt string gt Output an escape sequence or compile what s needed to do it RANGE nab n f True if n is in the range a b inclusive SHIFT n1n n2 Shift n1 n bits left or if n 0 n bits right Treat rest of line as a comment 0 n Show integer value in octal Tis Cn Show a number in base 10 R nw Show in current base right adjusted in a field of width w O R nw Octal output right adjusted in a field of w characters T R Kom wo 7 Decimal output right adjusted TIME Show time of day DATE Show date Extensions VAR n D Get state for TO variables and clear it VAR lt name gt Define a TO variable DVAR lt name gt Define a double TO variable SW a SW lt name gt Define lt name gt such that it stores its pfa in a PNT lt name gt Name and start a parameter li
5. TO DAC OVER IF NA ELSE DROP THEN TO DG zero if no digi BIT 1 TO ADF 16 MOD gt R NA R gt TO ADC modify naf for 32 ADC chnls PXY TO XY PXY DUP 18 gt IF DDROP PXY ELSE 1 THEN TO PXY DOES PAR VAR FUN CASE CASE ADC IF AD ELSE SP THEN C A ELSE to 1 CASE A C SET ELSE to 2 CASE _A C SP SET ELSE ON CASE PWR ON CTRL ELSE OFF CASE PWR OFF CTRL ELSE RESET CASE INTLK RESET _CTRL ELSE C ERR ENDS ELSE SWAP VAR DROP SCA CASE SP PCT SDAC ELSE RC CASE _DAC RD1 TO SP ELSE CASE _XY XY STATUS ELSE PC CASE _ PS ELSE RDC CASE ASKN TO SP ELSE WRC CASE ID SP 6 U R CR ELSE C ERR ENDS 18 CONFIG 1 N N1 2 N N2 4 N NG 5 N N5 6 N N w Y N N7 8 N N8 11 N N11 12 N N12 13 N N13 15 N N15 16 N N16 17 N MM 22 N DM a d bits N10 12 N11 12 N12 12 N13 12 N14 12 N15 12 N16 12 N17 1 N18 12 N19 12 N1 10 12 N1 11 12 N1 12 12 N1 13 12 N1 14 12 N1 15 12 N1 16 12 N1 17 1 N1 18 12 N1 19 12 N1 20 12 N1 21 12 N1 22 12 N1 23 12 N1 24 12 a d left righ N2 0 Ne N2 3 N2 N2 4 N N2 7 N2 N2 8 N2 N2 11 N21 t 1 2 5 6 9 9 The Journal of Forth Application and Research Volume 3 Number 4 Camac modules power supplies and slits in M15 GEC model ADC 32 32 chnl 12 bit analog to digital conv Joerger model D A 16 dual 16 bit digital to analog conv Joerger model DAC
6. col row for camac error reports help INFO List 2 help mags qi q2 q3 q4 b1 q5 b2 q q7 b3 sx1 q8 sx2 b4 group all q9 q10 q11 sep1 q12 q13 q14 sep2 q15 q16 q17 magnets slits sl1 sl2 sl3 sl4 sl5 sl group all slits all mags slits all elements scale s mags show pshl p mags cr slhl slits cr config n parameters time hd T3 xy time cr V show time in header nokey ter 13 V c leave only if return was hit Ji home clrs pshd 40 23 xy Hit return for attention rev Mar 85 time hd begin mags nokey while cr mm mtst nokey while slits nokey while time hd repeat 21 xy clrs Type for help cr save gt file TUNE M15 date space time cr file header wr mags cr slits V el t settings gt ter restore rd fload restore setpoints from data in file svcal gt file CALIB M15 date space time cr wm slits gt ter Ldcal rmC CALIB M15 load rC all 20 The Journal of Forth Application and Research Volume 3 Number 4 INFO M15 diagnostics RS 850330 Words must be separated by spaces Say DAC or ADC AMPS or COUNTS to qualify subsequent reads and writes value TO lt name gt name ON or OFF lt name gt RESET lt name gt MAGS value S lt names gt lt value gt SCALE RC names lt names gt FLIST lt filespec gt SAVE lt filespec gt RESTORE lt filespec gt SHO
7. the address at which can be found 1 the address 2 the size of the list CREATE HERE TO a8PNT OQ address size DOES PNT Vn in the declaration of a parameter of size n set up the address and offset and update the size of the list PNT DUP address 2 DUP a offset update size lt name gt define an integer parameter variable CREATE 2 PNT DOES Da AVAR CASE a ELSE 1 CASE ELSE 2 CASE ELSE C ERR ENDS pa lt name gt define a double integer parameter variable CREATE 4 PNT DOES Da a AVAR CASE DA ELSE 1 CASE D ELSE 2 CASE D ELSE C ERR ENDS ALLOCATE Va assume a to be a pointer to a list Initialize the pointer and allot space for the list HERE OVER 2 1 2 0 DO LOOP Extending Forth in a Camac Controlled Muon Channel 13 Listing 2 Source files Each of the source files listed below starts with a comment line in parentheses in which the first word is the filename LOAD files for diagnostics on M15 fload VT100 fload CAMAC fload DIGI fload CAMEM fload POWER fload SLITS fload CONFIG fload USER VT100 terminal dependent cursor addressing HOME ESC H 2 XY Esc T T H x y move cursor to col x row y CLRS ESC CJ Clear screen from cursor CLRL ESC IK V Clear from cursor to end of line UP Esc A Move cursor up BKSP ESC D Move cursor left DVAR XY
8. 8L 8 ch 12 bit digital to analog conv Triumf model 0550 8 chnl 4 bit digital I O module read bit intlck 1 on 3 remote write bit on 1 off 2 reset Triumf model 0576 1 octal 4 bit Input Gate Output Reg Triumf model 2401 128 24 bit word memory module Kinetics model 3291 dataway display digi d a bits amps N11 0 N60 12 750 ps Q1 N11 1 N61 12 750 ps Q2 N11 2 N 2 12 80 ps Q3 N11 3 N63 1 80 ps Q4 N11 4 N40 16 250 ps B1 N11 5 N64 12 80 ps Q5 N11 6 N4 1 16 250 ps B2 N11 7 N6 5 12 80 ps Q6 N12 N6 6 12 80 ps Q7 N12 1 N50 16 250 ps B3 N12 2 N6 7 12 80 ps SX1 N12 3 N7 12 80 ps Q8 N12 4 N71 12 80 ps SX2 N12 5 N5 1 16 250 ps B4 N12 6 N72 12 200 ps Q9 N12 7 N73 1 200 ps Q10 N13 0 N7 4 1 200 ps Q11 N13 1 N7 5 12 750 ps SEP1 N13 2 N7 6 12 200 ps Q12 N13 3 N7 7 12 200 ps Q13 N13 4 N8 12 200 ps Q14 0 0 N8 1 12 750 ps SEP2 no digi N13 6 N8 2 12 200 ps Q15 N13 7 N83 1 200 ps Q16 N13 5 N8 4 12 200 ps Q17 igor memory words left right mem pos width stat no N15 N15 1 MM 816 832 848 1 slit SL1 N15 3 N152 MM 817 833 849 2 slit SL2 N15 4 N15 5 MM 818 834 850 3 slit SL3 N15 7 N15 6 MM 819 835 851 4 slit SL4 N16 N16 1 MM 820 836 852 5 slit SL5 N16 3 N162 MM 821 837 853 6 slit SL6 Extending Forth in a Camac Controlled Muon Channel 19 USER routines for M15 Examples of use of the diagnostics in CAMAC POWER and SLITS serving as a makeshift user interface 3 22 to XYMES
9. Extending Forth in a Camac Controlled Muon Channel Robbie Spruit TRIUMF Vancouver B C Canada V6T 2A3 Abstract Contro and diagnostic software was developed for a recently commissioned muon channel at TRIUMF Logistics gave rise to separate efforts in several programming languages This paper describes the Forth diagnostic package The choice of programming language is discussed briefly Several extensions to Forth and their usage are shown in the framework of a detailed account of the software implementation Emphasis is placed on the production of readable code and on the design of constructs that closely model the structure of the application Contents Choice of language Beam line overview Channel control Forth implementation Terminal Camac Channel elements Functions Parameters User interface Conclusion References Appendices CalTech Forth Non standard words Extensions Source Files LOAD VT100 CAMAC DIGI POWER CONFIG USER INFO Preface When the M15 channel at TRIUMF delivered its first muons the very first channel settings had been established with the aid of a small Basic program Subsequent beam tuning was done with a set of Forth routines until the adaptation of an existing control program written in C for another channel was completed The Basic program was coded in six hours It was less than two pages and permitted the checking of the cabling and of the computer access to the power supply interfaces
10. MES 1 TO XYMES x y for messages ignore if y lt M Use instead of to direct messages to XYMES amp XYMES DUP gt IF XY ELSE DDROP THEN WRITE DIGI bit assignments of TRIUMF s I O module 1 CON NODIGI V used to fake status when a digi module is not V provided BS CREATE BIT DOES 8 OVER AND Define a bit set test BIT BIT CON input bits when reset BS OK V Interlock fault 1 BS ON Power Off 3 BS REMOTE V Local V output bits Q BIT PWR ON 1 BIT PWR OFF 2 BIT INTLK RESET 14 The Journal of Forth Application and Research Volume 3 Number 4 CAMAC for PDP 11 with a Kinetics 3912 crate controller OCTAL 166000 CON CAMAC Crate s address DECIMAL NA Vn na encode slot amp subaddress into Unibus address Q 15 RANGE ABORT Subaddress must be 0 15 SWAP 30 RANGE ABORT Slot nr must be 0 30 4 SHIFT 1 SHIFT CAMAC N CON V n define a slot module no RD CODE S SWAP a MOV NEXT na define an input action WR CODE a S MOV NEXT V na define an output action NA RD RD O NA WR WR V Data bits 15 1 NA RD RD HI Q 1 NA WR WR HI V Data bits 23 16 4 NA RD ST1 5 NA RD ST2 V Status register 1 amp 2 VAR NA provide global access to last used N A and VAR F function code F TO F TO HNA F NA B na f execute a single action SUN ST2 2 AND V x True if X was g
11. W lt pos n gt lt width gt TO SLx BYE Set DAC in integer amps x 10 or counts Print value of DAC or ADC in AMPS or COUNTS Remotely control power supply for lt name gt Reset power supply interlock Is a name for all power supplies Scale power supplies by integer percentage Scale all SCALE sets dacs to setpoints Read dac s into setpoints Show setpoint dac Cif different and adc List a file on the terminal Save settings in a file Restore a tune into the setpoints Show configuration parameters Set slit x xz1 6 in 1 mm integers End the program Do display Sample display shows benders scaled down by 10X Some DAC ADC s need adjusting DAC ADC 14 56 23 percent off SEP1 Q12 Q13 Q14 SEP2 Q15 off Q16 off Q17 of f slit width SL1 700 SL2 1001 SL3 251 SL4 1001 SL5 600 SL6 599 Hit return for attention rev Mar 85
12. agnets through certain momentum ranges For these cases command names were chosen with a left parenthesis as the last character These assign a certain value to a state variable which keeps its value until reset explicitly by a right parenthesis Thus B1 B2 B3 B4 shows the status of the first four benders and 10 SC B1 B2 scales the first two down ten percent The implementation of the TO concept originally used simple values for the state variable 0 as the default value 1 for TO and 2 for TO With the proliferation of command options this method began to stand out as an example of poor software practice defining the same association in more than one place and hoping that the definitions agree A switch class define construct named SW was implemented as a remedy It allows the prefix operators to be defined such that they switch a state or fuction variable to some unique value in this case the parameter field address As can be seen in the definition of PS in the file POWER comments are no longer required to identify the commands Parameters In a CREATE DOES construct the parameter field address is available on the stack when the part following DOES is executed The individual parameters can then be retrieved by applying offsets to this address Extending Forth in a Camac Controlled Muon Channel 9 For power supplies the large number of parameters required to define their state dictated the creation of a naming conventi
13. ccessible by name Thus allocation and initialization no longer require knowledge of offsets or order of declaration User interface An on line help facility was added and the software was installed to come up automatically with a continuous status display after logging in to the operating system Help consists of a list of the most common command options the last of which is the command to reinvoke the display Thus there is always an indication of what options are available A minimum of typing skill is required to switch between display and command mode When in command mode the user has access to the entire Forth command set This is where this implementation stops being user friendly Logically CalTech Forth s entire dictionary the assembler included is just one long list Fatal results even if unlikely are possible by mistyping Early Forth systems have always been criticized for such surprises There are a number of possible preventive programming measures None were pursued since power prevailed over protection and time was of the essence Notwithstanding its known drawbacks and pitfalls this simple user interface is highly effective requires a minimal development time and is immediately accessible to unfamiliar users without hindering the more experienced Conclusions The description of the Forth application program made it possible to present some language constructs data and function structures or pseudostructures in rea
14. ct spectral qualities such as divergence momemtum range intensity and spot size Q15 Q17 EXPERIMENTAL P TARGET NN LOCATION EL 291 5 BEAMLINE 1A EL 268 5 Figure 2 Muon channel M15 Channel Control Remotely controllable power supplies provide direct currents of up to 750 Amperes to the magnet coils Local interlock circuitry monitors such conditions as magnet temperature and coolant flow and automatically switches off the corresponding power supply when necessary Each power supply has an analogue input to set the current regulator an analogue output to monitor the actual output current digital outputs indicating on off and interlock status and digital inputs to switch power on and off and to allow a reset of interlock faults D A converters A D converters and digital I O modules housed in a Camac 1 crate provide for computer control as indicated in Figure 3 The slits are positioned with AC motors driven by a microprocessor in the same Camac crate and interfaced through similar A D and digital I O modules 6 The Journal of Forth Application and Research Volume 3 Number 4 COMPUTER TERMINAL CAMAC CRATE POWER SUPPLIES MAGNET COILS d Q 8 PE QUADRUPOLE DIPOLE SEXTUPOLE Figure 3 Camac interface connections Camac the phrase Computer Automated Measurement And Control has been adopted to make it an acronym is the name for an instrumentation bus standard which originate
15. d in the nuclear science community Extensive experimental calibration tuning is required to obtain a beam with particular char acteristics A given beam line tune is best represented by a set of magnetic field strengths Monitoring the actual fields with probes may be costly difficult or impossible The value given to the D A converter that sets the magnet current may provide a suitable measure Such is the case for M15 so that tunes are normally described by a set of DAC settings Automatic tuning has for economic and technical reasons only recently been given serious consideration Integration of the beam line control system with the detector and data acquisition systems is still in the planning stage The type of control considered here is the provision of convenient facilities for setting and monitoring the state of a number of beam line elements The interpretation of the detector readout and the choice of parameters for the elements are operations performed by a beam line physicist Forth Implementation The source code of the application programs is listed in the appendix The file named LOAD loads the following files VT1 CAMAC CAMEM DIGI POWER SLITS CONFIG and USER on top of the modified CalTech RSX Forth The file CAMEM deals with access and diagnostics for a special Triumf Camac memory module while in SLITS motor control is passed to a microprocessor via a protocol through such a memory module These two files have been l
16. eft out in order to avoid an encumbrance of site dependent trivia The type of features they offer and the programming principles they depend on are equally well or better explained with the files DIGI and POWER The conceptual design began with a tabular representation of the elements of the muon channel This became the file CONF IG Then the notions of what one wanted to do with the elements were Extending Forth in a Camac Controlled Muon Channel 7 put in the file POWER for magnet power supplies and in the file SLITS for the moveable slit plates The files VT1 and CAMAC are general utilities The user interface in the file USER was held to a minimum since eventually this would be handled by the existing C software The following narrative of the principal design modules is presented in the order in which the files are loaded Terminal Initially basic control was developed for a hardcopy terminal mode in which standard Forth terminal I O is adequate Later software was added to support a 24 X80 character video display A set of cursor commands is grouped in a file named after the terminal type in this case a VT100 The word ESC sends an escape sequence made up of the next word and preceded by an escape character A generic compilation construct was devised to allow the creation of words such as ESC which differ only slightly from regular string output but would normally be awkward to implement as they are to be used inside as well as ou
17. enerated Q ST2 1 AND V q True if Q was generated OCTAL NA 2 DUP 4 SHIFT 37 AND SWAP 17 AND na na NA NA SWAP 2 T R 3 T R decode and show n and a NAF NAF NA NA F 3 T R SPACE show last n a and f z X 2 AND IF M No X NAF THEN Q ST2 IF ST2 4 AND IF M Time out ELSE ST2 2 AND IF M No X ELSE ST2 1 AND IF M No Q ELSE ENDS NAF CR THEN DECIMAL i FS CREATE 7 RANGE IF DOES F RD Q ELSE 16 23 RANGE IF DOES 8 ROT WR F Q ELSE 31 RANGE IF DOES F X ELSE 1 ABORT F code must be to 31 ENDS na data na data na na S read operate write operate F RD1 8 F TLM 16 F WT1 24 F DIS 1 F RD 9 F CL1 17 F WT2 25 F XEQ 2 F RC1 10 F CLM 18 F SS1 26 F ENB 3 F RCM 11 F CL2 19 F SS2 27 F TST Extending Forth in a Camac Controlled Muon Channel 15 16 bit data diagnostic for a single subaddress W R N n1 n2 n1 complain if different DDUP IF OVER M Wrote 6 O R read 6 O R NAF CR ELSE DROP THEN CHKDN n1 n1 DUP NA WT1 O WR NA RD1 W R check write read on current N and A CHK DATA na Check single one s and single zeroes TO NA 1 BEGIN CHKD COM CHKD COM DUP WHILE 2 REPEAT POWER Control magnet power supplies DVAR PXY Q0 3 TO PXY V Starting point of first display column DVAR PXY2 46 3 TO PXY2 second VAR PCT Percentage increase for scale command VAR ADC V
18. ident C is well suited to either type of task The advantages of Forth interactiveness and structural extensibility were not sufficient reason to rewrite existing application software However when setbacks in the acquisition and installation of the system software began to jeopardize the timely completion of the C approach a parallel effort was started in Forth A version of CalTech Forth 2 had already been used on site to run FASTBUS test software 4 under RSX11 M on a PDP 11 34 Since the control system for M15 was to employ a Micro 11 with RSX11 M there were no problems with the installation Beam Line Overview TRIUMF is the name for Canada s meson facility in Vancouver British Columbia It is used for pure research in nuclear and particle physics as well as for applied research programs such as a the treatment of cancerous tumours with pion beams b the production of medical radioisotopes and c the use of neutron beams for geological analyses TRIUMF is operated by the universities of Alberta British Columbia Victoria and Simon Fraser under a contribution from the National Research Council of Canada Figure 1 shows the layout of the 147 m long main building The six segment cyclotron 18 m in diameter allows the simultaneous extraction of multiple proton beams at different energies of up to 520 MeV and 140 uA Two targets placed in the path of proton beam line 1 are the sources for a total of six secondary beams of pions and muo
19. l life as extensions to the Forth language 10 The Journal of Forth Application and Research Volume 3 Number 4 M MQ M ster E ci doceri d A concise style of implementing functional descriptions is achieved when individual references to parameters or structure members may be made without having to refer explicitly to the structure itself Coding prefix format commands by name permits a more readable implementation of constructs that make use of such operations References 1 Modular Instrumentation and Digital Interface System CAMAC ANSI IEEE Std 583 1975 2 M S Ewing The CalTech Forth Manual June 1978 A Technical Report of the Owens Valley Radio Observatory California Institute of Technology Pasadena Ca 91125 3 P Bartholdi The TO solution and TO continued FORTH Dimensions Vol 1 No 4 5 1979 4 C Logg Fastbus Diagnostic Operating System FBDOS Aug 1982 Informal paper Stanford Linear Accelerator Center Ca 94305 5 K Schleisiek Multiple Code Field Data Types and Prefix Operators Jrnl of Forth Appl amp Res Vol 1 No 2 Dec 1983 Manuscript received June 1985 Robbie Spruit P Eng M Sc Eng Delft learned about Forth in 1976 when working on data acquisition and instrument control systems for an international telescope construction project As a member of the Forth Standards Team he took part in the definition of the Forth 79 standard Mr Spruit is an independent consu
20. ltant based in Vancouver B C Canada with particular experience in control communication and interface systems in engineering and specific environments Among his current interests is the application of computer systems to natural language services Appendix CalTech Forth CalTech RSX Forth s direct threaded code its sixteen thread dictionary compressed name fields and sequential source files make for extremely fast compilation This compensates for the lack of a Forth editor To make a change in a source file one has to exit Forth invoke the system editor and rerun Forth It is possible to run a system program from within Forth but the entire process of reloading took only a few seconds so there was no pressing need to implement this feature A useful feature is the validity of program flow constructs outside of definitions It is more convenient to type 20 DO READ LOOP to show the result of twenty read actions than to have to go through the sequence of encasing this phrase in a new definition executing it once and FORGETting it A disadvantage of CalTech Forth is the divergence from the more widely used versions of Forth We did change it but rather than making a rigorous conversion to a Forth 79 or 83 standard we made modifications as required to be able to execute code that looked like standard Forth A few of the nonstandard words listed below are CalTech s Any inconsistencies are ours Non standard words FLIST lt filespec gt
21. ns d HANDLING FACILITY 42 MeV ISOTOPE PRODUCTION CYCLOTRON PROTON HALL EXTENSION MESON HALL MESON HALL EXTENSION Aa D M13 T1 u a dc in RADIOISOTOPE LABORATORY p nm n p FACILITY X p BATHO THERMAL MESON HALL BIOMEDICAL NEUTRON SERVICE LABORATORY FACILITY ANNEX Figure 1 Floor plan of the TRIUMF cyclotron building M15 is a dedicated surface muon channel It collects positively charged muons from pions decaying at rest within a few microns of the meson production target s surface Surface muons are longitudinally spin polarized and may be collected into beams of high optical quality These properties are exploited in two categories of experiments measurements of muon decay to test modern theories of particles and muon spin rotation experiments to test physical and chemical Extending Forth in a Camac Controlled Muon Channel 5 phenomena quite unrelated to nuclear or particle physics For example the muon is a sensitive probe of magnetism in solid state crystals A more detailed mechanical layout of the channel is given in Figure 2 The controllable elements shown are dipole magnets benders B1 to B4 which steer the beam and quadrupole and sextupole magnets Q1 to Q17 and SX1 and SX2 which are arranged in pairs or triplets to focus the beam The two DC separators were not included in the initial installation Movable slit plates not shown sele
22. on The initial approach was to store the parameter field address on entry after DOES in a variable named PAR For each parameter then a word was written to access it e g VAR PAR DAF PAR 4 ADF PAR B8 were used to get the address of the full scale values of the DAC and the ADC These definitions evolved into variables of the form PAR 4 PAR OF DAF PAR 8 PAR OF ADF where PAR OF was such that the parameters now worked with prefix operators which looked well since read access was much more common than overwriting In the course of development the number and order of parameters was changed a few times Each change required an edit of the offset literals This was not difficult but there was an awareness of something not being quite right PAR OF was replaced by underbar colon which needs no arguments It assumes it is being used in the context of a parameter list accessed via a pointer called PAR The name change of PAR to PAR reflects the change in type from VAR to PNT Not only was the readability of the parameter declarations greatly improved hereby the way was opened up for a similar improvement in parameter allocation and initialization The pointer declaration PNT was extended to mark the beginning of a data structure with subsequent parameter declarations increasing the size The word ALLOCATE used in the CREATE part of a CREATE DOES construct allots space for the parameters and makes them a
23. st _ lt name gt Define a single integer parameter variable _D lt name gt Define a double integer parameter variable ALLOCATE a Allot space for and redirect the list identified at a WHILE As in Forth 83 but REPEAT allows any number of WHILEs CASE Equivalent to OVER IF DROP C ERR n Abort in a bad case show n and error message ENDS End nested ELSEs Replaces any number of THENs but not those that bracket an IF or CASE clause without ELSE Listing 1 An implementation of the VAR SW and PNT extensions follows Address and assembler conventions are specific to this version of PDP 11 Forth CODE AVAR no op TST S 0 MOV AVAR Q4 CLR NEXT 1 aVAR SET TO 2 QVAR SET TO VAR lt name gt define an integer TO variable CREATE DOES VAR CASE 9 ELSE 1 CASE ELSE 2 CASE ELSE C ERR ENDS 12 The Journal of Forth Application and Research Volume 3 Number 4 DVAR lt name gt define a double integer TO variable CREATE DOES QVAR Q0 CASE Da ELSE 1 CASE D ELSE 2 CASE D ELSE C ERR ENDS SW a SW lt name gt define a function switch that applies to a HERE 8 pfa of word to be defined SWAP SET VAR PNT V PNT holds the address of the pointer defined with PNT V This implementation does not allow nested structures OPNT lt name gt Define a pointer to a parameter list The pointer itself when invoked by name leaves
24. t computer control can be done with lists or tables showing the hardware Camac layout Software to read and interpret such lists creates a program data base Control routines to be invoked by operator commands can then be written to act on these The option of intelligent constructs in Forth allows for a particularly elegant presentation The central notion is to treat a beam line element as an active entity characterised by configuration parameters and by the functions that are expected of it Allocation and initialization of configuration and working parameters was done in the CREATE part of a class define construct named PS and the functionality of the various command options in the DOES part 8 The Journal of Forth Application and Research Volume 3 Number 4 Functions Standard Forths define a variable as a routine that pushes an address on the stack The value located at this address may then be read by 8 or written by A suggestion by Charles Moore led to the smart variable which would return its value rather than its address unless preceded by the word TO in which case it would take on a new value from the stack 3 The word VAR is used to define such variables in this version of Forth Its implementation relies on a state variable set by TO and reset by the variable Extending this concept to our channel elements leads to software designations of elements that return a value unless told to take on a new val
25. tside of definitions ESC and are defined as follows ESC BL 33 EMIT MRITE a amp WRITE The definition for was a bit tricky since it has to cause the word in which it is used to be state sensitive but the result is satisfying it makes it easy to define some very useful words ESC makes it possible to code terminal dependent escape sequences in a format that is identical to the specification in the user s manual The effect of the sequences can be checked interactively with no need for additional definitions Camac A subaddress A in a slot N in a Camac crate is declared as an addressable entity to which a maximum of 32 I O function codes F may be applied The brevity of the routines presented in the listing derives from a number of simplifications All status is polled so interrupt handling is not necessary Direct access to the memory mapped I O page and the resulting compromise in operating system security is acceptable There is only one crate Multi branch multi crate addressing was not needed The minimum functionality required for this application a 16 bit read and a 16 bit write could be coded in a few lines The facilities provided here are used in general non interrupt Camac applications Camac error messages can optionally be directed to specific fields on the screen using the message facility defined in the terminal file The Channel The description of the channel configuration in terms that sui
26. ue by a prefix operator 5 The selection of different functions such as TO for incrementing is implemented using different values of the same state variable For power supplies the words ON OFF and RESET are treated in the same fashion as TO and TO For diagnostic purposes it is useful to change the meaning of an element s value The words DAC and ADC indicate that the power supply values are to refer to the setting of the D A converter or to the measure of the actual output current obtained through A D conversion The words AMPS and COUNTS indicate whether the values are measured in Amperes or in DAC or ADC counts When the interpretation of a value is in doubt one can always type it explicitly For example 25 AMPS TO Q1 35 TO Q2 ADC Q1 02 would check the setting of currents to the first two quadrupole magnets The words TO TO ON OFF and RESET refer to a single power supply The state variable they affect is implicitly and immediately reset The words DAC ADC COUNTS and AMPS explicitly set or reset a state and apply to any number of power supplies There are instances where one may want to issue a command for a group of power supplies For example once a tune has been established for a momentum of 30 MeV c the tune for 27 MeV c may be obtained by scaling all fields down by 10 percent Status display is another example of a command that could apply to all supplies To arrive at a tune it is necessary to sweep selected groups of m
Download Pdf Manuals
Related Search
Related Contents
Lustre 1.6 Operations Manual Doors Enterprise v5.01 User Manual - SECURI User manual & Installation GENICOM LN28 & ML280 User Manual Basler Pilot Camera User Manual WWB3/5 - Garantia 32x46,5 Session Strings Sound Set User Manual Copyright © All rights reserved.
Failed to retrieve file