1 / 12

EPICS ’ Stream ’ Device Support

This article explains the features and benefits of the EPICS Stream Device Support, which allows easy communication with temperature controllers and vacuum pumps using protocols like Serial (RS-232, RS485), Networked (TCP), and GPIB (IEEE-488). It provides an example implementation and highlights the advantages and challenges of using the Stream Device Support.

mimms
Download Presentation

EPICS ’ Stream ’ Device Support

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EPICS’Stream’Device Support Kay Kasemir ORNL/SNS kasemirk@ornl.gov Feb. 2013

  2. “Stream” Type Protocols Example Devices: • Temperature controllers: Lakeshore, Omega, … • Vacuum pumps: Varian, … • Serial (RS-232, RS485), Networked (TCP), GPIB (IEEE-488) • Text-based • Command/Response What is the current temperature on channel A?“KRDG? A\n” “+077.350E+0\n”It’s about 80 Kelvin!

  3. Pro/Cons • Seems easy • Human-readable • Testable with Hyperterm, minicom, telnet • Create Visual Basic, LabVIEW, … demo in no time • But beware! • Speed and Terminators (CR, LF, CR/LF, …) can magically change • Was set to something, then device power-cycled … • Must handle timeouts • Don’t just hang! • Must handle errors • Don’t read “MODEL 340” as 340 Kelvin

  4. The EPICS ‘Stream’ Device Idea Recordrecord(ai, "Temp:B"){ field(DTYP,"stream") field(INP, "@demo.protogetTempATC1") field(SCAN,"5 second")} Protocol File“demo.proto”Terminator = CR;getTempA{ out "KRDG? A"; in "%f";} IOC st.cmddrvAsynIPPortConfigure ("TC1", "192.168.164.10:23")

  5. What ‘Stream Device’ does for you • Connect to device • Re-connect after disconnects • Allow many records to communicate via one connection • Threading, queuing, … • Handle timeouts, errors • Put records into ‘alarm’ state • Debug options • Log every byte sent/received

  6. NetCat Example Using NetCat, we pretend to be a simple device. • IOC with Stream Device will ask:“B?” • We reply either • with valid reply to request for B:“B 42.13” • Invalid reply:“42.13”, “get lost”, … • Not at all, which should be treated as timeout, • a shutdown of the network connection.

  7. Full Example: Adding support to IOC • configure/RELEASE:SUPPORT=/home/controls/epics/R3.14.12.2/supportASYN=$(SUPPORT)/asynSTREAM=$(SUPPORT)/StreamDevice • demoApp/src/Makefiledemo_DBD += stream.dbddemo_DBD += asyn.dbddemo_DBD += drvAsynIPPort.dbddemo_LIBS += asyndemo_LIBS += stream

  8. EPICS Database demoApp/Db/demo.db record(ai, "B"){ field (DTYP, "stream") field (INP, "@demo.proto getB NC") field (SCAN, "5 second")} record(ao, "current"){ field (DTYP, "stream") field (OUT, "@demo.proto setCurrent NC") field (EGU, "A") field (PREC, "2") field (DRVL, "0") field (DRVH, "60") field (LOPR, "0") field (HOPR, "60“} record(ai, "A"){ field (DTYP, "stream") field (INP, "@demo.proto getA NC") field (SCAN, "I/O Intr")}

  9. Protocol File # Example with initialization,# otherwise only writes when processedsetCurrent{ out "CURRENT %.2f"; @init { out "CURRENT?"; in "CURRENT %f A"; }} # Used with SCAN, "I/O Intr":# Reacts to "A 5" at any timegetA{ PollPeriod = 50; in "A %f";} iocBoot/iocdemo/demo.proto Terminator = CR LF;InTerminator = LF;ReplyTimeout = 10000;ReadTimeout = 10000; # Used with SCAN “… second”:# Prompts, then expects "B 5"getB{ out "B?"; in "B %f“;}

  10. IOC Startup File iocBook/iocdemo/st.cmd epicsEnvSet ("STREAM_PROTOCOL_PATH", ".") drvAsynIPPortConfigure ("NC", "127.0.0.1:6543") # ASYN_TRACE_ERROR 0x0001# ASYN_TRACEIO_DEVICE 0x0002# ASYN_TRACEIO_FILTER 0x0004# ASYN_TRACEIO_DRIVER 0x0008# ASYN_TRACE_FLOW 0x0010# ASYN_TRACEIO_NODATA 0x0000# ASYN_TRACEIO_ASCII 0x0001# ASYN_TRACEIO_ESCAPE 0x0002# ASYN_TRACEIO_HEX 0x0004# Log some asyn info and in/out textsasynSetTraceMask("NC", 0, 4)asynSetTraceIOMask("NC", 0, 6) dbLoadRecords("db/stream.db","user=fred")

  11. Example Session • IOC…write 4B?\r\n…read 5B 17\n… got "34" where "B " was expected… No reply from device within 10000 ms • NetCatnc –l 127.0.0.1 6543B?B 17B?B 18B?B 3.14B?34B?

  12. Stream Device… • Allows you to concentrate on the protocol • Handles the rest • Connection • Threads • Parse results • Update record’s valueand alarm state “demo.proto”Terminator = CR;getTempA{ out "KRDG? A"; in "%f";}

More Related