Computerized point-counting with the swift mechanical point-counting stage and an easy-to-build...
-
Upload
d-brooks-mckinney -
Category
Documents
-
view
251 -
download
7
Transcript of Computerized point-counting with the swift mechanical point-counting stage and an easy-to-build...
Computers & Geosciences Vol. 19, No. 1, pp. 95-110, 1993 0098-3004/93 $6.00 + 0.00 Printed in Great Britain. All rights reserved Copyright © 1993 Pergamon Press Ltd
SHORT NOTE
COMPUTERIZED POINT-COUNTING WITH THE SWIFT MECHANICAL POINT-COUNTING STAGE AND AN
EASY-TO-BUILD SERIAL INTERFACE
D. BROOKS MCKINNEY Department of Geoscience, Hobart and William Smith Colleges, Geneva, NY 14456, U.S.A.
(Received 28 January 1992; revised 16 July 1992)
INTRODUCTION
In spite of advances in image processing, point-count- ing remains an important technique in determining rock modes. Electro-mechanical stages and count- ing/control units similar to those manufactured by the British firm James Swift (marketed in the United States by Hacker Instruments, Inc., Box 657, Fairfield, NJ 07007-0657) greatly speed point-count- ing and many geological organizations now use such systems. Although the more recent of these systems employ a digital counter to tally the modal counts, they do not produce computer-readable files. This Short Note describes an inexpensive, easy-to-build serial interface and accompanying software that allows a PC-compatible computer to control a Swift electro-mechanical stage. Computerization has several benefits: modes can be printed or saved to disk in a computer-readable format, modal analyses can be saved as files for incorporation into spread- sheets or other programs, modal counts in progress can be saved and restarted, and the computer can graph modal percent vs points counted during the counting process to estimate reliability levels.
SERIAL STAGE CONTROL UNIT
Figure 1 is a schematic of the serial stage control unit for the Swift electro-mechanical stage. This unit converts an RS-232 serial bit-stream into a voltage pulse that energizes the electro-mechanical stage's solenoid and thus advances it to the next point to be counted. B1, a full-wave silicon bridge rectifier, and capacitors C1--C3 are a voltage doubling circuit. When connected to a 12 V alternating current, this circuit produces a direct current voltage sufficient to energize the stage solenoid. LED 1 and its current- limiting resistor R1 serve as a power-on indicator. On power-up, the base of NPN transistor Q1 is not forward biased, the transistor does not conduct, and no voltage exists across the stage solenoid. RXD and GND are connected to the controlling computer's
RS-232 "Transmit Data" and "Logic Ground" lines respectively. An ASCII character sent out from the RS-232 port by the computer causes a pulsing current to pass through R3, the optoisolator integrated cir- cuit ICI, and LED 2. This current lights LED 2 as a "signal-received" indicator and causes the internal phototransistor in the optoisolator to conduct. When this phototransistor conducts, it forward biases the base of transister Q1, turning it on and so energizing the stage solenoid. Diode DI prevents damage to Q1 by current surges produced by the solenoid. Though the RS-232 bit-stream consists of several pulses, the mechanical stage is too slow to resolve these separate pulses and so it advances once for each ASCII character sent out from the computer's serial port. Experience has shown that this scheme works well for baud rates from 300 to 1200 bits per second and for a wide range of transmitted ASCII characters. The use of the optoisolator to couple the RS-232 signal to the stage control unit means that there is no direct electrical connection between the controlling com- puter and the + 12 V or higher circuits of the stage controller.
Figure 2 is the solder-side pattern of a printed circuit board for the controller and Figures 3 and 4 are photographs of a completed controller. The 12 V alternating current for the controller is supplied by a small plug-in wall transformer. Serial data enter the controller via a two-conductor cable and either a DB 9-pin or DB 25-pin connector. Pin assignments for these two types of serial connectors are given in Table 1. The controller is connected to the stage via another two-conductor cable terminated by alligator clips to attach the cable to the stage input terminals. The unit can be built in less than 2 h and requires no prior electronics experience. The cost of parts will differ with supplier, but the entire system can be built for less than $75. A circuit board, list of parts and vendors, detailed construction instructions, and diskette containing PCMODE software and docu- mentation (see next) are available from the author at nominal cost.
95
96 Short Note
RS-232
12V a.c.
D O LED 2
E ° t R2
LED 1
Stage controller schematic version 3; 1/17/92
D.B. McKinney Department of Geoscience Hobart & Wm. Smith Colleges Geneva, NY 14456
Q1
D1 O 1 Stage
solenoid
O
C1, C2 0.47 ~tF C3 47 txF R1 22 K ohm R2 470 ohm R3 1 K ohm D1 N4005 ICI 4N29 Q1 TIP31A
Figure 1. Schematic of serial stage controller. Inputs are 12 V a.c. power supply and RS-232 signals (left side of the schematic), output goes to stage solenoid (right side of schematic). R = resistor, C = capacitor, B = full-wave bridge rectifier, D = diode, Q = N P N transistor, IC = integrated circuit optoisolator, LED = light emitting diode, RXD = received data from computer's RS-232 port, GND = signal ground
connection from computer's RS-232 port.
E TAGE
t ~ . ~ 1 C3
RXD ~ R3 +
Figure 2. Solder-side printed circuit board pattern for serial stage controller (actual size). Note component polarities.
Circuit boards are available from author (see text).
A l though the software to operate the control ler is wri t ten for PC compatibles , the stage control ler is no t machine specific; it will work with any compute r tha t has an RS-232 port .
Table 1. RS-232 connector pin assignments
Circuit board DB 25-pin RS-232 DB 9-pin RS-232 terminal connector connector
"RXD" 2 3 "GND" 7 5
PCMODE: MODAL ANALYSIS SOFTWARE
P C M O D E (see Appendix) is a Tu rbo BASIC modal analysis p rogram for PC-compat ib les tha t suppor ts the serial stage controller. P C M O D E is menu-dr iven, easy to use, and largely self- explanatory. The p rog ram ' s basic funct ion is simple. It asks the user for a list of expected phases and the keyboard keys tha t will be used to represent
Figure 3. Component-side photograph of printed circuit board with components mounted. Two LEDs are on wire leads so that they can be mounted on enclosure box. Note coin for scale (diameter = 1.9 cm).
Short Note 97
ff
those phases. Then, whenever a key is pressed, the computer tallies the count for that phase, recomputes the modal percentages, and adwnces the stage. The advantage of the program lies chiefly in its input/output options. Analyses are stored on disk and previously stored files can be retrieved and the count continued, or the phase names and key assignments from a previous mode can be used as a template for a new modal analysis. During the count- ing process, modes can be printed at any point, or a plot of modal percent vs points counted (Fig. 5) can be examined to estimate reliability (Marschallinger, 1989). When an analysis is completed, it can be printed, stored as a text file, or stored in a quote and comma delimited file that can be imported into spreadsheets or database programs.
Although PCMODE was designed for use with the serial stage controller, it also can be used by itself, without an electro-mechanical stage. In this situation, PCMODE would tally the counts but the user would advance the stage manually.
REFERENCE
Figure 4. Completed stage controller unit with circuit board mounted in small plastic box. Wall transformer powers controller. Standard 9-pin female connector on two-conductor cable links controller to serial port of con- trolling computer. Another two-conductor cable terminated by alligator clips is used to connect controller to electro- mechanical stage. Note "power-on" and "signal-received"
LEDs protruding through controller box.
Marschallinger, 1989, COUNT: a BASIC program support- ing effective point-counting: Computers & Geosciences, v. 15, no. 8, p. 1335-1338.
Appendix overleaf
Opx: modal % vs data points
58
i l , I 0
Data points : total = 1266
Figure 5. Sample plot of modal percent vs number of points counted produced by PCMODE. As number of points increases, modal percent approaches steady value indicating that sufficient points have been
counted for reliable estimate of modal percent.
98 Short Note
APPENDIX
REM REM REM REM REM REM REM REM REM REM REM
PCMODE Program Lbting PCNODE, VERSION 3.2, 12/91
MODAL ANALYSIS PROGRAM TO SUPPORT SERIAL INTERFACE COMTROLER FOR THE SWIFT POINT COUNTING STAGE, wr i t ten in TURBO BASIC. D. BROOKS McKINNEY, ASSOC. PROFESSOR OF GEOSCIENCE DEPT. OF GEOSCIENCE HOBART AND WILLIAM SMITH COLLEGES GENEVA, NY 14456 (315) 781-3819
BITNET: "DBMCKBHWS" PERMISSION TO COPY AND/OR MODIFY THIS PROGPAM GRANTED TO ALL NON-PROFIT EDUCATIONAL ORGANIZATIONS
Setup:
DIM KeyCodeX(20),LabetS(20),KeyNameS(20),Count~(20) DIM MOOEN(25),ChangeN(25),TS(3500) CLS 'Opening t i t l e screen Pr int Pr int Pr int Pr int Pr int Pr int Pr int Pr int Pr int Pr int Pr int Pr int Pr int Pr int Pr int Pr int Pr int Pr int A~I I I I
While
" PQIGOE: Modal. Analysis Software"
D. Brooks McKinney m Department of Geosctence- Hobart and Will iam Smith Cottages" Geneva, NY 14456" Phone: 315-781-3819" Bi tnet : DBMCKIIHW$"
Permission to copy and use th is software granted to" e l | non-prof i t educationst i ns t i t u t i ons . "
I|
len(AS):O AS= i nkeyS
Press any key to cont inue. . . "
REM Read in MCOE.CFG conf igurat ion data and display cLs Pr int "PCMOOE PROGRAM STARTUP" On Error GoTo GeneratError Pr int Pr int "Opening PCMODE.CFG conf igurat ion f i l e . . . " REM PCMode.cfg is s f i l e ident i fy ing monitor type, default path, etc REM This f i l e must be in the same d i rectory as PSMCOE Delay 1 Open " I " , #4, "PCMocle.cf9" Pr int "PCMODE.CFG conf igurat ion data:" Line Input #4, DUlM; Line Input #4, Oum$ Pr in t Duma Input #4. ScrnZ Print ScrnX Line Input #4, Dum$ Pr int Dum$ Input #4, ForeX Pr int Fore~ Line Input #4, Dues Pr int Dum~ Input #4, BackX Pr int BeckX Line Input #4, Dum$ Pr int Oum$ Input #4, Ports Pr int Ports Line Input #4, Ound; Pr int Dum$ Line Input #4, Prt$ Pr int Prt$ Line Input #4, Dum$ Pr int Dum$ Line Input #4, Paths
Short Note 99
Print Paths For r ~ l to tan(Prt$) 'delete blanks
I f Mid$(PrtS,nX,1)<>,, - then PrinterS=PrinterSq(id$(PrtS,n~,l)
end i f next r~ For n~=l to ton(PathS) 'delete blanks
If MidS(PathS,nX,1)<>" " then P$=P$+Mid$(Psth$, n~(, 1 )
e n d i f next nX For nX=l to ton(PortS) 'delete blanks
i f Mid$(Port$,nX,1)<>" " then CPor t$=CPor t$+M | d$(Por t$,n)&, 1 )
end i f next r~ Port$=CPort$ Path$=P$ LPTs="LPT"+MidS(Printer$, 1,1)÷" :" 'Pr inter str ing CLose Print Print *'To change these values, ex i t program, use s text editor to ed i t " Print " PCMOOE.CFG and restart program." Print Print **Press any Key to Continue, CTRL+Sreek to abor t . . . " AS=**" While LOn(AS)=O 'Loop for keypress
AS= I nkeyS
CheckPr in t e r : REM To avoid possible deta-Losing crashes Later in program, make sure REM that the pr in ter is OK. See GaneratError for error handler. Print "Checking p r i n t e r . . . " Open "0", #1, LPT$ Print #1,"" CLose #1
Checkcom: REM Open corn port C$="COM'*+Por t$ Print
Print "Opening "+C$ delay 1.0
Open C$+":1200,N,8,2,DS,RS,CD" as #2 LEN:128 Start: ' I n i t i a | user distog
CLs SCREEN Scrr~ ' I f Scrr~.>2 then color functions avai lable IF scrrb'(>2 then COLOR Fore)~,BackX I f Scrn~2 then Locate 10,15 PRINT "MOOE Start-up options:" I f Scrn~2 then Locate 11,15 PRINT " 1) Get phase Labels arid set-up for a hem mode" I f Scrn~2 then Locate 12,15 PRINT " 2) Load a previously saved f i |e and continue a mode. I f Scrn~2 then Locate 13,15 PRINT " 3) Load a p r e v i o u s l y saved f i l e as a set-up for a new mode" I f ScrnZ>2 then Locate 14,15 PRINT "Enter iIJMber of desired opt ion. . . " I f Scrr~2 then Locate 15,15 INPUT "Option # ",0~ I f (OX<I) or (0~3) Then 'Check for va l id choice,
I f ScrnZ>2 then Locate 17,15 Print "Choice out of boundsl" eLoop i f not va l id I f ScrnX>2 then Locate 18,15 Print "Hi t any key to cont inue.. ." aS=InputS( 1 ) Goto start
End I f REM One of the three setup routines is executed. Each one returns REM to the main program with a l l the necessary labels and key REH assignments defined. I f 0)=1 Then
Call NewSetup etsei f 0"/,=2 then
I f StetusS="Abort" then wStatus$ iS set by GetFtte routine i f Goto Start ' there is an error Looking for a f i l e .
else ~Necessary because error handler built
lO0 Short Note
Call ContHode(Status$) end i f
else I f Stetus$="Abort" then Gate Start Call OtdSetup(Status$)
end i f REH At th is point, a l l keys are defined, ready to count
DISPLAY: Cts REH Display table on screen, write data, await keypress Print Print" Pr int" Pr int" Pr int" Pr int" Pr int" Pr int" Pr int" Print Pr int" Pr int"
HodaL Analysis: Press Appropriate Key to Count" Function Keys:"
FI: Refresh display (erase error messages)" F2: Add a new phase" F3: Print current counts and mode" F4: Plot Hode vs. Number of Points FS: Save/Print/Exit Options"
Right Arrow Key Advances Stage without Counting"
Key Phase Counts Hode Change"
Call DataOispLay *Write current data to screen REH With display on screen await a keypress, either to count REH or de a function.
GetKeyPress: *Wait for key to be pressed I($="" Whi te Len(l($)=O
K$=Inkey$ WEnd I f Len(K$)=1 then 'Len(K$)>1 for function key or arrow key CaLL CountKey(K$) 'Len(K$)=l te l ty count
I f Scrr~>2 then 'ScrnX=2 for Hercules, re , r i t e & prevent scrol l Cat L DataDispLay
else Gate Display
e n d t f ELse
Call FuncKey(KS,Act$) *Decode KS and specify Acts e n d i f I f Act$="Disptay" then GaTe Display *refresh display I f Act$:"PtotNode', then 'p lo t a mode time series
CaLi PLotMode Gate Display
e n d i f I f Act$="ExitOptions" then Gate ExitOptions
REH I f no branch to here, an error, Loop beck for another keypress Gate GetKeyPress
'F5 ex i t function key pressed to get here q4rite out ex i t menu to screen
ExitOptions: CLs Print Print Pr int" Pr int Pr int" Pr int" Pr int"
Print Pr int" Pr int" Print Pr int" Pr int" Pr int" Print Pr int" I nput"
PCHode Output/Exit Options,,
1) Print nlode." 2) Create a quote end comma delimited f i l e . " 3) Save this mode to be continued Later or used as a setup f i l e . "
4) DO another mode Nith the current setup." 5) EXIT program."
Choices 1, 2, and 3 return to this menu, 4 and 5 do not." Example: a f i l e can be saved (choice 2) and then printed " (choice 1), before exi t ing (choice 4 or 5). "
Enter desired option number..." Choice number: ";0~ 'Get choice from user
i f OX<I or 0"/.>5 then 'Check for an ok value Beop( 1 ) P r i n t " * * * * * * * * * * * * * * * * * * * * * * * * * * Print" Choice out of bounds. Pr int" PLease reenter." P r i n t " * * * * * * * * * * * * * * * * * * * * * * * * * Print" Press any Key to continue " I($=""
Short Note lOl
~qli te Lon(kS)=O~ I($= I nkey$ Wend GaTe ExttOpt | one
End I f REH Output/Exit Option branches REM PRINT NODE i f 0"/.=1 then
I f PStetus$="PrintError" then Beep 1 Print "Pr inter net ava i lab le . " delay 1
end i f I f PStetusS<>"PrintError" then Call PrintHode(PStetus$)
Gate Exi tOpt ions REH Write quote and comma f i l e ELself 0"/.=2 Then
Call QFiLe #write quote and comma delimited f i l e Gate Exi toptions
REM Save mode us a f i l e Etself O'h=3 then
Col L SereNade Gate Exi tOpt ions
REM Do a new mode with the same setup ELself 07=4 Then
CLs Print Print Print Print Print Print Print " Warningl Print " conttnuingl" Print Print " AS=.- While Len(A$)=O~ 'ket keypress, check for response AS= I nkey$
Wend I f NOt (AS="Y" Or A$="~') then Gate ExitOpttons CLs 'New sample, same setup. Get new sample data Print Print Print " New Sample Date . . . " Print Input " Enter New Sample ]D#: ",lOS Print Input " Enter New Sample Ti t le/Descr ipt ion: ",SampleS For |7,=1 to Nphases~ *CLear count array
CountX( i%)=0 next i% TotPt$7.=O eCLear totpts For i7.=1 to 3000 *CLear time series array
Ts(i~)=O next |Z Gate Display *Restart counting process
REM Exit routine Etsetf 07.=5 then *Confim ex i t ~ ex i t CLs Print Print Pr int" Confirm ExitT" Pr int" (Y tO ex i t , any other key to return)" Print A~"II While ten(A$)=O *Get keypress
As=lnkey$ wend I f AS="Y" or AS="~ then
Print Print " BYEI" Delay 0.5 Gate Ending
else Gate ExttOpt ions
'New mode dialog--dump counts but keep key assignments
Print out or save data as a f i l e before"; ~continuation l ine
Do you want to continue? (Y or N)"
'Loop back to ex i t options menu
e _ A ~ 19/I--il
102 Short Note
end i f End I f CLose #1 Goto Ending 'Skip over error handling routine
GeneratError: REM Error handling routine Cts I f Err=§7 or Err=27 then
Beep 1 CLose #1 Print ~srntng: Printer Not Respondingl- Print Print "ignore pr inter wsrning?" Print " (Y to ignore, other keys to re-check)" Print AS:m# Uht to Len(AS)=O
As=lnkey$ wend Xf (A$:"Y" or A$:"y u) then
PStatus$:"Pr t ntError" Resume CheckCoa
end i f Resume CheckPrtnter
end i f Pr|nt " Run time error= x. ERR Deep 1 Delay 1
Resume next Ending: end REM********** END OF MAIN PROGRAM
Sub DataDisptsy *Write date to screen Shared Nc I i cks~. Npheses:l. geyCode~r.( ), geyl la l$( ). CountZ( ). Scrn:i._
Change(). TotPtsX. LabelS(), |D$, SampleS. TS(). Ttae~.ActS | f (TotPtsX:O) then *kibes TotPtsX:O. zero NGOEN
For NXzl to Nphaaes~ HODEN(H'/,):O.O
Next N~, ELse
For N~I to HI:hOses, U4OOEN=MODEN(NX) *Save old value of MOI)EN NODEN(liX)mCount~(liX)/TotPts% eF|gure new value CHANGEN (N~):IOO*Abs(HODEN ( NX)- LNOOEN ) eFigure change
Next NX End i f For NY.:l to Nphases~ i f ScrnY.>2 then Locate (12+nX).5 FS= " \ \ % \ ~ ~ . . # # Print Using F$; KeyNameS(N:i).Labet$(NX),CountY.(N~)._
IO0*MGDEN (rh). CHNiGEN(liZ) Next li~ Xf ScrnY.>2 then Locate (12+nX).§ Print"Total Points Counted • ";TotPts:l ActS=.. End Sub
Sub PrtntMode(Stotue$) sprint out current mode Shared Nct| cks%. NphesesX,KeyCodeX(), ICeyllame$(), CountX(),_
Chenge(), TotPtsX, LabeLS(), IOS,sampt eS, TS(), Time%,ActS On Error Goto PrtntError Open "O",#1,"LPTI:"
Print #1,x" Print #1,"" Print #1,"" Print #1. x Modal Analysis" Print #1."Sapte# " ; Ida Prtnt #l,smpteS Print #1 ."Phase Mode" FS= " \ \ ###.##" Print #1,x For iX-1 to Npheses%
(~AWLR) u
Short Note 103
I f TotPtsX=O then Pr int #1, Using FS;LabetS(iX),O else Pr in t #1, Using F$;Labet$(iX),(CountX(iX)/TotPtsX)*lOO end i f
Next iX Pr in t #1," " Pr in t #1,"Total Po~nts Counted: ";TotPteX CLose #1 Gala EndPrint Pr intEr ,or : i f (ERR=57 or Err=27) then
CLS Seep 1 Pr int "Pr in ter not responding. Save, ex i t , and recal l to p r i n t . " Pr in t Status$='*Pr i ritE r ,or" delay 2
e n d i f EndPrint: OnError Gala GeneratError CLose #1 End Sub
Sub FuncKey(Ks,Acts) 'Decode funct ion key, and check i f va l id . I f not va l id , return ' t o main program for another keypress. I f va l id , functions: 'Fl:Updete disptay, F2:Add a new phase, F3:Prtnt current mode, 'F4: PLot Rode FS:Do ex i t rout ine. Return actS to main program. Shared NcLicksX, NphesesX, KeyCodeX(),KeyName$(),CountX(),PathS,Pstatus$,_
Change( ), TotPtsX, LabelS( ), I D$, SimpL e$, TS( ), T tmeX, Scrf~ 'Check i f va l id Ok~O CodeX=ASC(Ri ght$(K$, 1 )) | f CodeX>:59 and CocleX<--63 then OICX=I I f CocleY,=77 then OK~I I f OICX<I then
6eel)( 1 ) , r | * * . , * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * . Pr in t " That funct ion key is net defined." Pr in t " PLease press another key." pr i n t . * * * * m * * * * * * * * * * * * * * * * * * * * * : ; : ; ; ; ; : , , .
ELseif CodeX=S9 then 'F1, Update display Act$="O|sptsy ~
Etaeif CodeX=60 then 'F2, Add a phase Call AddPheses Act$="O t spt ey"
Etsei f CodeX=61 then 'F3, Pr int current mode I f PStatusSs"PrintError" then
Seep 1 Print "Pr in ter not avai lab le. " delay 1
end i f I f PStatus$<>"PrintError" then Call PrintMode(PStatus$) Acts="OispLay ~
Etsetf CodeX=62 then 'F4, Plot mode Actsu"PtotMode.
ELseif CocleX~3 then 'F5, Ex i t Options ActSa"Ext tOpt tons"
ELse Cat t MoveStage ActSu,,None-
End i f End SUB
SUB Countl(ey(KS) 'Check to see that keycode in IC$ is va l id , i f va l id , then ' t a l l y count by incrementing CountX() and advance stage to 'next point . I f not va l i d ( i . e . KS does not correspond to 'a defined key) sound beep, p r i n t error message and return ' t o main program for another keypress. Sh, red Nct I ckd, NphesesX, KeyCodelK),KeyNam$(),CounUK),_
Change(),TotPtsX, LabeLS(), IDS,Samptd,TS(),TImeX, ActS No~eyZ-1 For IX=l to NphaaesX
i f Asc(k'$)sd(eyCodeX(iX) then
104 Short Note
TotPtsX=TotPtsX+l CountX( tX):CountX( i~)+1 Ts(TotPtsX):iX XoKe~0
End I f Next iX i f Mokey'/.=l Then 'Error: not a va l id key
Beop(1 ) P r i n t fl t~t/tttt/~l~dr t~t Ikt/~ttt~t~ttt t t t k t t t * * t t t t * t t W t t * t t t t * t t el
Pr in t " That Key Hot Defined, Press correct key. r r i n t . tfrW/~tffttlalts~tkWtkWttklk/~l~W tWWttt }WWWWtWWWWWWWWWWWWWWWWW.
ELse CoL L HoveStage
End I f End SUB
SUB Me,setup 'Prompt for phase LabeLs and keys to represent phases, th is option ~used for • ne~ or d i f fe ren t setup. Shared Nc t i cksX, MphssesX, geyCodeX( ), KeyHame$( ), CountX( ), Paths ,_
Change( ), TotPtsX, LabeLS( ), ID$, SampL aS, TS( ), TimeX, ActS, ScrnX CLS Pr int Pr int Pr int Pr int Pr in t " I n i t i a l Set-Up Procedure" Pr int Pr in t " Ho~ many stage advance increments per count?" Pr int Input" Mumber of advances ( integer)? ",McLicksX Pr int Input" SampLe 19#: ",10$ Pr int Line Input " SampLe name or t i t l e : ",SampLeS Pr int Pr in t " Before s tar t ing a count you must associate s key" Pr in t " on the keypad with each phase you ~|sh to count." Pr in t " in the foLLo~ing dialog you ~ i t t be asked to enter" Pr in t " a phase Label (maximum 15 characters) and then to press. Pr in t " the keypad key that ~ i t t represent th i s phase." Pr in t " Addit ional phases can be added Later during the count i f " Pr in t " i t is necessary." Pr int Pr in t " [HPORTANT: HAKE SURE THAT *MUH LOCK e HODE FOR KEYPAD IS ONI !" Pr int Pr in t " Press any key to continue." KS="" Vht te Leo(KS):0
KS=I .keyS Wend CLS Col I AddPheses end sub
Sub AddPhsses 'Dialog with user to get Label and key assignment of a new phase to 'be added to current List of phases. Shared Mc L i cksX, MphssesX, geyCedeX( ), geyName$( ), CountX() ,_
Change( ), TotPtsX, LabeLS( ), lOS, SampLeS. TS( ), TimeX,ActS, ScrnX PheseLocp: CLo Pr int Pr int Pr int Pr int Pr int Pr int Pr in t " Adding Phases.... Pr int NphesesX=Npheses~+l Pr in t " Phase Number ";NphesesX Pr int Pr in t " Enter Phase Label (Hax 15 Char):" Pr int Input" " , LabetS(MphasesX)
Short Note i05
Pr in t P r in t " Press Keypad key to represent th is phase." KeyPad: KS="" Whi Le Lan(KS):O
KS: ! nkey$ Wend 'Check fo r dup l i ca te Key assignments For iY.=I to XphasesX
I f K$=KeyName$(i%) Then Seep( 1 ) Pr in t " t t~ t~ r ~t W ttt tt~W/t tfr W t t W t~W/~ltt Ifr W t an
Pr in t " DupLicate Keyl ! ! ! ! " Pr in t " PLease Pick Another." Pr in t " * * * * * * * * * * * * * * * * * * * * * * * Ooto Keypad
End I f Next t% KeyCode%(Npheses%):Asc(KS) t f ASC(K$):13 than
KeyName$(Nphases%) ="Ent" ELse KeyName$( Nphases%):K$ End i f Pr in t P r in t " Done adding phases?" P r in t " Press Y to return to main program;" P r in t " other keys to add another phase." KS::"" ~lhi Le Lan(KS)=O g$~Inkey$
Wend IF Not(K$="Y" or K$="y " ) then GaTe Phosetoop End sub
SUB HoveStage tSends Ncticks% number of s ignals to se r ia l port, advancing stage. Shored Ncticks%,Npheses%,KeyCode%(),KeyNmeS(),Count%(),_
Change(),TotPts%,LabeLS(),iO$,S~pLe$,TS(),Time%,ActS Move$="l" For i7.=1 to Ncticks%
Pr in t #2, Moves DeLoyO.14 next I%
End sub
SUB OtdSetup(Stotus$) 'Gets a f i l e name and re t r ieves an old setup f i l e . Re in i t i sL izes 'vaLues fo r s new count. Sets StatusS to abort i f f i l e er ror . ~Thts ts necessary to get around • TurboBssic bug that seems to 'disabLe e r ro r handler on second time through th i s or other rout ines ' t ha t caLL GetFtLeName. Shored NcL|cks%,Nphsses%,KeyCode%(),geyNme$(),Count%(),PathS,
Change(),TotPts%,LsbetS(),IDS,Sampte$,TS(),Time%,ActS~crr~ CLs Pr in t Pr in t Pr in t " Pr in t Pr in t " Pr in t " Pr in t " Pr in t " Pr in t " Pr in t " Pr in t . Pr in t CaLL ReadFiLe(Status$) CLs Pr in t Pr in t Pr in t Pr in t " Pr in t Input " Pr in t
Retr ieve an OLd Setup FiLe"
A saved modal analysis can be re t r ieved and used as" • temPLate for • new analysis. This rout ine queries " fo r • *.NO0 f i l m , and than reeds in that f i l e . You" ere asked to enter s ne~ sample |D number, t i t l e , and the" number of stage advance increments. Note that once s f i l e " has been reed In, I t may Later be modif ied in the counting" process to incLude add i t iona l phases."
Enter r u d e r of stage advance Increments per count."
Increments: ",Nct tcks%
106 Short Note
Pr in t " Enter new sample IO#." Pr in t Input " ID#: " , iD$ Pr in t Pr in t " Enter neu sample t i t L e / d e s c r i p t i o n . " Pr in t | rlput " SampLe: ",SampLeS For i~-1 to NphesesX
CountX( iX)=O next iX TotPts~O end sub
SU6 ContHode(Status$) 'Reads in s prev ious ly saved modal analysis and returns to counting eSee OtdFtte for discussion of Status$. Shared NcttcksX,NphsseeX, KeyCedeX(),geyNameS(),CountX(),Psth$,
Change(),TotPtsX, Lsbet$(),IDS, Sampte$,TS(),TimeX,ActSeScrnX Cts Pr in t Pr in t Pr in t " Continue a mode..." Pr in t Pr in t " This opt ion reads in a previously saved *.H(X) f i l e and " Pr in t " returns to the count." Pr in t CaLL ReadFiLe(Status$) end Sub
SUB Qf i te 'Writes a comma and quoteddet imted f i l e for use in a spreadsheet. 'Appends data i f f i l e a l ready ex is ts , creates i f not. Shared NcticksX,NpheeeeX, KeyCodeX(),geyNmd(),CountX(),Path$,_
Change()aTotPtsX, Lsbet$(),iDS,SampteS,TS(),TtmeX, ActS,ScrnX Cts Pr in t Pr in t Pr in t " Write *.QCD quote and comma de l imi ted f i l e . . . " Pr in t Pr in t " Pr in t " Pr in t " Pr in t " Pr in t " Pr in t FuncS:nAppencP *FiLe I/O mode CaLL GetFiteName(FiteSpecS, FuncS,Status$) Pr in t Pr in t Pr in t " Saving quote and coma dettmted f i Le as: ";FtLeSpec$ DetayO.6 Write #3, NuLLS, IDS fo r iY~,l to NphesesX
Write #3, LabetS(iX),(CountX(iX)/TotPtsX)*lO0 next iX end sub
This rout ine ~r i tes *.QCI) spreadsheet comptibte f iLe u i th " tso columns and one-more-than-the-number-of-pheses rous." The f i r s t coutusn contains phase names, the second modes.. SampLes are i nden t i f i ed by t he i r sample ID#. Writ ing to u a p re -ex is t ing f i l e appends date to i t .
SUB SsveHede 'Writes mode count data to s *.HOO tex t f i l e on disk for Later use, ' e i t h e r as s setup f i Le or to continue s mode in progress Shared Nc L i cksX, NphssesX, geyCodaX( ), geyNmeS( ), CountX(), _
Change( ) . TotPtsX, LabeLS(), l O$, Sampt e$, TS( ), TimeX,ActS, ScrnX Cts Pr in t Pr in t Pr in t Pr in t Pr in t P r in t " Pr in t P r in t " P r in t " P r in t " Pr in t m Pr in t " P r in t "
Save Node as A FiLe"
This rout ine saves the current modal analysis as a *.1400 f i l e . " This f i Le can be caLLed up Later to continue the current" nodal srmtysis, or used as a set-up f i l e . Af ter you specify ~ s f i Le name, the program displays a d i rec to ry of that name so" that you nay check fo r inadvertent overur i tes . Use of tdtdcard" f i Le specs is sttoued. Respond u i th * as f i l e name to see"
Short Note
Pr in t " a d i rec to ry . - Pr int Func~mOutput x StatusSuaOK" CaLL GetFIteName(FiteSpecS, Func$,Status$) Pr in t " Saving f i l e as: ";Fitespec$ OeLayO.6 WriteFiLe: Pr int #3,"*Modal AnaLysis Save FiLe/Do not a l te r Fornmt" Pr int #3,"SampLe IO~ I Pr int #3,1D$ Pr int #3,"SampLe TitLe/Descript ion" Pr int #3,SanlpLe$ Pr int /~5,"*Nmlber of CLicks/Move" Pr int #3,NcLtcksX Pr int #3,"*Nuld~er of Phases" Pr int #3,NplleaesX Pr int //3,.*Keytx)ard keycodes, 1 for each phase" For iX=l to NphasesX
Pr int #3,KeyCodeX(iX) Next iX Pr int #3,"*KeyHame Str ings, 1 for each phase" For iX=l to NphasesX
Pr int #3,Keytlame$(iX) Next iX Pr int #3,"*Phase Label s t r ings, 1 for each phase" For iX=l to NphasesX
Pr int #3,LabeLS(iX) Next iX Pr int //3,"*Counts par phase" For iX=l to NphasesX
Pr int #3,CountX(iZ) next iX Pr int #3,"*Time aeries date"
for ig=l to TotPtsX Pr int f/J, using "#//#.###";TS(iX)
next iX CLose#3 end sub
SUB GetFiLeNme(FiteSpecS, FuncS,Status$) 'DiaLog Nith user to get a f i l e name, check i t in directory, and ethen pass i t back to caLLing rout ine. shared PathS,ScrnX, Ftog$
NamFit:
GetOir:
Status$="OK" Pr in t " FiLe SeLect ion.. ."
107
P$=Path$ On Error Goto f iLeError FLag$="Dir" Pr in t
I f FuncS="input" then FiLeSpec$=P$+"*.HO0" 'Reed mode f i l e i f FuncSzN/q: l~' then FiLeSpac~P$+"*.QCO" eWrJte Quote Caum I f FuncS='~)utput" then FiteSpacS=P$+"*.NO0" 'Write mode f i l e Pr in t 'q)IRECTORY" Pr int p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FiLes FiteSpac$ 'Put up a d i rectory Pr in t " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "
CheckPath: Pr int Pr int " -> Current Path -->> ";P$ Pr in t Pr in t .0 Enter a new path or press RETURN to use thts path." Pr in t Input " -> New path? " , Ans$ I f ten(Ans$)>O then
! f nidS(Ans$, ten(Ans$), 1 )<>l,\. then Ard~S=Ans$+"\" PS=kns$
eta Goto 6etDt r
e n d i f Pr in t Pr in t " Enter f tLe name (no extension)." I f Func$-.Append" then
108 Short N o t e
NewName:
Pr in t " (SeLecting a f i l e that already ex is ts appends nay date)" end i f i f Func$="Output" then Pr in t " (SeLecting a f iLe that aLready ex is ts WRITES OVER d a l a i ) " end i f
Pr in t Input " -> FiLe name (no extension, blank to abort)? ",Arms i f Len(Ans$)=O then
Status$="Abort. Got. Done
end i f For n~=l to ten(AnsS) ' S t r i p out extension
i f Mid$(Ans$,n~, 1 )=" . " then Ans$=Left$(Ans$,nX- 1) next nX Pr in t I f Func$="Input" then Pr in t " Cenf lm f i l e name: " , AnsS+".HO0" e tse | f Func$="Append" then Pr in t " Cenf im f i l e name: % Ane$+".QCD" else Pr in t " Cenf im f iLe name: u, AnsS+".NO0" end i f
Pr in t P r in t " FiLe name OK? (Y to confirm)*'
P r in t " A$:-IO White ten(A$)=O
AS= ! nkey$
I f NOT (AS="Y" or AS=**),") then GoT, NewName F L ag$="Open,, I f Func$=-[nput" then FiteSpec$=P$+Ans$+".MOO" I f Func$=.Append. then Fi teSpacS=P$+krls$+n.QC9 n I f FuncS=-Output" then Fi teSpac$=PS+AnsS+-.HOO" Pr in t " FiLe seLected: "FiLespec$ deLay 0.6 CLose #3 Open Func$,#3,Fi tespec$
Got, Done Ft LeSrror:
I f FLeg$=.Dir,, end ERR=S3 then Pr in t I f Func$=-[nput. then
P r in t " No mode f iLes in th is d i r ec to r y l " Print** Try a new path or enter a bLank f i l e name to abor t . " Resume next
e lse Pr in t Pr in t " No .1400 or .OCD f iLes in th is d i r ec to r y l "
Done:
Resume next encl i f
eLsei f Ftag$="Open" and ERR:S3 then Pr in t Print** ProbLem in f iLespec. Check spaLt ingl" Pr in t P r i n t " PLease reenter.** DeLay 2 Cts Resume NamFi L e tse i f FtagS="Dir q and ERR=76 then Pr in t Print* ' No such path! PLease re-enter . " Pr in t deLay 2 Resume NamFi L ELse Pr in t " Run Time Error: **,ERR deLay 3 Resume NamFi L End I f
End SUB
SUB ReadFi te(Status$) 'This rout ine queries user for a f i Le name, checks d i rec to ry , and then
Short Note 109
,reads date |nto the progrm. I t |s called by both CentHode ,and OldSetup. Shared NcticksX, NphasesX, KeyCodeX(),geyNameS(),CountX(),_
Change(),TotPtsZ, Labet$(),IDS,SampLe$,TS(),TimeX,Act$,Scrr~ Func$="lnput" Call GetF|LeMame(F|teSpecS,FuncS,Status$) On error goto s tar t Line Input #3, Dummy$ 'Read t~o tines of t i t l e s Line zrq~t #3, oumys Input #3, I0$ Line Znput #3° Oummy$ Input #3, Samples Line Input #3, Dummy$ Input #3, Ncticks~ Line Input #3, OummyS Input #3, Npheses~ Line Input #3, DuamyS For iX=l to Xphases~
Input #3, KeyCode~(i~) next i% Line Input #3, Oume/$ For i~.=1 to HphasesX
Input #3, geyNameS(iX) next i~ Line Input #3, Oumm~ For i~=1 to Npheses%
Input #3, Labet$(i~) next i~ Line InpUt #3, D u r ~ For J~.=l to Nphases~
Input #3, Count~(i~) TotPtsX=TotPts~+Count~(i~)
next Line Input #3, Oummy$ for iX=l to TotPtsX
Input #3, TS(i~) next i~ Close#3 end sub
Sub PtotNode ~Ptot out a graph of Hode~ vs. counts for a phase. Shared NclicksX, NphasesX, KeyCode~(),KeyNameS(),CountX(),
Change(),TotPtsX, LabetS(),ID$,Sampte$,TS(),T|meX~ActS,ScrnX Dim Tptt(3500) Cts StsrtP[ot: I f Scrn~2 then Locate 3,10 Print "Enter number of phase to p l o t . . . " For r~=l to NphasesX
I f ScrnX>2 then Locate (4+n~),10 Fmt$=,, ##) -+Lebet$(r~) Print using FmtS; n~
next r~ I f ScrnY,>2 then Locate (6+nZ),lO Input "NuMber of phase to plot ",Nptt~ I f (Nptt~,>Nl=heses~ or NpltX<=O) then
6eep 1
Print "Number out of bounds. Try agafnl" Print * ********************************** Goto StartPlot
end i f Cm~=O For n ~ l to TotPts~
[ f Ts(l~)=Nplt~ thell Cun~=Cm~.+l
end i f TpL t (r~)=(Cum~nX)*100 next nX 14axP=O For n ~ l to TotPtsX I f Tptt(nX)>HaxP then
HaxP=Tplt (n,'~) end f f Next r~
~F|nd max
110 Short Note
NaxP=Ce.|L(NaXP) 'Increase for p lo t t ing I f NsxP>100 then
NexP=100 end i f cts wincloM (0,0)-(800,600) Line (100o500)- (700,100),, B DX=6OO/TotPtsX For n7.=1 to TotPtsX L ine((r~- 1 )*DX+IO0, (Tpt t (nX)*4OO/NaxP)+IO0)_
- (r~*OX+lO0,100),, BF next r~ For r ~ l to 11
ytick=((nX-1)*40)÷100 Line(90,yt ick)- (100, yt ick) t ine(700, yt |ck)- (710,yt ick)
next nX I f ScrnZ>2 then Locate 2,20 Print Labet$(Nptt~)+": Nodal Z vs. Data Points" I f ScrnT.>2 then
Locate 5,6 else For n7.=1 to 3
Print next r~
end i f Print NaxP I f ScrnT.>2 then
Locate 15,1 Print "NodeX.
end i f I f Scrn7.>2 then
Locate 26,6- else for nY.=l to 15
Print next r~
e n d i f pr int "0.0" I f ScrnX>2 then
Locate 27,20 else Print
e n d i f Print "Data Points: Total = " + S t r $ ( T o t P t s ~ ) ~ZIIII tJhi te Len(g$)=0
gS=lnkey$ Uend end sub