Multi Channel Analyser for the Amiga Host - - - - - (Non Scientists may give up here and Format the whole Disk) ######################################################################## This Programm was develloped mainly at weekends and within "long nights" to solve a very specific problem: our old MCA is going to give up its work, the IBM PC (which originally should replace it) is too stupid (or should I say the scientists are too stupid for the IBM PC ?), and the next solution (HP UNIX Workstation with VME computer) takes some time to look and buy and write programms... So, in our whole Institute (600 people) there is now exactly ONE (1!) Amiga for measurement, and this will be replaced within one or two years by a "more sophisticated" equipment. But I think this programm is too nice, and the problem so common, that it is like "throwing pearls to the sows" (as we say in german) to keep it in our Institute. So I decided to give this Programm to the Public Domain, in order to help other scientists with less money, but the same problems. The sources are NOT included, in order to have the possibility to make a "commercial" version one fine day... Copyright --------- coded by Dr. Rainer Kowallik Eisackstr. 14 1000 Berlin 62 Germany Postdoc at H A H N - M E I T N E R - I N S T I T U T GLIENICKERSTR. 100 1000 BERLIN 39 Germany This Programm may be freely redistributed, as long as no money (except a nominal copying fee) is taken. Military use is not allowed. Commercial Hardware devellopers will have to get a licenced version if they want to sell theier products together with this programm. An MCA Plug in card for the Amiga 2000 (3000) will be available at the begining of 1992 for about 2000 DM (or may be a little bit more) from Joern Ryba Computersysteme Bambergerstr. 54 1000 Berlin 30 My own computer mail address (EAN): kowallik@vax.hmi.dbp.de S=kowallik;OU=vax;P=hmi;A=dbp;C=de ########################################################################## What the Hell is this MCAah ? ------------------------------ MCAah is a programm, which serves (essentially) as computerdisplay for a Multi Channel Analyser. This particular Scietific Instrument is used to measure (for Example) Energy Spectra of gamma rays from radioactive Isotopes. But there is a whole bunch of related Applications, for which an MCA is needed (We do PAC and TDPAD with it). It is also possible (with nearly no modifications) to use MCAah as Display for Flourescence Spectroscopy or for a quadrupole massspectrometer or NMR or Moessbauer... You can display 1 dimensional spectra, where one measured value is displayed as function of one parameter. But MCAah can do (of course, since it is an Amiga programm) a little bit more for you. It serves you in pre-analysing data, and may well do the whole job (up to the title of your publication) alone, since it has an ARexx port and can so be programmed with nearly no effort. You can also add C-programms or PASCAL, or even FORTRAN programms to the external macro list. The interfaces are clean and well defined. If you don't mind, you can even take "your" (I suppose YOU would never buy such trash) IBM PC, connect it to the serial port, log in via the AUX: handler and control the whole measurement from a true compatible industry standard computer. Minimum Hardware ----------------- MCAah will run (or better creep) on an Amiga 2000 with at least 1MB Memory and two floppy drives. It will NOT run (or even creep) on an unexpanded Amiga 500. You SHOULD have at least 3 MB of Memory and a Harddisk. Best is (of course) 5 MB of Memory and an MC68030 installed, together with a fast Harddisk. Software and assignments needed ------------------------------- You will need to have RUNBACK and RUN in your c: directory. You should have assigned env: (to ram:) and lise: (to the lise directory, or at lest to the MCA directory) I recommend you to have the CShell (version 5.1) and the SKSHell and ARexx. On a System with 68030 under Kickstart 1.3 you need the SETCPU command in your c: directory to disable the cache when going to read hardware addresses. (Kickstart 2.0 offers an exec entry CacheControl(d0,d1) at offset -648. MCAah call this routine automatically) You should set the Tooltype SREEN=WORKBENCH since the requesters from the DemoHandler and SaveASCII routines will appear on the Workbenchscreen (for simplicity of programming. I could have programmed it better, but these programms are for YOU to read and not for me.) Fine, and how can I connect OUR MCA to MCAah ? ---------------------------------------------- Very simple (provided you have solved the Hardware connection) ! You will have to write a Handler (preferably in C) which must do the following tasks: 1) Read out the MCA and write the data to the Display buffer of the MCAah task. (simply an I*4 array of 8192 or 16K Elements) 2) Write back data from the Display buffer to the MCA. (or at least erasing all data, but this may be dangerous !) 3) Start the Measurement (ADC on) 4) Stop the Measurement (ADC off) 5) terminate the program Don't hesitate, there is a DemoHandler.c , which may serve as Example. This handler (if installed with HANDLER=DemoHandler in the icon Tooltypes) will reduce the efford (for the first AHA experience) even more. The DemoHandler allows you to have 5 separate "stupid" programs in RAM: which will be started to communicate with your Hardware. These programms are: RAM:MCAinit to do some initialization RAM:ReadMCA to read out the Hardware RAM:WriteMCA to write back an old spectrum RAM:ADC_ON to start a new measurement RAM:ADC_OFF to stop your measurement There are two Amiga environment variables, which you will need then: env:VKADUMP contains the Hex address of the "Display" Buffer of MCAah env:MAXSPCLEN contains the length of this buffer Attention ! The DemoHandler Errormessages will appear only on the Workbench screen ! If you decide to write a "real" handler, just write a programm to fullfill the following outline: The handler will receive 4 parameters: 1. The hex address to the I*4 buffer for the spectrum 2. The length of the buffer as set by SPCLEN 3. The hex address of the hardware as set by ADR 4. The hex address of an array of 5 APTRs The programm should then fill in the addresses of the following routines in the array: 1. Read spectrum to buffer 2. Load spectrum from buffer 3. Switch on ADC or start measurement 4. Switch off ADC or stop measurement 5. Exit Look at the DemoHandler.c programm to see how it works (it is much more simple, than it sounds here) Hardware connection ------------------- We (to tell you the truth: it was only me) connected an IBM PC plug in card to the Amiga using an ALF adapter socket. The ALF adapter was originally designed to connect an OMTI Harddisk controller to the Amiga 2000. This was a project from a german computer magazin named "c't" (They have 80% IBM articles, 10% Atari ST articles and about 5% Amiga articles. The rest goes to MacIntosh, and "the rest of the world") The main point is, that you can connect every IO based IBM XT hardware to the Amiga with very few changes (of course you will need a special adapter socket). But this works ONLY for IO based Hardware ! May be, this gives you an Idea of how it could work... How can I get my famous &%?=)/!"X$|.GRR spectra format from MCAah ------------------------------------------------------------------ This is a very simple task: You can write a programm, which will get the following 2 command line parameters: 1. The hex address of the I*4 buffer for the spectrum 2. The length of the spectrum in channels Make an entry for SAVE1 or SAVE2 in the Tooltypes (using info or Information from the Workbench menu) of MCAah.info SAVE1=Path_to_MyProg This entry will appear in the File Menu of MCAah. Again you can look at an example: SaveASCII.c will generate pure ASCII spectra files. The Requester from SaveASCII will appear only on the Workbenchscreen ! LISE Spectra format: ------------------- binary format: const byte = 0 Identifier for binary format const byte = [0,1,2] 0 for short int (16 bits) 1 for long int (32 bits) 2 for float (32 bits) short int max number of channels in spectrum char s[80] spectrum comment (ASCII text) float _tica time calibration factor short int _spare[4] for future expansion float / long / short spc[max] data Hints for operation -------------------- If you have solved all problems up to this point, I think you will be clever enough to figure out by yourself, what you can do with MCAah, and how it can be done. Some Hints: 1) A double click will move the Marker to the mousepointer position. 2) The Integral boundaries are set between click and release of the left mousebutton. Take the time, and watch out for the Display ! 3) The Data window is surrounded by 4 sliders, which change (Top) the X-Scale, (Bottom) the X-position (Left) the Y-Scale and (Right) the Y-position 4) You can change the all displayed values by clicking in the string gadget, and simply modify them. Of course, you can only change "Input" parameters. 5) Look at the menubar ! 6) You can get a Hardcopy of the actual spectrum from within the "tekamiga" window. Select "ext.macros/vector-actual" from the menubar. After the Spectrum is drawn on the tekamiga window you can select Hardcopy from the project menu of the tekamiga window. You can also save the spectrum as IFF superbitplane (for Page Stream) or as HP-GL. But the DXF and TEX entrys are dummys up to now ! 7) Known Bugs: On Kickstart 1.3 (don't come up with 1.2 !) it may happen, that my menu routines are crashing the system, when you release the right mousebutton without selecting a menu item. Kickstart 2.0 allways flashes the screen in this case. I think, this problem is too deep inside the menu creation routine as to fix it quickly. The calibrated X-scale has strange numbers. I'll fix it next time. The energy calibration is not implemented yet. Write an ARexx Macro if you need it right now, or wait until the next release. If you don't have RUN and RUNBACK in your c: directory, then you will not be able to start any external process ! MCAah may crash the system (without warning) if you don't have enough memory (e.g. for a new Window). The Tooltype Entrys in the MCAah.info file -------------------------------------------- You can set some parameters of this Program in the Icon tool types. Select the MCAah Icon and choose Info (or Information at 2.0) from the Workbench menu. Tool types and accepted values: DEMO=TRUE|FALSE|file (sets demo mode. Files are loaded) SPCLEN=8192 (sets length of spectra in channels) ADR=8f0440 (sets the hardware address of the MANY68) WAIT=0 (sets the number of empty loops for communication) PEAKDYN=20 (sets 'Peak dynamic' bigger values => smaller peaks) TICA=1.0 (sets the default time calibration) OFFSET=0.0 (sets the default constant offset) PAPER=0 (sets background color) INK=3 (sets drawing color) MARKER=1 (sets marker color) PRI=-10 (sets task priority) RATE=8 (sets update rate. >50 forces dynamic update) WARN=TRUE (sets warning flag) YAXIS=TRUE (turns y-axis on) GRID=0|1|2 (sets grid type) XSIZE=300 (sets width of display area) YSIZE=140 (sets height of display area) XADD=100 (adds display space to the right (for buttons)) YADD=100 (adds display space to the bottom (for buttons)) (If you set XADD and YADD to 0, you will get a) (sizable window without gadgets !) XPOS=30 (sets initial LeftEdge of window) YPOS=30 (sets initial TopEdge of window) MYPATH=LISE:MCAah (sets Path to program)) PORT=MCAah (sets name of AREXX port)) SCREEN=CUSTOM | WORKBENCH sets custom or workbench screen SAVE1=userprog (adds a user routine to save a spectrum in) (a foreign format. This routine will receive) (2 parameters: 1. The hex address of the I*4) (buffer for the spectrum and 2. The length) SAVE2=userprog there are only two entries ! HANDLER=prog. (set the path to the hardware handling programm.) (This will receive 4 parameter:) (1. The hex address to the I*4 buffer for the spectrum) (2. The length of the buffer as set by SPCLEN) (3. The hex address of the hardware as set by ADR) (4. The hex address of an array of 5 APTRs) (The programm should then fill in the addresses) (of the following routines in the array:) (1. Read spectrum to buffer) (2. Load spectrum from buffer) (3. Switch on ADC or start measurement) (4. Switch off ADC or stop measurement) (5. Exit) The ARexx Port -------------- The following commands can be send to the ARexx port named MCAah SAVE filename save actual spectrum to file SAVEPART from to filename save part of the actual spectrum EXIT quit MCAah LOG ON | OFF logarithmic scaling ZERO ON | OFF Zero line YSCALE ON | OFF y scale DISPMODE VECT | POIN | HIST set display mode MESSAGE string display Message in Message Window Note: Backslash is translated to LF CALIBRATION n set calibration factor OFFSET n set constant offset MARKER n set marker position NEXTPEAK set marker to next peak PREVPEAK set marker to previous peak INTEGRAL n m set integral area DISPLAYX x1 x2 set display range (horiz.) DISPLAYY y1 y2 set display range (vert.) NEWWINDOW portname xpos ypos opens a new window with Arexx port portname READSPC n returns the value at channel n READMARKER returns the value at marker position READMARKERPOS returns the marker position READINTEGRAL returns the sum as set by INTEGRAL READHEXADR returns the Buffer address in Hex READTIME returns the measurement time (or empty) READXY activates the Input Cursor and returns the coordinates: xxxxx , yyyyy READCAL returns the calibration factor READOFS returns the offset READSTRING text returns a string from the string box READFILE text returns string from fileselector box !!! The Result string is returned as Rexx Argstring AND !!! as env:RESULT AND as aztec environment variable RESULT !!! The CSHell version 5.10 was not able to handle the Rexx !!! Argstring correct. I hope, this will help you. External Macros --------------- If there is a file under MCAah.extmac This file will be processed and entries in the Menu bar will be made for 'Ext.Macro'. The file must consists of lines in the Format: NAME, CLI_command parameters options... . . . If the NAME contains a '+', then the whole spectrum is saved to RAM:TEMPSPEC before the command is executed If the NAME contains a '-', then the visible part of the spectrum is saved to RAM:TEMPSPEC before the command is executed. If '+' or '-' are not specified, the following parameters are passed to Macro (or more likely C-programm:) 1. %x address of spectrum buffer 2. %d length of spectra (maxspclen) 3. %d current marker position 4. %d start of display area 5. %d end of display area 6. %d start of integral area 7. %d end of integral area 8. %f actual calibration factor 9. %f actual offset 10. %x pointer to actual screen (struct Screen *) If you use My-Macro , c:KSH LISE:mymacro.sh as command, you can have a kshell macro in LISE:mymacro.sh which is called on menu request and can work on the actual spectrum under RAM:TEMPSPEC. Command line options (mostly for internal use !) ------------------------------------------------- possible options: -t n.m uses time calibration specified -tica n.m uses time calibration specified -offset n sets the default constant offset -load name load a spectra file into the VKA -csr prints the contents of the Control Status Register -paper n specifies background colour -ink n specifies drawing colour -marker n specifies marker colour -demo dont reads VKA, generates test spectrum -spclen n sets length of spectra in channels -slave hexadr starts only new window for buffer at address -actionflag hexadr sets an external action flag. <0 means terminate ! -wait n set number of empty loops to slow down the 68030 -peakdyn n set 'peak dynamic' bigger values => smaller peaks -adr x set HEX address of Status Register -pri n set priority of MCAah task. Default is -10 -rate n set update rate. n > 50 uses dynamic update mode. -warn On|Off sets warning flag -yaxis On|Off turns On/Off y-axis -xsize n sets width of display area -ysize n sets height of display area -xadd n adds display space to the right (for buttons) -xadd n adds display space to the bottom (for buttons) -xpos n sets x position of window -ypos n sets y position of window -mypath s sets path to program (internal use) default=%s",MyPath); -save1 s sets user routine to handle foreign formats -save2 s sets user routine to handle foreign formats -handler s sets hardware handling routine -port s sets name of AREXX port default = MCAah); -screen hexptr | CUSTOM sets a default screen pointer -info forces MCAah to read the Tooltypes in the .info file ----------------------------------------------------------------------- P.S.: Does anybody know a place in europe, where a Computerfreak AND graduated (PhD) Physicist could get a permanent position ? (preferably in Switzerland or Sweden) ?