EPICS database

An EPICS database file is used to create specific record instances that will be used by an IOC. It declares them by defining the name and EPICS record type. The name can be fully declared, such as time or can be completed later by expansion of a macro definition, such as $(P)cmd. The value of the macro will be specified in the IOC startup script, either through a call to dbLoadRecords() or dbLoadTemplate().

This file is written to be used by more than one IOC, so it uses a common macro for the IOC prefix ($(P)). In our example IOC, we’ll call this database file as (noting P is set to como:cr:):

dbLoadRecords("$(CMD_RESPONSE)/cmd_response.db","P=como:cr:,PORT=usb0")

(More on this in the section titled: EPICS IOC startup commands.)

record instances

name RTYP description
$(P)ai0 ai read the raw photocell sensor, \(V_P\)
$(P)ai0:mean ai photocell sensor, \(V_P\)
$(P)ai1 ai read the LED’s PWM “voltage”, \(V_{LED}\)
$(P)ai1:mean ai read LED “voltage”, \(V_{LED}\)
$(P)ai2:mean ai read temperature sensor, \(V_T\) (see temperature sensor)
$(P)ai2:mean ai read reference voltage, \(V_{cc}\) (see temperature sensor)
$(P)pwm11 ao set the LED brightness (effectively: set \(V_{LED}\))
$(P)rate ai read the update rate
$(P)period ao set the averaging period, s
$(P)epid epid Feedback control (see Example: Feedback using the epid record)
$(P)cmd stringout send command directly to Arduino and read response
  • RTYP: EPICS record type

Additional fields have been added as appropriate (from the examples shown in Stream protocol):

field description
DESC descriptive text about this record instance
EGU engineering units
PREC display precision
HOPR high limit for display purposes
LOPR low limit for display purposes
DRVH maximum allowed value
DRVL minimum allowed value
PINI process the record instance when EPICS starts
SCAN how frequently to process this record
VAL initial value for the record instance

The epid record instance will be explained in another section (Example: Feedback using the epid record).

file: cmd_reponse.db

The file is too large for this documentation.

EPICS database:cmd_response.db

temperature sensor

It is easy to measure temperature so let’s add that. A thermistor varies its resistance with temperature. The temperature can be measured using a voltage divider circuit.

fig.thermistor

Voltage divider circuit with the thermistor (thermistor.png)

We’ll connect the thermistor voltage signal, \(V_T\), to the Arduino’s ANALOG IN A2 pin and the supply voltage, \(V_{cc}\), to pin A3. Having actual measurements of \(V_{cc}\) will improve our precision of temperature reporting.

For a 10 kOhm (\(R_{ref}=10\mbox{ kOhm}\)) negative temperature coefficient thermistor, we’ll use a 10 kOhm resistor (\(R_4=10\mbox{ kOhm}\)) to balance the voltage divider so that its response is most sensitive at its reference temperatue (25 C). We measure the thermistor voltage, \(V_T\), and calculate its resistance, \(R_T\):

\[R_T = R_4 { V_T / V_{cc} \over 1 - V_T / V_{cc} }\]

The temperature, \(T\), is a non-linear function of \(R_T\). Taking \(r=ln(R_T / R_{ref})\) as a reduced resistance term to simplify the math, we use the extended “Steinhart and Hart” interpolation ([1]):

\[T = {1 \over A_1 + B_1 r + C_1 r^2 + D_1 r^3}\]

Tip

It’s easier to do the computation in EPICS records rather than the Arduino.

Using coefficients (Vishay thermistor, 10k NTC, \(\beta=3977\mbox{ K}\)) from the manufacturer’s data sheet [1]:

A1 3.354016E-03
B1 2.569850E-04
C1 2.620131E-06
D1 6.383091E-08

we can now compute a curve for the signal we expect to measure. See the next figure:

fig.ADC_vs_T_curve

Arduino ANALOG IN A2 units plotted as a function of temperature (F) for 10k NTC, \(\beta=3977\mbox{ K}\) thermistor. (ADC_vs_T_curve.png)

[1](1, 2) http://www.vishay.com/product?docid=29049