tutorial
15 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
15 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

mailto:norume@aps.anl.gov../asynDriver.htmltutorial.pdf../devGpib.htmlHowtocreateEPICSdevicesupportforasimpleserialorGPIBdeviceW.EricNorumnorume.aps.anl.govAugust19,20091 IntroductionThistutorialprovidesstep by stepinstructionsonhowtocreateEPICSsupportforasimpleserialorGPIB(IEEE 488)device. The steps are presented in a way that should make it possible to apply them in cookbook fashion to createsupport for other devices. For comprehensive description of all the details of the I/O system used here, refer to theasynDriver anddevGpib documentation.This document isn’t for the absolute newcomer though. You must have EPICS installed on a system somewhere andknowhowtobuildandruntheexampleapplication. Inparticularyoumusthavethefollowinginstalled:• EPICSR3.14.6orhigher.• EPICSmodules/soft/asynversion4.0orhigher.Serial and GPIB devices can now be treated in much the same way. The EPICS ’asyn’ driver devGpib module canuse the low level drivers which communicate with serial devices connected to ports on the IOC or to Ethernet/SerialconvertersorwithGPIBdevicesconnectedtolocalI/OcardsortoEthernet/GPIBconverters.I based this tutorial on the device support I wrote for a CVI Laser Corporation AB300 filter wheel. You’re almostcertainly interested in controlling some other device so you won’t be able to use the information directly. I chosethe AB300 as the basis for this tutorial since the AB300 has a very limited command set, which keeps this documentsmall, and yet ...

Informations

Publié par
Nombre de lectures 110
Langue English

Extrait

