Hi Ryan,
There might be a cleaner way, using asyn 4.26, but this is how I've done what you're describing in a database:
record(bi, "readback") {
field(DESC, "read the hardware value")
field(INP, "@asyn(...)")
field(FLNK, "readbackPut")
}
record(bo, "readbackPut") {
field(DESC, "copy readback to switch")
field(OMSL, "closed_loop")
field(DOL, "readback")
field(OUT, "switch PP")
}
record(bo, "switch") {
field(DESC, "output value")
field(OUT, "switchPut PP")
}
record(bo, "switchPut") {
field(DESC, "write the output value to hardware")
# Don't do anything if this is a readback
field(SDIS, "readbackPut.PACT")
field(DISV, "1")
field(OUT, "@asyn(...)")
}
If you write to "switch", it will get the value you wrote out to the hardware.
If "readback" writes to "switch", "switch" will process, so the value will be posted, but the the SDIS link will prevent a redundant write to the hardware.
Tim Mooney ([email protected]) (630)252-5417
Software Services Group (www.aps.anl.gov)
Advanced Photon Source, Argonne National Lab
________________________________________
From: [email protected] [[email protected]] on behalf of Ryan Pierce [[email protected]]
Sent: Monday, March 02, 2015 12:36 AM
To: [email protected]
Subject: Reading data from bo record?
I've just started building my first EPICS project (the computer
controlled beer brewing system I mentioned, which recently made
Hackaday's twitter feed:
https://twitter.com/HackadayPrize/status/570791651620347904 ) and I am
not sure about the behavior I'm observing.
The plan is to run a soft IOC on a Raspberry Pi using asyn,
communicating via USB serial with an Arduino running custom code derived
from cmd_response, and (for now at least) controlling this from CSS BOY.
I've succeeded in creating a PV of type bo, as well as defining a custom
command and custom Arduino code for it. I can do a caput to the PV of 1
or 0, or I can use one of many binary switch objects in CSS BOY, and
when I switch it, the Arduino takes the appropriate action. That's
great. But I've got a few questions:
1. I noticed that for a bo record, I can define an OUT but attempting to
define an INP produces an error. Ideally, I'd really like something
bidirectional, e.g. I can write a 1 or 0 to it, and that will trigger
asyn to call the command to write to it, but other actions with the
running Arduino code can also change the physical thing represented, it
can be queried, and the result may be the same as, or different from,
the last thing written to it.
Physical example: I've got three propane burners. I'd like PV's for each
of them, so I can turn them on or off. But I may want to write to a
different set of PVs that enables a thermostat mode, where code on the
Arduino turns the burner on or off automatically based on fluid
temperature. I'd like to be able to query that and display it on the
control screen.
I get the feeling EPICS is a Swiss Army knife with a lot of tools, but
being a beginner I really don't know what the best tool for the job
would be here. I'm thinking either:
A. I create a pair of bi and bo PV's for each burner. The bo would be
used to send commands to turn the burner off or on. But the bi would
indicate whether the burner actually is on of off.
B. Do something I'm missing to make the bo truly bidirectional. I'm
looking through the docs and am wondering if DOL and OMSL would do what
I wanted.
2. I noticed that in CSS BOY, I can define an LED with the PV name of
the bo in addition to a switch. When I flip the switch, there's a little
lag (due to my SCAN time, I suppose), but the LED eventually reports
correctly. In addition, the switch itself changes its appearance. I've
wondered whether CSS BOY is latching the last thing it wrote, or if the
IOC is latching the last write command it received. Seeing as I can
restart CSS BOY and these are always correct, I'm assuming the latter, Yes?
3. Doing a caget on the bo PV returns nothing. This confuses me. I'd
assume I'd get whatever the IOC is latching. Presumably, there's got to
be a way to get this, otherwise CSS BOY wouldn't be able to display it.
What's happening?
FYI: There has been a release of the Raspberry Pi 2, which seems to have
vastly higher performance than the earlier Pi's. I don't have one yet,
but that is eventually the plan. Right now, even the Arduino dev
environment is sluggish on the older Pi, but I'm hearing the Pi 2 feels
like a desktop. I'd really like to be able to run Apache, Tomcat, and
Web OPI on the Pi so I wouldn't have to rely on any external server.
Thanks,
Ryan
- References:
- Reading data from bo record? Ryan Pierce
- Navigate by Date:
- Prev:
Reading data from bo record? Ryan Pierce
- Next:
Using sCalcout record Chanaka De Silva
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
<2015>
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Reading data from bo record? Ryan Pierce
- Next:
RE: Reading data from bo record? tom.cobb
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
<2015>
2016
2017
2018
2019
2020
2021
2022
2023
2024
|