greg_goebel_hpib_tutorial.html 223 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  4. <head>
  5. <title>A Tutorial Introduction To HPIB</title>
  6. </head>
  7. <body>
  8. <h1><a name="top">A Tutorial Introduction To HPIB</a></h1>
  9. <p>
  10. <em>v4.1 / 01 jan 99 / greg_goebel / public domain / hpib_tutorial</em>
  11. </p>
  12. <p>
  13. * This document is a tutorial introduction to the HPIB interface, covering
  14. theory and use of the HPIB from fundamental specs to instrument programming
  15. and HPIB card configuration.
  16. </p>
  17. <hr />
  18. <h1>Table Of Contents</h1>
  19. <h2><a href="#ib1_m0">[1.0] HPIB Tutor (1): Introduction</a></h2>
  20. <h2><a href="#ib2_m0">[2.0] HPIB Tutor (2): HPIB 488.1 / HPIB Fundamentals</a></h2>
  21. <ul>
  22. <li><a href="#ib2_m1">[2.1] 488.1 OVERVIEW</a>
  23. </li>
  24. <li><a href="#ib2_m2">[2.2] HPIB FUNCTIONS &amp; CAPABILITIES</a>
  25. </li>
  26. <li><a href="#ib2_m3">[2.3] HPIB SIGNAL LINES &amp; COMMANDS</a>
  27. </li>
  28. <li><a href="#ib2_m4">[2.4] HPIB ADDRESSING</a>
  29. </li>
  30. <li><a href="#ib2_m5">[2.5] HPIB COMMANDS</a>
  31. </li>
  32. <li><a href="#ib2_m6">[2.6] HPIB IN OPERATION -- AN HP BASIC EXAMPLE</a>
  33. </li>
  34. <li><a href="#ib2_m7">[2.7] HPIB IN PRACTICE</a>
  35. </li>
  36. <li><a href="#ib2_m8">[2.8] ASCII TABLE FOR HPIB</a>
  37. </li>
  38. </ul>
  39. <h2><a href="#ib3_m0">[3.0] HPIB Tutor (3): IEEE 488.2 -- Overview &amp; Data Formats</a></h2>
  40. <ul>
  41. <li><a href="#ib3_m1">[3.1] OVERVIEW</a>
  42. </li>
  43. <li><a href="#ib3_m2">[3.2] DATA CODING &amp; FORMATS</a>
  44. </li>
  45. <li><a href="#ib3_m3">[3.3] SYNTAX</a>
  46. </li>
  47. </ul>
  48. <h2><a href="#ib4_m0">[4.0] HPIB Tutor (4): 488.2 Common Commands &amp; Status</a></h2>
  49. <ul>
  50. <li><a href="#ib4_m1">[4.1] 488.2 COMMON COMMANDS &amp; STATUS OVERVIEW</a>
  51. </li>
  52. <li><a href="#ib4_m2">[4.2] ESSENTIAL COMMON COMMANDS</a>
  53. </li>
  54. <li><a href="#ib4_m3">[4.3] STATUS REPORTING</a>
  55. </li>
  56. <li><a href="#ib4_m4">[4.4] SECONDARY COMMON COMMANDS</a>
  57. </li>
  58. </ul>
  59. <h2><a href="#ib5_m0">[5.0] HPIB Tutor (5): Introduction To SCPI</a></h2>
  60. <ul>
  61. <li><a href="#ib5_m1">[5.1] SCPI OVERVIEW</a>
  62. </li>
  63. <li><a href="#ib5_m2">[5.2] SCPI COMMAND SYNTAX</a>
  64. </li>
  65. <li><a href="#ib5_m3">[5.3] EXAMPLE SCPI COMMAND SETS</a>
  66. </li>
  67. <li><a href="#ib5_m4">[5.4] SCPI DATA FORMATS</a>
  68. </li>
  69. <li><a href="#ib5_m5">[5.5] STATUS &amp; TRIGGERING</a>
  70. </li>
  71. </ul>
  72. <h2><a href="#ib6_m0">[6.0] HPIB Tutor (6): A SCPI-Based HPIB Instrument -- The 34401 DMM</a></h2>
  73. <ul>
  74. <li><a href="#ib6_m1">[6.1] 34401 OVERVIEW</a>
  75. </li>
  76. <li><a href="#ib6_m2">[6.2] PROGRAMMING THE 34401</a>
  77. </li>
  78. <li><a href="#ib6_m3">[6.3] A SIMPLE 34401 EXAMPLE PROGRAM</a>
  79. </li>
  80. </ul>
  81. <h2><a href="#ib7_m0">[7.0] HPIB Tutor (7): Notes &amp; Comments</a></h2>
  82. <ul>
  83. <li><a href="#ib7_m1">[7.1] BENCHMARKS</a>
  84. </li>
  85. <li><a href="#ib7_m2">[7.2] PASS CONTROL &amp; NON-CONTROLLER OPERATION</a>
  86. </li>
  87. </ul>
  88. <hr />
  89. <h1><a name="ib1_m0">[1.0] HPIB Tutor (1): Introduction</a></h1>
  90. <p>
  91. * This section provides a tutorial overview of the Hewlett-Packard Interface
  92. Bus (HPIB) interface system, also known as the General-Purpose Interface Bus
  93. (GPIB) or by its Institute of Electrical and Electronic Engineers (IEEE)
  94. specification number, IEEE-488. HPIB is a scheme by which groups of devices
  95. may be connected to a controlling computer and communicate under its
  96. direction. It is highly standardized and instruments from multiple vendors
  97. can be operated in the same HPIB system.
  98. </p>
  99. <p>
  100. The HPIB standard is defined at several levels:
  101. </p>
  102. <ul>
  103. <li> The original 488.1 specification defines the mechanical and electrical
  104. characteristics of the interface and its fundamental protocols.
  105. </li>
  106. <li> The 488.2 specification refines the 488.1 spec to define an acceptable
  107. minimum configuration, and adds specifications for a basic set of
  108. instrument commands and common data formats.
  109. </li>
  110. <li> The SCPI (Standard Commands for Programmable Instrumentation)
  111. specification provides a detailed description of instrument commands that
  112. can be transferred over the HPIB. Strictly speaking, the SCPI commands
  113. can be implemented on an instrument using <em>any</em> sort of interface --
  114. HPIB, serial/RS-232, VXI backplane, tins and strings, or whatever -- but
  115. they are so applicable to HPIB that no discussion of HPIB would be
  116. complete without them.
  117. </li>
  118. </ul>
  119. <p>
  120. This document is divided into modules to discuss the following topics:
  121. </p>
  122. <ul>
  123. <li> Fundamental HPIB (488-1) operation.
  124. </li>
  125. <li> 488.2 specs and data formats.
  126. </li>
  127. <li> 488.2 commands.
  128. </li>
  129. <li> SCPI commands.
  130. </li>
  131. <li> A SCPI instrument, the 34401A DMM.
  132. </li>
  133. <li> Comments on benchmarking and passing control.
  134. </li>
  135. </ul>
  136. <p>
  137. There are plenty of source materials available for these topics and I have
  138. made full use of them. Materials on 488.1 and 488.2 are derived from the HP
  139. publication A TUTORIAL DESCRIPTION OF THE HEWLETT-PACKARD INTERFACE BUS,
  140. while the SCPI material is derived from Barry Eppler's A BEGINNER'S GUIDE
  141. TO SCPI. Of course, the section on the ALF draws heavily on the 34401A
  142. manual.
  143. </p>
  144. <p>
  145. This document requires a knowledge of fundamental computer concepts and
  146. nomenclature. A small knowledge of electronics technology is also useful.
  147. Little other knowledge is assumed.
  148. </p>
  149. <p>
  150. * If you are using this document for self-study rather than reference, a
  151. few guidelines should help you make the best use of it:
  152. </p>
  153. <ul>
  154. <li> All the material on 488.1 is fundamental and very useful, except possibly
  155. for the discussion of parallel poll (one of the few features of the basic
  156. spec that is of questionable use).
  157. <p>
  158. Very careful attention should be paid to the example program, which shows
  159. how the protocols actually work in practice. The section on &quot;HPIB IN
  160. PRACTICE&quot; helps give more background on the actual environment in which
  161. HPIB is used.
  162. </p>
  163. </li>
  164. <li> The discussion of 488.2 data formats does not need to be absorbed in
  165. detail. Just read it to get a general idea of the different types of
  166. formats, and refer back to it if necessary.
  167. </li>
  168. <li> The discussion of 488.2 commands provides a core command set for modern
  169. instrument programming. Some 488.2 commands are commonly used, however,
  170. while some are not, and this module has separate sections to discuss the
  171. two classes of commands. Please pay close attention to the section on
  172. important commands, and simply skim through the section on secondary
  173. commands. The section on status and triggering should be read carefully,
  174. but you don't need to absorb it in detail.
  175. </li>
  176. <li> The discussion of SCPI and the ALF should be read carefully, but you don't
  177. need to absorb it in detail. That will come when you work on a
  178. particular instrument in practice. Tinkering with ALF programming is
  179. highly recommended, however.
  180. </li>
  181. </ul>
  182. <p>
  183. * I wrote this document out of a sense of frustration. HPIB has been a core
  184. concern of my work for many years, but at the same time I never really felt
  185. like I understood the topic through its full spectrum, in the proper balance
  186. between minor details and broad application.
  187. </p>
  188. <p>
  189. The fact that there was no document available that described HPIB all the way
  190. from the fundamental definitions up to implementations led me to want to
  191. write one myself. I wanted to not only ensure that I did in fact have an
  192. understanding of that full range, but also to spare others the roundabout
  193. path I took to get there.
  194. </p>
  195. <p>
  196. The first major version was basically a ripoff of the source materials. The
  197. second major version was a complete rewrite and reorganization of the first
  198. (that started out, ironically, as an attempt to correct a single typographic
  199. error and got <em>remarkably</em> out of hand).
  200. </p>
  201. <p>
  202. The second version is far superior to the first since it focuses on practical
  203. concepts rather than some of the (sometimes bewildering and excessive) theory
  204. devised to support the 488.2 and (in particular) SCPI specs.
  205. </p>
  206. <p>
  207. While this document is necessarily terse -- it covers a very wide range of
  208. material -- you should find it informative and (if you can get into this sort
  209. of thing) even entertaining.
  210. </p>
  211. <p>
  212. * Some of the intermediate versions of this tutorial included materials on
  213. actual programming interfaces for HPIB, and how to configure PC HPIB and GPIB
  214. cards for the PC. For various reasons, this turned out to be a clumsy
  215. organization, and so those intermediate versions evolved into three
  216. independent document: this tutorial overview; a document on programming
  217. interfaces; and a document on HPIB card configuration.
  218. </p>
  219. <hr />
  220. <h1><a name="ib2_m0">[2.0] HPIB Tutor (2): HPIB 488.1 / HPIB Fundamentals</a></h1>
  221. <p>
  222. * This module provides an overview of the fundamental HPIB specification,
  223. IEEE 488.1
  224. </p>
  225. <hr />
  226. <ul>
  227. <li>
  228. <a href="#ib2_m1">[2.1] 488.1 OVERVIEW</a>
  229. </li>
  230. <li>
  231. <a href="#ib2_m2">[2.2] HPIB FUNCTIONS &amp; CAPABILITIES</a>
  232. </li>
  233. <li>
  234. <a href="#ib2_m3">[2.3] HPIB SIGNAL LINES &amp; COMMANDS</a>
  235. </li>
  236. <li>
  237. <a href="#ib2_m4">[2.4] HPIB ADDRESSING</a>
  238. </li>
  239. <li>
  240. <a href="#ib2_m5">[2.5] HPIB COMMANDS</a>
  241. </li>
  242. <li>
  243. <a href="#ib2_m6">[2.6] HPIB IN OPERATION -- AN HP BASIC EXAMPLE</a>
  244. </li>
  245. <li>
  246. <a href="#ib2_m7">[2.7] HPIB IN PRACTICE</a>
  247. </li>
  248. <li>
  249. <a href="#ib2_m8">[2.8] ASCII TABLE FOR HPIB</a>
  250. </li>
  251. </ul>
  252. <hr />
  253. <p>
  254. <a href="#top">BACK TO INDEX </a>
  255. </p>
  256. <h2><a name="ib2_m1">[2.1] 488.1 OVERVIEW</a></h2>
  257. <p>
  258. * The Hewlett-Packard Interface Bus (HPIB) is a strictly-defined
  259. general-purpose computer interface system, in effect an external computer bus
  260. that allows interconnection of instruments and other devices to a controlling
  261. computer. General specifications of HPIB include:
  262. </p>
  263. <ul>
  264. <li> A bus configuration will consist of a single Active Controller (though on
  265. occasions several controllers may reside on the same bus and &quot;pass
  266. control&quot; among each other) and one or more devices that can be instructed
  267. to &quot;talk&quot; or &quot;listen&quot; as instructed by the controller.
  268. </li>
  269. <li> Fifteen devices may be connected to one continuous bus.
  270. </li>
  271. <li> Total transmission path lengths over the interconnecting cables does not
  272. exceed 20 meters or 2 meters per device, whichever is less (when not using
  273. a bus extension technique).
  274. </li>
  275. <li> Data rate across the interface does not exceed 1 megabyte per second.
  276. (This data rate is rarely achieved in practice.)
  277. </li>
  278. </ul>
  279. <p>
  280. Investigations for an interface system that led to the HPIB spec began in
  281. 1965, and eventually resulted in the first HPIB spec, now designated IEEE
  282. 488.1-1975. Further work and investigations led to the additional spec for
  283. common commands and data formats, designated IEEE-488.2-1987.
  284. </p>
  285. <p>
  286. There are other specifications related to IEEE-488.1. The ANSI MC1.1 spec
  287. provides a definition identical to 488.1. The IEC 625-1 and BS 6146 standards
  288. are the same as 488.1, except that they provide interconnections through a
  289. 25-pin subminiature &quot;D&quot; connection, identical to that used on serial (RS-232)
  290. interfaces. These IEC and BS standards are very little used.
  291. </p>
  292. <p>
  293. The 488.1 and related specifications cover the logical, electrical, and
  294. mechanical specs of the HPIB system. The 488.2 spec extends this definition
  295. to provide a small set of common instrument commands and specifications for
  296. data to be sent over the HPIB. A further new specification, known as SCPI
  297. (Standard Commands for Programmable Instrumentation), defines instrument
  298. command sets for use over HPIB or other interfaces. 488.2 and SCPI are
  299. discussed in later modules in this series.
  300. </p>
  301. <p>
  302. * The key specifications of IEEE 488.1 are listed below:
  303. </p>
  304. <ul>
  305. <li> Interconnected devices: Up to 15 maximum on one contiguous bus.
  306. </li>
  307. <li> Interconnection path: Star or linear (or mixed) bus network, up to 20
  308. meters total transmission path length.
  309. </li>
  310. <li> Signal lines: 16 active lines, consisting of 8 data lines and 8
  311. communications management lines.
  312. </li>
  313. <li> Message transfer scheme: Byte-serial, bit-parallel, asynchronous data
  314. transfer using an interlocking 3-wire handshake.
  315. </li>
  316. <li> Maximum data rate: 1 megabyte per second over limited distances, 250 to
  317. 500 kilobytes per second typical maximum over a full transmission path.
  318. The actual data rate is determined by the devices on the bus.
  319. </li>
  320. <li> Address capability: Primary addresses, 31 Talk and 31 Listen; secondary
  321. addresses, 961 Talk and 961 Listen. There can be a maximum of 1 Talker
  322. and up to 14 Listeners at a time on a single bus.
  323. </li>
  324. <li> Pass control: In systems with more than one controller, only one can be
  325. active at a time. The currently active controller can pass control to one
  326. of the others. A non-active controller may request control. Only the
  327. controller designated as System Controller can demand control.
  328. </li>
  329. </ul>
  330. <h2><a name="ib2_m2">[2.2] HPIB FUNCTIONS &amp; CAPABILITIES</a></h2>
  331. <p>
  332. * The operation of the HPIB can be compared to that of a committee. A
  333. committee chairman controls which member talks and implies that the others
  334. should listen. IEEE 488.1 has one device that controls, deciding who talks
  335. and who listens (under normal circumstances the controlling device will be
  336. one half of the conversation, but it doesn't have to be). Every IEEE 488.1
  337. device must be capable of performing one or more of the following interface
  338. functions:
  339. </p>
  340. <ul>
  341. <li> Listener: A device capable of receiving data over the interface when
  342. addressed to Listen by the Active Controller. Examples of such devices
  343. are printers, programmable power supplies, or any other programmable
  344. instrument. There can be up to 14 Listeners on the HPIB at one time;
  345. usually the Active Controller will be a Talker while a single device is a
  346. Listener.
  347. </li>
  348. <li> Talker: A device capable of transmitting data over the interface when
  349. addressed to Talk by the Active Controller. Examples of such devices are
  350. voltmeters, data-acquisition systems, or any other programmable
  351. instrument. There can be only one addressed Talker on the HPIB at one
  352. time. Usually the Active ontroller will be a Listener while a device is a
  353. Talker.
  354. </li>
  355. <li> Controller: A device capable of specifying the Talker and Listeners for a
  356. data or command transfer. Note that the Active Controller will be
  357. configured as Listener or Talker to support its end of the transfer.
  358. There can be only one addressed controller on the interface at one time;
  359. in multiple controller systems active control may be passed between
  360. controllers, but only one can be a master &quot;System Controller&quot;.
  361. </li>
  362. </ul>
  363. <p>
  364. The IEEE 488.1 spec defines these functions in (agonizingly) concise terms
  365. using abstract state machines labeled with rigorously-defined nomenclature.
  366. These functions are referred to as interface capabilities.
  367. </p>
  368. <p>
  369. There are other interface capabilities besides Listener, Talker, or
  370. Controller, which are also defined in the 488.1 spec as state machines.
  371. These functions are listed below, along with their abbreviations:
  372. </p>
  373. <ul>
  374. <li> Talker / Extended Talker (T / TE): Capability required for a device to
  375. Talk. Extended Talker is a Talker that supports secondary addressing.
  376. </li>
  377. <li> Listener / Extended Listener (L / LE): Capability required for a device
  378. to Listen. Extended Listener is a Listener that supports secondary
  379. addressing.
  380. </li>
  381. <li> Source Handshake (SH): Allows a device to send command or data bytes over
  382. the HPIB using the HPIB &quot;three-wire handshake&quot; (to be explained
  383. presently).
  384. </li>
  385. <li> Acceptor Handshake (AH): Allows a device to receive command or data bytes
  386. over the HPIB using the three-wire handshake.
  387. </li>
  388. <li> Remote / Local (RL): Provides the capability to switch a device between
  389. response to its front-panel controls (LOCAL) and response to commands sent
  390. over the HPIB (REMOTE).
  391. </li>
  392. <li> Service Request (SR): Allows a device to assert an interrupt, or &quot;service
  393. request&quot; (SRQ), over the HPIB to obtain service from the Active
  394. Controller.
  395. </li>
  396. <li> Parallel Poll (PP): Provides the capability for a device to identify that
  397. it needs service when the Active Controller requests such status. This
  398. particular capability is little used.
  399. </li>
  400. <li> Device Clear (DC): Allows a device to be reset. Its actions are
  401. implementation-dependent.
  402. </li>
  403. <li> Device Trigger (DT): Allows a device to be &quot;triggered&quot; by an HPIB command
  404. to perform some implementation-dependent function.
  405. </li>
  406. <li> Controller (C): Allows a device to send addresses, universal commands,
  407. and addressed commands to other devices on the HPIB. It may also include
  408. the capability to conduct polling to determine devices requiring service.
  409. </li>
  410. <li> Drivers (E): Describes the type of electrical bus drivers used in a
  411. device.
  412. </li>
  413. </ul>
  414. <p>
  415. The IEEE 488.1 spec also defines subsets of these functions, given by a
  416. number appended to the function code. The spec recommends that each device
  417. be marked near its connector with the interface capability codes for the
  418. functions the device supports.
  419. </p>
  420. <p>
  421. For example, a device with:
  422. </p>
  423. <pre><strong>
  424. Talk capability.
  425. The ability to send status bytes.
  426. Listen capability.
  427. A Listen-only mode switch.
  428. Service request capability.
  429. Full remote-local capability without local lockout.
  430. Local configuration of the parallel poll capability.
  431. Complete device clear capability.
  432. No capability for device trigger.
  433. No Controller capability.
  434. </strong></pre>
  435. <p>
  436. -- would be identified with these codes:
  437. </p>
  438. <pre><strong>
  439. SH1 AH1 T6 L3 SR1 RL2 PP2 DC1 DT0 C0 E1
  440. </strong></pre>
  441. <p>
  442. A full description of the IEEE 488.1 spec's discussion of these capabilities
  443. is far beyond the scope of this document, and is in fact generally only
  444. useful for design engineers building HPIB devices.
  445. </p>
  446. <h2><a name="ib2_m3">[2.3] HPIB SIGNAL LINES &amp; COMMANDS</a></h2>
  447. <p>
  448. * The physical interconnection system used in HPIB uses a shared-bus
  449. structure, with 16 signal lines and 8 ground lines. The bus signal lines all
  450. use a low-true logic convention, and can be grouped into 3 sets:
  451. </p>
  452. <ul>
  453. <li> data lines
  454. </li>
  455. <li> byte transfer (handshake) lines
  456. </li>
  457. <li> general bus managment lines
  458. </li>
  459. </ul>
  460. <p>
  461. The organization of the signal lines is shown below:
  462. </p>
  463. <pre><strong>
  464. DIO1 --------------------------------- -+
  465. DIO2 --------------------------------- |
  466. DIO3 --------------------------------- |
  467. DIO4 --------------------------------- | data lines
  468. DIO5 --------------------------------- |
  469. DIO6 --------------------------------- |
  470. DIO7 --------------------------------- |
  471. DIO8 --------------------------------- -+
  472. NDAC --------------------------------- -+
  473. NRFD --------------------------------- | handshake lines
  474. DAV --------------------------------- -+
  475. EOI --------------------------------- -+
  476. REN --------------------------------- |
  477. SRQ --------------------------------- | general bus management lines
  478. ATN --------------------------------- |
  479. IFC --------------------------------- -+
  480. </strong></pre>
  481. <p>
  482. The signal lines use TTL voltage levels. The pinouts are as follows:
  483. </p>
  484. <pre><strong>
  485. *
  486. * *
  487. * *
  488. SIGNAL GROUND * [24] [12] * SHIELD (to earth ground)
  489. twisted-pair ground with ATN * [23] [11] * ATN
  490. twisted-pair ground with SRQ * [22] [10] * SRQ
  491. twisted-pair ground with IFC * [21] [ 9] * IFC
  492. twisted-pair ground with NDAC * [20] [ 8] * NDAC
  493. twisted-pair ground with NRFD * [19] [ 7] * NRFD
  494. twisted-pair ground with DAV * [18] [ 6] * DAV
  495. REN * [17] [ 5] * EOI
  496. DIO8 * [16] [ 4] * DIO4
  497. DIO7 * [15] [ 3] * DIO3
  498. DIO6 * [14] [ 2] * DIO2
  499. DIO5 * [13] [ 1] * DIO1
  500. * *
  501. * *
  502. *
  503. </strong></pre>
  504. <p>
  505. The data lines allow information transfer a byte at a time. Device commands
  506. and data are often transferred as strings of ASCII characters for ease of
  507. use, while large blocks of data are often transferred as binary data for
  508. speed and compactness. The data lines are also used by the HPIB protocol to
  509. send HPIB interface commands and addresses as bytes.
  510. </p>
  511. <p>
  512. The three handshake lines are used to transfer bytes over the data lines from
  513. a source (an addressed Talker or an Active Controller) to an acceptor (an
  514. addressed Listener or all devices receiving interface commands). The byte
  515. transfer controlled by the handshake lines allows more than one device to
  516. accept bytes simultaneously, and is &quot;asynchronous&quot;: that is, the rate of
  517. byte transfer is determined both by the source and acceptor(s), and can in
  518. principle take as long as necessary. When there are multiple acceptors, the
  519. byte transfer will take place at the speed of the slowest one.
  520. </p>
  521. <p>
  522. The three handshake lines are defined as follows:
  523. </p>
  524. <ul>
  525. <li> DAV (DAta Valid): Used by the source to indicate that a byte is ready to
  526. be read.
  527. </li>
  528. <li> NRFD (Not Ready For Data): Used by acceptor to indicate that it is not
  529. ready to receive a byte.
  530. </li>
  531. <li> NDAC (Not Data Accepted): Used by the acceptor to indicate that it has
  532. not yet read the byte.
  533. </li>
  534. </ul>
  535. <p>
  536. The low-true logic of the handshake lines can be confusing. The protocol can
  537. be outlined as follows:
  538. </p>
  539. <pre><strong>
  540. 1: NRFD HIGH All acceptors ready for byte.
  541. 2: DAV LOW Source says byte is valid ...
  542. 3: NRFD LOW ... so acceptors drop NRFD line.
  543. 4: NDAC HIGH All acceptors have accepted byte ...
  544. 5: DAV HIGH ... so source raises DAV line ...
  545. 6: NDAC LOW ... and acceptors drop NDAC line.
  546. 1: NRFD HIGH All acceptors ready for next byte, cycle begins again.
  547. </strong></pre>
  548. <p>
  549. Neither NRFD nor NDAC will go high unless all acceptors make them high.
  550. This allows the speed of the byte transfer to be controlled by the slowest
  551. acceptor. <em>all</em>
  552. </p>
  553. <p>
  554. The following illustration shows the handshake in a different way:
  555. </p>
  556. <pre><strong>
  557. +---------------------------------------------------------------+
  558. | |
  559. | ....................... ........... |
  560. byte | ............ ............... |
  561. | ....................... ........... |
  562. | |
  563. | .............. .................... |
  564. DAV | : : : |
  565. | :...................: :........ |
  566. | |
  567. | ........... ........... |
  568. NRFD | : : : : : : : : |
  569. | ......:.:.: :............................:.:.: :..... |
  570. | |
  571. | ........... |
  572. NDAC | : : : : |
  573. | ..........................:.:.: :........................ |
  574. | |
  575. +-----------+--+--+-------------+--+--+------------+--+--+------+
  576. | | | | | | | | |
  577. 1 2 3 4 5 6 1 2 3
  578. </strong></pre>
  579. <p>
  580. * The five general bus management lines are used to manage the orderly flow
  581. of information over the HPIB:
  582. </p>
  583. <ul>
  584. <li> ATN (ATtentioN): The ATN line is used by the Active Controller to
  585. indicate to all the devices on the HPIB that command and address bytes are
  586. being sent. These bytes are used to address Listeners and Talkers, obtain
  587. device status, and the like. When ATN is asserted, all devices must be
  588. able to respond to it within 200 nanoseconds and cease their current HPIB
  589. operations.
  590. </li>
  591. <li> IFC (InterFace Clear): The IFC line is used by the System Controller to
  592. reset the HPIB. When IFC is asserted, all devices must respond within 100
  593. microseconds: the Talker and Listeners are unaddressed and Serial Poll is
  594. disabled.
  595. </li>
  596. <li> REN (Remote ENable): The REN line is used by the System Controller to put
  597. devices in the remote programming mode. When asserted, all Listeners are
  598. placed in remote mode when addressed to Listen.
  599. <p>
  600. The 488.1 spec was relaxed in 1987 to permit devices to ignore the state
  601. of this line, but older devices will honor it.
  602. </p>
  603. </li>
  604. <li> SRQ (Service ReQuest): The SRQ line is used by HPIB devices to interrupt
  605. the Active Controller, which then performs a Serial Poll or Parallel Poll
  606. to determine which device requested service, and why. The poll clears the
  607. SRQ.
  608. </li>
  609. <li> EOI (End Or Identify): When ATN is asserted, the EOI line is used by the
  610. Active Controller to conduct a Parallel Poll. When ATN is false, the EOI
  611. line may be used by the Talker to indicate the last byte of a stream of
  612. bytes.
  613. </li>
  614. </ul>
  615. <p>
  616. The signal lines are driven either by open-collector or tristate drivers.
  617. Maximum data rate is 250 kilobytes per second for open-collector drivers and
  618. 1 megabyte per second for tristate drivers.
  619. </p>
  620. <p>
  621. The connector for the HPIB cable allows connectors to be stacked on top of
  622. each other, to allow for daisy-chained or star connections (though the stack
  623. grows clumsy above three levels of stacking). Some specialized HPIB cables
  624. (such as those often used on personal computers, where access to I/O cards is
  625. mechanically restricted) may have a connector that does not permit stacking.
  626. </p>
  627. <p>
  628. * Note the important distinction between the operation of the HPIB when ATN
  629. is asserted and when it is released. When ATN is asserted by the Active
  630. Controller, the HPIB is in Command Mode: the Active Controller configures
  631. the HPIB or performs other control tasks. When ATN is released, the HPIB is
  632. in data mode: the addressed Talker sends bytes to the addressed Listeners.
  633. </p>
  634. <p>
  635. In Command Mode, the Active Controller sends four classes of commands:
  636. </p>
  637. <ul>
  638. <li> Talk and Listen addresses are bytes that define which device on the HPIB
  639. will be the active Talker and which will be the active Listeners. When
  640. ATN is asserted, all devices will be waiting for commands. All will
  641. receive the address bytes, and those who match those addresses will accept
  642. them.
  643. </li>
  644. <li> Universal commands are commands the Active Controller sends to <em>all</em>
  645. devices on the HPIB, and all instruments capable of reacting to the
  646. commands do so. The universal commands include five commands encoded as
  647. bytes sent over the DIO lines (&quot;multiline&quot; commands) and four commands
  648. sent using the general bus management lines (&quot;uniline&quot; commands).
  649. </li>
  650. <li> Addressed commands are byte commands similar to the universal multiline
  651. commands, except that they apply only to those devices that have been
  652. addressed.
  653. </li>
  654. <li> Secondary commands are byte commands that are always used in addition to
  655. addresses, multiline universal commands, or addressed commands (the
  656. &quot;primary commands&quot;) to add command functionality. They are used, for
  657. example, to support secondary addressing.
  658. </li>
  659. </ul>
  660. <p>
  661. In data mode (ATN released), device-dependent data (device programming
  662. command bytes, measurement data bytes, and status bytes) is transferred from
  663. the addressed Talker to the addressed Listeners. Only the addressed
  664. Listeners actually handshake the byte.
  665. </p>
  666. <p>
  667. The actual format for the device-dependent data is beyond the scope of the
  668. 488.1 spec. It can, and does, have any format desired by the device
  669. manufacturers. The 488.2 and SCPI specs have made substantial progress in
  670. clearing up this chaotic situation, however.
  671. </p>
  672. <p>
  673. * Most common operations on an HPIB consist of byte transfers between an
  674. addressed Talker and addressed Listener(s), as well as capabilities to clear
  675. devices either singly or universally, and trigger them to perform some
  676. device-dependent function. The signal lines and command set, as described
  677. above, also support some other functionality:
  678. </p>
  679. <ul>
  680. <li> A device can interrupt the Active Controller by asserting the SRQ line, as
  681. discussed above. The SRQ is a single line, however, and if there are
  682. multiple devices on the HPIB that have been configured to assert an SRQ,
  683. the Active Controller will have to &quot;poll&quot; the devices to figure out which
  684. one actually asserted the SRQ.
  685. <p>
  686. More than one device could in principle assert an SRQ at the same time.
  687. The Active Controller can poll the devices in one of two ways: serial
  688. poll or parallel poll.
  689. </p>
  690. </li>
  691. <li> In a serial poll, the Active Controller asks each device in turn to send
  692. back a status byte that indicates whether the device has asserted the SRQ.
  693. <p>
  694. Bit 6 of this byte (where the bits are numbered 0 through 7) is set if the
  695. device is requesting service. The definition of the other bits is
  696. device-dependent (under 488.1 at least; 488.2 provides a much more concise
  697. definition of the status byte).
  698. </p>
  699. <p>
  700. The Active Controller performs a serial poll by addressing the device to
  701. Talk, then sends the SPE (Serial Poll Enable) command byte. The Active
  702. Controller releases ATN, and the device returns the status byte. The
  703. Active Controller then reasserts ATN and sends the SPD (Serial Poll
  704. Disable) command byte to end the poll sequence. The Active Controller
  705. performs this same sequence with every device it needs to poll.
  706. </p>
  707. </li>
  708. <li> That makes serial poll of a large system relatively slow, so the 488.1
  709. spec also defines a parallel poll that allows multiple devices to respond
  710. simultaneously. However, this scheme is so complicated that it is almost
  711. never used. (We had an HPIB product that implemented parallel poll, but
  712. did it with an unavoidable bug. We didn't find out about it for almost
  713. three years after it was introduced.)
  714. <p>
  715. In a parallel poll, each device is assigned one of the 8 DIO lines to
  716. respond on, as well as whether to respond with a 1 or with a 0. This
  717. assignment is made by sending the PPC (Parallel Poll Configure) command
  718. byte to the addressed Listeners, followed by a PPE (Parallel Poll Enable)
  719. secondary command (which can take on a range of values large enough to
  720. encode all the response options).
  721. </p>
  722. <p>
  723. To parallel poll the devices, the Active Controller asserts the EOI and
  724. ATN lines simultaneously, and all the devices capable of responding to
  725. parallel poll put their approriate 1 or 0 on their appropriate DIO line in
  726. response. The Active Controller reads this composite byte and uses it to
  727. determine which devices have requested service.
  728. </p>
  729. <p>
  730. To disable parallel poll, the Active Controller sends a PPC command byte
  731. to the addressed Listeners, followed by a PPD (Parallel Poll Disable)
  732. secondary command byte.
  733. </p>
  734. </li>
  735. <li> It is also possible to have multiple controllers on the same HPIB. One is
  736. designated System Controller; it is the only one that has control of the
  737. IFC line. It can pass active control of the HPIB to another controller,
  738. which can pass control in turn to a third controller, and so on. The
  739. System Controller can always take back control from the Active Controller
  740. by asserting IFC to bring the HPIB back to its reset configuration.
  741. <p>
  742. The Active Controller can pass control to another controller by addressing
  743. it to Talk and then sending it the TCT (Take Control) addressed command
  744. byte. This capability is infrequently used (and tends to lead to a lot of
  745. trouble when people use it and don't understand it).
  746. </p>
  747. </li>
  748. </ul>
  749. <p>
  750. The addressing scheme and command bytes are discussed in more detail in the
  751. following sections.
  752. </p>
  753. <h2><a name="ib2_m4">[2.4] HPIB ADDRESSING</a></h2>
  754. <p>
  755. * Every 488.1 device has at least one Talk and Listen address (with the
  756. exception of freak antique devices that only Talk or Listen). A device's
  757. address is normally set at the factory, but can traditionally be changed
  758. (in older devices) by adjusting a set of DIP switches or (in more modern
  759. instruments) with front-panel inputs. Many devices display their HPIB
  760. address on power-up.
  761. </p>
  762. <p>
  763. If the device has DIP switches, they are usually arranged as follows:
  764. </p>
  765. <pre><strong>
  766. 1 2 4 8 16
  767. +---------------------------+
  768. | +-+ +-+ +-+ +-+ +-+ | 1
  769. | |X| | | |X| | | | | |
  770. | | | |X| | | |X| |X| |
  771. | +-+ +-+ +-+ +-+ +-+ | 0
  772. +---------------------------+
  773. A1 A2 A3 A4 A5
  774. </strong></pre>
  775. <p>
  776. This switch setting gives an address of 5. In nearly all cases an instrument
  777. has the same Talk and Listen address. The 488.1 spec allows them to be
  778. different, but in practice that is a useless complexity. Most modern
  779. instruments allow the user to press a button to display the current HPIB
  780. address to eliminate the need to turn the instrument around and figure out
  781. the switch settings.
  782. </p>
  783. <p>
  784. The switch settings allow the device to be set to Talk/Listen addresses from
  785. 0 to 30. The Listen address bytes are defined by adding a decimal value of 32
  786. to the address, while the Talk address bytes are defined by adding a decimal
  787. value of 64 to the address. For the example given by the switch settings
  788. above, this gives the following address bytes:
  789. </p>
  790. <pre><strong>
  791. Listen address 5 = 32 + 5 = 37 decimal = 001 00101 binary
  792. Talk address 5 = 64 + 5 = 69 decimal = 010 00101 binary
  793. </strong></pre>
  794. <p>
  795. The Talk and Listen address bytes are often referred to in documentation by
  796. the mnemonics TAD (Talk ADdress) and LAD (Listen ADdress). The full range of
  797. Talk addresses is therefore given by TAD0 through TAD30, and the full range
  798. of Listen addresses is given by LAD0 through LAD30.
  799. </p>
  800. <p>
  801. Remember that a Controller also has a Talk and Listen address to allow it to
  802. transfer bytes in data mode to other devices on the HPIB. 21 and 30 are
  803. common Controller Talk / Listen addresses in HP equipment, though it can be
  804. any address. Note that adding a device with the same address as the
  805. Controller is a common error, and can lead to baffling problems.
  806. </p>
  807. <p>
  808. The Controller's Talk and Listen address are often referred to as MTA (My
  809. Talk Address) and MLA (My Listen Address) for convenience, but there's no
  810. difference between the address format used by the Controller and by devices.
  811. Note that the Controller has to send the address bytes even when it is
  812. addressing itself!
  813. </p>
  814. <p>
  815. Note also that the address switches can physically be set to a value of 31,
  816. but that is <em>not</em> a valid HPIB address! The address byte that has the
  817. value 32 + 31 = 63 decimal is <em>not</em> LAD31, it's a special address byte
  818. called Unlisten (UNL), which tells the currently addressed Listeners to stop
  819. being Listeners, usually preparatory to addressing new Listeners.
  820. </p>
  821. <p>
  822. Similarly, the address byte that has the value 64 + 31 = 95 decimal is not
  823. TAD31, it's a special address byte called Untalk (UNT), which tells the
  824. currently addressed Talker to stop being a Talker, usually preparatory to
  825. assigning a new Talker.
  826. </p>
  827. <p>
  828. Actually Untalk is a little redundant, since sending out a new TAD will
  829. automatically Untalk the current Talker -- as there can be only one Talker at
  830. a time.
  831. </p>
  832. <p>
  833. * As noted, the 488.1 spec allows the 31-address limit to be extended to 961
  834. addresses with a &quot;secondary address&quot; byte. This byte is sent after a
  835. LAD or TAD byte and consists of the decimal value 96 added to an address in
  836. the range of 0 through 30. This secondary address byte is referred by the
  837. mnemonic SC, giving the secondary address bytes SC0 through SC31.
  838. </p>
  839. <p>
  840. There is no secondary address 31, even though that byte is not otherwise
  841. used. Apparently this convention was specified for consistency with the
  842. primary Talk/Listen address bytes.
  843. </p>
  844. <p>
  845. Secondary addresses are not normally used to allow addressing of more devices
  846. on the HPIB. As noted, the HPIB cannot accommodate more than 15 instruments
  847. under normal conditions, and the idea of a system having anywhere near 961
  848. devices is hard to take seriously. It is more often used to allow individual
  849. access to different modules in a modular instrument system, such as a VXI
  850. mainframe or data-acquisition box, which in either case consist of a chassis
  851. containing multiple plug-in cards that perform separate functions.
  852. </p>
  853. <p>
  854. There are modular devices in which different modules are selected by sending
  855. a high-level command to the mainframe in which they are plugged. Such
  856. schemes are not standardized and vary widely, but are collectively referred
  857. to as &quot;subaddressing&quot;, if only as a term of convenience. Please take care
  858. when programming a modular instrument to determine if the instrument supports
  859. secondary addressing or subaddressing.
  860. </p>
  861. <h2><a name="ib2_m5">[2.5] HPIB COMMANDS</a></h2>
  862. <p>
  863. * The five universal multiline (byte) commands are, as noted, accepted by
  864. <em>all</em> devices on the HPIB. The commands consist of:
  865. </p>
  866. <ul>
  867. <li> DCL (Device CLear): The universal DCL command causes all devices to
  868. return to a device-dependent initial state.
  869. </li>
  870. <li> LLO (Local LockOut): The LLO command disables the return-to-local front
  871. panel key on the device; the user can no longer change the device settings
  872. from its front panel.
  873. </li>
  874. <li> SPE (Serial Poll Enable): The SPE command tells the addressed Talker to
  875. return a single status byte. This status byte tells whether the device
  876. has asserted an SRQ (indicated by bit 6 set to 1).
  877. </li>
  878. <li> SPD (Serial Poll Disable): The SPD command takes the device out of
  879. serial poll mode and returns it to normal Talker activity.
  880. </li>
  881. <li> PPU (Parallel Poll Unconfigure): The PPU command resets all parallel
  882. poll devices to an idle state. As noted earlier, parallel poll is little
  883. used.
  884. </li>
  885. </ul>
  886. <p>
  887. * The four complementary uniline universal commands consist of the three
  888. general bus managements lines IFC, REN, and ATN executing their normal
  889. functions, plus the combination of EOI and ATN, which is used to conduct a
  890. parallel poll, as described earlier.
  891. </p>
  892. <p>
  893. * The addressed command bytes are only accepted by addressed devices.
  894. Whether the devices are the Listeners or the Talkers depends on the command.
  895. The five commands are as follows:
  896. </p>
  897. <ul>
  898. <li> GET (Group Execute Trigger): The GET command tells all the addressed
  899. Listeners to perform some device-dependent function, like take a
  900. measurement. GET allows for synchronizing a measurement function between
  901. multiple devices. This is only used in specialized cases.
  902. </li>
  903. <li> SDC (Selected Device Clear): The SDC command resets the addressed
  904. Listeners to a device-dependent state. It performs the same function as
  905. DCL, but only resets the addressed Listeners, not all the devices.
  906. </li>
  907. <li> GTL (Go To Local): The GTL command sets the addressed Listeners back to
  908. local mode.
  909. </li>
  910. <li> PPC (Parallel Poll Configure): The PPC command causes the addressed
  911. Listeners to be configured by the Parallel Poll Enable secondary command
  912. byte that immediately follows this byte.
  913. </li>
  914. <li> TCT (Take Control Talker): The TCT command tells the addressed Talker to
  915. become the active Controller.
  916. </li>
  917. </ul>
  918. <p>
  919. * The two secondary commands consist the PPE (Parallel Poll Enable) and PPD
  920. (Parallel Poll Disable). Both are send to the addressed Listeners after they
  921. receive the PPC byte.
  922. </p>
  923. <p>
  924. PPE actually consists of a set of commands that have the exact same values
  925. (96 plus 0 through 30) as the secondary address bytes. A PPE command byte is
  926. distinguished from the matching secondary address byte by the fact that a PPE
  927. byte follows a PPC command byte, while the secondary address byte follows a
  928. Talk or Listen address.
  929. </p>
  930. <p>
  931. PPE configures the addressed Listeners that receive it to respond to a
  932. parallel poll by setting a given DIO line to a particular polarity (1 or 0).
  933. PPD tells the addressed Listeners not to respond to a parallel poll.
  934. </p>
  935. <h2><a name="ib2_m6">[2.6] HPIB IN OPERATION -- AN HP BASIC EXAMPLE</a></h2>
  936. <p>
  937. * Now that we have considered the theoretical aspects of the 488.1
  938. specification, let's put all these details together by observing the HPIB
  939. transactions of a typical HPIB controller.
  940. </p>
  941. <p>
  942. In this case, the controller is a computer running HP's measurement-oriented
  943. HP BASIC language, connected to a 34401 digital multimeter (DMM) over HPIB.
  944. The Controller's HPIB interface is designated by a one-digit number code
  945. called an &quot;interface select code&quot;, or ISC. The default ISC is usually 7.
  946. </p>
  947. <p>
  948. The DMM is set to its default HPIB address of 22. HP BASIC locates the
  949. instrument by tacking the HPIB address onto the end of the ISC, so the DMM is
  950. identified by the number 722. The controller itself in this case has a
  951. default Talk/Listen address of 30.
  952. </p>
  953. <p>
  954. The following HP BASIC program clears the DMM, reads a DC voltage from it,
  955. prints it, serial-polls the DMM, and prints the results. The only reason
  956. that the serial poll is conducted is to give the program another thing to
  957. show off. There normally isn't any reason to do a serial poll after taking a
  958. measurement, though it is a simple way to determine if any gross instrument
  959. errors have occurred.
  960. </p>
  961. <pre><strong>
  962. 10 REAL Rdg
  963. 20 INTEGER Stat
  964. 30 ASSIGN @Dmm TO 722 ! Define DMM HPIB address.
  965. 40 CLEAR 7 ! Clear HPIB interface.
  966. 50 OUTPUT @Dmm;&quot;*RST&quot; ! Reset DMM.
  967. 60 OUTPUT @Dmm;&quot;*CLS&quot; ! Clear DMM.
  968. 70 OUTPUT @Dmm;&quot;MEASURE:VOLTAGE:DC? DEF&quot; ! Measure DC voltage.
  969. 80 ENTER @Dmm;Rdg ! Get value back.
  970. 90 PRINT &quot;Reading Value: &quot;;Rdg ! Print it.
  971. 100 Stat=SPOLL(@Dmm) ! Serial poll DMM.
  972. 110 PRINT &quot;Serial Poll status: &quot;;Stat ! Print status value.
  973. 120 END
  974. </strong></pre>
  975. <p>
  976. Let's take a look at the statements in the program in detail.
  977. </p>
  978. <p>
  979. * The first three lines simply declare variables. &quot;Rdg&quot; is a REAL variable
  980. used to store the voltage reading; &quot;Stat&quot; is an INTEGER variable used to
  981. store the status byte returned by the serial poll; and &quot;@Dmm&quot; is an &quot;I/O
  982. path&quot; or &quot;I/O handle&quot; that stores the device address of 722.
  983. </p>
  984. <p>
  985. The statement:
  986. </p>
  987. <pre><strong>
  988. CLEAR 7
  989. </strong></pre>
  990. <p>
  991. -- simply clears all the devices on the HPIB, though there's only one in this
  992. case. The HPIB operations performed are as follows:
  993. </p>
  994. <pre><strong>
  995. REN ATN : DCL
  996. </strong></pre>
  997. <p>
  998. This table and the ones that follow give the byte(s) transferred by the HP
  999. BASIC statement and the status of the bus-management lines. The 3-wire
  1000. handshake is implied in each byte transfer, and so will not be mentioned.
  1001. Just remember that each line in a table defines a single byte transfer using
  1002. the 3-wire handshake.
  1003. </p>
  1004. <p>
  1005. The right side of the table gives the byte transferred. In this case it is
  1006. the universal command byte, DCL, or Device CLear, which clears the interfaces
  1007. of the instruments on the HPIB.
  1008. </p>
  1009. <p>
  1010. The left side of this table gives the status of the three control lines REN,
  1011. ATN, and EOI. SRQ and IFC are always inactive in this sequence of examples,
  1012. so they won't be shown. REN and ATN are active, indicating a command byte, so
  1013. they are shown. EOI is inactive and is not shown.
  1014. </p>
  1015. <p>
  1016. The next statement is:
  1017. </p>
  1018. <pre><strong>
  1019. OUTPUT @Dmm;&quot;*RST&quot;
  1020. </strong></pre>
  1021. <p>
  1022. The OUTPUT statement is used by HP BASIC to send bytes over the HPIB to the
  1023. remote device, the DMM. In this example, the following bytes are sent:
  1024. </p>
  1025. <pre><strong>
  1026. REN ATN : TAD30 (MTA)
  1027. REN ATN : UNL
  1028. REN ATN : LAD22
  1029. REN : &quot;*&quot;
  1030. REN : &quot;R&quot;
  1031. REN : &quot;S&quot;
  1032. REN : &quot;T&quot;
  1033. REN : CR
  1034. REN : LF
  1035. </strong></pre>
  1036. <p>
  1037. The first three bytes are sent to set up the Controller as a Talker and the
  1038. DMM as a Listener, and then the ASCII string &quot;*RST&quot; (device Reset) is sent to
  1039. the DMM. The string is &quot;terminated&quot; by the carriage-return (CR) and line-feed
  1040. (LF) control characters -- that is, when the DMM receives the CR-LF, it
  1041. assumes that the command is complete and acts upon it.
  1042. </p>
  1043. <p>
  1044. Note how ATN is active when sending the three HPIB command bytes, and how it
  1045. is inactive when sending the instrument command string.
  1046. </p>
  1047. <p>
  1048. Another OUTPUT statement follows:
  1049. </p>
  1050. <pre><strong>
  1051. OUTPUT @Dmm;&quot;*CLS&quot;
  1052. </strong></pre>
  1053. <p>
  1054. This performs roughly the same actions as the first OUTPUT statement but
  1055. with a different string, &quot;*CLS&quot; (clear status):
  1056. </p>
  1057. <pre><strong>
  1058. REN ATN : TAD30 (MTA)
  1059. REN ATN : UNL
  1060. REN ATN : LAD22
  1061. REN : &quot;*&quot;
  1062. REN : &quot;C&quot;
  1063. REN : &quot;L&quot;
  1064. REN : &quot;S&quot;
  1065. REN : CR
  1066. REN : LF
  1067. </strong></pre>
  1068. <p>
  1069. Note that the OUTPUT statement sends the same MTA-UNL-LAD22 addressing
  1070. sequence that was sent in the previous step. In theory that is redundant --
  1071. the Controller is already the addressed Talker and the DMM is already the
  1072. addressed Listener -- and in fact there is a way in HP BASIC to eliminate the
  1073. addressing sequence, but in practice that is generally a useless
  1074. micro-efficiency.
  1075. </p>
  1076. <p>
  1077. Note also that &quot;*RST&quot; and &quot;*CLS&quot; are &quot;common commands&quot; that are defined by
  1078. the 488.2 spec. They will be discussed in more detail in a later chapter.
  1079. </p>
  1080. <p>
  1081. The question arises: why send these commands if we've already sent a DCL?
  1082. Simple answer: DCL only resets the HPIB interface on the DMM, and returning
  1083. the instrument to a completely known state requires a little more work.
  1084. </p>
  1085. <p>
  1086. The third OUTPUT statement:
  1087. </p>
  1088. <pre><strong>
  1089. OUTPUT @Dmm;&quot;MEASURE:VOLTAGE:DC? DEF&quot;
  1090. </strong></pre>
  1091. <p>
  1092. -- sends the DMM command bytes needed to tell the DMM to read a DC voltage:
  1093. </p>
  1094. <pre><strong>
  1095. REN ATN : TAD30 (MTA)
  1096. REN ATN : UNL
  1097. REN ATN : LAD22
  1098. REN : &quot;M&quot;
  1099. REN : &quot;E&quot;
  1100. REN : &quot;A&quot;
  1101. REN : &quot;S&quot;
  1102. REN : &quot;U&quot;
  1103. REN : &quot;R&quot;
  1104. REN : &quot;E&quot;
  1105. REN : &quot;:&quot;
  1106. REN : &quot;V&quot;
  1107. REN : &quot;O&quot;
  1108. REN : &quot;L&quot;
  1109. REN : &quot;T&quot;
  1110. REN : &quot;A&quot;
  1111. REN : &quot;G&quot;
  1112. REN : &quot;E&quot;
  1113. REN : &quot;:&quot;
  1114. REN : &quot;D&quot;
  1115. REN : &quot;C&quot;
  1116. REN : &quot;?&quot;
  1117. REN : &quot; &quot;
  1118. REN : &quot;D&quot;
  1119. REN : &quot;E&quot;
  1120. REN : &quot;F&quot;
  1121. REN : CR
  1122. REN : LF
  1123. </strong></pre>
  1124. <p>
  1125. Other than the string being longer, this is identical in logic to the
  1126. previous two output statements. Note that the DMM command conforms to the
  1127. SCPI command set, which will be discussed in detail in a later chapter. The
  1128. command string's meaning in this case should be obvious, except for the &quot;DEF&quot;
  1129. string, which specifies the DEFault voltage range for the DMM.
  1130. </p>
  1131. <p>
  1132. Now that the HP BASIC program has told the DMM to read the voltage using an
  1133. OUTPUT statement, the program has to read the voltage value back, using the
  1134. matching ENTER statement:
  1135. </p>
  1136. <pre><strong>
  1137. ENTER @Dmm;Rdg
  1138. </strong></pre>
  1139. <p>
  1140. This performs the actions:
  1141. </p>
  1142. <pre><strong>
  1143. REN ATN : UNL
  1144. REN ATN : LAD30 (MLA)
  1145. REN ATN : TAD22
  1146. REN : &quot;-&quot;
  1147. REN : &quot;1&quot;
  1148. REN : &quot;.&quot;
  1149. REN : &quot;4&quot;
  1150. REN : &quot;5&quot;
  1151. REN : &quot;0&quot;
  1152. REN : &quot;5&quot;
  1153. REN : &quot;2&quot;
  1154. REN : &quot;0&quot;
  1155. REN : &quot;4&quot;
  1156. REN : &quot;0&quot;
  1157. REN : &quot;E&quot;
  1158. REN : &quot;+&quot;
  1159. REN : &quot;0&quot;
  1160. REN : &quot;1&quot;
  1161. REN EOI : LF
  1162. </strong></pre>
  1163. <p>
  1164. The ENTER statement is similar to the OUTPUT statement, except that the
  1165. direction of byte transfer is reversed: the Controller is the Listener and
  1166. the DMM is the Talker. The DMM returns the voltage value as a string; the
  1167. terminator at the end of the value is a line-feed combined with assertion of
  1168. the EOI line. This particular termination scheme is defined in the 488.2
  1169. spec.
  1170. </p>
  1171. <p>
  1172. Once the program receives the voltage value back, it is printed to the
  1173. computer's display with:
  1174. </p>
  1175. <pre><strong>
  1176. PRINT &quot;Reading Value: &quot;;Rdg
  1177. </strong></pre>
  1178. <p>
  1179. The HP BASIC program then queries the DMM for serial-poll status with:
  1180. </p>
  1181. <pre><strong>
  1182. Stat=SPOLL(@Dmm)
  1183. </strong></pre>
  1184. <p>
  1185. This performs the following actions:
  1186. </p>
  1187. <pre><strong>
  1188. REN ATN : UNL
  1189. REN ATN : LAD30 (MLA)
  1190. REN ATN : TAD22
  1191. REN ATN : SPE
  1192. REN : 0
  1193. REN ATN : SPD
  1194. REN ATN : UNT
  1195. </strong></pre>
  1196. <p>
  1197. The Controller sets itself up as an addressed Listener and sets up the DMM as
  1198. an addressed Talker. The Controller then send the SPE (Serial Poll Enable)
  1199. command byte to tell the DMM to respond to the poll. The DMM returns a byte
  1200. with the value of 0 (same as the NULL character) indicating it has nothing to
  1201. report. Note that ATN is released when the poll-response byte is returned,
  1202. as only the Controller can send bytes while it is asserted. ATN is then
  1203. asserted again, the Controller sends the SPD (Serial Poll Disable) command
  1204. byte, and then UNTalks the DMM.
  1205. </p>
  1206. <p>
  1207. * This example covers the vast majority of what is in practice done by HPIB
  1208. users: it sends a command to one device and reads back a value from it, then
  1209. polls the device for errors.
  1210. </p>
  1211. <p>
  1212. To be sure, this example is oversimplified, in that instruments often return
  1213. large amounts of data. Sending numeric data in string format is
  1214. time-consuming and clumsy, so in practice large blocks of data are sometimes
  1215. sent in binary format. It would have been nice to have had the DMM assert an
  1216. SRQ, but configuring the DMM to do so is too complicated for a simple
  1217. example.
  1218. </p>
  1219. <p>
  1220. It is also appropriate in most cases to set an I/O timeout on a device in an
  1221. HP BASIC program (using the ON TIMEOUT statement) to prevent the program from
  1222. hanging if the DMM doesn't respond in the 3-wire handshake, but again, for
  1223. simplicity, this was not done.
  1224. </p>
  1225. <p>
  1226. Note that in this example, there is only one addressed Talker and one
  1227. addressed Listener. While the 488.1 spec does allow for multiple addressed
  1228. Listeners, in practice there is usually only one. No parallel poll is
  1229. performed; as noted, it is virtually never done. A pass control is not
  1230. performed; this can be a complicated procedure, and the situations that
  1231. require it are rare.
  1232. </p>
  1233. <h2><a name="ib2_m7">[2.7] HPIB IN PRACTICE</a></h2>
  1234. <p>
  1235. * After its introduction in the 1970s, HPIB was commonly used to interface
  1236. instruments, printers and plotters, and disk drives to early personal
  1237. computers and workstations. HP, not surprisingly, was strongly dedicated to
  1238. HPIB and came out with a wide range of HPIB devices that were hooked up to
  1239. dedicated BASIC-language workstation computers that often had built-in HPIB
  1240. ports.
  1241. </p>
  1242. <p>
  1243. Over time, HPIB printers, plotters, and disk drives, as well as dedicated
  1244. BASIC-language workstations, became extinct, but HPIB remained and remains
  1245. important for constructing instrumentation systems, using UNIX (tm)
  1246. workstations and (in particular) personal computers as Controllers. A
  1247. plug-in HPIB card is used to connect the controller to a benchtop or rack of
  1248. instruments; standard languages, such as C or BASIC, are generally used to
  1249. direct the system.
  1250. </p>
  1251. <p>
  1252. There are a variety of different plug-in cards available from different
  1253. vendors for different platforms, generally based on the Texas Instruments
  1254. 9920 chip or the Nippon Electric 7210 chip. National Instruments (NI)
  1255. introduced an IC of their own that can be switched to function either as the
  1256. TI chip or the NEC chip, and have used it on their own HPIB cards. The
  1257. different vendors' cards are not in general compatible at a hardware level.
  1258. </p>
  1259. <p>
  1260. For the most part, the HPIB cards are controlled by standard programming
  1261. languages such as C or BASIC, through a special library of subprogram calls
  1262. provided with the HPIB card. Traditionally, these libraries have not been
  1263. compatible, either, though NI did provide a driver for Windows named GPIB.DLL
  1264. that other vendors emulated.
  1265. </p>
  1266. <p>
  1267. HP devised their own standardized interface control library, named SICL
  1268. (Standard Instrument Control Language), and further efforts have been made to
  1269. create a &quot;universal&quot; interface control library that is supported by multiple
  1270. vendors. This universal library has the name VISA (Virtual Instrument
  1271. Standard Interface). So far, VISA has met with limited success.
  1272. </p>
  1273. <p>
  1274. The libraries are useful for writing programs to control instruments from a
  1275. controller. HPIB is very well thought-out and interfacing from a controller
  1276. to an instrument is easy.
  1277. </p>
  1278. <p>
  1279. However, it is much more difficult to use them to write a program that allows
  1280. a computer to be used as a &quot;device&quot; by a separate controller, since this
  1281. requires a low-level knowledge of the HPIB spec. An experienced programmer
  1282. will take many months to master the specs. Similarly, multiple-controller
  1283. applications are difficult to set up, and should be regarded with caution.
  1284. </p>
  1285. <p>
  1286. External HPIB interfaces are also available that plug into a parallel port.
  1287. Software drivers allow such interfaces to be accessed as if they were
  1288. directly plugged into the PC.
  1289. </p>
  1290. <p>
  1291. A particularly interesting new technology is the LAN-HPIB bridge, which is
  1292. a small box that contains a LAN and HPIB interface and allows communications
  1293. with an HPIB device over a network. With the proper software, such a
  1294. LAN-HPIB bridge can be largely transparent to software, though the user has
  1295. to remember that the LAN is a mutual-access interface and that latency times
  1296. can be long.
  1297. </p>
  1298. <p>
  1299. HPIB bus extenders are available that allow operation of HPIB systems over
  1300. long distances, using a coaxial-cable or fiber-optic link. There are also
  1301. extenders that operate as modems, allowing in principle operation over any
  1302. distance, but they are suspect since they don't always meet HPIB timing
  1303. specs.
  1304. </p>
  1305. <p>
  1306. National Instruments has defined a &quot;TNT&quot; spec extension to HPIB to
  1307. allow extremely high operation speeds, but such a claim should be regarded
  1308. skeptically: the TNT spec will only work if the remote devices support
  1309. it, and few do.
  1310. </p>
  1311. <p>
  1312. In general, maximum performance over an HPIB system is in the 100 KB to 250
  1313. KB range when performing long data transfers. In all but the most highly
  1314. optimized systems, overall program operations determines the speed, not raw
  1315. HPIB throughput. Specs for HPIB cards claiming much higher speeds should
  1316. also be regarded skeptically: such performance figures are based on
  1317. unrealistic tests, and in practice one HPIB card is just about as fast as the
  1318. other.
  1319. </p>
  1320. <h2><a name="ib2_m8">[2.8] ASCII TABLE FOR HPIB</a></h2>
  1321. <p>
  1322. * The table below gives the full standard 7-bit ASCII character set and the
  1323. values of each character in decimal (D), hexadecimal (H), and octal (0),
  1324. along with the corresponding HPIB address or command byte (if one exists).
  1325. </p>
  1326. <p>
  1327. Note that LAD0-LAD30 is abbreviated to L0-L30, and TAD0-TAD30 is abbreviated
  1328. to T0-T30. The secondary command bytes (secondary addresses and the PPE /
  1329. PPD commands) are listed in the right-hand column as SC0-SC31.
  1330. </p>
  1331. <pre><strong>
  1332. __________________________________________________________________________
  1333. ASCII Table For HPIB
  1334. __________________________________________________________________________
  1335. ch ctl cmd D H O ch cmd D H O ch cmd D H O ch cmd D H O
  1336. ___________________ ________________ ________________ __________________
  1337. NUL ^@ 0 0 0 sp L0 32 20 40 @ T0 64 40 100 ' SC0 96 60 140
  1338. SOH ^A GTL 1 1 1 ! L1 33 21 41 A T1 65 41 101 a SC1 97 61 141
  1339. STX ^B 2 2 2 &quot; L2 34 22 42 B T2 66 42 102 b SC2 98 62 142
  1340. ETX ^C 3 3 3 # L3 35 23 43 C T3 67 43 103 c SC3 99 63 143
  1341. EOT ^D SDC 4 4 4 $ L4 36 24 44 D T4 68 44 104 d SC4 100 64 144
  1342. ENQ ^E PPC 5 5 5 % L5 37 25 45 E T5 69 45 105 e SC5 101 65 145
  1343. ACK ^F 6 6 6 &amp; L6 38 26 46 F T6 70 46 106 f SC6 102 66 146
  1344. BEL ^G 7 7 7 ` L7 39 27 47 G T7 71 47 107 g SC7 103 67 147
  1345. ___________________ _______________ ________________ __________________
  1346. BS ^H GET 8 8 10 ( L8 40 28 50 H T8 72 48 110 h SC8 104 68 150
  1347. HT ^I TCT 9 9 11 ) L9 41 29 51 I T9 73 49 111 i SC9 105 69 151
  1348. LF ^J 10 a 12 * L10 42 2a 52 J T10 74 4a 112 j SC10 106 6a 152
  1349. VT ^K 11 b 13 + L11 43 2b 53 K T11 75 4b 113 k SC11 107 6b 153
  1350. FF ^L 12 c 14 , L12 44 2c 54 L T12 76 4c 114 l SC12 108 6c 154
  1351. CR ^M 13 d 15 - L13 45 2d 55 M T13 77 4d 115 m SC13 109 6d 155
  1352. SO ^N 14 e 16 . L14 46 2e 56 N T14 78 4e 116 n SC14 110 6e 156
  1353. SI ^O 15 f 17 / L15 47 2f 57 O T15 79 4f 117 o SC15 111 6f 157
  1354. ___________________ _______________ ________________ __________________
  1355. DLE ^P 16 10 20 0 L16 48 30 60 P T16 80 50 120 p SC16 112 70 160
  1356. DC1 ^Q LLO 17 11 21 1 L17 49 31 61 Q T17 81 51 121 q SC17 113 71 161
  1357. DC2 ^R 18 12 22 2 L18 50 32 62 R T18 82 52 122 r SC18 114 72 162
  1358. DC3 ^S 19 13 23 3 L19 51 33 63 S T19 83 53 123 s SC19 115 73 163
  1359. DC4 ^T DCL 20 14 24 4 L20 52 34 64 T T20 84 54 124 t SC20 116 74 164
  1360. NAK ^U PPU 21 15 25 5 L21 53 35 65 U T21 85 55 125 u SC21 117 75 165
  1361. SYN ^V 22 16 26 6 L22 54 36 66 V T22 86 56 126 v SC22 118 76 166
  1362. ETB ^W 23 17 27 7 L23 55 37 67 W T23 87 57 127 w SC23 119 77 167
  1363. ___________________ _______________ ________________ __________________
  1364. CAN ^X SPE 24 18 30 8 L24 56 38 70 X T24 88 58 130 x SC24 120 78 170
  1365. EM ^Y SPD 25 19 31 9 L25 57 39 71 Y T25 89 59 131 y SC25 121 79 171
  1366. SUB ^Z 26 1a 32 : L26 58 3a 72 Z T26 90 5a 132 z SC26 122 7a 172
  1367. ESC ^[ 27 1b 33 ; L27 59 3b 73 [ T27 91 5b 133 { SC27 123 7b 173
  1368. FS ^\ 28 1c 34 &lt; L28 60 3c 74 \ T28 92 5c 134 SC28 124 7c 174
  1369. GS ^] 29 1d 35 = L29 61 3d 75 ] T29 93 5d 135 } SC29 125 7d 175
  1370. RS ^^ 30 1e 36 &gt; L30 62 3e 76 ^ T30 94 5e 136 ~ SC30 126 7e 176
  1371. US ^_ 31 1f 37 ? UNL 63 3f 77 _ UNT 95 5f 137 DEL SC31 127 7f 177
  1372. __________________________________________________________________________
  1373. GTL Go To Local. PPU Parallel Poll Unconfigure.
  1374. SDC Selected Device Clear. SPE Serial Poll Enable.
  1375. PPC Parallel Poll Configure. SPD Serial Poll Disable.
  1376. GET Group Execute Trigger. L0-L30 Listen addresses (32+ADDR).
  1377. TCT Take Control. UNL Unlisten (= L31).
  1378. GTL Go To Local. T0-T30 Talk addresses (64+ADDR).
  1379. LLO Local Lockout. UNT Untalk (= T31).
  1380. DCL Device Clear. SC0-SC31 Secondary commands (96+ADDR).
  1381. __________________________________________________________________________
  1382. </strong></pre>
  1383. <hr />
  1384. <h1><a name="ib3_m0">[3.0] HPIB Tutor (3): IEEE 488.2 -- Overview &amp; Data Formats</a></h1>
  1385. <p>
  1386. * This chapter and the next discusses the IEEE 488.2 specification.
  1387. </p>
  1388. <hr />
  1389. <ul>
  1390. <li>
  1391. <a href="#ib3_m1">[3.1] OVERVIEW</a>
  1392. </li>
  1393. <li>
  1394. <a href="#ib3_m2">[3.2] DATA CODING &amp; FORMATS</a>
  1395. </li>
  1396. <li>
  1397. [<a href="#ib3_m3">3.3] SYNTAX</a>
  1398. </li>
  1399. </ul>
  1400. <hr />
  1401. <p>
  1402. <a href="#top">BACK TO INDEX</a>
  1403. </p>
  1404. <h2><a name="ib3_m1">[3.1] OVERVIEW</a></h2>
  1405. <p>
  1406. * The 488.1 spec addressed the fundamental problems of interconnecting
  1407. digital devices, defining the mechanical and electrical requirements and the
  1408. basic communications protocols.
  1409. </p>
  1410. <p>
  1411. Clearly that wasn't enough. Even though HPIB devices could be connected in a
  1412. mechanical, electrical, and logical fashion, that didn't guarantee that they
  1413. could communicate. Devices from different vendors had wildly differing HPIB
  1414. capability sets, and used incompatible data formats, serial-poll status
  1415. formats, and entirely different command formats.
  1416. </p>
  1417. <p>
  1418. IEEE 488.2-1987 was defined to address these problems. 488.2 provides:
  1419. </p>
  1420. <ul>
  1421. <li> A minimum required set of interface capabilities.
  1422. </li>
  1423. <li> Data formats.
  1424. </li>
  1425. <li> Device message protocols.
  1426. </li>
  1427. <li> A core common command set.
  1428. </li>
  1429. <li> A well-defined status-reporting model.
  1430. </li>
  1431. </ul>
  1432. <p>
  1433. This chapter discusses the details of data formats and protocols. The
  1434. following chapter discusses the common command set and status reporting.
  1435. </p>
  1436. <p>
  1437. * The minimum required set of interface capabilities defined by 488.2 is
  1438. given below:
  1439. </p>
  1440. <ul>
  1441. <li> Source Handshake / SH1 / Full capability.
  1442. </li>
  1443. <li> Acceptor Handshake / AH1 / Full capability.
  1444. </li>
  1445. <li> Talker / T(TE)5 or T(TE)6 / Basic Talker, serial poll, unTalk on MLA.
  1446. </li>
  1447. <li> Listener / L(LE)3 or L(LE)4 / Basic Listener, unListen on MTA.
  1448. </li>
  1449. <li> Service Request / SR1 / Full capability.
  1450. </li>
  1451. <li> Device Clear / DC1 / Full capability.
  1452. </li>
  1453. <li> Remote Local / RL0 or RL1 / None or full capability.
  1454. </li>
  1455. <li> Parallel Poll / PP0 or PP1 / None or full capability.
  1456. </li>
  1457. <li> Device Trigger / DT0 or DT1 / None or full capability.
  1458. </li>
  1459. <li> Controller / (C0 or C4) and (C5 or C7 or C8 or C11) / None or respond to
  1460. SRQ, send interface messages, pass &amp; receive control.
  1461. </li>
  1462. <li> Electrical Interface / E1 or E2 / Open collector or tristate.
  1463. </li>
  1464. </ul>
  1465. <p>
  1466. This minimum capability set states that <em>all</em> HPIB devices must be able to
  1467. send and receive data, request service, and respond to a device clear
  1468. command. It also details the minimum capabilities that a device must have
  1469. when it implements controller, parallel poll, and remote-local functions.
  1470. </p>
  1471. <p>
  1472. * 488.2 defines a set of data formats. For example, it defines a format for
  1473. binary, octal, and hexadecimal numbers, as well as formats to send long
  1474. blocks of 8-bit bytes or strings of ASCII characters. The table below lists
  1475. the supported formats:
  1476. </p>
  1477. <ul>
  1478. <li> Listener Formats
  1479. <ul>
  1480. <li> &lt;Decimal Numeric Program Data&gt; / REQUIRED
  1481. </li>
  1482. <li> &lt;Character Program Data&gt; / optional
  1483. </li>
  1484. <li> &lt;Suffix Program Data&gt; / optional
  1485. </li>
  1486. <li> &lt;Non-Decimal Numeric Program Data&gt; / optional
  1487. </li>
  1488. <li> &lt;String Program Data&gt; / optional
  1489. </li>
  1490. <li> &lt;Arbitrary Block Program Data&gt; / optional
  1491. </li>
  1492. <li> &lt;Expression Program Data&gt; / optional
  1493. </li>
  1494. </ul>
  1495. </li>
  1496. <li> Talker Formats:
  1497. <ul>
  1498. <li> &lt;NR1 Numeric Response Data&gt; / REQUIRED
  1499. </li>
  1500. <li> &lt;Arbitrary ASCII Response Data&gt; / REQUIRED
  1501. </li>
  1502. <li> &lt;Character Response Data&gt; / optional
  1503. </li>
  1504. <li> &lt;NR2 Numeric Response Data&gt; / optional
  1505. </li>
  1506. <li> &lt;NR3 Numeric Response Data&gt; / optional
  1507. </li>
  1508. <li> &lt;Hexadecimal Numeric Response Data&gt; / optional
  1509. </li>
  1510. <li> &lt;Octal Numeric Response Data&gt; / optional
  1511. </li>
  1512. <li> &lt;Binary Numeric Response Data&gt; / optional
  1513. </li>
  1514. <li> &lt;String Response Data&gt; / optional
  1515. </li>
  1516. <li> &lt;Definite Length Arbitrary Block Response Data&gt; / optional
  1517. </li>
  1518. <li> &lt;Indefinite Length Arbitrary Block Response Data&gt; / optional
  1519. </li>
  1520. <li> &lt;Expression Response Data&gt; / optional
  1521. </li>
  1522. </ul>
  1523. </li>
  1524. </ul>
  1525. <p>
  1526. 488.2 introduced a new concept that makes it possible for older devices to
  1527. communicate with devices that use this new standard: &quot;forgiving listening --
  1528. precise talking.&quot;
  1529. </p>
  1530. <p>
  1531. Forgiving listening means that a 488.2 device can accept a wide range of data
  1532. formats. Precise talking means that a 488.2 device will transmit data in a
  1533. rigorous set of formats.
  1534. </p>
  1535. <p>
  1536. * Device message protocols allow devices to communicate by defining how to
  1537. send device commands, parameters, and data. 488.2 &quot;syntax&quot; defines what to
  1538. do when a device receives multiple commands, an incomplete command, or is
  1539. interrupted while processing a command.
  1540. </p>
  1541. <p>
  1542. 488.2 also defines the protocols by which devices exchange data. For
  1543. example, it describes the order in which data is sent; requires that a device
  1544. cannot send data until commanded to do so; and specifies that when a device
  1545. receives a new command it will flush its output queue, and respond to that
  1546. command.
  1547. </p>
  1548. <h2><a name="ib3_m2">[3.2] DATA CODING &amp; FORMATS</a></h2>
  1549. <p>
  1550. * 488.2 specifies three sets of codes for operation with HPIB devices:
  1551. </p>
  1552. <ul>
  1553. <li> US ASCII 7-bit (ANSI X3.4-1977) for alphanumerics.
  1554. </li>
  1555. <li> Binary 8-bit integer.
  1556. </li>
  1557. <li> Binary floating-point codes (IEEE 32- and 64-bit floating-point codes).
  1558. </li>
  1559. </ul>
  1560. <p>
  1561. Using these codes, 488.2 defines data formats for decimal, octal, and
  1562. hexadecimal integers, decimal floating point numbers, strings, character
  1563. strings, and arbitrary strings. Most of these formats use ASCII characters
  1564. to represent the data.
  1565. </p>
  1566. <p>
  1567. In sending ASCII and 8-bit binary, the order of the bits in the byte sent
  1568. over the HPIB matches the numbering of the DIO lines. That is, bit 1 of an
  1569. ASCII character matches DIO line 1. When sending streams of bytes, the
  1570. most-significant byte in the stream is sent first.
  1571. </p>
  1572. <p>
  1573. The data formats are concisely described in 488.2 using &quot;railroad track&quot;
  1574. diagrams, which provide a flowchart of the approved order of the elements of
  1575. the data format. The detail provided by these diagrams is not necessary for
  1576. this discussion, so we will base our descriptions on a simple description and
  1577. some examples.
  1578. </p>
  1579. <p>
  1580. The device listening formats are described below. They are known as &quot;program
  1581. formats&quot; since they are used to configure the instrument, though the formats
  1582. do not necessarily define device programming commands as such.
  1583. </p>
  1584. <p>
  1585. * The &lt;Decimal Numeric Program Data&gt; format is also known as &lt;NRf&gt; for
  1586. &quot;flexible Numeric Representation&quot;. This is basically an ASCII decimal
  1587. numeric string floating-point format. Legal numbers in this scheme include:
  1588. </p>
  1589. <pre><strong>
  1590. .123
  1591. 0.123
  1592. 123.
  1593. 12.3
  1594. +12.3
  1595. -12.3
  1596. +12.3e10
  1597. -12.3E10
  1598. 12.3E+10
  1599. 12.3E-10
  1600. 12.3 E-10
  1601. 12.3 e - 10
  1602. </strong></pre>
  1603. <p>
  1604. The mantissa cannot have more than 255 characters, and the exponent must be
  1605. in the range of -32,000 to 32,000.
  1606. </p>
  1607. <p>
  1608. If a device receives an &lt;NRf&gt; of greater precision than it can handle, it
  1609. rounds off the number. Rounding ignores the sign of the number; values less
  1610. than 1/2 round down, and values greater than or equal to 1/2 round up. For
  1611. example, suppose we have an instrument that can only handle two digits;
  1612. rounding is performed as follows:
  1613. </p>
  1614. <pre><strong>
  1615. 1.3499 --&gt; 1.3
  1616. 1.35 --&gt; 1.4
  1617. -2.456 --&gt; -2.5
  1618. -2.447 --&gt; -2.4
  1619. </strong></pre>
  1620. <p>
  1621. A suffix, used to define the units and (optionally) the multipliers of the
  1622. data, may also be used with &lt;NRf&gt; data. The defined unit suffixes are as
  1623. follows:
  1624. </p>
  1625. <pre><strong>
  1626. _________________________________________________________________________
  1627. Class Preferred Suffix Allowed Suffix
  1628. _________________________________________________________________________
  1629. Ratio DB Decibel
  1630. PCT Percent
  1631. PPM Parts Per Million
  1632. Angle RAD Radian
  1633. SR Steradian
  1634. DEG Degree
  1635. GON Grade
  1636. MNT Minute of arc
  1637. SEC Second
  1638. REV Revolution
  1639. Time S Second
  1640. D Day
  1641. HR Hour
  1642. MIN Minute
  1643. ANN Year
  1644. Frequency HZ Hertz
  1645. MHZ Megahertz
  1646. Temperature CEL Degree Celsius
  1647. K Degree Kelvin
  1648. FAR Degree Fahrenheit
  1649. Length M Meter
  1650. FT Feet
  1651. IN Inch
  1652. MI Mile
  1653. NAMI Nautical Mile
  1654. ASU Astronomical Unit
  1655. PRS Parsec
  1656. Volume L Liter
  1657. Mass G Gram
  1658. TNE Tonne
  1659. Atomic Mass U Atomic Mass Unit
  1660. Energy J Joule
  1661. EV Electronvolt
  1662. Power W Watt
  1663. DBM DB On 1 Milliwatt
  1664. Force N Newton
  1665. Pressure ATM Atmosphere
  1666. INHG Inches of Mercury
  1667. PAL Pascal
  1668. TORR Torr
  1669. Fluid Pressure BAR Bar
  1670. Chemical Measure MOL Mole
  1671. Viscosity ST Stokes
  1672. P Poise
  1673. Charge C Coulomb
  1674. Current A Ampere
  1675. Potential V Volt
  1676. Resistance OHM Ohm
  1677. MOHM Megohm
  1678. Conductance SIE Siemens
  1679. Capacitance F Farad
  1680. Inductance H Henry
  1681. Luminous Intensity CD Candela
  1682. Illuminance LX Lux
  1683. Luminous Flux LM Lumen
  1684. Magnetic Induction T Tesla
  1685. Magnetic Flux WB Weber
  1686. Radioactivity BQ Becquerel
  1687. Absorbed Dose GY Gray
  1688. Dose Equivalent SV Sievert
  1689. _________________________________________________________________________
  1690. </strong></pre>
  1691. <p>
  1692. The defined multipliers are as follows:
  1693. </p>
  1694. <pre><strong>
  1695. ___________________________
  1696. exponent mnemonic name
  1697. ___________________________
  1698. 1E18 EX EXA
  1699. 1E15 PE PETA
  1700. 1E12 T TERA
  1701. 1E9 G GIGA
  1702. 1E6 MA MEGA
  1703. 1E3 K KILO
  1704. 1E-3 M MILLI
  1705. 1E-6 U MICRO
  1706. 1E-9 N NANO
  1707. 1E-12 P PICO
  1708. 1E-15 F FEMTO
  1709. 1E-18 A ATTO
  1710. ___________________________
  1711. </strong></pre>
  1712. <p>
  1713. In the latest incarnation of 488.2, &lt;Suffix Program Data&gt; may also be used on
  1714. its own, without use of a preceding &lt;NRf&gt; element.
  1715. </p>
  1716. <p>
  1717. * The &lt;Non-Decimal Numeric Program Data&gt; format is a numeric string
  1718. representation of hexadecimal, octal, and binary numbers:
  1719. </p>
  1720. <pre><strong>
  1721. #HA2F a hexadecimal A2F
  1722. #ha3e a hexadecimal a3e
  1723. #hA3f a hexadecimal A3f
  1724. #Q73 an octal 73
  1725. #q54 an octal 54
  1726. #B01101 a binary 01101
  1727. #b10010 a binary 10010
  1728. </strong></pre>
  1729. <p>
  1730. * The &lt;String Program Data&gt; format is for sending ASCII strings (using 7-bit
  1731. USASCII characters):
  1732. </p>
  1733. <pre><strong>
  1734. 'this is a legal string'
  1735. &quot;this is also a legal string&quot;
  1736. &quot;this string contains an embedded ' that is not a delimiter&quot;
  1737. 'this string contains an embedded &quot; that is not a delimiter'
  1738. &quot;this string contains an embedded &quot;&quot; that is not a delimiter&quot;
  1739. </strong></pre>
  1740. <p>
  1741. Note that the two last examples do exactly the same thing, but in different
  1742. ways.
  1743. </p>
  1744. <p>
  1745. * The &lt;Arbitrary Block Program Data&gt; spec provides a scheme for sending
  1746. binary or 8-bit ASCII) data. There are two formats: a definite-length
  1747. format and an indefinite-length format.
  1748. </p>
  1749. <p>
  1750. Both formats start with a &quot;#&quot; character to distinguish them from other
  1751. device-listening formats. In the definite-length format, the &quot;#&quot; character
  1752. is followed by:
  1753. </p>
  1754. <ul>
  1755. <li> A single ASCII digit that gives the number of ASCII digits in the field
  1756. following it.
  1757. </li>
  1758. <li> A string of ASCII digits (where the field length was defined as above)
  1759. that gives the number of data bytes to follow the field.
  1760. </li>
  1761. <li> A stream of data bytes of a length given by the field above.
  1762. </li>
  1763. </ul>
  1764. <p>
  1765. This format may be a little easier to understand with some examples (note
  1766. that &lt;DAB&gt; stands for some arbitrary data byte):
  1767. </p>
  1768. <pre><strong>
  1769. #15&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;
  1770. #213&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;
  1771. </strong></pre>
  1772. <p>
  1773. In the first example, the length field is 1 digit long and specifies 5
  1774. following data bytes. In the second example, the length field is 2 digits
  1775. long and specifies 13 following data bytes.
  1776. </p>
  1777. <p>
  1778. In the indefinite-length format, the length field evaluates to 0 and is
  1779. followed by a stream of data bytes that is terminated by a newline
  1780. (line-feed) character, along with assertion of the EOI line. (It is necessary
  1781. to use EOI because arbitrary data bytes will often evaluate to a line-feed
  1782. character, a revelation that novice I/O programmers usually find out about
  1783. the hard way.) For example:
  1784. </p>
  1785. <pre><strong>
  1786. #0&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;NL&amp;EOI
  1787. </strong></pre>
  1788. <p>
  1789. * The &lt;Expression Program Data&gt; format evaluates to a scalar, vector, matrix,
  1790. or string value. It is very general-purpose and consists solely of a
  1791. string of ASCII characters in the range of codes 32 to 126, with the
  1792. exception of 5 characters: <em>very</em>
  1793. </p>
  1794. <pre><strong>
  1795. [ &quot; ] [ # ] [ ' ] [ , ] [ ; ]
  1796. </strong></pre>
  1797. <p>
  1798. -- with the entire string enclosed in parentheses. This format basically
  1799. evaluates to ANY sequence of characters enclosed in parenthesis. It can be
  1800. considered an &quot;escape&quot; format that allows for command formats not allowed by
  1801. the rest of the 488.1 spec.
  1802. </p>
  1803. <p>
  1804. The device listening formats discussed above are very broad and forgiving.
  1805. The device talking formats are much more precise.
  1806. </p>
  1807. <p>
  1808. * The &lt;NR1 Numeric Response Data -- Integers&gt; format defines integer decimal
  1809. numbers with no decimal point or fractional part. For example:
  1810. </p>
  1811. <pre><strong>
  1812. 123
  1813. +123
  1814. -12345
  1815. </strong></pre>
  1816. <p>
  1817. * The &lt;NR2 Numeric Response Data -- Fixed Point&gt; format defines decimal
  1818. numbers with a fractional part but no exponent. For example:
  1819. </p>
  1820. <pre><strong>
  1821. 12.3
  1822. +1.234
  1823. -0.12345
  1824. </strong></pre>
  1825. <p>
  1826. * The &lt;NR3 Numeric Response Data -- Floating Point&gt; format defines decimal
  1827. numbers with a fractional part and an exponent. For example:
  1828. </p>
  1829. <pre><strong>
  1830. 1.23E+5
  1831. 123.4E-56
  1832. -12345.678E+90
  1833. </strong></pre>
  1834. <p>
  1835. * The &lt;Hexadecimal Numeric Response Data&gt; format is exactly the same as the
  1836. listening format for hex numbers, except that lowercase letters are not
  1837. allowed. For example:
  1838. </p>
  1839. <pre><strong>
  1840. #HAD0E
  1841. #H01F2
  1842. #HF3B
  1843. </strong></pre>
  1844. <p>
  1845. * The &lt;Octal Numeric Response Data&gt; format is exactly the same as the
  1846. listening format for octal numbers, except that lowercase letters are not
  1847. allowed. For example:
  1848. </p>
  1849. <pre><strong>
  1850. #Q7035
  1851. #Q30572
  1852. #Q765432
  1853. </strong></pre>
  1854. <p>
  1855. * The &lt;Binary Numeric Response Data&gt; format is exactly the same as the
  1856. listening format for binary numbers, except that lowercase letters are not
  1857. allowed. For example:
  1858. </p>
  1859. <pre><strong>
  1860. #B01101
  1861. #B10101010
  1862. #B1011
  1863. </strong></pre>
  1864. <p>
  1865. * The &lt;Character Response Data&gt; format defines the means by which mnemonic
  1866. strings are sent between devices. These strings contain only ASCII numeric
  1867. digits, upper-case ASCII alphabetic characters, and the &quot;_&quot; character. They
  1868. must start with an upper-case ASCII alphabetic character, and cannot be more
  1869. than 12 characters long. For example:
  1870. </p>
  1871. <pre><strong>
  1872. START
  1873. R2_D2
  1874. </strong></pre>
  1875. <p>
  1876. * The &lt;String Response Data&gt; format defines how a device sends an arbitrary
  1877. text string. It is the same as the listening format, except that
  1878. double-quotes are legal characters but single-quotes are not. For example:
  1879. </p>
  1880. <pre><strong>
  1881. &quot;You say hello&quot;
  1882. &quot;I say &quot;&quot;Goodbye&quot;&quot;.&quot;
  1883. </strong></pre>
  1884. <p>
  1885. * The &lt;Definite Length Arbitrary Block Response Data&gt; format is for sending
  1886. binary data of a specified length. It is exactly the same as the listening
  1887. format:
  1888. </p>
  1889. <pre><strong>
  1890. #3128&lt;DAB1&gt;&lt;DAB2&gt;&lt;DAB3&gt; ... &lt;DAB128&gt;
  1891. </strong></pre>
  1892. <p>
  1893. * The &lt;Indefinite Length Arbitrary Block Response Data&gt; format is for sending
  1894. binary data of an unspecified length. It is exactly the same as the listening
  1895. format:
  1896. </p>
  1897. <pre><strong>
  1898. #0&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;&lt;DAB&gt;NL&amp;EOI
  1899. </strong></pre>
  1900. <p>
  1901. * The &lt;Arbitrary ASCII Response Data&gt; format allows a device to respond with
  1902. undelimited ASCII text. It consists of a stream of ASCII bytes terminated by
  1903. a newline-with-EOI. This is a very general (and somewhat ill-defined)
  1904. format -- note that it allows for responses that could easily be confused for
  1905. other response types -- and its use is discouraged. <em>very</em>
  1906. </p>
  1907. <p>
  1908. * The &lt;Expression Response Data&gt; format is the response counterpart to the
  1909. &lt;Expression Program Data&gt; type. It is also general-purpose and consists
  1910. solely of a string of ASCII characters in the range of codes 32 to 126, with
  1911. the exception of 5 characters:
  1912. </p>
  1913. <pre><strong>
  1914. [ &quot; ] [ # ] [ ' ] [ , ] [ ; ]
  1915. </strong></pre>
  1916. <p>
  1917. -- with the entire string enclosed in parentheses. Like the response data
  1918. format, this format is used to cover any format not otherwise covered in the
  1919. 488.2 spec.
  1920. </p>
  1921. <h2><a name="ib3_m3">[3.3] SYNTAX</a></h2>
  1922. <p>
  1923. * In the previous section we discussed the data formats defined by 488.2 --
  1924. the &quot;words&quot; of the &quot;language&quot;, so to speak. In this section we move up from
  1925. simple &quot;words&quot; to the syntax that provides a framework for those &quot;words&quot;.
  1926. </p>
  1927. <p>
  1928. As with the data formats, the syntax that a device will recognize is much
  1929. less precise than the syntax that it will generate -- &quot;forgiving listening,
  1930. precise talking&quot; again.
  1931. </p>
  1932. <p>
  1933. * The elements of listening syntax fall into the following categories:
  1934. </p>
  1935. <ul>
  1936. <li> Terminators
  1937. </li>
  1938. <li> Separators
  1939. </li>
  1940. <li> Commands
  1941. </li>
  1942. <li> Queries
  1943. </li>
  1944. </ul>
  1945. <p>
  1946. There is only one form of terminator. The &lt;Program Message Terminator&gt;
  1947. defines how to terminate a message to a listening device. There are three
  1948. possible terminators:
  1949. </p>
  1950. <ul>
  1951. <li> A newline.
  1952. </li>
  1953. <li> A newline with EOI.
  1954. </li>
  1955. <li> An EOI.
  1956. </li>
  1957. </ul>
  1958. <p>
  1959. A terminator is also sometimes informally referred to as an &quot;arnold&quot;, but
  1960. this usage is clearly outside of the 488.2 spec.
  1961. </p>
  1962. <p>
  1963. * Separators fall into three categories. The &lt;Program Message Separator&gt; is
  1964. just a &quot;;&quot; (semicolon), and is placed between commands in a single message to
  1965. create a complex command.
  1966. </p>
  1967. <p>
  1968. The &lt;Program Header Separator&gt; is just blank (&quot;white&quot;) space, and is used to
  1969. separate commands and their parameters. This is the only case where white
  1970. space is significant in 488.2. In other listening formats it is ignored, and
  1971. in talking formats is not usually generated.
  1972. </p>
  1973. <p>
  1974. The &lt;Program Data Separator&gt; is just a &quot;,&quot; (comma), and is used to separate
  1975. data in a data stream.
  1976. </p>
  1977. <p>
  1978. * Commands, or more properly &lt;Command Program Headers&gt;, also fall into three
  1979. categories, though in this case the categories are less distinct.
  1980. </p>
  1981. <p>
  1982. The &lt;Simple Program Header&gt; is just a command string, or &lt;Program Mnemonic&gt;.
  1983. Legal command strings consist of lowercase and uppercase letters, plus the
  1984. &quot;_&quot; (underscore) character. For example:
  1985. </p>
  1986. <pre><strong>
  1987. MEASURE
  1988. </strong></pre>
  1989. <p>
  1990. The &lt;Compound Command Program Header&gt; is a set of &lt;Program Mnemonic&gt; strings,
  1991. separated by &quot;:&quot; (colon) characters. A &quot;:&quot; may be added in front as well.
  1992. For example:
  1993. </p>
  1994. <pre><strong>
  1995. MEASURE:VOLTAGE
  1996. :MEASURE:VOLTAGE
  1997. </strong></pre>
  1998. <p>
  1999. The &lt;Common Command Program Header&gt; is the format for the common commands
  2000. defined by 488.2. Their distinguishing feature is that they are preceded by
  2001. a &quot;*&quot; (asterisk). For example:
  2002. </p>
  2003. <pre><strong>
  2004. *IDN
  2005. *RST
  2006. *SRE
  2007. </strong></pre>
  2008. <p>
  2009. * There are three queries, or more properly &lt;Query Program Headers&gt;. The
  2010. queries are used to interrogate a device for information. The three queries
  2011. are complementary to the three commands, and include:
  2012. </p>
  2013. <ul>
  2014. <li> &lt;Simple Query Program Header&gt;
  2015. </li>
  2016. <li> &lt;Compound Query Program Header&gt;
  2017. </li>
  2018. <li> &lt;Common Query Program Header&gt;
  2019. </li>
  2020. </ul>
  2021. <p>
  2022. The three have the same syntax as the complementary commands, except that a
  2023. &quot;?&quot; is tacked on to the end.
  2024. </p>
  2025. <p>
  2026. * The talking syntax is similar to the listening syntax, but much more
  2027. concise. The talking syntax applies to two types of data that a device may
  2028. return in response to a query:
  2029. </p>
  2030. <ul>
  2031. <li> Response Data: This is data returned by the instrument in response to a
  2032. query. Since a &lt;Compound Query Program Header&gt; may ask for multiple
  2033. responses, a single response data stream may contain the responses to
  2034. multiple queries.
  2035. </li>
  2036. <li> Learn String: This is the data returned in response to a query that
  2037. interrogates a device for a setting. This data includes not only the
  2038. value of the setting but the command header that tells the device to make
  2039. that setting. This learn string can be sent later, verbatim, to restore
  2040. the setting.
  2041. </li>
  2042. </ul>
  2043. <p>
  2044. There are only four elements to the talking syntax:
  2045. </p>
  2046. <ul>
  2047. <li> &lt;Response Message Terminator&gt;: The only legal terminator for the talking
  2048. syntax is a newline along with an EOI. This is used at the end of a
  2049. stream of response data.
  2050. </li>
  2051. <li> &lt;Response Message Unit Separator&gt;: This separator is defined as a &quot;;&quot;
  2052. (semicolon), and is used to separate different responses in the response
  2053. stream.
  2054. </li>
  2055. <li> &lt;Response Data Data Separator&gt;: This separator is defined as a &quot;,&quot;
  2056. (comma), and is used to separate data items in a response.
  2057. </li>
  2058. <li> &lt;Response Header Separator&gt;: This separator is defined as a &quot; &quot; (space),
  2059. and is used to separate the response header from the response data.
  2060. </li>
  2061. </ul>
  2062. <hr />
  2063. <h1><a name="ib4_m0">[4.0] HPIB Tutor (4): 488.2 Common Commands &amp; Status</a></h1>
  2064. <p>
  2065. * The 488.2 spec also includes a &quot;common command&quot; set that provides a minimal
  2066. subset of instrument commands, as well as a consistent way of returning
  2067. status information. This chapter describes these issues in detail.
  2068. </p>
  2069. <hr />
  2070. <ul>
  2071. <li>
  2072. <a href="#ib4_m1">[4.1] 488.2 COMMON COMMANDS &amp; STATUS OVERVIEW</a>
  2073. </li>
  2074. <li>
  2075. <a href="#ib4_m2">[4.2] ESSENTIAL COMMON COMMANDS</a>
  2076. </li>
  2077. <li>
  2078. <a href="#ib4_m3">[4.3] STATUS REPORTING</a>
  2079. </li>
  2080. <li>
  2081. <a href="#ib4_m4">[4.4] SECONDARY COMMON COMMANDS</a>
  2082. </li>
  2083. </ul>
  2084. <hr />
  2085. <p>
  2086. <a href="#top">BACK TO INDEX</a>
  2087. </p>
  2088. <h2><a name="ib4_m1">[4.1] 488.2 COMMON COMMANDS &amp; STATUS OVERVIEW</a></h2>
  2089. <p>
  2090. * The common commands defined under 488.2 are not bus commands, but strings
  2091. sent as data with ATN off. (These common commands include both commands and
  2092. queries, but for convenience they are collectively referred to as commands.)
  2093. The complete common command set is as follows:
  2094. </p>
  2095. <ul>
  2096. <li> AUTO CONFIGURE COMMANDS: Set device addresses via software.
  2097. <ul>
  2098. <li> *AAD / Assign Address / optional
  2099. </li>
  2100. <li> *DLF / Disable Listener Function / optional
  2101. </li>
  2102. </ul>
  2103. </li>
  2104. <li> SYSTEM DATA COMMANDS: Store or retrieve information about HPIB devices,
  2105. such as device descriptions and options.
  2106. <ul>
  2107. <li> *IDN? / Identification Query / REQUIRED
  2108. </li>
  2109. <li> *OPT? / Option Identification Query / optional
  2110. </li>
  2111. <li> *PUD / Protected User Data / optional
  2112. </li>
  2113. <li> *PUD? / Protected User Data Query / optional
  2114. </li>
  2115. <li> *RDT / Resource Description Transfer / optional
  2116. </li>
  2117. <li> *RDT? / Resource Description Transfer Query / optional
  2118. </li>
  2119. </ul>
  2120. </li>
  2121. <li> INTERNAL OPERATION COMMANDS: Control or read the internal operation of a
  2122. device through resets, self-tests, or self-calibration.
  2123. <ul>
  2124. <li> *CAL? / Calibration Query / optional
  2125. </li>
  2126. <li> *LRN? / Learn Device Setup Query / optional
  2127. </li>
  2128. <li> *RST / Reset / REQUIRED
  2129. </li>
  2130. <li> *TST? / Self-Test Query / REQUIRED
  2131. </li>
  2132. </ul>
  2133. </li>
  2134. <li> SYNCHRONIZATION COMMANDS: Control device synchronization within an HPIB
  2135. system.
  2136. <ul>
  2137. <li> *OPC / Operation Complete / REQUIRED
  2138. </li>
  2139. <li> *OPC? / Operation Complete Query / REQUIRED
  2140. </li>
  2141. <li> *WAI / Wait to Continue / REQUIRED
  2142. </li>
  2143. </ul>
  2144. </li>
  2145. <li> MACRO COMMANDS: Allow the user to define new commands as &quot;macros&quot; of
  2146. other commands.
  2147. <ul>
  2148. <li> *DMC / Define Macro / optional
  2149. </li>
  2150. <li> *EMC / Enable Macro / optional
  2151. </li>
  2152. <li> *EMC? / Enable Macro Query / optional
  2153. </li>
  2154. <li> *GMC? / Get Macro Contents Query / optional
  2155. </li>
  2156. <li> *LMC? / Learn Macro Query / optional
  2157. </li>
  2158. <li> *PMC / Purge Macros / optional
  2159. </li>
  2160. <li> *RMC / Remove Individual Macro / optional
  2161. </li>
  2162. </ul>
  2163. </li>
  2164. <li> PARALLEL POLL COMMANDS: Control how a device responds to a parallel poll,
  2165. and allow access to the same information without performing a parallel
  2166. poll.
  2167. <ul>
  2168. <li> *IST? / Individual Status Query / required if PP1
  2169. </li>
  2170. <li> *PRE / Parallel Poll Enable Register Enable / required if PP1
  2171. </li>
  2172. <li> *PRE? / Parallel Poll Enable Register Enable Query / required if PP1
  2173. </li>
  2174. </ul>
  2175. </li>
  2176. <li> STATUS &amp; EVENT COMMANDS: Control device status reporting.
  2177. <ul>
  2178. <li> *CLS / Clear Status / REQUIRED
  2179. </li>
  2180. <li> *ESE / Event Status Enable / REQUIRED
  2181. </li>
  2182. <li> *ESE? / Event Status Enable Query / REQUIRED
  2183. </li>
  2184. <li> *ESR? / Event Status Register Query / REQUIRED
  2185. </li>
  2186. <li> *PSC / Power On Status Clear / optional
  2187. </li>
  2188. <li> *PSC? / Power On Status Clear Query / optional
  2189. </li>
  2190. <li> *SRE / Service Request Enable / REQUIRED
  2191. </li>
  2192. <li> *SRE? / Service Request Enable Query / REQUIRED
  2193. </li>
  2194. <li> *STB? / Read Status Byte Query / REQUIRED
  2195. </li>
  2196. </ul>
  2197. </li>
  2198. <li> DEVICE TRIGGER COMMANDS: Perform a Device Trigger and control how a
  2199. device responds to a trigger command.
  2200. <ul>
  2201. <li> *DDT / Define Device Trigger / optional if DT1
  2202. </li>
  2203. <li> *DDT? / Define Device Trigger Query / optional if DT1
  2204. </li>
  2205. <li> *TRG / Trigger / required if DT1
  2206. </li>
  2207. </ul>
  2208. </li>
  2209. <li> CONTROLLER COMMANDS: Defines the means of passing control between devices.
  2210. <ul>
  2211. <li> *PCB / Pass Control Back / required if ctl
  2212. </li>
  2213. </ul>
  2214. </li>
  2215. <li> STORED SETTING COMMANDS: Save and restore the state of the device.
  2216. <ul>
  2217. <li> *RCL / Recall Instrument State / optional
  2218. </li>
  2219. <li> *SAV / Save Instrument State / optional
  2220. </li>
  2221. <li> *SDS / Save Default Device Settings / optional
  2222. </li>
  2223. </ul>
  2224. </li>
  2225. </ul>
  2226. <p>
  2227. The spec defines some of these commands as required, and some as optional.
  2228. In practice the required commands are always implemented on any respectable
  2229. modern instrument, while most of the optional commands are implemented only
  2230. on certain classes of instruments or never at all.
  2231. </p>
  2232. <p>
  2233. * 488.2 provides a major enhancement of the definition of the serial poll
  2234. status byte defined in 488.1 spec. The original definition only defined bit
  2235. 6 as the &quot;request service&quot; flag; 488.2 also defines two more bits, the Event
  2236. Status Bit (ESB) and Message Available (MAV), plus an additional status
  2237. register and provisions for others. (488.2 also includes an expansion of the
  2238. definition of parallel poll provided in 488.1.)
  2239. </p>
  2240. <p>
  2241. * The 488.2 common command set makes programming a device somewhat simpler as
  2242. it predefines certain elementary commands common to many devices. However,
  2243. it does not address the command syntax relevant to the specific functions of
  2244. the devices. That domain is covered by the SCPI standard, the subject of the
  2245. following chapter.
  2246. </p>
  2247. <h2><a name="ib4_m2">[4.2] ESSENTIAL COMMON COMMANDS</a></h2>
  2248. <p>
  2249. * In practice, the most important common commands are those outlined below:
  2250. </p>
  2251. <ul>
  2252. <li> SYSTEM DATA COMMANDS
  2253. <ul>
  2254. <li> *IDN? / Identification Query / REQUIRED
  2255. </li>
  2256. </ul>
  2257. </li>
  2258. <li> INTERNAL OPERATION COMMANDS
  2259. <ul>
  2260. <li> *LRN? / Learn Device Setup Query / optional
  2261. </li>
  2262. <li> *RST / Reset / REQUIRED
  2263. </li>
  2264. <li> *TST? / Self-Test Query / REQUIRED
  2265. </li>
  2266. </ul>
  2267. </li>
  2268. <li> SYNCHRONIZATION COMMANDS
  2269. <ul>
  2270. <li> *OPC / Operation Complete / REQUIRED
  2271. </li>
  2272. <li> *OPC? / Operation Complete Query / REQUIRED
  2273. </li>
  2274. <li> *WAI / Wait to Continue / REQUIRED
  2275. </li>
  2276. </ul>
  2277. </li>
  2278. <li> STATUS &amp; EVENT COMMANDS
  2279. <ul>
  2280. <li> *CLS / Clear Status / REQUIRED
  2281. </li>
  2282. <li> *ESE / Event Status Enable / REQUIRED
  2283. </li>
  2284. <li> *ESE? / Event Status Enable Query / REQUIRED
  2285. </li>
  2286. <li> *ESR? / Event Status Register Query / REQUIRED
  2287. </li>
  2288. <li> *PSC / Power On Status Clear / optional
  2289. </li>
  2290. <li> *PSC? / Power On Status Clear Query / optional
  2291. </li>
  2292. <li> *SRE / Service Request Enable / REQUIRED
  2293. </li>
  2294. <li> *SRE? / Service Request Enable Query / REQUIRED
  2295. </li>
  2296. <li> *STB? / Read Status Byte Query / REQUIRED
  2297. </li>
  2298. </ul>
  2299. </li>
  2300. <li> DEVICE TRIGGER COMMANDS
  2301. <ul>
  2302. <li> *TRG / Trigger / required if DT1
  2303. </li>
  2304. </ul>
  2305. </li>
  2306. </ul>
  2307. <p>
  2308. * The *IDN? (Identification) query causes a device to return a string to
  2309. identify itself; this string has the format:
  2310. </p>
  2311. <pre><strong>
  2312. &lt;manufacturer&gt;,&lt;model&gt;,&lt;serial_number&gt;,&lt;firmware_rev_level&gt;
  2313. </strong></pre>
  2314. <p>
  2315. Note that the serial number and firmware revision level are returned as &quot;0&quot;
  2316. if not available. For example, a device might return a string of the form:
  2317. </p>
  2318. <pre><strong>
  2319. HEWLETT-PACKARD,347A,222101113,A1
  2320. </strong></pre>
  2321. <p>
  2322. * While the *LRN? (Learn Device Setup) query is optional, many devices
  2323. implement it; it tells the device to return a &quot;learn string&quot; to the
  2324. controller that contains the commands necessary to put the device back into
  2325. its current state. This string can either be in ASCII or binary format,
  2326. since the format isn't specified by 488.2. Oddly, there is no *LRN command,
  2327. just a *LRN? query.
  2328. </p>
  2329. <p>
  2330. * The *RST (Reset) command resets the device. It performs the following
  2331. actions:
  2332. </p>
  2333. <ul>
  2334. <li> Sets device functions to a known state.
  2335. </li>
  2336. <li> Sets the Device Defined Trigger (see *DDT command) to a known state.
  2337. </li>
  2338. <li> Disables macros (see the section on macro commands).
  2339. </li>
  2340. <li> Aborts all pending operations.
  2341. </li>
  2342. <li> Clears any received *OPC or *OPC? commands in progress.
  2343. </li>
  2344. </ul>
  2345. <p>
  2346. The *RST command does not affect:
  2347. </p>
  2348. <ul>
  2349. <li> The state of the HPIB address or its address.
  2350. </li>
  2351. <li> The bytes in the output queue.
  2352. </li>
  2353. <li> The service request enable register.
  2354. </li>
  2355. <li> The standard event status register.
  2356. </li>
  2357. <li> The power-on flag.
  2358. </li>
  2359. <li> Macro definitions (though they are disabled), calibration data,
  2360. protected user data, or the Resource Description Transfer Query Response.
  2361. </li>
  2362. </ul>
  2363. <p>
  2364. Note that *RST is the highest of three levels of resets defined under 488.1
  2365. and 488.2. These three levels are:
  2366. </p>
  2367. <ul>
  2368. <li> The 488.1 IFC line causes a level-1 reset. It unaddresses all devices and
  2369. returns control to the system controller.
  2370. </li>
  2371. <li> The 488.1 DCL and SDC (universal device clear and selected device clear)
  2372. command bytes perform a level-2 reset. They clear the device input and
  2373. output buffers and allow it to receive new commands.
  2374. </li>
  2375. <li> The 488.2 *RST command performs a level-3 reset: it actually clears the
  2376. device itself as described above.
  2377. </li>
  2378. </ul>
  2379. <p>
  2380. * The *TST? (Self-Test) query causes the device to perform an internal
  2381. selftest and report back the status of the test. It is similar to the *CAL?
  2382. command and, like the *CAL? command, returns &quot;0&quot; if successful, and an error
  2383. code in the range &quot;-32767&quot; to &quot;32767&quot; if not.
  2384. </p>
  2385. <p>
  2386. * The *OPC (Operation Complete) command tells the device to set bit 0 in the
  2387. Standard Event Status Register (described in the next section) when it
  2388. completes all pending operations.
  2389. </p>
  2390. <p>
  2391. The matching *OPC? query tells the device to place an ASCII &quot;1&quot; in the
  2392. device's output queue when it completes all pending operations.
  2393. </p>
  2394. <p>
  2395. * The *WAI (Wait to Continue) command makes the device wait until all
  2396. previous commands or queries complete, rather than execute a new command in
  2397. an overlapped fashion. The device then continues executing commands that
  2398. follow the *WAI command.
  2399. </p>
  2400. <p>
  2401. * The *CLS (Clear Status) command clears the status register and associated
  2402. status data structures summarized in the Status Byte, such as the Event
  2403. Status Register (described in the next section).
  2404. </p>
  2405. <p>
  2406. * The *ESE (Standard Event Status Enable) command allows you to set the
  2407. contents of the Standard Event Status Enable Register. It takes a decimal
  2408. numeric string in the range &quot;0&quot; to &quot;255&quot;, representing the bit pattern in the
  2409. register. If a bit is set, the corresponding bit in the Standard Event
  2410. Status Register will be flagged into the Status Byte.
  2411. </p>
  2412. <p>
  2413. The *ESE? query interrogates the Standard Event Status Enable Register. It
  2414. returns a decimal numeric string in the range &quot;0&quot; to &quot;255&quot;.
  2415. </p>
  2416. <p>
  2417. The *ESR? (Event Status Register) query reads the contents of the Standard
  2418. Event Status Register; the SESR is then cleared. A decimal numeric string in
  2419. the range &quot;0&quot; to &quot;255&quot;, representing the bit pattern in the SESR, is
  2420. returned. This is explained in more detail in the next section.
  2421. </p>
  2422. <p>
  2423. * The *PSC (Power-On Status Clear) command (which is optional, but often
  2424. implemented) controls the clearing of the Service Request Enable Register,
  2425. the Standard Event Status Enable Register, the Parallel Poll Enable Register,
  2426. and (in the latest flavor of 488.2) such device-specific registers as the
  2427. implementor may find useful to reset.
  2428. </p>
  2429. <p>
  2430. Sending a &quot;0&quot; with the &quot;*PSC&quot; command sets the power-on clear flag, causing
  2431. the three registers to be cleared at power-up. Sending any other number in
  2432. the range &quot;-32767&quot; to &quot;32767&quot; clears the power-on clear flag, but leaves the
  2433. registers in their previous state.
  2434. </p>
  2435. <p>
  2436. The *PSC? query returns the status of the power-on clear flag. It returns
  2437. &quot;1&quot; if the flag is set, and &quot;0&quot; if the flag is cleared.
  2438. </p>
  2439. <p>
  2440. * The *SRE (Service Request Enable) command sets the Service Request Enable
  2441. Register (discussed in next section). It takes a decimal numeric string in
  2442. the range &quot;0&quot; to &quot;255&quot; as a parameter, with the string representing the bit
  2443. pattern to be stored in the register. Any bit enabled will cause an SRQ when
  2444. the matching bit in the status byte is activated.
  2445. </p>
  2446. <p>
  2447. The *SRE? query returns the contents of the Service Request Enable Register.
  2448. The contents are returned as a decimal numeric string in the range &quot;0&quot; to
  2449. &quot;63&quot;, &quot;128&quot; to &quot;191&quot;. (The gap in the range is due to the fact that bit 6,
  2450. the RQS bit, cannot be set and is always returned as &quot;0&quot;.)
  2451. </p>
  2452. <p>
  2453. The *STB? (Status Byte) query reads the device Status Byte, with bit 6
  2454. representing the Master Summary Status (MSS) bit instead of the RQS bit. The
  2455. query returns a decimal numeric string in the range &quot;0&quot; to &quot;255&quot;. This is
  2456. explained in more detail in the next section.
  2457. </p>
  2458. <p>
  2459. * The *TRG (Trigger) command performs the same function as the GET command
  2460. byte.
  2461. </p>
  2462. <h2><a name="ib4_m3">[4.3] STATUS REPORTING</a></h2>
  2463. <p>
  2464. * The 488.1 spec, as described in previous chapters, defined a status byte to
  2465. be returned by a device in response to a serial poll. However, the only
  2466. thing that 488.1 defined in this byte was bit 6, which was set if the polled
  2467. device had asserted a service request.
  2468. </p>
  2469. <p>
  2470. 488.2 expands on this status reporting scheme and allows the status to be
  2471. retrieved not only via through a serial poll, but also through the 488.2
  2472. *STB? query. 488.2 also extends the definition of the status byte and
  2473. provides an additional, second-level status register, plus a mechanism for
  2474. determining whether or not a status flag can cause an SRQ. The following
  2475. illustration diagrams the 488.2 status model (explanations follow):
  2476. </p>
  2477. <pre><strong>
  2478. Status Byte
  2479. +-----+ +-----+
  2480. | 0 +--&gt;| 0 +--&gt;-+
  2481. | | | | |
  2482. | 1 +--&gt;| 1 +--&gt;-+
  2483. | | | | |
  2484. | 2 +--&gt;| 2 +--&gt;-+
  2485. | | | | |
  2486. | 3 +--&gt;| 3 +--&gt;-+
  2487. | | | | +-[OR]-+
  2488. from output queue ----&gt;| MAV +--&gt;| MAV +--&gt;-+ |
  2489. | | | | | |
  2490. +-----+ +-----+ +---------&gt;| ESB +--&gt;| ESB +--&gt;-+ |
  2491. | OPC | | OPC +--&gt;-+ | | | | | | |
  2492. | | | | | | +----&gt;| RQS +--&gt;| --- +--&gt;-+ |
  2493. | RQC | | RQC +--&gt;-+ | | | | | | | |
  2494. | | | | | | | | 7 +--&gt;| 7 +--&gt;-+ |
  2495. | QYE | | QYE +--&gt;-+ | | +-----+ +-----+ |
  2496. | | | | | | | *STB *SRE &lt;mask&gt; |
  2497. | DDE +--&gt;| DDE +--&gt;-+ | | *SRE? |
  2498. | | | | +-[OR]-+ +---------------------------------+
  2499. | EXE +--&gt;| EXE +--&gt;-+
  2500. | | | | |
  2501. | CME +--&gt;| CME +--&gt;-+
  2502. | | | | |
  2503. | URQ +--&gt;| URQ +--&gt;-+
  2504. | | | | |
  2505. | PON +--&gt;| PON +--&gt;-+
  2506. +-----+ +-----+
  2507. *ESR? *ESE &lt;mask&gt;
  2508. *ESE?
  2509. </strong></pre>
  2510. <p>
  2511. In 488.2 bits 4, 5, and 6 in the status byte are defined as follows:
  2512. </p>
  2513. <ul>
  2514. <li> Bit 4 is the message available bit, or MAV, which indicates whether or not
  2515. the device's data output queue is empty. Whenever the device has data
  2516. available, this bit will be set.
  2517. </li>
  2518. <li> Bit 5 is the event-status bit, or ESB, which captures events generated
  2519. from the Standard Event Status Register, which is defined below.
  2520. </li>
  2521. <li> Bit 6 is defined slightly differently depending on whether the status byte
  2522. is read via a serial poll or through the *STB? query. In a serial poll,
  2523. bit 6 is defined as the RQS (request service) bit, and tells the HPIB
  2524. controller whether the device has requested service or not. If it has
  2525. requested service, the serial poll clears the bit.
  2526. <p>
  2527. In a *STB? query, bit 6 is the master status summary (MSS) bit and
  2528. indicates that the device has requested service, even if the device has
  2529. been serial polled and the RQS bit has been cleared. That is, MSS is
  2530. &quot;sticky&quot; and RQS is not.
  2531. </p>
  2532. </li>
  2533. </ul>
  2534. <p>
  2535. The other bits, as before, are undefined. However, the other bits are
  2536. intended to be used as status-summary bits for device-dependent event
  2537. registers. (The SCPI spec defines these bits in more detail.)
  2538. </p>
  2539. <p>
  2540. The second status register defined by 488.2, the Standard Event Status
  2541. register (SRER), contains the following flags:
  2542. </p>
  2543. <ul>
  2544. <li> Bit 0 -- Operation Complete (OPC) -- indicates that the device has
  2545. completed any pending operations and is ready to accept new commands.
  2546. This bit is generated only in response to the Operation Complete (*OPC)
  2547. command.
  2548. </li>
  2549. <li> Bit 1 -- Request Control (RQC) -- indicates that the device wants to
  2550. become the active controller.
  2551. </li>
  2552. <li> Bit 2 -- Query Error (QYE) -- indicates an error occurred while the
  2553. controller was trying to read the device's data output queue. The cause
  2554. will be either the queue was empty, or the queue overflowed.
  2555. </li>
  2556. <li> Bit 3 -- Device-Dependent Error (DDE) -- indicates some unspecified device
  2557. error occurred.
  2558. </li>
  2559. <li> Bit 4 -- Execution Error (EXE) -- indicates that the device detected an
  2560. error while trying to execute a command. The cause will be either the
  2561. device received a command that was inappropriate to the device, or the
  2562. device could not execute a valid command due to some device condition.
  2563. </li>
  2564. <li> Bit 5 -- Command Error (CME) -- indicates that the device has detected a
  2565. command error. These errors include being sent commands that do not
  2566. conform to 488.2 format or commands that are incorrectly spelled.
  2567. </li>
  2568. <li> Bit 6 -- User Request (URQ) -- indicates that the user has activated some
  2569. device-dependent control to request service.
  2570. </li>
  2571. <li> Bit 7 -- Power On (PON) -- indicates that the device has been power-cycled
  2572. since the last time it was queried.
  2573. </li>
  2574. </ul>
  2575. <p>
  2576. As noted earlier, the ESB bit in the status bit register is set if any
  2577. standard events occur -- that is, if any enabled bit in the SESR is set.
  2578. </p>
  2579. <p>
  2580. The SESR can be read with the *ESR? query. The corresponding standard event
  2581. status enable register can be set (to enable events on the SESR bits) with
  2582. the *ESE &lt;mask&gt; command, and read with the *ESE? query.
  2583. </p>
  2584. <p>
  2585. The SESR is cleared by a *CLS command, reading the SESR with *ESR?, or by a
  2586. power cycle (though in this last case the PON bit will be set after the SESR
  2587. is cleared).
  2588. </p>
  2589. <p>
  2590. The 488.2 spec allows other event registers to be implemented and summed into
  2591. the unused bits of the status byte, but does not define what these other
  2592. registers to be. (The SCPI spec added these definitions with a vengeance!)
  2593. </p>
  2594. <p>
  2595. * The device data output queue has been mentioned several times in this
  2596. discussion; it stores output messages to be read from the device, and can be
  2597. read simply by addressing the device to talk and then handshaking the bytes.
  2598. The MAV bit will be set as long as there are bytes available.
  2599. </p>
  2600. <p>
  2601. The *CLS command does not clear the output queue. It can only be cleared by
  2602. the *RST command, the 488.1 DCL (device clear) command byte, or by
  2603. power-cycling. This reduces the chances of losing data.
  2604. </p>
  2605. <p>
  2606. * 488.2 enhances the parallel poll protocol defined in 488.1 by adding a
  2607. Parallel Poll Enable Register. Again, as Parallel Poll is rarely used, this
  2608. will not be discussed further.
  2609. </p>
  2610. <p>
  2611. * The following example program -- which is for a 34401 DMM, but will work on
  2612. any 488.2-compatible instrument -- uses the common commands to conduct a
  2613. device verification. Note how the results of the self-test are obtained by
  2614. programming the DMM to assert SRQ when done.
  2615. </p>
  2616. <pre><strong>
  2617. 10 DIM S$[50] ! Dimension a string.
  2618. 20 CLEAR SCREEN ! Clear display.
  2619. 30 ASSIGN @Dmm TO 722 ! Assign path to DMM.
  2620. 40 !
  2621. 50 ON TIMEOUT 7,5 GOTO Timetrap ! Jump on 5-second timeout.
  2622. 60 !
  2623. 70 DISP &quot;Clearing DMM!&quot;
  2624. 80 CLEAR @Dmm ! Send SDC to DMM.
  2625. 90 OUTPUT @Dmm;&quot;*RST;*CLS&quot; ! Reset &amp; clear status.
  2626. 100 !
  2627. 110 DISP &quot;Getting DMM status!&quot;
  2628. 120 OUTPUT @Dmm;&quot;*IDN?&quot; ! Get ID from DMM.
  2629. 130 ENTER @Dmm;S$
  2630. 140 DISP S$
  2631. 150 !
  2632. 160 WAIT 2 ! Delay 2 seconds.
  2633. 170 DISP &quot;Testing DMM!&quot;
  2634. 180 ON INTR 7 GOTO Srqtrap ! Set up interface event.
  2635. 181 ENABLE INTR 7;2 ! Enable trap on SRQ.
  2636. 190 OUTPUT @Dmm;&quot;*ESE 1;*SRE 32&quot; ! Enable SRQ on OPC.
  2637. 191 OUTPUT @Dmm;&quot;*OPC?&quot; ! Clear any current pending OPC.
  2638. 192 ENTER @Dmm;S$
  2639. 200 OUTPUT @Dmm;&quot;*TST?;*OPC&quot; ! Test DMM, flag OPC.
  2640. 210 LOOP ! Wait for SRQ.
  2641. 220 END LOOP
  2642. 230 !
  2643. 240 Timetrap: ! Go here on timeout.
  2644. 250 DISP &quot;Timed out -- done!&quot;
  2645. 260 STOP
  2646. 270 !
  2647. 280 Srqtrap: ! Go here on SRQ.
  2648. 281 DISP &quot;Got SRQ!&quot;
  2649. 290 ENTER @Dmm;S$
  2650. 300 DISP &quot;Test result: &quot;;S$;&quot; - done!&quot;
  2651. 310 END
  2652. </strong></pre>
  2653. <p>
  2654. Note how the device is cleared with a CLEAR command and by sending the
  2655. *RST;*CLS string. This is the recommended means of clearing a 488.2 device
  2656. back to a known state.
  2657. </p>
  2658. <p>
  2659. Note also how this program sets up a &quot;timeout&quot; on the HPIB interface which
  2660. causes a jump if an HPIB action takes longer than the specified timeout. For
  2661. the sake of keeping things simple, most of the examples in this document
  2662. don't set a timeout, but you should <em>always</em> do this in your own programs,
  2663. since your program will hang indefinitely if you don't.
  2664. </p>
  2665. <p>
  2666. As a self-test takes a long time, it is likely to exceed a specified timeout,
  2667. so this program configures the DMM to do an SRQ when the test operation is
  2668. complete. It would actually be just as simple in this case to use SPOLL to
  2669. query the Status Byte and check for Bit 6 set, but knowing how to set up an
  2670. SRQ is useful in general.
  2671. </p>
  2672. <h2><a name="ib4_m4">[4.4] SECONDARY COMMON COMMANDS</a></h2>
  2673. <p>
  2674. * The remaining commands are implemented only in certain classes of
  2675. instruments, or aren't implemented at all.
  2676. </p>
  2677. <p>
  2678. * The optional Macro Commands allow a device to accept &quot;macro&quot; strings that
  2679. designate and instruct the device to execute a specific series of commands.
  2680. </p>
  2681. <p>
  2682. The *DMC (Define Macro) command sets up a relationship between a macro name
  2683. and the commands the macro will execute. The macro is defined by sending the
  2684. *DMC command, followed by a arbitrary block program element or string
  2685. designating the label, followed by a string defining the macro; for example:
  2686. </p>
  2687. <pre><strong>
  2688. *DMC &quot;HOME&quot;,#18MOVE 0,0
  2689. </strong></pre>
  2690. <p>
  2691. -- defines a command that moves a pen plotter to its home position.
  2692. </p>
  2693. <p>
  2694. Macro definitions also allow the user to pass parameters within the macro;
  2695. dummy parameters appear as a &quot;$&quot;, followed by a single digit in the range &quot;1&quot;
  2696. to &quot;9&quot;, within the macro definition. The dummy parameter can be used several
  2697. times within the macro definition string.
  2698. </p>
  2699. <p>
  2700. The macro label may be either in the form of a command or query, though it
  2701. cannot be the same as a common command or query. It may be the same as a
  2702. device-dependent command; when the macro label is the same as a
  2703. device-dependent command, the device will execute the macro instead of the
  2704. device command (as long as macros are enabled).
  2705. </p>
  2706. <p>
  2707. The *EMC (Enable Macro) command enables and disables operation of macros; if
  2708. it is sent with a parameter of &quot;0&quot; it disables macros, if it is sent with a
  2709. parameter in the range &quot;-32767&quot; to &quot;32767&quot; will enable macros. Note that
  2710. this command only disables macro <em>operation</em>. The macros will retain their
  2711. definitions and will regain their functions when enabled again. The matching
  2712. *EMC? (Enable Macro) query returns &quot;1&quot; if macros are enabled and &quot;0&quot; if they
  2713. are disabled.
  2714. </p>
  2715. <p>
  2716. The *GMC? (Get Macro Contents) query allows the user to inspect the
  2717. definition of a particular macro; the user send &quot;*GMC?&quot; followed by the
  2718. macro label, and the device sends back the macro definition. For example,
  2719. sending:
  2720. </p>
  2721. <pre><strong>
  2722. *GMC? &quot;HOME&quot;
  2723. </strong></pre>
  2724. <p>
  2725. -- returns the definition for &quot;HOME&quot;, which is &quot;#18MOVE 0,0&quot;, as shown in an
  2726. earlier example.
  2727. </p>
  2728. <p>
  2729. The *LMC? (Learn Macro) query returns the labels of all currently-defined
  2730. macros, as strings separated by commas. If no macros are defined the device
  2731. will return a null string (&quot;&quot;). The response will be the same whether macros
  2732. are enabled or disabled.
  2733. </p>
  2734. <p>
  2735. The *PMC (Purge Macro) command wipes all defined macros from device memory.
  2736. </p>
  2737. <p>
  2738. The *RMC (Remove Individual Macro) command (added in the latest version of
  2739. 488.2) allows the user to get rid of a single macro. The name of the macro
  2740. to be deleted is included as a string parameter to the command.
  2741. </p>
  2742. <p>
  2743. * The auto-address commands -- *AAD and *DLF -- allow a controller to
  2744. software-configure an HPIB system. Since this capability is optional,
  2745. however, there is no necessity that all the devices in an HPIB system
  2746. implement auto-addressing even if they are 488.2-compliant, and so this
  2747. capability is in practice useless.
  2748. </p>
  2749. <p>
  2750. * The *OPT? (Option Identification) query tells the device to return its
  2751. options as a string containing fields separated by commas. Note that missing
  2752. options are returned as a &quot;0&quot;, and that if the device has no options, it also
  2753. returns a &quot;0&quot;. The maximum length of the response is 255 characters.
  2754. </p>
  2755. <p>
  2756. * The *PUD (Protected User Data) command stores up to 63 bytes of
  2757. device-dependent data. The data can be retrieved with a *PUD? query.
  2758. </p>
  2759. <p>
  2760. * The *RDT (Resource Description Transfer) command is similar to *PUD, but it
  2761. writes a data that provides information describing the device. A matching
  2762. *RDT? query retrieves the stored data.
  2763. </p>
  2764. <p>
  2765. * The *CAL? (Calibration) query tells the device to perform a
  2766. self-calibration. It returns &quot;0&quot; if successful, or an error code from
  2767. &quot;-32767&quot; to &quot;32767&quot; if not.
  2768. </p>
  2769. <p>
  2770. * The parallel poll commands -- *IST?, *PRE, and *PRE? -- support Parallel
  2771. Poll operations, which almost nobody uses to begin with. They will not be
  2772. discussed further.
  2773. </p>
  2774. <p>
  2775. * The *DDT (Define Device Trigger) command stores a sequence of commands that
  2776. a device will execute when it receives a GET command byte or a *TRG common
  2777. command. It has a matching *DDT? query.
  2778. </p>
  2779. <p>
  2780. * The *PCB (Pass Control Back) command is used by the active controller to
  2781. tell what device to return control to after control has been passed to it.
  2782. The command takes a decimal numeric string in the range of &quot;0&quot; to &quot;30&quot;,
  2783. representing the controller's address, as a parameter.
  2784. </p>
  2785. <p>
  2786. * The instrument state commands allow a device to store a configuration in
  2787. its own memory and then recall it later. The *RCL (Recall Instrument State)
  2788. command restores the device state from a state definition stored in local
  2789. (device) memory. The command takes a number defining which memory block to
  2790. use, with the numbers starting at &quot;0&quot; and going up to a device-defined upper
  2791. limit. The state restored by the *RCL command are the same functions
  2792. affected by the *RST command. (The device may have a protection mechanism
  2793. that prevents the recall unless it is enabled.)
  2794. </p>
  2795. <p>
  2796. The *SAV (Save Instrument State) command stores the device state in local
  2797. memory. The command is followed by a numeric parameter defining which block
  2798. to use. (The device may have a protection mechanism that prevents the store
  2799. unless it is enabled.)
  2800. </p>
  2801. <p>
  2802. The *SDS (Save Default Device Settings) command allows a default state
  2803. definition to be stored in a given memory block in the device. The command
  2804. takes a number (as defined for *RCL and *SAV) defining which memory to
  2805. restore to its default setting.
  2806. </p>
  2807. <hr />
  2808. <h1><a name="ib5_m0">[5.0] HPIB Tutor (5): Introduction To SCPI</a></h1>
  2809. <p>
  2810. * This chapter provides an overview of the Standards Commands for
  2811. Programmable Instruments (SCPI) command set spec.
  2812. </p>
  2813. <hr />
  2814. <ul>
  2815. <li>
  2816. <a href="#ib5_m1">[5.1] SCPI OVERVIEW</a>
  2817. </li>
  2818. <li>
  2819. <a href="#ib5_m2">[5.2] SCPI COMMAND SYNTAX</a>
  2820. </li>
  2821. <li>
  2822. <a href="#ib5_m3">[5.3] EXAMPLE SCPI COMMAND SETS</a>
  2823. </li>
  2824. <li>
  2825. <a href="#ib5_m4">[5.4] SCPI DATA FORMATS</a>
  2826. </li>
  2827. <li>
  2828. <a href="#ib5_m5">[5.5] STATUS &amp; TRIGGERING</a>
  2829. </li>
  2830. </ul>
  2831. <hr />
  2832. <p>
  2833. <a href="#top">BACK TO INDEX</a>
  2834. </p>
  2835. <h2><a name="ib5_m1">[5.1] SCPI OVERVIEW</a></h2>
  2836. <p>
  2837. * The SCPI specification defines a programming language used to control test
  2838. and measurement instruments such as oscilloscopes, function generators, power
  2839. supplies, and spectrum analyzers. Such instruments implement SCPI in their
  2840. firmware.
  2841. </p>
  2842. <p>
  2843. SCPI is in some senses a follow-on to IEEE 488.2. The 488.2 spec defined
  2844. general commands, while SCPI provides the commands required for the operation
  2845. of specific types of instruments.
  2846. </p>
  2847. <p>
  2848. The first pass at a more comprehensive programming language spec was HP's
  2849. Test &amp; Measurement Language (TMSL), announced in August 1989 and offered as
  2850. an industry standard. This first attempt defined 850 commands. In April
  2851. 1990, a consortium of manufacturers adopted the TMSL definition as the basis
  2852. for SCPI, incorporating some features (a Data Interchange Format, or DIF)
  2853. proposed by Tektronix.
  2854. </p>
  2855. <p>
  2856. The initial SCPI consortium consisted of HP, Tektronix, Fluke, Phillips,
  2857. Wavetek, Racal-Dana, Keithley, Bruel &amp; Kjaer, and National Instruments. The
  2858. SCPI Consortium now maintains the SCPI definition and the formal document
  2859. that describes it.
  2860. </p>
  2861. <p>
  2862. The benefit of SCPI is compatibility -- that is, interoperability between
  2863. different instruments. The same command that performs a certain function on
  2864. one instrument will perform exactly that same function on an entirely
  2865. different instrument, as long as both share that capability. An instrument
  2866. control program designed for a certain type of instrument, such as a function
  2867. generator, will work for a comparable function generator from a different
  2868. vendor with few or no changes.
  2869. </p>
  2870. <p>
  2871. SCPI is designed with commands at several levels of generality to help
  2872. provide this compatibility. A high-level SCPI command such as
  2873. MEASURE:VOLTAGE:AC? (&quot;read an AC voltage&quot;) will work on both an oscilloscope
  2874. and a DVM. At the same time, SCPI also provides commands for low-level
  2875. instrument control that allow precise instrument programming, but are not
  2876. likely to work on another instrument.
  2877. </p>
  2878. <p>
  2879. While SCPI may seen a little intimidating and obscure at first (some refer
  2880. to it as &quot;C for instruments&quot;), it is much more consistent and understandable
  2881. than other instrument command sets. Since it does cover the full range of
  2882. programmable instrumentation, the full SCPI spec is of course complicated,
  2883. but the basic rules are not hard to understand and you can pick them up
  2884. easily.
  2885. </p>
  2886. <h2><a name="ib5_m2">[5.2] SCPI COMMAND SYNTAX</a></h2>
  2887. <p>
  2888. * SCPI is, as noted, a superset of the 488.2 spec in terms of its data
  2889. formats, its usage of common commands, and the 488.2 status system, and uses
  2890. much of the same nomenclature. SCPI &quot;program messages&quot;, for example, are the
  2891. data sent from the controller to the instrument. Similarly, SCPI &quot;response
  2892. messages&quot; are the formatted data returned from the instrument to the
  2893. controller. They both adhere to the 488.2 principle of &quot;forgiving listening,
  2894. precise talking&quot;.
  2895. </p>
  2896. <p>
  2897. Also as with 488.2, SCPI defines both commands and queries. One of the nicer
  2898. principles on which SCPI is based, in fact, is if there is a command that
  2899. sets a value, there is a matching query that reads back that value.
  2900. </p>
  2901. <p>
  2902. The 488.2 commands encompassed by SCPI were explained in the previous chapter
  2903. and will not be examined in any more detail here. The &quot;subsystem commands&quot;
  2904. are the heart of SCPI and the focus of the rest of this discussion.
  2905. </p>
  2906. <p>
  2907. * SCPI organizes commands into various sets that match &quot;subsystems&quot; of the
  2908. target instrument. The commands for each subsystem are defined in a
  2909. hierarchical structure similar to the hierarchical file system found on most
  2910. computers. In SCPI, this command structure is called a &quot;command tree&quot;. A
  2911. simplified example, for the SENSe command as implemented on a DMM, is shown
  2912. below:
  2913. </p>
  2914. <pre><strong>
  2915. SENSe
  2916. |
  2917. +---------------+---------------+
  2918. | |
  2919. CURRent VOLTage
  2920. | |
  2921. +------+------+ +------+------+
  2922. | | | |
  2923. RANGe RESolution RANGe RESolution
  2924. | | | |
  2925. +---+---+ | +---+---+ |
  2926. | | | | | |
  2927. UPPer AUTO AUTO UPPer AUTO AUTO
  2928. </strong></pre>
  2929. <p>
  2930. Definitions of the other subsystems are irrelevant for the moment. The SENSe
  2931. subsystem is just a good way to discuss the syntax of SCPI, and other
  2932. subsystems will be illustrated in the next section.
  2933. </p>
  2934. <p>
  2935. The command tree is described with nomenclature similar to that used for file
  2936. systems. The command at the top of the tree is the &quot;root&quot; command, and
  2937. subsystem commands are linked into &quot;paths&quot; through the tree. For example,
  2938. one path through the tree is defined by the command sequence:
  2939. </p>
  2940. <pre><strong>
  2941. :SENSe:VOLTage:RANGe:AUTO
  2942. </strong></pre>
  2943. <p>
  2944. -- which sets the DMM to read voltages and uses autoranging. Note how
  2945. colons (&quot;:&quot;) are used as path separators. Another path is:
  2946. </p>
  2947. <pre><strong>
  2948. :SENSe:CURRent:RANGe:UPPer
  2949. </strong></pre>
  2950. <p>
  2951. -- which sets the DMM to read currents and uses the upper current range of
  2952. the DMM. Note that the full path of a command does not need to be sent
  2953. to the DMM each time, but how and why that is so needs more detailed
  2954. explanation. <em>not</em>
  2955. </p>
  2956. <p>
  2957. Commands sent to an instrument are intrepreted by a software routine called a
  2958. &quot;parser&quot;. When decoding SCPI subsystem commands, the parser has to keep
  2959. track of the &quot;current path&quot; of the command, which is something like the
  2960. &quot;current directory&quot; in a hierarchical file system: it specifies the
  2961. subsystem block the DMM is decoding commands for.
  2962. </p>
  2963. <p>
  2964. The parser navigates through the tree as directed by subsystem command
  2965. strings according to the following rules:
  2966. </p>
  2967. <ul>
  2968. <li> After power-on or the *RST common command is sent, the current path is set
  2969. to the root.
  2970. </li>
  2971. <li> A message terminator, usually a &lt;newline&gt; (line-feed) character, also sets
  2972. the current path to the root.
  2973. </li>
  2974. <li> A colon (&quot;:&quot;) is, as shown above, a path separator. Each time the parser
  2975. finds a colon in the subsystem command string it moves down through the
  2976. command tree one level. If the colon is the first character in the
  2977. string, however, it specifies the root. (The extensive use of colons in
  2978. SCPI subsystem command strings has led to a slightly disrespectful
  2979. description of the language as &quot;colon cancer&quot;.)
  2980. </li>
  2981. <li> A semicolon (&quot;;&quot;) separates two commands in the same subsystem command
  2982. string without changing the current path.
  2983. </li>
  2984. <li> Whitespace characters, such as &lt;tab&gt; and &lt;space&gt;, are generally ignored.
  2985. However, whitespace inside a subsytem command keyword is forbidden. For
  2986. example, MEAS ure is not a legal keyword.
  2987. <p>
  2988. Whitespace is also required to separate a parameter from a command. For
  2989. example, :SOURce:VOLTage6.2 is incorrect, you must use :SOURce:VOLTage
  2990. 6.2.
  2991. </p>
  2992. </li>
  2993. <li> Commas (&quot;,&quot;) are used to separate multiple parameters for a single
  2994. subsystem command.
  2995. </li>
  2996. <li> Common commands, such as *RST, are not subsystem commands and are not
  2997. interpreted as part of a path.
  2998. </li>
  2999. </ul>
  3000. <p>
  3001. For example:
  3002. </p>
  3003. <pre><strong>
  3004. :SENSe:VOLTage ; RANGe:AUTO ; RESolution:AUTO
  3005. </strong></pre>
  3006. <p>
  3007. -- is the same as executing:
  3008. </p>
  3009. <pre><strong>
  3010. :SENSe:VOLTage:RANGe:AUTO
  3011. :SENSe:VOLTage:RESolution:AUTO
  3012. </strong></pre>
  3013. <p>
  3014. Note that the spaces around the &quot;;&quot; are strictly window-dressing. The parser
  3015. ignores them, they're just there to make the string easier to read.
  3016. Similarly:
  3017. </p>
  3018. <pre><strong>
  3019. :SENSe:VOLTage:RANGe:AUTO ; :SENSe:CURRent:RANGe:UPPer
  3020. </strong></pre>
  3021. <p>
  3022. -- is the same as executing both commands separately, since the &quot;:&quot;
  3023. immediately following the separating &quot;;&quot; resets the current path to root.
  3024. </p>
  3025. <p>
  3026. * The command tree is specified concisely through a &quot;subsystem command table&quot;
  3027. that define the commands and their parameters. For example, the SENSE
  3028. command tree illustrated previously evaluates to the following command table:
  3029. </p>
  3030. <pre><strong>
  3031. _______________________________________
  3032. Command Parameters
  3033. _______________________________________
  3034. [:SENSe]
  3035. :CURRent
  3036. :RANGe
  3037. :AUTO Boolean or ONCE
  3038. [:UPPer] numeric
  3039. :RESolution numeric
  3040. :AUTO Boolean or ONCE
  3041. :VOLTage
  3042. :RANGe
  3043. :AUTO Boolean or ONCE
  3044. [:UPPer] numeric
  3045. :RESolution numeric
  3046. :AUTO Boolean or ONCE
  3047. _______________________________________
  3048. </strong></pre>
  3049. <p>
  3050. The hierarchy of the command paths is given by the level of indenting in the
  3051. &quot;Command&quot; column of the table. Following the indenting yields subsystem
  3052. command strings of the form:
  3053. </p>
  3054. <pre><strong>
  3055. :SENSe:CURRent:RANGe:AUTO ON
  3056. </strong></pre>
  3057. <p>
  3058. As you should have noticed by now, most of the keywords are listed as strings
  3059. of uppercase letters, followed by lowercase letters. This mixing of cases is not part of the SCPI definition as such. SCPI isn't case-sensitive, and
  3060. so you can send subsystem commands all upppercase, all lowercase, or any
  3061. mixture of the two.
  3062. <em>not</em>
  3063. </p>
  3064. <p>
  3065. What the lowercase letters in the definitions specify is that those
  3066. characters are optional, and may be discarded if desired. To illustrate:
  3067. </p>
  3068. <pre><strong>
  3069. :SENS:CURR:RANG:AUTO ON
  3070. </strong></pre>
  3071. <p>
  3072. -- is the same as:
  3073. </p>
  3074. <pre><strong>
  3075. :SENSe:CURRent:RANGe:AUTO ON
  3076. </strong></pre>
  3077. <p>
  3078. The keywords in square brackets are &quot;implied&quot; keywords, meaning that if a
  3079. subsystem command at that path level is not specified, it is assumed. For
  3080. example:
  3081. </p>
  3082. <pre><strong>
  3083. :SENSe:VOLTage:RANGe:UPPer 6.5
  3084. </strong></pre>
  3085. <p>
  3086. -- is the same as:
  3087. </p>
  3088. <pre><strong>
  3089. :VOLTage:RANGe 6.5
  3090. </strong></pre>
  3091. <p>
  3092. An implied keyword should not be used in a command string unless it is
  3093. necessary to do so. Implied keywords often are defined to define
  3094. enhancements of SCPI. They are left implied to keep from &quot;breaking&quot; programs
  3095. that use commands that conform to earlier revs. Avoiding the use of implied
  3096. keywords makes it more likely a program will work with an earlier type of
  3097. SCPI instrument.
  3098. </p>
  3099. <p>
  3100. For almost all commands that can set a value, there is a matching query that
  3101. can read one back. This is similar to 488.2 common command queries in that
  3102. the query string is the same as the comparable command string, but with a &quot;?&quot;
  3103. tacked on. For example, the command:
  3104. </p>
  3105. <pre><strong>
  3106. :SENSe:VOLTage:RANGe
  3107. </strong></pre>
  3108. <p>
  3109. -- has the matching query:
  3110. </p>
  3111. <pre><strong>
  3112. :SENSe:VOLTage:RANGe?
  3113. </strong></pre>
  3114. <p>
  3115. If a table contains a keyword that ends in a &quot;?&quot;, that means that the
  3116. subsystem command string only exists as a query, and there is no command
  3117. form. Other subsystem commands may not have matching queries, as they
  3118. initiate events, such as device triggers, and do not set values that can be
  3119. queried.
  3120. </p>
  3121. <p>
  3122. The parameters for each command, if any, are listed in the right column of
  3123. the table. If any parameters are optional, they are listed in square
  3124. brackets, just like the implied keywords. The ranges of optional values are
  3125. defined in the documentation for a specific instrument.
  3126. </p>
  3127. <p>
  3128. Commands are sent to the instrument followed by their parameters, if any are
  3129. required. Note that parameters must be separated from the command by a
  3130. space, and multiple parameters are separated by commas (&quot;,&quot;). The full
  3131. command sequence is terminated by a newline, an EOI, or both.
  3132. </p>
  3133. <h2><a name="ib5_m3">[5.3] EXAMPLE SCPI COMMAND SETS</a></h2>
  3134. <p>
  3135. * For examples of SCPI syntax, consider simplified command sets for a
  3136. hypothetical signal generator, DVM, and relay scanner.
  3137. </p>
  3138. <p>
  3139. These devices are examples of the three classes of programmable instruments:
  3140. source, sense, and switch devices:
  3141. </p>
  3142. <ul>
  3143. <li> Source instruments output some kind of signal, such as power supplies and
  3144. pulse generators.
  3145. </li>
  3146. <li> Sense instruments are those which measure signals, such as power meters
  3147. and counters.
  3148. </li>
  3149. <li> Switch instruments use relays or solid-state switches to route signals
  3150. between an instrument and devices under test.
  3151. </li>
  3152. </ul>
  3153. <p>
  3154. More sophisticated instruments may combine multiple instrument functions in a
  3155. single package.
  3156. </p>
  3157. <p>
  3158. Our hypothetical signal generator can produce sine, triangle, or square wave
  3159. outputs. The output is programmable from 1 Hz to 100 kHz at levels of 0 to
  3160. 500 mV RMS. The output impedance can be switched between 50 and 75 ohms.
  3161. </p>
  3162. <p>
  3163. At power-on, or after *RST, the signal generator is set to output a 1
  3164. millivolt RMS, 1 kHz sine wave with an output impedance of 75 ohms, although
  3165. the actual output is disabled. The signal generator is programmed in fixed
  3166. units of Hz, volts RMS, and ohms. The command table is illustrated below:
  3167. </p>
  3168. <pre><strong>
  3169. __________________________________________
  3170. Command Parameters
  3171. __________________________________________
  3172. :OUTPut
  3173. [:STATe] Boolean
  3174. :IMPedance 50 or 75
  3175. [:SOURce]
  3176. :FREQuency
  3177. [:FIXed] 1 to 1e5
  3178. :VOLTage
  3179. [:LEVel]
  3180. [:IMMediate]
  3181. [AMPlitude] 0 to 0.5
  3182. :FUNCtion
  3183. [:SHApe] SINe or SQUare or
  3184. TRIangle
  3185. __________________________________________
  3186. </strong></pre>
  3187. <p>
  3188. This device incorporates two subsystems, an OUTPut subsystem and a SOURce
  3189. subsystem. Note how the command set incorporates a large number of implied
  3190. keywords -- a common feature of practical SCPI implementations that greatly
  3191. reduces the number of commands you actually need to remember -- and
  3192. simplifies to only five distinct command forms:
  3193. </p>
  3194. <pre><strong>
  3195. :FREQ 100 Set output frequency (to 100 Hz).
  3196. :VOLT 0.1 Set output voltage (to 100 mV RMS).
  3197. :FUNC TRI Set output function (to triangle wave).
  3198. :OUTPut:IMP 50 Set output impedance (to 50 ohms).
  3199. :OUTPut ON Turn on outputs.
  3200. </strong></pre>
  3201. <p>
  3202. The matchinq queries consist of:
  3203. </p>
  3204. <pre><strong>
  3205. :FREQ? Query output frequency.
  3206. :VOLT? Query output voltage.
  3207. :FUNC? Query output function.
  3208. :OUTPut:IMP? Query output impedance.
  3209. :OUTPut? Query output state.
  3210. </strong></pre>
  3211. <p>
  3212. Note that the :OUTPut:IMP command only has two values, 50 or 75. Other
  3213. values will be rounded to the allowed value.
  3214. </p>
  3215. <p>
  3216. Note also the :OUTPut ON command, which can cause problems for novices, since
  3217. the output terminals of a SCPI instrument are disabled after power-on or
  3218. *RST. The programmer has to use :OUTPut ON to specifically enable the
  3219. outputs.
  3220. </p>
  3221. <p>
  3222. * The hypothetical DVM is capable of making either AC or DC voltage
  3223. measurements. It measures input voltages from 0 to 100 volts DC or AC RMS.
  3224. The DVM has two rear panel BNC ports, for the &quot;measurement complete&quot; output
  3225. and an &quot;external trigger&quot; input. For better noise rejection, the DVM
  3226. provides a low-pass input filter that is programmable to frequencies of 100,
  3227. 200, or 1000 Hz.
  3228. </p>
  3229. <p>
  3230. After power-on or *RST, the DVM is configured to read DC voltages using
  3231. autoranging and the best possible resolution. The input impedance is set to
  3232. 10 megohms, and the input filter is set to 1000 Hz. The trigger source is
  3233. set to IMMediate. Its command table is shown below:
  3234. </p>
  3235. <pre><strong>
  3236. _______________________________________________
  3237. Command Parameters
  3238. _______________________________________________
  3239. :CONFigure
  3240. [:SCALar]
  3241. :VOLTage
  3242. :AC numeric,numeric (*)
  3243. [:DC] numeric,numeric (*)
  3244. :FETCh
  3245. [:SCALar]
  3246. :VOLTage
  3247. :AC? numeric,numeric (*)
  3248. [:DC]? numeric,numeric (*)
  3249. :INITiate
  3250. [:IMMediate]
  3251. :INPut
  3252. :IMPedance 50 or 1e6
  3253. :FILTer
  3254. [:LPASs] 100 or 200 or 1000
  3255. :MEASure
  3256. [:SCALar]
  3257. :VOLTage
  3258. :AC numeric,numeric (*)
  3259. [:DC] numeric,numeric (*)
  3260. :READ
  3261. [:SCALar]
  3262. :VOLTage
  3263. :AC? numeric,numeric (*)
  3264. [:DC]? numeric,numeric (*)
  3265. [:SENSe]
  3266. :FUNCtion AC or DC
  3267. :TRIGger
  3268. [:IMMediate]
  3269. :SOURce IMMediate or EXTernal
  3270. :COUNt numeric
  3271. _______________________________________________
  3272. (*): The first numeric parameter specifies the
  3273. input voltage range from 0.001 to 100 volts by
  3274. powers of 10; the second specifies the voltage
  3275. resolution, which is rounded to 0.001, 0.01,
  3276. or 0.1 volts.
  3277. _______________________________________________
  3278. </strong></pre>
  3279. <p>
  3280. This device has 8 command subsystems that provide somewhat overlapping
  3281. functionality. The commands :MEASure, :CONFigure &amp; :READ, and :INITiate &amp;
  3282. :FETCh demonstrate how SCPI allows you to take measurements at differing
  3283. levels of detail. :MEASure, for example, is very easy to use; all you need
  3284. to know is what quantity you want to measure. :CONFigure &amp; :READ are not
  3285. quite as easy to use, but they are very flexible; and :INITiate &amp; :FETCh are
  3286. hard to use, but offer maximum flexibility.
  3287. </p>
  3288. <p>
  3289. The high-level commands are actually equivalent to sequences of low-level
  3290. commands, so it makes sense to study the low-level commands first and then
  3291. work our way up. However, in practice, a smart programmer will never use a
  3292. low-level command when a higher-level one will do the job, since the
  3293. higher-level commands make the job easier to implement and understand, as
  3294. well as easier to port to other systems.
  3295. </p>
  3296. <p>
  3297. Most measurements can be modeled as a three-step process:
  3298. </p>
  3299. <ul>
  3300. <li> Set up the instrument.
  3301. </li>
  3302. <li> Trigger the measurement.
  3303. </li>
  3304. <li> Retrieve the reading.
  3305. </li>
  3306. </ul>
  3307. <p>
  3308. When you use low-level commands, you must do each of these steps explicitly.
  3309. Typically, you begin setup by sending *RST to place the instrument into a
  3310. known state, and then you change each setting, one by one, until you have the
  3311. instrument configured. Then you trigger the measurement. The trigger may be
  3312. generated automatically by your setup commands, or you can send an explicit
  3313. trigger command. For example, an :INITiate:IMMediate command, forces the
  3314. measurement to occur as soon as the command is interpreted. Finally, you can
  3315. read the measurement using a :FETCh query.
  3316. </p>
  3317. <p>
  3318. For the DVM, a low-level sequence of commands to read an AC voltage looks
  3319. like this:
  3320. </p>
  3321. <pre><strong>
  3322. 10 OUTPUT @Dvm;&quot;*RST&quot; ! Reset into a known state.
  3323. 20 OUTPUT @Dvm;&quot;:FUNC AC&quot; ! Change function to AC volts.
  3324. 30 OUTPUT @Dvm;&quot;:INP:IMP 50&quot; ! Change input impedance to 50 ohms.
  3325. 40 OUTPUT @Dvm;&quot;:INIT:IMM&quot; ! Trigger a reading.
  3326. 50 OUTPUT @Dvm;&quot;:FETCH:VOLT:AC?&quot; ! Query for the reading.
  3327. 60 ENTER @Dvm;Vac ! Get the reading.
  3328. </strong></pre>
  3329. <p>
  3330. Let's compare this to programming the instrument with high-level commands.
  3331. :MEASure is the simplest (and generally most useful) way to make and read a
  3332. measurement. A single :MEASure command is equivalent to programming an
  3333. instrument setting, sending an :INITiate:IMMediate, followed by a :FETCh
  3334. query. The same AC volts measurement shown above can be simplified using
  3335. :MEASure to:
  3336. </p>
  3337. <pre><strong>
  3338. 10 OUTPUT @Dvm;&quot;:MEAS:VOLT:AC?&quot; ! Measure AC volts.
  3339. 20 ENTER @Dvm;Vac ! Get the reading.
  3340. </strong></pre>
  3341. <p>
  3342. Using :MEASure does have its disadvantages. When you use :MEASure, the
  3343. instrument chooses the &quot;best&quot; default settings to accomplish the measurement
  3344. you want. Usually instrument documentation lists the settings associated
  3345. with :MEASure. However, sometimes the instrument's idea of a &quot;best&quot; setting
  3346. conflicts with your needs. For example, suppose you want to use the DVM to
  3347. read an AC voltage through a 1 megohm input impedance. :MEASure won't work,
  3348. because it always sets the input impedance to 50 ohms for an AC measurement.
  3349. </p>
  3350. <p>
  3351. :CONFigure and :READ offer a reasonable compromise between :MEASure and
  3352. low-level commands. :CONFigure performs an instrument setup, while :READ
  3353. triggers a measurement and reads back the voltage, and so :CONFigure followed
  3354. by :READ is equivalent to a :MEASure. This is how you could read an AC
  3355. voltage through a 1 megohm input impedance:
  3356. </p>
  3357. <pre><strong>
  3358. 10 OUTPUT @Dvm;&quot;*RST&quot; ! Reset to a known state.
  3359. 20 OUTPUT @Dvm;&quot;:CONF:VOLT:AC&quot; ! Set up to read AC volts.
  3360. 30 OUTPUT @Dvm;&quot;:INP:IMP 1e6&quot; ! Set input impedance.
  3361. 40 OUTPUT @Dvm;&quot;:READ:VOLT:AC?&quot; ! Trigger and query for reading.
  3362. 50 ENTER @Dvm;Vac ! Read back the voltage.
  3363. </strong></pre>
  3364. <p>
  3365. * Our hypothetical scanner is a simple, 8-channel multiplexer switch. It
  3366. includes two rear panel BNC ports: &quot;channel closed&quot; and &quot;external trigger&quot;.
  3367. At power on or after *RST, all channels are open and the trigger source is
  3368. set to immediate. The command table follows:
  3369. </p>
  3370. <pre><strong>
  3371. _______________________________________________
  3372. Command Parameters
  3373. _______________________________________________
  3374. [:ROUTe]
  3375. :CLOSe (@0:7)
  3376. :OPEN (@0:7)
  3377. :SCAN (@0:7)
  3378. :TRIGger
  3379. [:IMMediate]
  3380. :SOURce IMMediate or EXTernal
  3381. _______________________________________________
  3382. </strong></pre>
  3383. <p>
  3384. This is, like the source, a simple device, with only two command subsystems.
  3385. Note how the Scanner uses a &quot;channel list&quot; as a parameter. This is a special
  3386. parameter used in some :ROUTe subcommands. Typical examples of channel lists
  3387. include:
  3388. </p>
  3389. <pre><strong>
  3390. (@1) Channel 1.
  3391. (@1:4) Channels 1 through 4.
  3392. (@1,3) Channels 1 and 3 only.
  3393. (@1:4,7) Channels 1 through 4, and 7.
  3394. </strong></pre>
  3395. <p>
  3396. The :OPEN and :CLOSe commands simply open and close switches in the channel
  3397. list. The :SCAN command places a channel list into the internal memory of
  3398. the switch box. Once a :SCAN has been programmed, the scanner closes channels
  3399. in sequence using break-before-make as it receives each trigger, and begins
  3400. again at the first channel in the list when it completes the last.
  3401. </p>
  3402. <p>
  3403. The following statements configure the scanner to scan channels 1 through 3
  3404. using the rear panel BNC external trigger:
  3405. </p>
  3406. <pre><strong>
  3407. 40 OUTPUT @Scan;&quot;*RST;*CLS&quot;
  3408. 50 OUTPUT @Scan;&quot;:SCAN (@1:3)&quot;
  3409. 60 OUTPUT @Scan;&quot;:TRIG:SOUR EXT&quot;
  3410. </strong></pre>
  3411. <p>
  3412. You can query the condition of any individual channel or channel list. SCPI
  3413. instruments always return a 1 or a 0 in the same order that the channel list
  3414. in the query was specified. The meaning of 1 or 0 depends on whether you
  3415. query using the :OPEN or :CLOSe command. If you query using :OPEN, a 1 means
  3416. open and a 0 means closed, while if you query using :CLOSe, a 1 means closed
  3417. and a 0 means open.
  3418. </p>
  3419. <p>
  3420. The following statements perform some simple queries:
  3421. </p>
  3422. <pre><strong>
  3423. 10 OUTPUT @Scan;&quot;OPEN? (@1)&quot; ! Is channel 1 open?
  3424. 20 ENTER @Scan;Ch1 ! Read back state (1=TRUE=OPEN).
  3425. 30 OUTPUT @Scan;&quot;CLOSE? (@1)&quot; ! Is channel 1 closed?
  3426. 40 ENTER @Scan;Ch1 ! Read back state (1=TRUE=CLOSED).
  3427. 50 OUTPUT @Scan;&quot;OPEN? (@1:4)&quot; ! Are any of channels 1 through 4 open?
  3428. 60 ENTER @Scan;Ch1,Ch2,Ch3,Ch4 ! Read back states of four channels.
  3429. </strong></pre>
  3430. <p>
  3431. * As an example consider programming the three instruments to test the gain
  3432. of a three-stage amplifier. The signal generator drives a sine wave into the
  3433. input stage of the amplifier, the scanner routes signals from the output of
  3434. each stage into the DVM, and gains are computed using simple voltage ratios,
  3435. not DB.
  3436. </p>
  3437. <p>
  3438. Measurement speed is optimized in this application by setting the DVM to a
  3439. fixed range and performing &quot;hardwired handshaking&quot; between the DVM and the
  3440. switch box. This is done by linking the DVM's &quot;measurement complete&quot; output
  3441. to the switch box's &quot;external trigger&quot; input, and linking the switch box's
  3442. &quot;channel closed&quot; output back to the DVM's &quot;external trigger&quot; input.
  3443. </p>
  3444. <p>
  3445. Each time the DVM completes a measurement, it pulses the &quot;measurement
  3446. complete&quot; output, which is turn causes the switch box to move to the next
  3447. channel in its scan list. When the switch box closes this channel, the box
  3448. pulses its &quot;channel closed&quot; output, which feeds back to the DVM to trigger
  3449. the next measurement.
  3450. </p>
  3451. <p>
  3452. The program to perform these measurements follows below:
  3453. </p>
  3454. <pre><strong>
  3455. 10 CLS
  3456. 15 INTEGER Dummy
  3457. 20 REAL Readings(0:3)
  3458. 30 !
  3459. 40 ASSIGN @Dvm TO 722 ! Set up paths to devices.
  3460. 50 ASSIGN @Switch TO 711
  3461. 60 ASSIGN @Siggen TO 719
  3462. 70 !
  3463. 80 CLEAR @Dvm ! Clear device interfaces.
  3464. 90 CLEAR @Switch
  3465. 100 CLEAR @Siggen
  3466. 110 !
  3467. 120 OUTPUT @Dvm;&quot;*CLS;*RST&quot; ! Reset the devices.
  3468. 130 OUTPUT @Switch;&quot;*CLS;*RST&quot;
  3469. 140 OUTPUT @Siggen;&quot;*CLS;*RST&quot;
  3470. 150 !
  3471. 160 ! Configure the DVM to measure a 500 mV RMS signal with 5 mv
  3472. 170 ! resolution.
  3473. 180 !
  3474. 190 OUTPUT @Dvm;&quot;:CONF:VOLT:AC 0.5,0.005&quot;
  3475. 200 !
  3476. 210 ! Once armed, accept four triggers from the external trigger.
  3477. 220 !
  3478. 230 OUTPUT @Dvm;&quot;:INIT ; :TRIG:COUNT 4; SOUR EXT&quot;
  3479. 240 !
  3480. 250 ! Set the signal generator's output frequency to 100 kHz at 500 mV
  3481. 260 ! RMS. The output function is SINE (default at *RST).
  3482. 270 !
  3483. 280 OUTPUT @Siggen;&quot;:FREQ 1e5 ; :VOLT 0.5&quot;
  3484. 290 !
  3485. 300 ! Change the source output frequency to 50 ohms.
  3486. 310 !
  3487. 320 OUTPUT @Switch;&quot;:SCAN (@1:4) ; :TRIG:SOUR EXT&quot;
  3488. 330 !
  3489. 340 ! Begin measurement -- turn on the source output signal; the *OPC?
  3490. 350 ! query returns a 1 only after the output has settled.
  3491. 360 !
  3492. 370 OUTPUT @Siggen;&quot;:OUTPUT ON ; *OPC?&quot;
  3493. 380 ENTER @Siggen;Dummy
  3494. 390 !
  3495. 400 ! Close the first channel in the switch, the hardwired triggering
  3496. 410 ! does the rest.
  3497. 420 !
  3498. 430 OUTPUT @Switch;&quot;:INIT ; :TRIG:IMM&quot;
  3499. 440 !
  3500. 450 ! Put readings in the output queue.
  3501. 460 !
  3502. 470 OUTPUT @Dvm;&quot;:READ:VOLT:AC?&quot;
  3503. 480 DISP &quot;Waiting for the measurement to complete.&quot;
  3504. 490 !
  3505. 500 ! Get readings into array as they become available.
  3506. 510 !
  3507. 520 ENTER @Dvm;Readings(*)
  3508. 530 DISP &quot;Measurement complete.&quot;
  3509. 540 !
  3510. 550 ! Turn off signal generator output.
  3511. 560 !
  3512. 570 OUTPUT @Siggen;&quot;:OUTPUT OFF&quot;
  3513. 580 !
  3514. 590 ! Calculate and print gains.
  3515. 595 !
  3516. 600 PRINT &quot;Stage 1 gain = &quot;;Readings(1)/Readings(0)
  3517. 610 PRINT &quot;Stage 2 gain = &quot;;Readings(2)/Readings(1)
  3518. 620 PRINT &quot;Stage 3 gain = &quot;;Readings(3)/Readings(2)
  3519. 630 !
  3520. 640 END
  3521. </strong></pre>
  3522. <h2><a name="ib5_m4">[5.4] SCPI DATA FORMATS</a></h2>
  3523. <p>
  3524. * SCPI data types are essentially derived (with some small additions) from
  3525. the program data types defined in 488.2. The formats are flexible (&quot;forgiving
  3526. listening&quot;) and a quick survey should be easily understood.
  3527. </p>
  3528. <p>
  3529. Simple numeric parameters encompass familiar integer and floating-point
  3530. formats:
  3531. </p>
  3532. <pre><strong>
  3533. 100
  3534. 100.
  3535. -1.23
  3536. 4.5e3
  3537. -7.89E-01
  3538. .5
  3539. </strong></pre>
  3540. <p>
  3541. Numeric parameters are a superset of simple numeric parameters, and add
  3542. certain constant values to that definition. All instruments will recognize
  3543. the constants:
  3544. </p>
  3545. <pre><strong>
  3546. MAXimum
  3547. MINimum
  3548. </strong></pre>
  3549. <p>
  3550. -- though the exact value of these constants is device-dependent. Other
  3551. special values, such as:
  3552. </p>
  3553. <pre><strong>
  3554. UP
  3555. INFinity
  3556. DEFault
  3557. </strong></pre>
  3558. <p>
  3559. -- may be defined for specific instruments. For example:
  3560. </p>
  3561. <pre><strong>
  3562. 100 OUTPUT @Dvm;&quot;:VOLT:DC MAX&quot;
  3563. 110 OUTPUT @Dvm;&quot;:CONF:VOLT:DC 10.0,Min&quot;
  3564. </strong></pre>
  3565. <p>
  3566. Discrete parameters are keywords associated with a list of discrete settings
  3567. in a device. Like subsystem commands, they have a long and a short form.
  3568. Upper- and lower-case letters may be mixed, but the value returned for a
  3569. discrete parameter by a subsystem query will always be uppercase. Samples of
  3570. discrete parameters include:
  3571. </p>
  3572. <pre><strong>
  3573. INTernal: Specify internal trigger source.
  3574. EXTernal: Specify external trigger source.
  3575. POSitive: Specify trigger arm on positive transition.
  3576. NEGative: Specify trigger arm on negative transition.
  3577. BOTH: Specify trigger arm on either transition.
  3578. </strong></pre>
  3579. <p>
  3580. For some practical examples:
  3581. </p>
  3582. <pre><strong>
  3583. 100 OUTPUT @Dvm;&quot;:TRIGGER:SOURCE INT&quot;
  3584. 110 OUTPUT @Dvm;&quot;:ARM:SLOPE NEGATIVE&quot;
  3585. </strong></pre>
  3586. <p>
  3587. Boolean parameters should be familiar:
  3588. </p>
  3589. <pre><strong>
  3590. ON
  3591. OFF
  3592. TRUE
  3593. FALSE
  3594. 1
  3595. 0
  3596. </strong></pre>
  3597. <p>
  3598. When you query a Boolean setting, you will always get back a &quot;1&quot; or &quot;0&quot;.
  3599. For example:
  3600. </p>
  3601. <pre><strong>
  3602. 100 OUTPUT @Dvm;&quot;:OUTPUT ON&quot;
  3603. 110 OUTPUT @Dvm;&quot;:OUTPUT 0&quot;
  3604. </strong></pre>
  3605. <p>
  3606. String parameters allow ASCII strings to be sent as parameters. For
  3607. example:
  3608. </p>
  3609. <pre><strong>
  3610. 'this is a STRING'
  3611. &quot;this is also a string&quot;
  3612. &quot;one double quote inside brackets: [&quot;&quot;]&quot;
  3613. 'one single quote inside brackets: ['']'
  3614. </strong></pre>
  3615. <p>
  3616. Single quotes are the most convenient format for HP BASIC:
  3617. </p>
  3618. <pre><strong>
  3619. 110 OUTPUT @Dvm;&quot;:DISPLAY:TEXT 'STOP!'&quot;
  3620. </strong></pre>
  3621. <p>
  3622. Block parameters are sent using the indefinite-length and definite-length
  3623. block formats defined by 488.2, where the formats for indefinite-length and
  3624. definite-length blocks are respectively:
  3625. </p>
  3626. <pre><strong>
  3627. #0&lt;DAB&gt;&lt;DAB&gt; ... &lt;DAB&gt;NL&amp;EOI
  3628. #&lt;num_digits_in_byte_count&gt;&lt;byte_count&gt;&lt;DAB1&gt;&lt;DAB2&gt; ... &lt;DABn&gt;
  3629. </strong></pre>
  3630. <p>
  3631. For example, the following HP BASIC commands send the same 7 bytes of ASCII
  3632. text as indefinite- and definite-length blocks respectively:
  3633. </p>
  3634. <pre><strong>
  3635. 120 OUTPUT @Dvm;&quot;#0ABC_XYZ&quot;,END ! END asserts EOI.
  3636. OUTPUT @Dvm;&quot;#17ABC_XYZ&quot; ! &lt;num_digits&gt;=1, &lt;byte_count&gt;=7
  3637. </strong></pre>
  3638. <p>
  3639. Non-decimal numeric parameters allow numeric information to be sent as
  3640. binary, octal, or hexadecimal:
  3641. </p>
  3642. <pre><strong>
  3643. #b010110100
  3644. #Q773662
  3645. #h3FA1
  3646. </strong></pre>
  3647. <p>
  3648. The header may be upper- or lower-case characters.
  3649. </p>
  3650. <p>
  3651. * As mentioned earlier, data returned to a host in response to a SCPI query
  3652. is known as &quot;response data&quot;. The response data types, which are also derived
  3653. from 488.2 response data types, match the data types defined for parameters
  3654. but with more concise and restricted syntax (&quot;precise talking&quot;).
  3655. </p>
  3656. <p>
  3657. Note that multiple data elements returned in response to a query are
  3658. separated by commas (&quot;,&quot;). Note also that, since multiple queries can be sent
  3659. as a single program message:
  3660. </p>
  3661. <pre><strong>
  3662. :QUERY1?;:QUERY2?
  3663. </strong></pre>
  3664. <p>
  3665. -- then multiple responses can also be sent as a single response message,
  3666. with the responses separated by semicolons (&quot;;&quot;). (Sending multiple queries
  3667. in a single program message is bad form, though it is not illegal.) Response
  3668. data is always terminated with a newline and EOI. <em>always</em>
  3669. </p>
  3670. <p>
  3671. Real response data defines floating-point data types with a uniform format:
  3672. </p>
  3673. <pre><strong>
  3674. 1.23E+0
  3675. -1.0E+2
  3676. -1.23
  3677. -100.0
  3678. -7.89E-01
  3679. 0.5
  3680. </strong></pre>
  3681. <p>
  3682. Integer response data defines an integer-only data format:
  3683. </p>
  3684. <pre><strong>
  3685. 0
  3686. +100
  3687. -100
  3688. 256
  3689. 65535
  3690. 4
  3691. </strong></pre>
  3692. <p>
  3693. Discrete response data is defined exactly as is discrete parameter data, but
  3694. the response data, unlike the discrete parameter data, is always
  3695. uppercase: <em>always</em>
  3696. </p>
  3697. <pre><strong>
  3698. INT
  3699. EXT
  3700. POS
  3701. NEG
  3702. </strong></pre>
  3703. <p>
  3704. String response data is defined like string parameter data, except that only
  3705. double-quotes are legal:
  3706. </p>
  3707. <pre><strong>
  3708. &quot;this is a string&quot;
  3709. &quot;one double quote inside brackets: [&quot;&quot;]&quot;
  3710. </strong></pre>
  3711. <p>
  3712. Definite-length and indefinite-length block response data types are totally
  3713. identical to their parameter equivalents.
  3714. </p>
  3715. <p>
  3716. Binary, octal, and hexadecimal response data types are identical to their
  3717. parameter equivalents, except that lower-case headers are not allowed:
  3718. </p>
  3719. <pre><strong>
  3720. #B00001111
  3721. #Q0707
  3722. #H0F1F
  3723. </strong></pre>
  3724. <h2><a name="ib5_m5">[5.5] STATUS &amp; TRIGGERING</a></h2>
  3725. <p>
  3726. * SCPI specifies advanced features for status and triggering. In fact, it
  3727. defines more features than anyone could ever want.
  3728. </p>
  3729. <p>
  3730. The status system is in particular extremely complicated. As it turns out,
  3731. most of the features were simply due to different HP instrument divisions
  3732. promoting their own pet features when the spec was being defined, with the
  3733. end result being a system that can be extremely confusing.
  3734. </p>
  3735. <p>
  3736. As a way of getting a grasp of the SCPI status system, consider a simple
  3737. example: the status system of the 34401 (ALF) DMM, which is illustrated
  3738. below:
  3739. </p>
  3740. <pre><strong>
  3741. +-----+ +-----+
  3742. | VOV +--&gt;| VOV +--&gt;-+
  3743. | | | | |
  3744. | COV +--&gt;| COV +--&gt;-+ VOV: voltage overload
  3745. | | | | | COV: current overload
  3746. | 2 +--&gt;| 2 +--&gt;-+ OOV: ohms overload
  3747. | | | | | TLO: limit test fail lo
  3748. | 3 +--&gt;| 3 +--&gt;-+ THI: limit test fail hi
  3749. | | | | |
  3750. | 4 +--&gt;| 4 +--&gt;-+
  3751. | | | | |
  3752. | 5 +--&gt;| 5 +--&gt;-+
  3753. | | | | |
  3754. | 6 +--&gt;| 6 +--&gt;-+
  3755. | | | | |
  3756. | 7 +--&gt;| 7 +--&gt;-+
  3757. | | | | +------------+
  3758. | 8 +--&gt;| 8 +--&gt;-+ |
  3759. | | | | | |
  3760. | OOV +--&gt;| OOV +--&gt;-+ |
  3761. | | | | | |
  3762. | 10 +--&gt;| 10 +--&gt;-+ |
  3763. | | | | | |
  3764. | TLO +--&gt;| TLO +--&gt;-+ |
  3765. | | | | | |
  3766. | THI +--&gt;| THI +--&gt;-+ |
  3767. | | | | | | Status Byte
  3768. | 13 +--&gt;| 13 +--&gt;-+ | +-----+ +-----+
  3769. | | | | | | | 0 +--&gt;| 0 +--&gt;-+
  3770. | 14 +--&gt;| 14 +--&gt;-+ | | | | | |
  3771. | | | | | | | 1 +--&gt;| 1 +--&gt;-+
  3772. | 15 +--&gt;| 15 +--&gt;-+ | | | | | |
  3773. +-----+ +-----+ | | 2 +--&gt;| 2 +--&gt;-+
  3774. STAT:QUES:EVEN? STAT:QUES:ENAB &lt;mask&gt; | | | | | |
  3775. STAT:QUES:ENAB? +---&gt;| QUE +--&gt;| QUE +--&gt;-+
  3776. | | | | +-[OR]-+
  3777. from output queue ----&gt;| MAV +--&gt;| MAV +--&gt;-+ |
  3778. | | | | | |
  3779. +-----+ +-----+ +---------&gt;| ESB +--&gt;| ESB +--&gt;-+ |
  3780. | OPC +--&gt;| OPC +--&gt;-+ | | | | | | |
  3781. | | | | | | +----&gt;| RQS +--&gt;| --- +--&gt;-+ |
  3782. | RQC +--&gt;| RQC +--&gt;-+ | | | | | | | |
  3783. | | | | | | | | 7 +--&gt;| 7 +--&gt;-+ |
  3784. | QYE +--&gt;| QYE +--&gt;-+ | | +-----+ +-----+ |
  3785. | | | | | | | *STB *SRE &lt;mask&gt; |
  3786. | DDE +--&gt;| DDE +--&gt;-+ | | *SRE? |
  3787. | | | | +-[OR]-+ +---------------------------------+
  3788. | EXE +--&gt;| EXE +--&gt;-+
  3789. | | | | |
  3790. | CME +--&gt;| CME +--&gt;-+
  3791. | | | | |
  3792. | URQ +--&gt;| URQ +--&gt;-+
  3793. | | | | |
  3794. | PON +--&gt;| PON +--&gt;-+
  3795. +-----+ +-----+
  3796. *ESR? *ESE &lt;mask&gt;
  3797. *ESE?
  3798. </strong></pre>
  3799. <p>
  3800. This is a consistent extension of the 488.2 status system. In this case, an
  3801. additional status bit, QUE (Questionable Data), is used to reflect the status
  3802. of an additional status register, the Questionable Data register, which
  3803. contains a subset of SCPI bit definitions required by the ALF. (Note that
  3804. the bit acronyms specified are not defined by SCPI, I just made them up
  3805. to make the diagram simpler.) <em>not</em>
  3806. </p>
  3807. <p>
  3808. The Questionable Data Register can be queried with: STAT:QUES:EVEN?. Its
  3809. event enable register can be set with STAT:QUES:ENAB &lt;mask&gt;, and the event
  3810. masks can be read with STAT:QUES:ENAB?.
  3811. </p>
  3812. <p>
  3813. While only 5 bits are defined in the Questionable Data Register on the ALF,
  3814. the SCPI standard provides definitions for most of the other bits as well.
  3815. Note that SCPI also defines bit 7 of the Status Byte as OPR, which reflects
  3816. the status of a another 16-bit status register, the Standard Operation Status
  3817. Register, that is not implemented on the ALF.
  3818. </p>
  3819. <p>
  3820. * The SCPI trigger system is also very sophisticated, but more useful. An
  3821. instrument trigger system synchronizes an instrument's actions -- such as
  3822. making a measurement or generating an output signal -- with specific events
  3823. -- such as a software command or an external trigger input.
  3824. </p>
  3825. <p>
  3826. The SCPI triggering system can become quite complicated but a simple subset
  3827. of it incoporates three levels:
  3828. </p>
  3829. <ul>
  3830. <li> An INIT level that simply tells the device to trigger.
  3831. </li>
  3832. <li> A TRIG level that adds triggering conditions.
  3833. </li>
  3834. <li> An ARM level that adds pretriggering setup conditions.
  3835. </li>
  3836. </ul>
  3837. <p>
  3838. This is more than enough for most purposes, and in fact many instruments
  3839. don't implement even this level of triggering capabilities.
  3840. </p>
  3841. <p>
  3842. * Example commands using INIT include:
  3843. </p>
  3844. <pre><strong>
  3845. :ABORt Abort operations, go to idle.
  3846. :INIT:IMM Execute programmed operation.
  3847. :INIT:CONT ON Execute programmed operations continuously.
  3848. :INIT:CONT OFF Stop programmed operations after current one is done.
  3849. </strong></pre>
  3850. <p>
  3851. On their own, the INIT commands simply tell the device to do something
  3852. immediately, either once, using :INIT:IMM, or continuously, using :INIT:CONT
  3853. ON (with the sequence broken by :INIT:CONT OFF or ABORT).
  3854. </p>
  3855. <p>
  3856. * The TRIG commands add a layer of qualification to the triggering. The TRIG
  3857. commands are very complicated, so a list of typical commands will have to do:
  3858. </p>
  3859. <pre><strong>
  3860. :TRIG:SOURCE IMM Trigger on INIT:IMM (default action).
  3861. :TRIG:SOURCE INT Trigger on internal signal (input signal).
  3862. :TRIG:SOURCE EXT Trigger on external trigger input.
  3863. :TRIG:SOURCE MAN Trigger on front-panel button or the like.
  3864. :TRIG:SOURCE BUS Trigger on HPIB GET or *TRG command.
  3865. :TRIG:LEVEL 3 Specify level at which trigger occurs (5 volts).
  3866. :TRIG:SLOPE POS Trigger on rising edge of signal.
  3867. :TRIG:SLOPE NEG Trigger on falling edge of signal.
  3868. :TRIG:SLOPE BOTH Trigger on both edges of signal.
  3869. :TRIG:COUPL AC Specify AC coupling to trigger input.
  3870. :TRIG:COUPL DC Specify DC coupling to trigger input.
  3871. :TRIG:DELAY 5 Specify delay of action after triggering (5 seconds).
  3872. :TRIG:ECOUNT 4 Specify number of trigger events to cause trigger (4).
  3873. :TRIG:HYST 0.05 Specify noise margin in trigger signal.
  3874. :TRIG:TTL Specify trigger on TTL signal levels.
  3875. </strong></pre>
  3876. <p>
  3877. This should be self-explanatory, except for the :TRIG:HYST command. It is
  3878. necessary to specify a noise margin with a trigger because the input signal
  3879. that causes the trigger may be noisy, and if the noise jumps around the
  3880. trigger level during a signal transition, the trigger may occur multiple
  3881. times when it's only supposed to happen once.
  3882. </p>
  3883. <p>
  3884. For example, suppose we trigger off an input signal hitting 3 volts on a
  3885. positive slope. The hysteresis spec tells the triggering system not to
  3886. trigger again until the input signal travels downward again by at least the
  3887. noise margin.
  3888. </p>
  3889. <p>
  3890. To demonstrate a TRIG configuration, assume that you want to make a
  3891. measurement when the input signal passes through 5 volts, with either a
  3892. positive or negative slope. The signal contains noise that averages about 2
  3893. millivolts peak to peak. This could be done with the following sequence of
  3894. trigger commands:
  3895. </p>
  3896. <pre><strong>
  3897. 10 OUTPUT @Dev;&quot;*RST;*CLS&quot; ! Clear the device.
  3898. 20 CALL Config_dev(@Dev) ! Set up device configuration.
  3899. 25 !
  3900. 30 OUTPUT @Dev;&quot;:TRIG:SOURCE EXT&quot; ! Trigger on external trigger input.
  3901. 40 OUTPUT @Dev;&quot;:TRIG:LEVEL 5&quot; ! Trigger at 5 V level.
  3902. 50 OUTPUT @Dev;&quot;:TRIG:SLOPE BOTH&quot; ! Trigger at any crossing.
  3903. 60 OUTPUT @Dev;&quot;:TRIG:HYST 0.002&quot; ! Compensate for noise.
  3904. 65 !
  3905. 70 OUTPUT @Dev;&quot;:INIT:IMM&quot; ! Wait for it.
  3906. 75 !
  3907. 80 CALL Get_trace(@Dev,Data(*)) ! Get trace from device.
  3908. </strong></pre>
  3909. <p>
  3910. Note how :INIT:IMM is used to tell the device to wait for a trigger. The
  3911. TRIG statements merely qualify what the trigger will be. Note also the CALL
  3912. statements in this listing. These invoke user-defined subprograms to perform
  3913. the indicated actions.
  3914. </p>
  3915. <p>
  3916. * The ARM commands offer a second level of triggering to provide
  3917. pretriggering conditions. Their syntax is effectively the same as the TRIG
  3918. commands, with the keyword &quot;ARM&quot; substituted for &quot;TRIG&quot;.
  3919. </p>
  3920. <p>
  3921. For example, assume that you want to measure a TTL signal input. Before
  3922. triggering the measurement, you want to first capture two negative TTL edges
  3923. on an input fed to the external trigger input, and then capture three
  3924. negative TTL edges on the input signal itself.
  3925. </p>
  3926. <pre><strong>
  3927. 10 OUTPUT @Dev;&quot;*RST;*CLS&quot; ! Clear the device.
  3928. 20 CALL Config_dev(@Dev) ! Set up device configuration.
  3929. 25 !
  3930. 30 OUTPUT @Dev;&quot;:ARM:SOURCE EXT&quot; ! Arm on external trigger input.
  3931. 40 OUTPUT @Dev;&quot;:ARM:TTL&quot; ! Arm signal is TTL.
  3932. 50 OUTPUT @Dev;&quot;:ARM:EDGE NEG&quot; ! Arm on negative edges.
  3933. 60 OUTPUT @Dev;&quot;:ARM:ECOUNT 2&quot; ! Count two edges to arm.
  3934. 65 !
  3935. 70 OUTPUT @Dev;&quot;:TRIG:SOURCE INT&quot; ! Trigger on input signal.
  3936. 80 OUTPUT @Dev;&quot;:TRIG:TTL&quot; ! Trigger is TTL.
  3937. 90 OUTPUT @Dev;&quot;:TRIG:EDGE NEG&quot; ! Trigger on negative edges.
  3938. 100 OUTPUT @Dev;&quot;:TRIG:ECOUNT 3&quot; ! Count three edges to trigger.
  3939. 105 !
  3940. 110 OUTPUT @Dev;&quot;:INIT:IMM&quot; ! Wait for trigger.
  3941. 115 !
  3942. 120 CALL Get_trace(@Dev,Data(*)) ! Get trace from device.
  3943. </strong></pre>
  3944. <p>
  3945. The illustration below shows the operation of this trigger sequence:
  3946. </p>
  3947. <pre><strong>
  3948. A B
  3949. +-------------------------------------------------------------+
  3950. | 1 2 |
  3951. |........ ...... ...................................... |
  3952. EXT | : : : : |
  3953. | :....: :....: |
  3954. | |
  3955. | ...... ...... ...... ...... ...... ..... |
  3956. INT | : : : : : : : : : : : |
  3957. | ....: :....: :....: :....: :....: :....: |
  3958. | |
  3959. | 1 2 3 |
  3960. +-------------------------------------------------------------+
  3961. C
  3962. A: The :INITiate:IMMediate command begins the arming sequence.
  3963. B: The arming conditions are satisfied (2 negative edges on D01).
  3964. C: The trigger conditions are satisfied (3 negative edges after arm).
  3965. </strong></pre>
  3966. <p>
  3967. Even more complicated triggering actions could be defined as needed.
  3968. </p>
  3969. <hr />
  3970. <h1><a name="ib6_m0">[6.0] HPIB Tutor (6): A SCPI-Based HPIB Instrument -- The 34401 DMM</a></h1>
  3971. <p>
  3972. * This chapter illustrates the implementation of SCPI by showing how it is
  3973. implemented in a practical instrument, the popular 34401 digital multimeter
  3974. (DMM), known informally as the &quot;Alf&quot;.
  3975. </p>
  3976. <p>
  3977. Due to its relative simplicity and wide range of functionality, the Alf is an
  3978. excellent demonstration of a SCPI-based instrument. This chapter will
  3979. outline the functionality of the DMM, describe its SCPI command set, and
  3980. provide short programming examples of its use.
  3981. </p>
  3982. <hr />
  3983. <ul>
  3984. <li>
  3985. <a href="#ib6_m1">[6.1] 34401 OVERVIEW</a>
  3986. </li>
  3987. <li>
  3988. <a href="#ib6_m2">[6.2] PROGRAMMING THE 34401</a>
  3989. </li>
  3990. <li>
  3991. <a href="#ib6_m3">[6.3] A SIMPLE 34401 EXAMPLE PROGRAM</a>
  3992. </li>
  3993. </ul>
  3994. <hr />
  3995. <p>
  3996. <a href="#top">BACK TO INDEX</a>
  3997. </p>
  3998. <h2><a name="ib6_m1">[6.1] 34401 OVERVIEW</a></h2>
  3999. <p>
  4000. * The 34401 DMM has the following measurement capabilities:
  4001. </p>
  4002. <ul>
  4003. <li> AC and DC volts, with a range from 0.1 to 1000 volts (750 volts AC).
  4004. </li>
  4005. <li> Resistance, with a range from 100 ohms to 100 megohms.
  4006. </li>
  4007. <li> AC and DC current, with a range from 10 milliamps (DC only) to 3 amps.
  4008. </li>
  4009. <li> Frequency and period, with ranges from 3 hertz to 300 kilohertz.
  4010. </li>
  4011. <li> Continuity and diode checking.
  4012. </li>
  4013. <li> Display resolution from 4.5 to 6.5 digits.
  4014. </li>
  4015. <li> Several math functions, and a capability to store 512 readings in memory.
  4016. </li>
  4017. <li> A menu-driven front-panel interface and a vacuum-fluorescent display.
  4018. </li>
  4019. </ul>
  4020. <p>
  4021. Both HPIB and RS-232 interfaces are standard for remote programming and for
  4022. direct printer output. The RS-232 output can be modified to provide a digital
  4023. pass-fail output.
  4024. </p>
  4025. <p>
  4026. The Alf features a SCPI-based command set (with some extensions for features
  4027. not included in the SCPI standard at the time the DMM was designed), plus the
  4028. ability to emulate the HP 3478A DMM or the Fluke 8840A/8842A DMM.
  4029. </p>
  4030. <p>
  4031. Note that the 34401 was described as having &quot;relative&quot; simplicity. Due to
  4032. its wide range of capabilities, there is still a lot of detail to consider.
  4033. These capabilities are broken down into the following categories:
  4034. </p>
  4035. <ul>
  4036. <li> Measurement configuration.
  4037. </li>
  4038. <li> Math operations.
  4039. </li>
  4040. <li> Triggering.
  4041. </li>
  4042. <li> System-related operations.
  4043. </li>
  4044. <li> Remote interface configuration.
  4045. </li>
  4046. <li> Calibration.
  4047. </li>
  4048. <li> Power-on and reset state.
  4049. </li>
  4050. </ul>
  4051. <p>
  4052. * The DMM's measurement configuration features include the following:
  4053. </p>
  4054. <ul>
  4055. <li> AC signal filter: You can select one of three different AC input filters
  4056. to optimize reading speed or low-frequency accuracy. The slow filter
  4057. takes 7 seconds to take a reading, the medium filter takes 1 second, and
  4058. the fast filter takes a tenth of a second.
  4059. <p>
  4060. The AC filter selection is stored in volatile memory. The DMM defaults to
  4061. the medium filter on power-on or *RST. (Unless otherwise specified, all
  4062. other settings and values are stored in volatile memory, and &quot;go away&quot; if
  4063. you turn off the DMM.)
  4064. </p>
  4065. </li>
  4066. <li> Continuity threshold resistance: When measuring continuity, the DMM emits
  4067. a continuous tone if the measured resistance is less than a &quot;threshold
  4068. resistance&quot;. You can set the threshold to any value from 1 to 1000 ohms.
  4069. The threshold resistance can only be set from the front panel. It cannot
  4070. be set programmatically.
  4071. </li>
  4072. <li> DC input resistance: By default, the DMM's input resistance is fixed at
  4073. 10 megohms for all DC voltage ranges to minimize noise pickup. To reduce
  4074. the effects of measurement loading errors, you can set the input
  4075. resistance to greater than 10 gigohms for the 100 millivolts DC, 1 volt
  4076. DC, and 10 volts DC ranges.
  4077. </li>
  4078. <li> Resolution: Resolution is expressed in terms of the number of digits the
  4079. DMM can measure or display. You can set the resolution to 4.5, 5.5, or
  4080. 6.5 digits. Setting the DMM to 6.5 digits provides the greatest accuracy,
  4081. while setting it to 4.5 digits provides the greatest measurement speed.
  4082. The DMM defaults to 5.5 digits on power-on or *RST.
  4083. <p>
  4084. The resolution is fixed at 4.5 digits for continuity and diode tests. For
  4085. AC measurements, the resolution is actually fixed at 6.5 digits, but it
  4086. will be masked to the appropriate resolution setting.
  4087. </p>
  4088. <p>
  4089. For DC and resistance measurements, changing the number of digits also
  4090. changes the &quot;integration time&quot;, or the length of time the DMM takes to
  4091. make a measurement. The more digits, the more power-line cycles (PLCs)
  4092. needed to establish the measurement. The integration time can be set
  4093. programmably.
  4094. </p>
  4095. </li>
  4096. <li> Front-rear input terminal switching: The DMM has input terminals on both
  4097. the front and the back, and you can make any measurement from either set of
  4098. terminals. Terminal switching can <em>only</em> be performed from the front
  4099. panel buttons. There is no way to do it programmatically.
  4100. </li>
  4101. <li> Autozero: When autozero is enabled (the default), the DMM internally
  4102. disconnects the input signal following each measurement, and takes a &quot;zero
  4103. reading&quot;. It then subtracts the zero reading from the preceding reading.
  4104. This nulls out the effect of input offset voltages.
  4105. <p>
  4106. If autozero is disabled, the DMM takes one zero reading and subtracts it
  4107. from all following measurements. It takes a new zero reading each time
  4108. you change the function, range, or integration time.
  4109. </p>
  4110. </li>
  4111. <li> Ranging: You can let the DMM select the range using autoranging or you
  4112. can select a fixed range using manual ranging. The range is fixed for
  4113. continuity tests and diode tests. For ratio measurements, the specified
  4114. range applies to the signal connect to the INPUT terminals, and
  4115. autoranging is automatically selected for reference voltage measurements
  4116. on the SENSE terminals. The DMM defaults to autoranging on power-on or
  4117. *RST.
  4118. </li>
  4119. </ul>
  4120. <p>
  4121. * There are five math operations, only one of which can be enabled at a time.
  4122. Each performs a mathematical operation on each reading, or stores data on a
  4123. series of readings. The math operations use one or more internal registers,
  4124. while others hold the results of the math operation.
  4125. </p>
  4126. <p>
  4127. The table below shows the allowed math / measurement function combinations:
  4128. </p>
  4129. <pre><strong>
  4130. ___________________________________________________
  4131. Null Min-Max dB dBm Limit
  4132. ___________________________________________________
  4133. DC V X X X X X
  4134. AC V X X X X X
  4135. DC I X X X
  4136. AC I X X X
  4137. OHMS 2W X X X
  4138. OHMS 4W X X X
  4139. FREQ X X X
  4140. PER X X X
  4141. CONT
  4142. DIODE
  4143. RATIO X X
  4144. ___________________________________________________
  4145. </strong></pre>
  4146. <p>
  4147. Note that only one math operation can be set at a time; setting a new math
  4148. operation clears the previous one. The operations are as follows:
  4149. </p>
  4150. <ul>
  4151. <li> The min-max operation stores the minimum and maximum readings during a
  4152. series of measurements. The DMM then calculates the average of all
  4153. readings and records the number of readings taken since min-max was
  4154. enabled.
  4155. </li>
  4156. <li> In null or relative measurements, each reading is the difference between a
  4157. stored null value and the input signal. The null value can be set to any
  4158. value between 0 and +/-120% of the highest range for the present function.
  4159. The null value can be set directly as a number from the front-panel or
  4160. SCPI command, or it can be directly read in from a measurement.
  4161. </li>
  4162. <li> The DMM AC measurements can be made in dB as referenced to some stored
  4163. reference value. The reference value is defined in dBm, and can be set
  4164. from any value between 0 dBm and +/-200 dBm. The value can be set
  4165. directly from the front panel or SCPI command -- or it can be directly
  4166. entered from a measurement.
  4167. <p>
  4168. The dBm operation calculates the power delivered by an AC signal to a
  4169. resistance, referenced to 1 milliwatt. You can choose from 17 different
  4170. resistance values, from 50 to 8000 ohms, with the default being 600 ohms.
  4171. </p>
  4172. </li>
  4173. <li> The limit test operation allows you to perform pass/fail testing on upper
  4174. and lower that you specify. You can set the upper and lower limits to any
  4175. value between 0 and +/-120% of the highest range for the present function.
  4176. The upper limit should be a more positive number than the lower limit.
  4177. The default limits are both 0.
  4178. <p>
  4179. The DMM can be programmed to generate a service request on a failed
  4180. reading. There are also jumpers inside the DMM that allow you to use the
  4181. DMM's serial port to output pass-fail indication signals; pin 1 will
  4182. provide a low-going pulse (from 5 VDC to 0, for 2 milliseconds minimum) on
  4183. a passed test, while pin 9 will provide a similar low-going pulse on a
  4184. failed test. (Note that setting this configuration means that the RS-232
  4185. port can no longer be used for serial communications.)
  4186. </p>
  4187. <p>
  4188. You can set limits from the front panel either programmatically, or by
  4189. making a measurement.
  4190. </p>
  4191. </li>
  4192. </ul>
  4193. <p>
  4194. * The DMM's triggering system allows you to generate triggers manually or
  4195. automatically, take multiple readings per trigger, and insert a delay before
  4196. each reading. Normally, the DMM takes one reading per trigger, but you can
  4197. specify multiple readings -- up to 50,000 -- per trigger.
  4198. </p>
  4199. <p>
  4200. You can trigger the DMM from the front panel using a single trigger, an
  4201. external trigger, or auto triggering. Single triggering takes one reading
  4202. each time you press the &quot;Single&quot; button. External triggering is like single
  4203. triggering, but the DMM waits for a pulse on the rear-panel EXTERNAL TRIGGER
  4204. BNC input before taking a reading. Auto triggering takes continuous readings
  4205. at the fastest possible rate for the current configuration.
  4206. </p>
  4207. <p>
  4208. Setting up a trigger requires the following steps:
  4209. </p>
  4210. <ul>
  4211. <li> The DMM must be configured for a measurement by selecting the function,
  4212. range, resolution, and so on.
  4213. </li>
  4214. <li> The trigger source must be selected: either a software (HPIB) trigger, a
  4215. hardware trigger from the EXTERNAL TRIGGER terminal, or an immediate
  4216. internal trigger.
  4217. </li>
  4218. <li> Finally, the DMM must be placed into the &quot;wait for trigger&quot; state and wait
  4219. for the trigger to come along.
  4220. </li>
  4221. </ul>
  4222. <p>
  4223. The actions required to perform these steps are outlined below.
  4224. </p>
  4225. <ul>
  4226. <li> Trigger source choices: The DMM can be configured from the front panel to
  4227. accept a single pushbutton trigger, a hardware trigger from the EXTERNAL
  4228. TRIGGER input, or continuously take readings using auto trigger. Auto
  4229. triggering is the default. The DMM can be configured programmatically to
  4230. accept a software trigger over the HPIB, a hardware trigger from the
  4231. EXTERNAL TRIGGER, or an immediate internal trigger.
  4232. <p>
  4233. Note that the EXTERNAL TRIGGER queues up one trigger input. If a
  4234. measurement is in progress and a trigger pulse comes in, that trigger
  4235. pulse will initiate the next measurement immediately after the current one
  4236. is completed.
  4237. </p>
  4238. <p>
  4239. Software triggering is accomplished with the *TRG common command or the
  4240. GET byte command. The DMM must be configured to the wait-for-trigger
  4241. state for these trigger commands to operate.
  4242. </p>
  4243. </li>
  4244. <li> Number of Samples: By default, the DMM takes one reading each time it
  4245. receives a trigger from the selected trigger source (if the DMM is in the
  4246. wait-for-trigger state). You can, however, instruct the DMM to take
  4247. multiple readings for each trigger received. The number of samples can
  4248. range from 1 to 50,000, and can be set either from the front panel or
  4249. programmatically.
  4250. </li>
  4251. <li> Number of Triggers: By default, the DMM accepts only one trigger before
  4252. taking a measurement and then returning to idle mode. You can, however,
  4253. instruct the DMM to accept multiple triggers before taking a reading. The
  4254. number of triggers can range from 1 to 50,000. Note that it can only be
  4255. set programmatically, there is no front-panel capability.
  4256. </li>
  4257. <li> Trigger Delay: You can insert a delay between the trigger signal and each
  4258. sample that follows. This may be useful in a system where an output has a
  4259. certain settling time. The delay time can be set from 0 to 3600 seconds,
  4260. and can be set either programmatically or from the front panel. If you
  4261. specify multiple readings on a trigger, the delay time applies to each
  4262. measurement.
  4263. <p>
  4264. The default delay time depends on the function, range, integration time,
  4265. and AC filter setting of the DMM; refer to DMM documentation for details.
  4266. </p>
  4267. </li>
  4268. <li> Reading Hold: This feature allows you to &quot;latch&quot; a reading and leave it
  4269. on the display. This is useful for troubleshooting systems where you
  4270. cannot place the probes and see the DMM display at the same time. This
  4271. feature can only be set from the front panel.
  4272. </li>
  4273. <li> EXTERNAL TRIGGER &amp; VOLTMETER COMPLETE: The triggering system interfaces
  4274. to the outside world through two BNC connectors on the back panel. The
  4275. EXTERNAL TRIGGER connector triggers a reading (if configured to do so)
  4276. when a low-true (5 VDC to 0) pulse occurs on that input. The VOLTMETER
  4277. COMPLETE terminal generates a similar low-true pulse when the reading is
  4278. complete.
  4279. </li>
  4280. </ul>
  4281. <p>
  4282. * System-related operations include such topics as reading memory, errors,
  4283. self-test, and display control:
  4284. </p>
  4285. <ul>
  4286. <li> Reading Memory: The DMM can store up to 512 readings in an internal
  4287. memory queue. You can recall the readings to the display, or read buffered
  4288. readings back programmatically.
  4289. </li>
  4290. <li> Error Conditions: The DMM can queue up to 20 error codes in internal
  4291. memory. The error codes can be read back from the front panel or
  4292. programmatically, and are read out as oldest-first. If more than 20
  4293. errors have occurred, the most recent is replaced with &quot;too many errors&quot;
  4294. (error 350) error message, and no more errors will be stored until you
  4295. remove some from the queue.
  4296. <p>
  4297. If no errors have occurred when you read the error queue, the DMM responds
  4298. with a &quot;no error&quot; (error 0) error message.
  4299. </p>
  4300. <p>
  4301. The display error flag will not be cleared until all the errors have been
  4302. read. The error queue is cleared at power-on or *RST.
  4303. </p>
  4304. </li>
  4305. <li> Self-Test: The DMM performs a power-on self-test that checks a minimum
  4306. amount of the DMM's functionality. A longer, more complete self-test
  4307. (taking 15 seconds) can be initiated from the front panel or
  4308. programmatically. The self-test will clear readings memory, but otherwise
  4309. the settings will not be disturbed.
  4310. </li>
  4311. <li> Display Control: You can turn the front-panel display or off, either from
  4312. the front panel or programmatically. You can also programmatically
  4313. display a message on the front panel.
  4314. </li>
  4315. <li> Beeper Control: The DMM contains a speaker that will beep under certain
  4316. conditions. You can turn it off (for a subset of those conditions) and
  4317. back on again, either from the front panel or programmatically.
  4318. </li>
  4319. <li> Comma separators: You can set the DMM to display comma separators in long
  4320. numbers. This feature can only be set from the front panel.
  4321. </li>
  4322. <li> Firmware revision query: The DMM has three microprocessors. You can query
  4323. the DMM, either from the front panel or programmatically, for the revision
  4324. levels of their firmware.
  4325. </li>
  4326. <li> SCPI Language Version: You can query the DMM programmatically to
  4327. determine its SCPI revision level.
  4328. </li>
  4329. </ul>
  4330. <p>
  4331. * You can set configuration operations for the DMM's remote programming
  4332. interface (HPIB or RS-232) from the front panel. Of course it is impossible
  4333. to do it programmatically. You can also select the DMM's command set. (If
  4334. you are having troubles communicating with the DMM, you might check to see
  4335. what interface or language option is set.)
  4336. </p>
  4337. <p>
  4338. All these configuration settings are stored in non-volatile memory. It will
  4339. be retained even if the DMM is switched off.
  4340. </p>
  4341. <ul>
  4342. <li> Remote interface selection: You can select remote operation over either
  4343. the HPIB or RS-232 port from the front panel.
  4344. </li>
  4345. <li> HPIB configuration: You can set the DMM's address anywhere from 0 to 31.
  4346. The factory-set default is 22. If you set the address to 31, the DMM will
  4347. be in talk-only mode, which will allow it to talk directly to a printer.
  4348. </li>
  4349. <li> RS-232 configuration: You can select standard baud rates from 300 to 9600
  4350. baud. You can also set parity as &quot;None&quot; (8 data bits), &quot;Even&quot; (7 data
  4351. bits), or &quot;Odd&quot; (7 data bits). The factory preset is 9600 baud and even
  4352. parity.
  4353. </li>
  4354. <li> Programming language selection: You can select one of three command sets
  4355. for the DMM: SCPI (default), HP3478A, or Fluke 8840A. Note that you can
  4356. only perform remote interface programming over RS-232 with the SCPI
  4357. language, since the other selections only support HPIB.
  4358. </li>
  4359. </ul>
  4360. <p>
  4361. * The DMM allows you to lock out unauthorized calibrations, as well as obtain
  4362. a count of the number of times it has been calibrated or a message stored
  4363. during calibration. Of course, this information is stored in nonvolatile
  4364. memory.
  4365. </p>
  4366. <ul>
  4367. <li> Calibration security: This allows you to enter a security code to prevent
  4368. accidental or unauthorized calibrations of the DMM. It is set to secured
  4369. at the factory, with the calibration code &quot;HP033401&quot;.
  4370. <p>
  4371. You can set the security code programmatically or from the front panel.
  4372. If you set it programmatically, it may consists of up to 12 alphanumeric
  4373. characters, the first of which must be a letter. If you set it from the
  4374. front panel, the code consists of the characters &quot;HP&quot; plus 6 digits (all 8
  4375. characters are required).
  4376. </p>
  4377. </li>
  4378. <li> Calibration count: The number of times the DMM has been calibrated can be
  4379. read from the front panel or over the remote programming interface.
  4380. </li>
  4381. <li> Calibration message: You can store a string of up to 40 characters in the
  4382. DMM to identify calibration information, such as the date of last
  4383. calibration, due date of next calibration, and so on.
  4384. </li>
  4385. </ul>
  4386. <h2><a name="ib6_m2">[6.2] PROGRAMMING THE 34401</a></h2>
  4387. <p>
  4388. * The simplest way to obtain a reading from the DMM is via the MEASure?
  4389. command. However, this command does not offer much flexibility, since the DMM
  4390. gives you the settings it thinks best for you and then makes the measurement.
  4391. Optional features, such as setting NULL operation, won't work.
  4392. </p>
  4393. <p>
  4394. The only settings you can set are function, range, and resolution. You can
  4395. set these as parameters to the MEASure? command itself:
  4396. </p>
  4397. <pre><strong>
  4398. MEASure:&lt;function&gt; &lt;range&gt;, &lt;resolution&gt;
  4399. </strong></pre>
  4400. <p>
  4401. The relevant functions include:
  4402. </p>
  4403. <pre><strong>
  4404. VOLTage:DC? DC voltage.
  4405. VOLTage:DC:RATio? DC voltage ratio.
  4406. VOLTage:AC? AC voltage.
  4407. CURRent:DC? DC current.
  4408. CURRent:AC? AC current.
  4409. RESistance? Ohms.
  4410. FRESistance? 4-wire ohms.
  4411. FREQuency? Frequency count.
  4412. PERiod? Period.
  4413. CONTinuity? Continuity.
  4414. DIODe? Diode test.
  4415. </strong></pre>
  4416. <p>
  4417. For example:
  4418. </p>
  4419. <pre><strong>
  4420. 100 OUTPUT @Dmm;&quot;MEAS:VOLT:DC? 10,0.003&quot; ! DC, 10 V range, 3 mV resolution.
  4421. 110 ENTER @Dmm;Volts
  4422. </strong></pre>
  4423. <p>
  4424. For more programming flexibility, use the CONFigure command. This will also
  4425. preset the DMM to the settings it thinks best, but it won't take a reading;
  4426. if you want to change some of the settings you may do so, and then take a
  4427. reading with the READ? command.
  4428. </p>
  4429. <p>
  4430. READ? will arm the DMM into the wait-for-trigger state. On triggering, the
  4431. DMM will obtain the reading and place it in the output buffer.
  4432. </p>
  4433. <p>
  4434. Note that if READ? is used, the output data will <em>not</em> be buffered in
  4435. internal memory. You have to enter the readings as they arrive in the output
  4436. buffer or they are lost. Note also that you can provide the same function,
  4437. range, and resolution parameters for CONFigure that you can with MEASure?
  4438. </p>
  4439. <p>
  4440. For example:
  4441. </p>
  4442. <pre><strong>
  4443. 100 OUTPUT @Dmm;&quot;CONF:VOLT:DC 10,0.003&quot; ! DC, 10 V range, 3 mV resolution.
  4444. 110 OUTPUT @Dmm;&quot;TRIG:SOUR EXT&quot; ! Trigger on external source.
  4445. 120 OUTPUT @Dmm;&quot;READ?&quot; ! Wait for trigger and get value.
  4446. 130 ENTER @Dmm;Volts
  4447. </strong></pre>
  4448. <p>
  4449. The INITiate and FETCh? commands provide the lowest level of control. To
  4450. read the DMM, you configure it using other commands, and then put it in the
  4451. wait-for-trigger state with INITiate. Once the DMM has triggered and taken
  4452. measurements, you can retrieve them with FETCh?; the readings are buffered in
  4453. internal memory, and FETCh? retrieves them one at a time.
  4454. </p>
  4455. <p>
  4456. For example:
  4457. </p>
  4458. <pre><strong>
  4459. 100 OUTPUT @Dmm;&quot;CONF:VOLT:DC 10,0.003&quot; ! DC, 10 V range, 3 mV resolution.
  4460. 110 OUTPUT @Dmm;&quot;TRIG:SOUR EXT&quot; ! Trigger on external source.
  4461. 120 OUTPUT @Dmm;&quot;INIT&quot; ! Wait for trigger.
  4462. 130 OUTPUT @Dmm;&quot;FETC?&quot; ! Get value.
  4463. 140 ENTER @Dmm;Volts
  4464. </strong></pre>
  4465. <p>
  4466. This example uses the CONF command to set up the DMM. You can also use the
  4467. FUNCtion, RANGe, and RESolution low-level configuration commands to perform
  4468. the precise setup you need:
  4469. </p>
  4470. <pre><strong>
  4471. 100 OUTPUT @Dmm;&quot;FUNC:VOLT:DC&quot; ! DC volts.
  4472. 110 OUTPUT @Dmm;&quot;RANG 10&quot; ! 10 V range.
  4473. 120 OUTPUT @Dmm;&quot;RES 0.003&quot; ! 3 mV resolution.
  4474. 130 OUTPUT @Dmm;&quot;TRIG:SOUR EXT&quot; ! Trigger on external source.
  4475. 140 OUTPUT @Dmm;&quot;INIT&quot; ! Wait for trigger.
  4476. 150 OUTPUT @Dmm;&quot;FETC?&quot; ! Get value.
  4477. 160 ENTER @Dmm;Volts
  4478. </strong></pre>
  4479. <p>
  4480. There are a wide range of such low-level configuration commands, besides
  4481. FUNCtion, RANGe, and RESolution:
  4482. </p>
  4483. <pre><strong>
  4484. NPLCycles Set number of power-line cycles for a measurement.
  4485. FREQuency:APERture Set aperture gate time for period measurements.
  4486. PERiod:APERture Set aperture gate time for period measurements.
  4487. DETector:BANDwidth Set filter frequency for input signal.
  4488. ZERO:AUTO Enable or disable autozero mode.
  4489. INPut:IMPedance:AUTO Enable or disable auto input resistance mode.
  4490. </strong></pre>
  4491. <p>
  4492. Each of these commands has a matching query. There is also a query,
  4493. ROUTe:TERMinals?, to determine if the front or back input terminals are
  4494. enabled.
  4495. </p>
  4496. <p>
  4497. * The five math operations are set as follows:
  4498. </p>
  4499. <pre><strong>
  4500. CALCulate:FUNCtion NULL (default)
  4501. CALCulate:FUNCtion DB
  4502. CALCulate:FUNCtion DBM
  4503. CALCulate:FUNCtion AVERage
  4504. CALCulate:FUNCtion LIMit
  4505. </strong></pre>
  4506. <p>
  4507. You can query the function setting with the CALCulate;FUNCtion? query. Once
  4508. the function has been set, you then have to enable it to get it to operate:
  4509. </p>
  4510. <pre><strong>
  4511. CALCulate:STATe ON
  4512. </strong></pre>
  4513. <p>
  4514. You can disable the math using the OFF parameter instead of the ON parameter.
  4515. You can interrogate the state with a CALCulate:STATe? query.
  4516. </p>
  4517. <p>
  4518. You set the parameters for the math operations with the commands listed
  4519. below. Note that the appropriate operation must be set before setting the
  4520. parameters:
  4521. </p>
  4522. <pre><strong>
  4523. CALCulate:NULL:OFFSet
  4524. CALCulate:DB:REFerence
  4525. CALCulate:DBM:REFerence
  4526. CALCulate:LIMit:LOWer
  4527. CALCulate:LIMit:UPPer
  4528. </strong></pre>
  4529. <p>
  4530. You can interrogate one of these values from the DMM with the matching query.
  4531. Finally, you can determine the results for those math operations that return
  4532. them with:
  4533. </p>
  4534. <pre><strong>
  4535. CALCulate:AVERage:MINimum? Gives minimum of min-max operation.
  4536. CALCulate:AVERage:MAXimum? Gives maximum of min-max operation.
  4537. CALCulate:AVERage:AVERage? Gives average of min-max operation.
  4538. CALCulate:AVERage:COUNt? Gives number of values in min-max operation.
  4539. </strong></pre>
  4540. <p>
  4541. The following sample program shows how to use the CONFigure command with a
  4542. dBm math operation:
  4543. </p>
  4544. <pre><strong>
  4545. 10 DIM Ohms(1:5)
  4546. 20 ASSIGN @Dmm TO 722
  4547. 30 CLEAR 7 ! Clear HPIB and DMM.
  4548. 40 OUTPUT @Dmm;&quot;*RST;*CLS&quot; ! Reset DMM.
  4549. 60 OUTPUT @Dmm;&quot;CALC:DBM:REF 5.0&quot; ! 50 ohm reference resistance.
  4550. 70 OUTPUT @Dmm;&quot;CONF:VOLT:AC 1,0.001&quot; ! Set DMM to 1 amp AC range.
  4551. 80 OUTPUT @Dmm;&quot;DET:BAND 200&quot; ! Select 200 Hz (fast) AC filter.
  4552. 90 OUTPUT @Dmm;&quot;TRIG:COUN 5&quot; ! DMM will accept 5 triggers.
  4553. 100 OUTPUT @Dmm;&quot;TRIG:SOUR IMM&quot; ! Trigger source is IMMediate.
  4554. 110 OUTPUT @Dmm;&quot;CALC:FUNC DBM&quot; ! Select dBm function.
  4555. 120 OUTPUT @Dmm;&quot;CALC:STAT ON&quot; ! Enable math.
  4556. 130 OUTPUT @Dmm;&quot;READ?&quot; ! Get readings, put in output buffer.
  4557. 140 ENTER @Dmm; Ohms(*)
  4558. 150 PRINT USING &quot;K,1&quot;; Ohms(*)
  4559. 160 END
  4560. </strong></pre>
  4561. <p>
  4562. * The DMM's triggering capabilities were outlined in the last section. You
  4563. can generate triggers either manually or automatically, take multiple
  4564. readings per trigger (up to 50,000), and insert a delay before each reading.
  4565. To trigger the DMM, you must perform the following steps:
  4566. </p>
  4567. <ul>
  4568. <li> You must configure the DMM for the measurement by selecting the function,
  4569. range, resolution, and so on.
  4570. </li>
  4571. <li> Then you must select the trigger source: command trigger (GET or *TRG),
  4572. EXTERNAL TRIGGER input, or an immediate internal trigger.
  4573. </li>
  4574. <li> Then you must make sure that the DMM is ready to accept a trigger by being
  4575. placed in the wait-for-trigger state. A trigger will not be accepted until
  4576. the DMM is in this state.
  4577. </li>
  4578. </ul>
  4579. <p>
  4580. The triggering system is controlled by the following commands:
  4581. </p>
  4582. <pre><strong>
  4583. INITiate Set DMM to wait-for-trigger state.
  4584. FETCh? Get reading from DMM.
  4585. READ? Set DMM to wait-for-trigger state, get readings.
  4586. TRIGger:SOURce Set trigger source.
  4587. TRIGger:DELay Set trigger delay.
  4588. TRIGger:DELay:AUTO Enable or disable automatic trigger delay.
  4589. SAMPLe:COUNt Set number of readings per trigger.
  4590. TRIGger:COUNt Set number of triggers per reading.
  4591. </strong></pre>
  4592. <p>
  4593. Note that all these commands except INITiate and READ? have matching
  4594. queries. Note also that FETCh?, unlike READ, actually doesn't perform any
  4595. triggering action, but it is closely related to INITiate, and so is included
  4596. with the triggering commands.
  4597. </p>
  4598. <p>
  4599. * The DMM's system-related commands cover a grab-bag of functions, such as
  4600. display control, beeper control, queries for DMM errors and status, and reset
  4601. and self-test commands. They include:
  4602. </p>
  4603. <pre><strong>
  4604. DISPlay Turn the DMM display on or off.
  4605. DISPlay? Query the display state.
  4606. DISPlay:TEXT Display up to 12 characters on the DMM display.
  4607. DISPlay:TEXT? Query the display text.
  4608. DISPlay:TEXT:CLEar Clear the message displayed on the front panel.
  4609. SYSTem:BEEPer Issue a single beep immediately.
  4610. SYSTem:BEEPer:STATe Disable or enable a front-panel beeper.
  4611. SYSTem:BEEPer:STATe? Query beeper state.
  4612. SYSTem:ERRor? Query the DMM's error queue.
  4613. SYSTem:VERsion? Query the DMM for SCPI version.
  4614. DATA:POINts? Query the number of readings in the DMM.
  4615. *RST Reset the DMM.
  4616. *TST? Self-test the DMM.
  4617. *IDN? Get DMM ID.
  4618. </strong></pre>
  4619. <p>
  4620. * The DMM's status subsystem was discussed in the last chapter. It includes
  4621. the 488.2 Status Byte and Standard Event register, plus the SCPI questionable
  4622. data register.
  4623. </p>
  4624. <p>
  4625. The Status Byte implements four status bits, as listed below. Note that the
  4626. lowest bit is BIT 0, and that each bit is accompanied by its decimal weight:
  4627. </p>
  4628. <ul>
  4629. <li> BIT 3 (8) -- Questionable Data: Indicates a bit set in the Questionable
  4630. Data register.
  4631. </li>
  4632. <li> BIT 4 (16) -- Message Available: Indicates data available in the output
  4633. queue.
  4634. </li>
  4635. <li> BIT 5 (32) -- Standard Event: Indicates a bit set in the Standard Event
  4636. register.
  4637. </li>
  4638. <li> BIT 6 (64) -- Request Service: Indicates that the DMM has requested
  4639. service.
  4640. </li>
  4641. </ul>
  4642. <p>
  4643. The Status Byte is read during a controller serial poll. If the DMM has
  4644. asserted SRQ, this clears the SRQ and BIT 6. It can also be read with the
  4645. STB? query. In this case BIT 6 will remain set until it is cleared with a
  4646. *CLS command.
  4647. </p>
  4648. <p>
  4649. The Status Byte enable register can be set with the *SRE command and read
  4650. with the *SRE? query; a set bit will cause an SRQ. The enable register can
  4651. only be cleared by sending *SRE 0 or by power-cycling, and even with
  4652. power-cycling, the DMM must have been configured to clear that enable
  4653. register with the *PSC 1 command before power-down. If *PSC 0 has been sent
  4654. instead, the enable settings will be retained.
  4655. </p>
  4656. <p>
  4657. * The Standard Event register implements six status bits:
  4658. </p>
  4659. <ul>
  4660. <li> BIT 0 (1) -- Operation Complete: Indicates that all commands prior to and
  4661. including a *OPC command have been executed.
  4662. </li>
  4663. <li> BIT 2 (4) -- Query Error: Indicates that the DMM tried to read an empty
  4664. output buffer; that a new command line has been sent before a previous
  4665. query has been sent; or that both the input and output buffers are full.
  4666. </li>
  4667. <li> BIT 3 (8) -- Device Error: Indicates that a self-test, calibration, or
  4668. reading overload error occurred.
  4669. </li>
  4670. <li> BIT 4 (16) -- Execution Error: Indicates that a command execution error
  4671. has occurred.
  4672. </li>
  4673. <li> BIT 5 (32) -- Command Error: Indicates a syntax error in a command string
  4674. sent to the DMM.
  4675. </li>
  4676. <li> BIT 7 (128) -- Power On: Indicates that power has been turn on and the
  4677. event register has not yet been read or cleared.
  4678. </li>
  4679. </ul>
  4680. <p>
  4681. The Standard Event register can be read with the *ESR? query. Note that
  4682. this register cannot be written to. The Standard Event enable register is
  4683. written to with the *ESE command and read with the *ESE? query, and bits set
  4684. will cause an SRQ, as long as BIT 5 in the Status Byte Enable register is
  4685. set.
  4686. </p>
  4687. <p>
  4688. Sending an *ESR? clears the Standard Event register. It is also cleared by
  4689. the *CLS command. Similarly to the Status Byte enable register, the Standard
  4690. Event enable register can only be cleared with *ESE 0 or by power-cycling (as
  4691. long as *PSC 1 has been sent before power-down).
  4692. </p>
  4693. <p>
  4694. The Operation Complete flag in this register is particularly handy. Using
  4695. this flag, the controller can initiate a long DMM operation, and then go do
  4696. something else until the operation completes. When the DMM is done, it will
  4697. assert an SRQ and interrupt the controller. The controller has to go through
  4698. the following sequence of steps to implement this scheme:
  4699. </p>
  4700. <pre><strong>
  4701. 100 CLEAR @Dmm ! Clear DMM interface.
  4702. 110 OUTPUT @Dmm;&quot;*CLS&quot; ! Clear DMM status registers.
  4703. 120 OUTPUT @Dmm;&quot;*ESE 1&quot; ! Enable OPC event.
  4704. 130 OUTPUT @Dmm;&quot;*SRE 32&quot; ! Enable SRQ on OPC event.
  4705. 140 OUTPUT @Dmm;&quot;*OPC?&quot; ! Send dummy *OPC? to ensure synch.
  4706. 150 ENTER @Dmm;Dummy ! Read back dummy value.
  4707. 160 ON INTR 7 GOSUB Handler ! Set jump to handler routine on SRQ.
  4708. 170 ENABLE INTR 7;1 ! Enable SRQ interrupt for controller.
  4709. 180 OUTPUT @DMM;&quot;&lt;command&gt;; *OPC?&quot; ! Send command, followed by *OPC?.
  4710. </strong></pre>
  4711. <p>
  4712. The controller will go on and do other things; when the operation is
  4713. complete, the DMM will assert an SRQ and cause a jump to the interrupt
  4714. handler.
  4715. </p>
  4716. <p>
  4717. * The Questionable Data register implements five status bits:
  4718. </p>
  4719. <ul>
  4720. <li> BIT 0 (1) -- Voltage Overload: Indicates overrange on DC volts, AC volts,
  4721. frequency, period, diode, or ratio function.
  4722. </li>
  4723. <li> BIT 1 (2) -- Current Overload: Indicates overrange on DC or AC current
  4724. function.
  4725. </li>
  4726. <li> BIT 9 (512) -- Ohms Overload: Indicates overrange on 2-wire or 4-wire
  4727. ohms test.
  4728. </li>
  4729. <li> BIT 11 (2048) -- Limit Test Fail LO: Indicates that reading has gone
  4730. below the lower limit in the limit test.
  4731. </li>
  4732. <li> BIT 12 (4096) -- Limit Test Fail HI: Indicates that reading has gone
  4733. above the upper limit in the limit test.
  4734. </li>
  4735. </ul>
  4736. <p>
  4737. You can read the Questionable Data register with the STATus:QUEStionable:
  4738. EVENT? query. This action clears the register. *CLS also clears this
  4739. register.
  4740. </p>
  4741. <p>
  4742. The Questionable Data enable register is set with the STATus:QUEStionable:
  4743. ENABle command. It can be read with the STATus:QUESTionable:ENABle? query.
  4744. Bits set will cause an SRQ, as long as BIT 5 in the Status Byte Enable
  4745. register is set. This enable register is <em>always</em> cleared by power-up.
  4746. It can also be cleared by the STATus:PREset command or by setting it to 0 with
  4747. STATus:QUEStionable: ENABle 0.
  4748. </p>
  4749. <p>
  4750. * The calibration commands allow you to perform a calibration of the DMM,
  4751. determine how many times the DMM has been calibrated, set and query
  4752. calibration codes, and set and query calibration information. The
  4753. calibration commands include:
  4754. </p>
  4755. <pre><strong>
  4756. CALibration? Perform a calibration.
  4757. CALibration:COUNt? Get number of calibrations.
  4758. CALibration:SECure:CODE Set calibration security code.
  4759. CALibration:SECure:STATe Unsecure or secure for calibration.
  4760. CALibration:SECure:STATe? Query security state.
  4761. CALibration:STRing Store calibration data.
  4762. CALibration:STRing? Read calibration data.
  4763. CALibration:VALue Set value of calibration reference.
  4764. CALibration:VALue? Read value of calibration reference.
  4765. </strong></pre>
  4766. <p>
  4767. * Finally, to complete the command set, there are three RS-232-only
  4768. (non-SCPI) commands that perform functions that are inherent to HPIB but not
  4769. to RS-232:
  4770. </p>
  4771. <pre><strong>
  4772. SYSTem:LOCal Put DMM into local state.
  4773. SYSTem:REMote Put DMM into remote operation.
  4774. SYSTem:RWLock Put DMM into local lockout.
  4775. </strong></pre>
  4776. <p>
  4777. Note that you will not get RS-232 communications to work properly unless
  4778. you send a SYSTem:REMote command after reset. <em>not</em>
  4779. </p>
  4780. <p>
  4781. * Error codes are not explained in this document, since a description of the
  4782. error accompanies the error code returned by the instrument.
  4783. </p>
  4784. <h2><a name="ib6_m3">[6.3] A SIMPLE 34401 EXAMPLE PROGRAM</a></h2>
  4785. <p>
  4786. * The following HP BASIC example program demonstrates elementary programming
  4787. techniques for the 34401. It uses a simple text-input menu system to allow
  4788. you to read AC or DC volts or current, resistance, and frequency, perform
  4789. test and status operations on the DMM, and clear the display and exit the
  4790. program. A practical program would be more sophisticated, but this is, after
  4791. all, an example.
  4792. </p>
  4793. <pre><strong>
  4794. 10 DIM S$[100],P$[100],M$[5],R$[5] ! String, prompt, mode, reply vars.
  4795. 20 REAL T ! Used for timeout tracking.
  4796. 30 INTEGER Sts ! Stores serial poll result.
  4797. 40 CLEAR SCREEN
  4798. 50 !
  4799. 60 ON TIMEOUT 7,3 GOSUB Timetrap ! Set up timeout trap.
  4800. 70 ASSIGN @Dmm TO 722 ! Open path to DMM.
  4801. 80 ON ERROR GOSUB Errtrap ! Set up error trap.
  4802. 90 !
  4803. 100 M$=&quot;DC&quot; ! Define DC or AC operations.
  4804. 110 LOOP
  4805. 120 P$=&quot;COMMAND: (M)ode=&quot;&amp;M$&amp; / (V)olts / (A)mps&quot;
  4806. 130 DISP P$&amp;&quot; / (O)hms / (F)req / (C)ls / (S)ystem / (Q)uit&quot;;
  4807. 140 INPUT R$ ! Get reply to prompt.
  4808. 150 IF R$=&quot;&quot; THEN R$=&quot;Z&quot; ! Check for empty input.
  4809. 160 R$=UPC$(R$[1,1]) ! Get first character as uppercase.
  4810. 170 !
  4811. 180 SELECT R$ ! Test character:
  4812. 190 !
  4813. 200 CASE &quot;M&quot; ! Mode: Toggle mode between DC &amp; AC.
  4814. 210 IF M$=&quot;DC&quot; THEN
  4815. 220 M$=&quot;AC&quot;
  4816. 230 ELSE
  4817. 240 M$=&quot;DC&quot;
  4818. 250 END IF
  4819. 260 !
  4820. 270 CASE &quot;V&quot; ! Volts: Get AC or DC volts.
  4821. 280 DISP &quot;Getting volts ... &quot;
  4822. 290 IF M$=&quot;DC&quot; THEN
  4823. 300 OUTPUT @Dmm;&quot;MEAS:VOLT:DC?&quot;
  4824. 310 ELSE
  4825. 320 OUTPUT @Dmm;&quot;MEAS:VOLT:AC?&quot;
  4826. 330 END IF
  4827. 340 ENTER @Dmm;S$
  4828. 350 PRINT &quot;Voltage value: &quot;;S$
  4829. 360 !
  4830. 370 CASE &quot;A&quot; ! Amps: Get AC or DC amps.
  4831. 380 DISP &quot;Getting amps ... &quot;
  4832. 390 IF M$=&quot;DC&quot; THEN
  4833. 400 OUTPUT @Dmm;&quot;MEAS:CURR:DC?&quot;
  4834. 410 ELSE
  4835. 420 OUTPUT @Dmm;&quot;MEAS:CURR:AC?&quot;
  4836. 430 END IF
  4837. 440 ENTER @Dmm;S$
  4838. 450 PRINT &quot;Current value: &quot;;S$
  4839. 460 !
  4840. 470 CASE &quot;O&quot; ! Ohms: Get 2-wire resistance.
  4841. 480 DISP &quot;Getting resistance ... &quot;
  4842. 490 OUTPUT @Dmm;&quot;MEAS:RES?&quot;
  4843. 500 ENTER @Dmm;S$
  4844. 510 PRINT &quot;Ohms value: &quot;;S$
  4845. 520 !
  4846. 530 CASE &quot;F&quot; ! Freq: Get frequency.
  4847. 540 DISP &quot;Getting frequency ... &quot;
  4848. 550 OUTPUT @Dmm;&quot;MEAS:FREQ?&quot;
  4849. 560 ENTER @Dmm;S$
  4850. 570 PRINT &quot;Frequency value: &quot;;S$
  4851. 580 !
  4852. 590 CASE &quot;C&quot; ! Cls: Clear display.
  4853. 600 CLEAR SCREEN
  4854. 610 !
  4855. 620 CASE &quot;S&quot; ! System: Do system functions.
  4856. 630 GOSUB System
  4857. 640 !
  4858. 650 CASE &quot;Q&quot; ! Quit program.
  4859. 660 DISP &quot;Done!&quot;
  4860. 670 STOP
  4861. 680 !
  4862. 690 CASE ELSE ! Bogus input.
  4863. 700 INPUT &quot;ERROR: Bad command. Press enter to continue.&quot;,R$
  4864. 710 !
  4865. 720 END SELECT
  4866. 730 END LOOP
  4867. 740 !
  4868. 750 System: ! Perform system commands.
  4869. 760 LOOP
  4870. 770 INPUT &quot;COMMAND: (C)lear / (I)d / (T)est / (E)rror / (R)eturn&quot;,R$
  4871. 780 IF R$=&quot;&quot; THEN R$=&quot;Z&quot; ! Test for empty input.
  4872. 790 R$=UPC$(R$[1,1]) ! Get first character as uppercase.
  4873. 800 !
  4874. 810 SELECT R$ ! Test character:
  4875. 820 !
  4876. 830 CASE &quot;C&quot; ! Clear DMM.
  4877. 840 DISP &quot;Clearing DMM ... &quot;
  4878. 850 CLEAR @Dmm
  4879. 860 OUTPUT @Dmm;&quot;*RST;*CLS&quot;
  4880. 870 PRINT &quot;Reset complete!&quot;
  4881. 880 !
  4882. 890 CASE &quot;I&quot; ! Get ID string.
  4883. 900 DISP &quot;Getting ID ... &quot;
  4884. 910 OUTPUT @Dmm;&quot;*IDN?&quot;
  4885. 920 ENTER @Dmm;S$
  4886. 930 PRINT &quot;Dmm ID string: &quot;;S$
  4887. 940 !
  4888. 950 CASE &quot;T&quot; ! Self-test DMM.
  4889. 960 DISP &quot;Testing ... &quot;
  4890. 970 OUTPUT @Dmm;&quot;*CLS;*ESE 1;*OPC?&quot; ! Flag OPC when test over.
  4891. 980 ENTER @Dmm;S$
  4892. 990 OUTPUT @Dmm;&quot;*TST?;*OPC&quot; ! Test, flag OPC.
  4893. 1000 T=TIMEDATE ! Get initial time.
  4894. 1010 LOOP
  4895. 1020 Sts=SPOLL(@Dmm) ! Spoll for ESB (=OPC) bit.
  4896. 1030 EXIT IF BIT(Sts,5)=1
  4897. 1040 EXIT IF TIMEDATE-T&gt;30 ! Keep checking for 30 seconds.
  4898. 1050 END LOOP
  4899. 1060 IF BIT(Sts,5)=1 THEN
  4900. 1070 ENTER @Dmm;S$
  4901. 1080 PRINT &quot;Test status: &quot;;S$
  4902. 1090 ELSE
  4903. 1100 PRINT &quot;Test timed out!&quot;
  4904. 1110 END IF
  4905. 1120 !
  4906. 1130 CASE &quot;E&quot; ! Get error status.
  4907. 1140 DISP &quot;Getting error status ... &quot;
  4908. 1150 OUTPUT @Dmm;&quot;SYST:ERR?&quot;
  4909. 1160 ENTER @Dmm;S$
  4910. 1170 PRINT &quot;Error status: &quot;;S$
  4911. 1180 !
  4912. 1190 CASE &quot;R&quot; ! Return to main.
  4913. 1200 RETURN
  4914. 1210 !
  4915. 1220 CASE ELSE ! Bogus input.
  4916. 1230 INPUT &quot;ERROR: Bad command. Press enter to continue.&quot;,R$
  4917. 1240 !
  4918. 1250 END SELECT
  4919. 1260 !
  4920. 1270 END LOOP
  4921. 1280 RETURN
  4922. 1290 !
  4923. 1300 Timetrap: ! Trap timeout error.
  4924. 1310 INPUT &quot;ERROR: Timeout -- press Enter to continue.&quot;,R$
  4925. 1320 ERROR RETURN
  4926. 1330 !
  4927. 1340 Errtrap: ! Trap error.
  4928. 1350 PRINT ERRM$ ! Print error string.
  4929. 1360 INPUT &quot;ERROR: Press Enter to continue.&quot;,R$
  4930. 1370 ERROR RETURN
  4931. 1380 !
  4932. 1390 END
  4933. </strong></pre>
  4934. <hr />
  4935. <h1><a name="ib7_m0">[7.0] HPIB Tutor (7): Notes &amp; Comments</a></h1>
  4936. <p>
  4937. * This last chapter covers a few interesting topics in HPIB not easily
  4938. discussed elsewhere.
  4939. </p>
  4940. <hr />
  4941. <ul>
  4942. <li>
  4943. <a href="#ib7_m1">[7.1] BENCHMARKS</a>
  4944. </li>
  4945. <li>
  4946. <a href="#ib7_m2">[7.2] PASS CONTROL &amp; NON-CONTROLLER OPERATION</a>
  4947. </li>
  4948. </ul>
  4949. <hr />
  4950. <p>
  4951. <a href="#top">BACK TO INDEX</a>
  4952. </p>
  4953. <h2><a name="ib7_m1">[7.1] BENCHMARKS</a></h2>
  4954. <p>
  4955. * There is an old saying that there are lies, damn lies, and statistics, to
  4956. which a modern wit added &quot;damn statistics&quot; (&quot;four out of five doctors
  4957. recommend&quot;), then &quot;benchmarks&quot;. To this I add: &quot;damn benchmarks&quot;.
  4958. </p>
  4959. <p>
  4960. Benchmarking is a confusing topic where one is given a very specific value
  4961. whose <em>real</em> relationship to what he or she actually wants to know is no
  4962. more than an approximation, subject to a number of conditions.
  4963. </p>
  4964. <p>
  4965. This is, as shall be explained, inevitable, so the important question is one
  4966. of what constitutes &quot;benchmarks&quot; (honestly-stated information) and what
  4967. constitutes &quot;damn benchmarks&quot; (meaningless hype), and how one can tell the
  4968. difference.
  4969. </p>
  4970. <p>
  4971. * In the case of HPIB, there are a lot of benchmarks and damn benchmarks out
  4972. there. Customers often want to get estimates for the performance (in
  4973. kilobytes per second) they can expect to obtain for an HPIB application with
  4974. a specific HPIB card. There are two types of benchmarks that need to be
  4975. provided in response: &quot;typical&quot; performance figures, and &quot;maximum&quot;
  4976. performance figures.
  4977. </p>
  4978. <p>
  4979. Typical performance figures are usually obtained by setting up the PC and a
  4980. low-cost instrument (the HP 34401 &quot;Alf&quot; DMM is currently popular for this
  4981. task) and then simulating a typical customer application.
  4982. </p>
  4983. <p>
  4984. This sounds simple enough, and it is, but the complexity comes in considering
  4985. what information you're getting out of it. The performance of the system
  4986. will depend on four factors:
  4987. </p>
  4988. <ul>
  4989. <li> The speed of the PC running the test. The simplest way of judging a PC's
  4990. speed is the clock speed of the processor, but this can be highly
  4991. misleading, since it doesn't take into consideration the fact that the
  4992. processor may have a 16-bit or 32-bit data path width, different speeds of
  4993. RAM, different amounts and speeds of cache -- and, more importantly, such
  4994. overall system considerations as display graphics speed, hard disk speed,
  4995. and whether DOS or Windows is running the test. (There are utilities
  4996. available to give a figure of merit of overall PC performance, but their
  4997. results are highly dependent on the assumptions used in their design.)
  4998. </li>
  4999. <li> The assumptions used in writing the program to make the test, as well as
  5000. the language used -- C or BASIC or whatever -- used to write the program.
  5001. An unrealistic example program would simply send a command and read a
  5002. value over and over again. A realistic example program would update a
  5003. graphics display, store the data returned in a file, and do error and
  5004. status checking, emulating a simple data-logging application.
  5005. </li>
  5006. <li> The type of HPIB card used in the PC. As will be discussed momentarily,
  5007. this is the least important consideration in this type of benchmark.
  5008. </li>
  5009. <li> The speed at which the instrument can communicate. This is a <em>very</em>
  5010. important consideration. HPIB is designed so that one device cannot talk
  5011. faster than another device can listen (which is not true for, say,
  5012. people), and of course one device cannot listen faster than the other
  5013. talks (which is true for people and everything else, as imposed by simple
  5014. logic).
  5015. <p>
  5016. Note that many benchmark requests are for performance of HPIB with a
  5017. specific instrument. However, in this document the issue is deriving
  5018. general performance figures for the PC's HPIB card, and instrument
  5019. performance, though important in itself, will not be considered further
  5020. here.
  5021. </p>
  5022. </li>
  5023. </ul>
  5024. <p>
  5025. In practice, such a typical benchmark says almost nothing about the
  5026. performance of an HPIB card, since almost any HPIB card you could buy would
  5027. be able to keep up with the actions of the system. The speed will be far more
  5028. determined by the PC and the design of the program, since the data
  5029. transactions over HPIB are a small part of the total. The typical benchmark
  5030. is useful in that it provides a minimum value that the user can expect to
  5031. obtain.
  5032. </p>
  5033. <p>
  5034. * The maximum performance benchmark is where things get more interesting. In
  5035. this case, the benchmark is optimized for the maximum possible performance to
  5036. provide an upper limit on HPIB card operation.
  5037. </p>
  5038. <p>
  5039. The four constraints outlined for the typical benchmark above apply in the
  5040. maximum performance benchmark case as well, but with added subtleties:
  5041. </p>
  5042. <ul>
  5043. <li> PC operation speed is optimized. This means going into the PC's
  5044. configuration files and eliminating anything that might hinder the
  5045. benchmark's performance, and tweaking anything left that could be tweaked
  5046. that could enhance it by, say, freeing up as much memory as possible.
  5047. Hard disk drives will be defragmented, disk cache sizes will be increased,
  5048. and compressed drives will not be used for the test (since the data
  5049. compression algorithm will slow down data storage as compared to an
  5050. uncompressed disk).
  5051. <p>
  5052. PC configurations can vary enough so that even the same model of PC with
  5053. the same options can give surprisingly different results.
  5054. </p>
  5055. </li>
  5056. <li> The program itself will be optimized for raw speed. To this end, the
  5057. program will be written strictly to obtain data from the instrument using
  5058. the fastest possible instrument operation mode -- and in <em>as large blocks
  5059. of data as possible</em>. It will do <em>absolutely nothing else</em>.
  5060. <p>
  5061. This is not deceptive, since this particular benchmark is intended to
  5062. determined maximum sustained performance, an important specification for
  5063. many practical applications. For typical HPIB operation involving many
  5064. small transfers of commands and data, this spec says very little. A
  5065. Lamborghini is a fast car, but if it's caught in city traffic it can't go
  5066. any faster than any other car.
  5067. </p>
  5068. <p>
  5069. HPIB communications tend to increase greatly in speed as the block size of
  5070. a single transfer operation increases in length. This is because telling
  5071. an instrument to do something requires sending a few commands, providing a
  5072. certain overhead for the transaction, and each individual HPIB operation
  5073. invoked by the program has a certain overhead as well. If you have one
  5074. very long transfer of data in a single HPIB operation, then as the
  5075. transaction gets longer, the overhead time becomes more negligible in
  5076. comparison.
  5077. </p>
  5078. <p>
  5079. The assumptions of the program's design are important again, though what
  5080. constitutes &quot;realistic&quot; and &quot;unrealistic&quot; in this case are a little more
  5081. evasive.
  5082. </p>
  5083. <p>
  5084. First, there is the question of whether the instrument is being instructed
  5085. to perform a realistic operation, or is simply being told to return data
  5086. even though it cannot realistically obtain data at that rate. This is
  5087. usually not much of a worry if the person making the benchmark has a good
  5088. grasp of the instrument.
  5089. </p>
  5090. <p>
  5091. Second, and more important, are the issues of what is done with the data
  5092. when it is returned, and how much is returned. The fastest benchmarks
  5093. will throw away the data returned from the instrument, which is entirely
  5094. unrealistic. More realistic benchmarks will store it in memory, and a
  5095. better benchmark will store it to hard disk. (It is not practical in most
  5096. cases to manipulate data as it is coming in if speed is desired, so data
  5097. has to be stored and manipulated later.)
  5098. </p>
  5099. <p>
  5100. The amount of data affects the benchmark as well, since simply getting
  5101. back a one-second burst of data will give, in general, faster rates than
  5102. getting back the data over a period of several minutes. If the data is
  5103. stored to disk, the amount is important as well, because once disk cache
  5104. is filled up the speed of disk access changes abruptly. If you don't get
  5105. close to that limit, you won't have a realistic assessment of the impact
  5106. of hard disk speed since the data is <em>really</em> being stored in RAM.
  5107. </p>
  5108. <p>
  5109. Note that in some applications a customer may simply want to get a short
  5110. burst of data and put it in memory, rather than store data on disk for
  5111. several minutes, and the short-burst-to-memory benchmark -- usually about
  5112. twice as fast as a sustained transfer to disk -- may be precisely what is
  5113. desired.
  5114. </p>
  5115. </li>
  5116. <li> The HPIB card's speed is important in a maximum-performance benchmark
  5117. since it now becomes the bottleneck, and the card itself isn't all there
  5118. is to it any more. The configuration of the HPIB connections made in the
  5119. benchmark system also becomes important, since HPIB transfers slow down
  5120. perceptibly when more and longer cables are added to the system, analogous
  5121. to the fact that filling up pipes from a pump becomes slower when you have
  5122. more and longer pipes to fill.
  5123. <p>
  5124. For maximum performance, it is a reasonable assumption to insist on a
  5125. single short cable to the instrument, since if the user wants to obtain
  5126. maximum speed in practice that will be required.
  5127. </p>
  5128. <p>
  5129. The use of short connections also allows further optimizations, since many
  5130. HPIB cards can be reprogrammed to use faster bus timing that isn't
  5131. realistic in other circumstances. Again, this isn't deceptive if a
  5132. maximum performance figure is desired, but such optimizations are
  5133. inapplicable for typical operation.
  5134. </p>
  5135. </li>
  5136. <li> The speed of the instrument also becomes a major factor for maximum
  5137. performance benchmarks; there are relatively few instruments that can
  5138. operate above, say, 250 kilobytes per second, and most are below 100
  5139. kilobytes per second -- the PC's HPIB card is often faster and so is just
  5140. waiting on the instrument.
  5141. <p>
  5142. Some benchmarks are performed using dummy devices. I often use a second
  5143. computer with an HPIB card as a dummy device, which is in practice pretty
  5144. realistic, but sometimes specialized hardware is used to determine maximum
  5145. HPIB card transfer rates. This is unrealistic, except for determining the
  5146. absolute theoretical limit of the card's operation. The card will never
  5147. come close to that rate in practical operation.
  5148. </p>
  5149. </li>
  5150. </ul>
  5151. <p>
  5152. The maximum-performance benchmark actually does reveal true facts about the
  5153. HPIB card, but it is made under constrained and specific circumstances, and
  5154. except in providing an upper limit, only gives specific information when the
  5155. test conditions are fully known.
  5156. </p>
  5157. <p>
  5158. Note that some vendors are promoting HPIB card with supposed
  5159. enhanced-performance features. The catch is that such enhanced performance
  5160. is only available under specialized circumstances (as above) and with
  5161. instruments that also support the same enhanced-performance spec, and which
  5162. are few in number these days. There is a need for a faster instrument
  5163. interface than HPIB, but it will probably be derived from new high-speed
  5164. serial buses and the like currently being implemented on PCs.
  5165. </p>
  5166. <p>
  5167. * In summary, when you ask for benchmark figures, you will need to know what
  5168. you are asking for and what you can expect. What most users want to know is:
  5169. &quot;How fast can my application run?&quot; Without implementing the application,
  5170. nobody can say. All that can be done is give an estimate of limits and
  5171. constraints.
  5172. </p>
  5173. <p>
  5174. Realistic benchmarks will provide both typical and maximum performance
  5175. figures, with an outline of what the benchmark programs do and the necessary
  5176. details, such as the type and configuration of PC, the programming language
  5177. used, the instrument used in the test, and so on. Any reasonable benchmark
  5178. will also clearly state that there is no guarantee that a specific
  5179. application will obtain the same figures, since the specific performance only
  5180. relates to the benchmark test itself.
  5181. </p>
  5182. <p>
  5183. In marketing copy, it is hard to point out these details, so you should
  5184. assume that if you are given a performance figure without comment it is a
  5185. maximum figure and obtained under optimum circumstances. Really impressive
  5186. performance figures (some vendors quote a &quot;megabyte per second&quot;, which is the
  5187. theoretical limit to HPIB transfer rates) should be regarded with suspicion
  5188. as &quot;damn benchmarks&quot; since they were probably put together using unrealistic
  5189. assumptions.
  5190. </p>
  5191. <p>
  5192. In practice, actual performance is a system issue, and will be determined by
  5193. the user's knowledge of all system elements -- PC configuration, program
  5194. design, HPIB optimization, and instrument operation. A fast HPIB card counts
  5195. for very little if the application is dumping data to a bottleneck like a
  5196. tape drive. But having realistic benchmarks for any one element will tell
  5197. you what is, and what is not, possible.
  5198. </p>
  5199. <h2><a name="ib7_m2">[7.2] PASS CONTROL &amp; NON-CONTROLLER OPERATION</a></h2>
  5200. <p>
  5201. * Some HPIB programmers attempt to write programs that assume non-controller
  5202. operation. They want to either temporarily pass control to another
  5203. controller, or operate as a pure slave (talk-listen-but-not-control) device
  5204. They find they run into difficulties.
  5205. </p>
  5206. <p>
  5207. While passing control is straightforward, it does require a good
  5208. understanding of how the HPIB protocols (and the interface library that
  5209. implements them) work. However, operation as a slave is much trickier and
  5210. very difficult to implement in a reliable fashion.
  5211. </p>
  5212. <p>
  5213. This problem is compounded by the fact that many interface libraries
  5214. implement pass-control or slave-operation features in a slipshod fashion, and
  5215. often have not tested what they have implemented in any methodical way. For
  5216. these reasons, it is strongly recommended that passing control not be done
  5217. unless there is no other way to do the required task, and that slave
  5218. operation be avoided if at all possible.
  5219. </p>
  5220. <p>
  5221. Nonetheless, if you are forced to deal with these matters, hear are some
  5222. clues and hints. Since HP BASIC for stand-alone workstations has the most
  5223. robust HPIB implmentation I know of, the discussion is purely based on HP
  5224. BASIC commands. You will need to find analogous commands on your target
  5225. system, though it is likely the implementation will not be anywhere near as
  5226. good.
  5227. </p>
  5228. <p>
  5229. The following discussion necessarily repeats information provided in a more
  5230. terse fashion in earlier chapters for the sake of coherence.
  5231. </p>
  5232. <p>
  5233. * If you have multiple controllers on the same HPIB, one will be the system
  5234. controller and all the others will be non-system controllers. On traditional
  5235. HP BASIC workstations, this is set with a DIP switch.
  5236. </p>
  5237. <p>
  5238. The first visible distinction between the two is this: when you power up the
  5239. controllers, the system controller will come up by default operating as a
  5240. controller -- that is, you will be able to communicate with instruments --
  5241. while the non-system controllers will be operating by default as slaves --
  5242. that is, they will not be able to address any devices on the HPIB.
  5243. </p>
  5244. <p>
  5245. This means that if you perform:
  5246. </p>
  5247. <pre><strong>
  5248. OUTPUT 705;&quot;*IDN?&quot;
  5249. </strong></pre>
  5250. <p>
  5251. -- on the system controller, it will work fine (assuming that there is a
  5252. device with address 705 out there on the HPIB), but if you do it with a
  5253. non-system controller, you'll get an error message:
  5254. </p>
  5255. <pre><strong>
  5256. ERROR 173 Active/system controller req'd
  5257. </strong></pre>
  5258. <p>
  5259. Some users set up a non-system controller, get this error message, and think
  5260. it's a bug. No, it's doing what it's supposed to be doing.
  5261. </p>
  5262. <p>
  5263. Now suppose you put these two controllers on the same HPIB and wish to pass
  5264. control between them. The first issue is one which is often forgotten by
  5265. HPIB users: that a controller has an HPIB address, just like an instrument
  5266. (the default controller address for an RMB workstation is 21), and you
  5267. can't have two devices on the bus with the exact same address.
  5268. </p>
  5269. <p>
  5270. Fortunately, you can set a controller to another HPIB address by writing to
  5271. HPIB status register 3:
  5272. </p>
  5273. <pre><strong>
  5274. CONTROL 7,3;1 ! Set interface 7 to HPIB address 1.
  5275. </strong></pre>
  5276. <p>
  5277. I assume the HPIB is at interface select code 7, a convention that I will
  5278. stick with in the rest of the discussion. I usually prefer to set the
  5279. non-system controller to address 1 and leave the system controller to address
  5280. 21.
  5281. </p>
  5282. <p>
  5283. Given this knowledge, it is perfectly easy to pass control from the system
  5284. controller to the non-system controller with:
  5285. </p>
  5286. <pre><strong>
  5287. PASS CONTROL 701 ! Sends TCT (Take ConTrol) byte.
  5288. </strong></pre>
  5289. <p>
  5290. The non-system controller can then pass it back with:
  5291. </p>
  5292. <pre><strong>
  5293. PASS CONTROL 721
  5294. </strong></pre>
  5295. <p>
  5296. * Seems pretty simple, right? Well, it is simple, but not quite that
  5297. simple. There's a few other details to consider. <em>that</em>
  5298. </p>
  5299. <p>
  5300. The first detail can be phrased as a question: how does an RMB program know
  5301. if it's running on a system controller or nonsystem controller, or if it is
  5302. the current active controller? Without this knowledge, the ability to pass
  5303. control will lead quickly to mutual confusion within the programs on the two
  5304. systems.
  5305. </p>
  5306. <p>
  5307. This is pretty straightforward, with that information provided by status
  5308. register 3. Bit 7 says if the controller is a system controller (1) or
  5309. non-system controller (0) and bit 6 says if the controller is the active
  5310. controller (1) or inactive controller (0):
  5311. </p>
  5312. <pre><strong>
  5313. STATUS 7,2;Sts
  5314. IF BIT(Sts,7)=1 THEN
  5315. PRINT &quot;System controller.&quot;
  5316. ELSE
  5317. PRINT &quot;Non-system controller.&quot;
  5318. END IF
  5319. IF BIT(Sts,6)=1 THEN
  5320. PRINT &quot;Active controller.&quot;
  5321. ELSE
  5322. PRINT &quot;Inactive controller.&quot;
  5323. END IF
  5324. </strong></pre>
  5325. <p>
  5326. Note that the five lowest bits of status register 3 also give the HPIB
  5327. address of the controller:
  5328. </p>
  5329. <pre><strong>
  5330. PRINT &quot;HPIB Address =&quot;;BINAND(Sts,31) ! Print lowest five bits.
  5331. </strong></pre>
  5332. <p>
  5333. Anyway, this status is essential for avoiding confusion in
  5334. controller-noncontroller operation.
  5335. </p>
  5336. <p>
  5337. * The second detail concerns the actual protocol for passing control. To be
  5338. sure, if one controller passes control to a second controller, the second
  5339. controller becomes active controller without any further trouble, but
  5340. usually the inactive controller is the one driving the process, since it
  5341. wants to do something and the active controller is in the way.
  5342. </p>
  5343. <p>
  5344. So the inactive controller can assert an SRQ -- service request -- using
  5345. the REQUEST statement to ask the active controller to pass control:
  5346. </p>
  5347. <pre><strong>
  5348. REQUEST 7,64
  5349. </strong></pre>
  5350. <p>
  5351. Note that only the interface select code is specified. Naturally, since all
  5352. this does is assert the SRQ line and make a serial poll response byte (here
  5353. given as 64) available. A value of 64 sets bit 6, which indicates a service
  5354. request. Setting any other bits is optional.
  5355. </p>
  5356. <p>
  5357. The active controller will then perform serial polls to see who asserted the
  5358. SRQ. If it's the inactive controller, it then passes control:
  5359. </p>
  5360. <pre><strong>
  5361. STATUS 7,7;Sts
  5362. IF BIT(Sts,10)=1 THEN ! SRQ bit is bit 10 of HPIB status 7.
  5363. Sts=SPOLL(701) ! Serial poll inactive controller.
  5364. IF BIT(Sts,6)=1 THEN ! If SRQ bit set, then pass control.
  5365. PASS CONTROL 701
  5366. END IF
  5367. END IF
  5368. </strong></pre>
  5369. <p>
  5370. This code sample assumes operation on the system controller. Note that this
  5371. sample actually checks the SRQ bit in status register 7 to see if an SRQ
  5372. has happened. In reality, it may be easier to do it using an interrupt:
  5373. </p>
  5374. <pre><strong>
  5375. ON INTR 7 GOSUB Srqtrap ! Set up jump.
  5376. ENABLE INTR 7,2 ! Specify SRQ interrupt.
  5377. ...
  5378. Srqtrap: !
  5379. Sts=SPOLL(701)
  5380. IF BIT(Sts,6)=1 THEN
  5381. PASS CONTROL 701
  5382. END IF
  5383. RETURN
  5384. </strong></pre>
  5385. <p>
  5386. * The third detail is that the system controller can, unlike all the other
  5387. controllers on the same HPIB, get control back any time it wants it, by
  5388. executing the command ABORT, which asserts IFC (interface clear) and restores
  5389. all the interfaces to their default state.
  5390. </p>
  5391. <p>
  5392. * The distinction between the concepts of system controller and active
  5393. controller should be clearly described by the discussion so far, but since
  5394. this is a confusing issue let me summarize it.
  5395. </p>
  5396. <p>
  5397. There can be multiple controllers on a single HPIB connection. Any of them
  5398. can be active controller if control is passed to them. There is, however,
  5399. only one system controller. It comes up as active controller on boot-up
  5400. (the non-system controllers are inactive on boot-up), and it can take control
  5401. back from any other controller by executing ABORT.
  5402. </p>
  5403. <p>
  5404. The system controller is not necessarily the active controller. The active
  5405. controller can jump from controller to controller as control is passed over
  5406. the bus. But it is <em>always</em> the system controller, and it is the <em>only</em>
  5407. system controller.
  5408. </p>
  5409. <p>
  5410. * This explains about all there is to know about passing control in itself,
  5411. with the exception of one final detail: why do it?
  5412. </p>
  5413. <p>
  5414. The only good reason that I know for passing control is that instruments
  5415. often have the capability to dump a plot to a plotter or printer on the same
  5416. HPIB. Some of the older instruments will demand to be made system controller
  5417. for this operation. The program sends it a command to print, passes
  5418. control to it, then wait for it to pass control back.
  5419. </p>
  5420. <p>
  5421. However, it is a common misconception that this is the <em>only</em> way to
  5422. perform this task. The logic is that the instrument is talking to the
  5423. printer or plotter, and of course it has to be a controller to do that,
  5424. right?
  5425. </p>
  5426. <p>
  5427. No, not really. A controller can set up one device as a talker and another
  5428. as a listener, and then the two can talk to each other without controller
  5429. intervention. Assuming an instrument at address 713 and a printer at address
  5430. 705, most instruments that have the capability to dump directly to a printer
  5431. could be instructed to do so with something like this:
  5432. </p>
  5433. <pre><strong>
  5434. OUTPUT 713;&quot;PRINT?&quot;
  5435. SEND 7;UNT UNL TALK 713 LISTEN 705 DATA &quot;&quot;
  5436. </strong></pre>
  5437. <p>
  5438. The SEND command sends HPIB command bytes, setting up the talker-listener
  5439. transaction (the DATA &quot;&quot; at the end releases the ATN line, allowing the
  5440. transaction to proceed).
  5441. </p>
  5442. <p>
  5443. Of course, if the instrument understands the 488.2 OPC? (operation complete)
  5444. query, the program can also instruct it to assert an SRQ when it is done with
  5445. the print operation. However, that is a little beyond the scope of this
  5446. discussion.
  5447. </p>
  5448. <p>
  5449. * So passing control can be done easily, but in general it's not all that
  5450. useful. What is not so easy to do is try to write an RMB program that
  5451. operates completely in noncontroller mode -- that is, just like an instrument
  5452. on the HPIB, its operations directed by the controller.
  5453. </p>
  5454. <p>
  5455. Using an HPIB controller is easy. It tells the other devices what to do
  5456. whenever it pleases, and they have to respond accordingly. For this reason,
  5457. being an HPIB slave is hard. It has to respond whenever required, with the
  5458. information the controller expects to get back.
  5459. </p>
  5460. <p>
  5461. This normally means that you have to set up an interrupt in the noncontroller
  5462. so it can respond when needed. The most useful interrupt for this purpose is
  5463. the &quot;talker-listener address change&quot; (TLAC) flag associated with the
  5464. interface, which is asserted any time the slave is addressed. An interrupt
  5465. on TLAC can be set up as follows:
  5466. </p>
  5467. <pre><strong>
  5468. ON INTR 7 GOSUB Tlacintr
  5469. ENABLE INTR 7;256
  5470. </strong></pre>
  5471. <p>
  5472. When the slave gets the TLAC interrupt, it can then check to see if it is
  5473. addresses to talk or listen and respond accordingly:
  5474. </p>
  5475. <pre><strong>
  5476. Tlacintr: !
  5477. STATUS 7,6;Sts
  5478. IF BIT(Sts,10)=1 THEN ! Addressed to listen (LADS).
  5479. ENTER 7;S$ ! Get a command (I/O is from interface).
  5480. ELSE
  5481. IF BIT(Sts,9)=1 THEN ! Addressed to talk (TADS)
  5482. SELECT S$
  5483. CASE &quot;*IDN?&quot;
  5484. OUTPUT 7;Addrstr$
  5485. ...
  5486. END SELECT
  5487. END IF
  5488. END IF
  5489. </strong></pre>
  5490. <p>
  5491. Note that status register 6 contains the listen-addressed (LADS) bit (bit 10)
  5492. and the talk-addressed (TADS) bit (bit 9), and that the ENTERs and OUTPUTs
  5493. have to be from the interface (remember, only a controller has addressing
  5494. privileges).
  5495. </p>
  5496. <p>
  5497. This is a pretty rough outline of what needs to be done, however. The slave
  5498. must actually be able to respond precisely to whatever the controller asks of
  5499. it using the list of CASE statments above. The protocol for doing this has to
  5500. be agreed-on by the controller and slave.
  5501. </p>
  5502. <p>
  5503. This is not too hard if the controller just sends a command and the slave
  5504. makes a response. The slave's operation would look something like this:
  5505. </p>
  5506. <pre><strong>
  5507. get TLAC interrupt
  5508. slave is listen addressed
  5509. get and check command
  5510. go back to wait on TLAC interrupt
  5511. get TLAC interrupt
  5512. slave is talk addressed
  5513. provide proper output for command
  5514. go back and wait on TLAC interrupt
  5515. </strong></pre>
  5516. <p>
  5517. The slave has to do a lot of error checking, however. If anything goes
  5518. wrong, it needs to issue an error and then go back and wait for the
  5519. controller to issue a new command it understands.
  5520. </p>
  5521. <p>
  5522. Where this gets really tricky is when you want to transfer, say, a file of
  5523. indeterminate length between the controller and slave. Once the slave has
  5524. been given the command to send a file and is then addressed to talk, it then
  5525. must sit in a loop and send the file line by line and assume the controller
  5526. is reading it, since the slave remains in talk mode until otherwise
  5527. instructed. On the last line, the slave needs to assert EOI with the last
  5528. byte to tell the controller that the transmission is over. Similar comments
  5529. apply to transferring a file from the controller to the slave.
  5530. </p>
  5531. <p>
  5532. This may sound straightforward, but in practice it can be a real nuisance to
  5533. get to work. RS-232, which is a peer-to-peer system, for once works better
  5534. than HPIB.
  5535. </p>
  5536. <p>
  5537. In summary, once more: you don't want to try to do things like this if you
  5538. have any choice in the matter. Under RMB it is tricky. Under other
  5539. applications and interface libraries, it may be completely impossible.
  5540. </p>
  5541. <hr />
  5542. </body>
  5543. </html>