HowtocreateEPICSdevicesupportforasimpleserialorGPIB
device
W.EricNorum
norume.aps.anl.gov
August19,2009
1 Introduction
Thistutorialprovidesstep by stepinstructionsonhowtocreateEPICSsupportforasimpleserialorGPIB(IEEE 488)
device. The steps are presented in a way that should make it possible to apply them in cookbook fashion to create
support for other devices. For comprehensive description of all the details of the I/O system used here, refer to the
asynDriver anddevGpib documentation.
This document isn’t for the absolute newcomer though. You must have EPICS installed on a system somewhere and
knowhowtobuildandruntheexampleapplication. Inparticularyoumusthavethefollowinginstalled:
• EPICSR3.14.6orhigher.
• EPICSmodules/soft/asynversion4.0orhigher.
Serial and GPIB devices can now be treated in much the same way. The EPICS ’asyn’ driver devGpib module can
use the low level drivers which communicate with serial devices connected to ports on the IOC or to Ethernet/Serial
convertersorwithGPIBdevicesconnectedtolocalI/OcardsortoEthernet/GPIBconverters.
I based this tutorial on the device support I wrote for a CVI Laser Corporation AB300 filter wheel. You’re almost
certainly interested in controlling some other device so you won’t be able to use the information directly. I chose
the AB300 as the basis for this tutorial since the AB300 has a very limited command set, which keeps this document
small, and yet has commands which raise many of the issues that you’ll have to consider when writing support for
otherdevices. Ifyou’dliketoprintthistutorialyoucandownloadPDFversion .
2 DeterminetherequiredI/Ooperations
The first order of business is to determine the set of the device will have to perform. A look at the AB300
documentation reveals that there are four commands that must be supported. Each command will be associated with
anEPICSprocessvariable(PV)whosetypemustbeappropriatetothedatatransferredbythecommand. TheAB300
commandsandprocessvariablerecordtypesIchoosetoassociatewiththemareshownintable1.
There are lots of other ways that the AB300 could be handled. It might be useful, for example, to treat the filter
positionasmulti bitbinaryrecordsinstead.
3 Createanewdevicesupportmodule
Now that the device operations and EPICS process variable types have been chosen it’s time to create a new EPICS
application to provide a place to perform subsequent software development. The easiest way to do this is with the
makeSupport.plscriptsuppliedwiththeEPICSASYNpackage.
1
../asynDriver.htmlmailto:norume@aps.anl.gov../devGpib.htmltutorial.pdfTable1: AB300filterwheelcommands
CVILaserCorporationAB300filterwheel
Command EPICSrecordtype
Reset longout
Gotonewposition
Queryposition longinstatus
HerearethecommandsIran. You’llhavetochangethe tothepathwhereyour
EPICSASYNdriverisinstalled.
mkdirab300
cdab300
/home/EPICS/modules/soft/asyn/bin/linux x86/makeSupport.pl tdevGpibAB300
3.1 Makesomechangestothefilesinconfigure/
Edit the file which makeSupport.pl created and confirm that the entries describing the paths to
yourEPICSbaseandASYNsupportarecorrect. Forexamplethesemightbe:
Editthe filewhichmakeSupport.plcreatedandspecifytheIOCarchitecturesonwhichtheappli
cationistorun. IwantedtheapplicationtorunasasoftIOC,soIuncommentedthe
definitionandsetthedefinitiontobeempty:
3.2 Createthedevicesupportfile
The contents of the device support file provide all the details of the communication between the device and EPICS.
The makeSupport.pl command created a skeleton device support file in . Of course, device
supportforadevicesimilartotheoneyou’reworkingwithprovidesaneveneasierstartingpoint.
The remainder this section describes the changes that I made to the skeleton file in order to support the AB300 filter
wheel. You’llhavetomodifythestepsasappropriateforyourdevice.
3.2.1 DeclaretheDSETtablesprovidedbythedevicesupport
Since the AB300 provides only longin and longout records most of the xxx define statements can be removed.
Because of the way that the device initialization is performed you must define an analog in DSET even if the device
providesnoanalog inrecords(asisthecasefortheAB300).
2
ASYN=/home/EPICS/modu_ARCHSDSET_LOCROSS_COMPILER_TARGET#defineconfigure/CONFIGnorume>S/baseDSET_AIEPICS_BASE=/home/EPICdevLiAB300_ARCHSnorume>=configure/RELEASECROSS_COMPILER_TARGET#defineDSET_devAiAB300AB300Sup/devAB300.cDSET_LI/home/EPICS/modules/s#defineoft/asyndevLoAB300norume>les/soft/asyn3.2.2 Selecttimeoutvalues
The default value of (2 seconds) is reasonable for the AB300, but I increased the value of to
5secondssincethefilterwheelcanbeslowinresponding.
3.2.3 Cleanupsomeunusedvalues
The skeleton file provides a number of example character string arrays. None are needed for the AB300 so I just
removedthem. Notmuchspacewouldbewastedbyjustleavingtheminplacehowever.
3.2.4 Declarethecommandarray
This is the hardest part of the job. Here’s where you have to figure how to produce the command strings required to
controlthedeviceandhowtoconvertthedeviceresponsesintoEPICSprocessvariablevalues.
EachcommandarrayentrydescribesthedetailsofasingleI/Ooperationtype. Theapplicationdatabaseusestheindex
of the entry in the command array to provide the link between the process variable and the I/O operation to read or
writethatvalue.
ThecommandarrayentriesIcreatedfortheAB300areshownbelow. Theelementsofeachentryaredescribedusing
thenamesfromtheGPIBdocumentation .
Commandarrayindex0–DeviceReset
dset Thiscommandisassociatedwithanlongoutrecord.
type AWRITEoperationistobeperformed.
pri Thisoperationwillbeplacedonthelow priorityqueueofI/Orequests.
cmd BecausethisisaGPIBWRITEoperationthiselementisunused.
format The format string to generate the command to be sent to the device. The first two bytes are the RESET
command, the third byte is the ECHO command. The AB300 sends no response to a reset command so I send
the ’ECHO’ to verify that the device is responding. The resets itself fast enough that it can see an echo
commandimmediatelyfollowingtheresetcommand.
Note that the process variable value is not used (there’s no printf format character in the command string).
TheAB300isresetwhenevertheEPICSrecordisprocessed.
rspLen The size of the readback buffer. Although only one readback byte is expected I allow for a few extra bytes
justincase.
msgLen Thesizeofthebufferintowhichthecommandstringisplaced. Iallowedalittleextraspaceincasealonger
commandisusedsomeday.
convert Nospecialconversionfunctionisneeded.
P1,P2,P3 There’snospecialconversionfunctionsonoargumentsareneeded.
pdevGpibNames There’snonametable.
3
/*%*/mustwithin5.0after/*#defineI/ONULL,0,viceNULL,thisNULL,W"\033"},time#define10,TIMEOUT0,TIMEOUTtimeoutTIMEWINDOWde{&DSET_LO,longGPIBWRWaitITE,2.0IB_Q_LOW,TIMEWINDONULL,*/"\377\37this7\033",../devGpib.html10,completeeos Theend of stringvalueusedtomarktheendofthereadbackoperation. GPIBdevicescanusuallyleavethisentry
NULL since they use the End Or Identify (EOI) line to delimit messages.Serial devices which have the same
end of string value for all commands couldalso leave these entries NULL and set the end of string value with
theiocshasynOctetSetInputEoscommand.
Commandarrayindex1–Gotonewfilterposition
dset Thiscommandisassociatedwithanlongoutrecord.
type AWRITEoperationistobeperformed.
pri Thisoperationwillbeplacedonthelow priorityqueueofI/Orequests.
cmd BecausethisisaGPIBWRITEoperationthiselementisunused.
format Theformatstringtogeneratethecommandtobesenttothedevice. Thefilterposition(1 6)canbeconverted
totherequiredcommandbytewiththeprintf format.
rspLen Thesizeofthereadbackbuffer. AlthoughonlytworeadbackbytesareexpectedIallowforafewextrabytes
justincase.
msgLen Thesizeofthebufferintowhichthecommandstringisplaced. Iallowedalittleextraspaceincasealonger
commandisusedsomeday.
convert Nospecialconversionfunctionisneeded.
P1,P2,P3 There’snospecialconversionfunctionsonoargumentsareneeded.
pdevGpibNames There’snonametable.
eos Theend of stringvalueusedtomarktheendofthereadbackoperation.
Commandarrayindex2–Queryfilterposition
dset Thiscommandisassociatedwithanlonginrecord.
type AREADoperationistobeperformed.
pri Thisoperationwillbeplacedonthelow priorityqueueofI/Orequests.
cmd Thecommandstringtobesenttothedevice. TheAB300respondstothiscommandbysendingbackthreebytes:
thecurrentposition,thecontrollerstatus,andaterminating .
format Becausethisoperationhasitsownconversionfunctionthiselementisunused.
rspLen Thereisnocommandechotoberead.
msgLen The size of the buffer into which the reply string is placed. Although only three reply bytes are expected I
allowforafewextrabytesjustincase.
convert There’snosscanfformatthatcanconvertthereplyfromtheAB300soaspecialconversionfunctionmustbe
provided.
4
NULL,NULL,NULL,GPIBWR"\035",ITE,10,IB_Q_LOW,\030"},IB_Q_LOW,"\030"},AD,0,GPIBRE",{&DSET_LI,"{&DSET_LO,NULL,'\030'%c0,NULL,10,0,convertPositionReply,NULL,0,10,0,NULL,"\017%cP1,P2,P3 Thespecialconversionfunctionrequiresnoarguments.
pdevGpibNames There’snonametable.
eos Theend of stringvalueusedtomarktheendofthereadoperation.
Commandarrayindex3–Querycontrollerstatus This command array entry is almost identical to the previous
entry. Theonlychangeisthatadifferentcustomconversionfunctionisused.
3.2.5 Writethespecialconversionfunctions
Asmentionedabove,specialconversionfunctionsareneedtoconvertreplym

  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents