EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: Re:RE: Re:RE: the way pv sent to serial changed
From: Mark Rivers <[email protected]>
To: "'l123173'" <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Wed, 13 Apr 2016 14:38:47 +0000

Hi Li,

 

You can do this as follows.

 

Make a new record that contains the velocity for each axis:

 

record(ao,"VEL1")
{
     field(EGU,"um/s")
     field(VAL,"6")
}
 
Change the RPS protocol to this:
 
RPS{
    out "\x02RPS\$1/%(\$2)d/%d/0";
}
 
Change the RPS1 record to this:
 
record(ao,"RPS1")
{
     field(DTYP,"stream")
     field(ASLO,"0.1")
     field(EGU,"um")
     field(OUT,"@test.proto RPS(1,VEL1) $(PORT) $(A)")
}
 
You can now change the value of the VEL1 record and the new velocity will be sent in the command.
 
I just tested it, and it works:
 
This is my startup script:
 
#############################################################
< envPaths
# Tell EPICS all about the record types, device-support modules, drivers,
# etc. in this build from CARS
dbLoadDatabase("../../dbd/CARSLinux.dbd")
CARSLinux_registerRecordDeviceDriver(pdbbase)
 
drvAsynIPPortConfigure("IP","gse-tetramm2:10001",0,0,0)
asynSetTraceIOMask("IP",0,2)
asynSetTraceMask("IP",0,9)
 
 
dbLoadRecords("test.db", "PORT=IP,A=0")
 
iocInit
 
dbpf RPS1.VAL 1
dbpf VEL1 2
dbpf RPS1.VAL -1
#############################################################
 
 
This is the output when I run the IOC (with some lines removed to keep it short):
 
#############################################################

# Tell EPICS all about the record types, device-support modules, drivers,

# etc. in this build from CARS

dbLoadDatabase("../../dbd/CARSLinux.dbd")

CARSLinux_registerRecordDeviceDriver(pdbbase)

 

drvAsynIPPortConfigure("IP","gse-tetramm2:10001",0,0,0)

asynSetTraceIOMask("IP",0,2)

asynSetTraceMask("IP",0,9)

 

dbLoadRecords("test.db", "PORT=IP,A=0")

 

iocInit

Starting iocInit

iocRun: All initialization complete

 

dbpf RPS1.VAL 1

DBR_DOUBLE:         1                  

dbpf VEL1 2

DBR_DOUBLE:         2                   

dbpf RPS1.VAL -1

DBR_DOUBLE:         -1                 

 

2016/04/13 09:32:19.140 gse-tetramm2:10001 write 12

\002RPS1/6/10/0

2016/04/13 09:32:19.142 gse-tetramm2:10001 write 13

\002RPS1/2/-10/0

#############################################################

 

So you can see that I am able to change the velocity (VEL1 record) from the default of 6 to 2 and that changes the output string correctly.

 

I should mention that this is not the way I would normally recommend controlling a motor.  I would recommend writing a model 3 driver for the motor record.  You just need to implement a few functions like pasynMotorAxis::move(), pasynMotorAxis::poll(), pasynMotorAxis::stop(), etc.  It would probably not be many more lines than you .proto and .db files, and would be much more flexible and powerful.

 

Mark

 

 

From: l123173 [mailto:[email protected]]
Sent: Wednesday, April 13, 2016 8:07 AM
To: Mark Rivers
Subject: Re:RE: Re:RE: the way pv sent to serial changed

 

Hello Mark,
The attachment are the db and proto file, and I list them here.

These are part of *.proto file:
RPS{

    out "\x02RPS\$1/6/%d/0";

}
I want to make the number 6 could be changed through convenient way.


*****************************************
here is the *.proto file
****************************************

#Terminator = CR LF;
getIDN {
    out "*IDN?";
    in "%\$1[^\r\n]";
    ExtraInput = Ignore;
}
ORG{
    out "\x02ORG%d/8/0";
}
RPS{
    out "\x02RPS\$1/6/%d/0";
}
APS{
    out "\x02APS\$1/5/%d/0";
}
zhuzhouRPS{
    out "\x02RPS4/1/%d/0";
}
zhuzhouAPS{
    out "\x02APS4/1/%d/0";
}
STR-b{
    out "\x02STR4";
    in "C\tSTR%*d\t%d\t%*d\t%*d\t%*d\t%*d\t%*d";
}
STR{
    out "\x02STR\$1";
    in "C\tSTR%*d\t%*d\t%*d\t%*d\t%d\t%*d\t%*d";
}
feedback{
    out "\x02STR\$1";
    in "C\tSTR%*d\t%*d\t%*d\t%*d\t%*d\t%*d\t%d";
}
STATE{
    out "\x02STR\$1";
    in "C\tSTR%*d\t%d\t%*d\t%*d\t%*d\t%*d\t%*d";
}
IDN{
    out "\x02IDN%d";
}
STP{
    out "\x02STP%d/0";
}
RDP1{
    out "\x02RDP1";
    in "C\tRDP1\t%d";
}
RDE1{
    out "\x02RDE1";
    in "C\tRDE1\t%d";
}
RDP2{
    out "\x02RDP2";
    in "C\tRDP2\t%d";
}
RDE2{
    out "\x02RDE2";
    in "C\tRDE2\t%d";
}
RDP3{
    out "\x02RDP3";
    in "C\tRDP3\t%d";
}
RDE3{
    out "\x02RDE3";
    in "C\tRDE3\t%d";
}
RDP4{
    out "\x02RDP4";
    in "C\tRDP4\t%d";
}
RDE4{
    out "\x02RDE4";
    in "C\tRDE4\t%d";
}

******************************************
db file
*****************************************

#
# Simple database and stream protocol file for basic SCPI (IEEE488.2) commands
#
 
 
#
# Short and long form of identification string
#
 
record(longout, "ORG")
{
    field(DESC, "origin return")
    field(DTYP, "stream")
    field(HOPR,"4")
    field(LOPR,"2")
    field(OUT,  "@devka.proto ORG $(PORT) $(A)")
}
 
record(longin, "STR1")
{
    field(DESC, "read axis status")
    field(DTYP, "stream")
    field(SCAN,"1 second")
    field(INP,  "@devka.proto STR(1) $(PORT) $(A)")
}
 
record(longin, "STR2")
{
    field(DESC, "read axis status")
    field(DTYP, "stream")
    field(SCAN,"1 second")
    field(INP,  "@devka.proto STR(2) $(PORT) $(A)")
}
 
record(longin, "STR3")
{
    field(DESC, "axis 4 status read")
    field(DTYP, "stream")
    field(SCAN,"1 second")
    field(INP,  "@devka.proto STR(3) $(PORT) $(A)")
}
 
record(longin, "STR4")
{
    field(DESC, "axis 4 status read")
    field(DTYP, "stream")
    field(SCAN,"1 second")
    field(INP,  "@devka.proto STR(4) $(PORT) $(A)")
}
 
#record(longin, "origin1")
#{
#    field(DESC, "origin point")
#    field(DTYP, "stream")
#    field(SCAN,"1 second")
#    field(INP,  "@devka.proto origin(1) $(PORT) $(A)")
#}
 
 
record(longin, "STATE1")
{
    field(DESC, "axis 1 driving state")
    field(DTYP, "stream")
    field(SCAN,"1 second")
    field(INP,  "@devka.proto STATE(1) $(PORT) $(A)")
}
 
record(longin, "STATE2")
{
    field(DESC, "axis 2 driving state")
    field(DTYP, "stream")
    field(SCAN,"1 second")
    field(INP,  "@devka.proto STATE(2) $(PORT) $(A)")
}
 
record(longin, "STATE3")
{
    field(DESC, "axis 3 driving state")
    field(DTYP, "stream")
    field(SCAN,"1 second")
    field(INP,  "@devka.proto STATE(3) $(PORT) $(A)")
}
 
record(longin, "STATE4")
{
    field(DESC, "axis 4 driving state")
    field(DTYP, "stream")
    field(SCAN,"1 second")
    field(INP,  "@devka.proto STATE(4) $(PORT) $(A)")
}
 
record(longin, "feedback3")
{
    field(DESC, "axis 3 driving state")
    field(DTYP, "stream")
    field(SCAN,"1 second")
    field(INP,  "@devka.proto feedback(3) $(PORT) $(A)")
}
 
 
record(ao,"RPS1")
{
     field(DTYP,"stream")
     field(ASLO,"0.1")
     field(EGU,"um")
     field(OUT,"@devka.proto RPS(1) $(PORT) $(A)")
}
 
###
record(ao, "APS1")
{
    field(DESC, "axis 1 move absolutly")
    field(DTYP, "stream")
    field(ASLO,"0.05")
    field(EGU,"um")
    field(OUT,"@devka.proto APS(1) $(PORT) $(A)")
}
 
 
 
record(ao, "RPS2")
{
    field(DESC, "2 move relativly")
    field(DTYP, "stream")
    field(ASLO,"0.12")
    field(EGU,"arcsec")
    field(OUT,"@devka.proto RPS(2) $(PORT) $(A)")
}
 
record(ao, "APS2")
{
    field(DESC, "axis 2 move absolutly in arcsec")
    field(DTYP, "stream")
    field(ASLO,"0.065")
    field(EGU,"arcsec")
    field(OUT,"@devka.proto APS(2) $(PORT) $(A)")
}
 
record(ao, "APS2_in_deg")
{
    field(DESC, "axis 2 move absolutly in deg")
    field(DTYP, "stream")
    field(ASLO,"0.00000179")
    field(EGU,"deg")
    field(OUT,"@devka.proto APS(2) $(PORT) $(A)")
}
 
 
record(ao,"RPS2_in_deg")
{
     field(DTYP,"stream")
     field(ASLO,"0.0000336")
     field(EGU,"deg")
     field(OUT,"@devka.proto RPS(2) $(PORT) $(A)")
}
 
record(ao, "RPS3")
{
    field(DESC, "3 move relativly")
    field(DTYP, "stream")
    field(ASLO,"0.41")
    field(EGU,"arcsec")
    field(OUT,"@devka.proto RPS(3) $(PORT) $(A)")
}
 
record(ao, "APS3")
{
    field(DESC, "axis 3 move absolutly in arcsec")
    field(DTYP, "stream")
    field(ASLO,"0.085")
    field(EGU,"arcsec")
    field(OUT,"@devka.proto APS(3) $(PORT) $(A)")
}
 
 
record(ao, "APS3_in_deg")
{
    field(DESC, "axis 3 move absolutly in deg")
    field(DTYP, "stream")
    field(ASLO,"0.0000237")
    field(EGU,"deg")
    field(OUT,"@devka.proto APS(3) $(PORT) $(A)")
}
 
record(ao,"RPS3_in_deg")
{
     field(DTYP,"stream")
     field(ASLO,"0.0001125")
     field(EGU,"deg")
     field(OUT,"@devka.proto RPS(3) $(PORT) $(A)")
}
 
record(ao, "RPS4")
{
    field(DESC, "4 move relativly")
    field(DTYP, "stream")
    field(ASLO,"0.2")
    field(EGU,"arcsec")
    field(OUT,"@devka.proto zhuzhouRPS $(PORT) $(A)")
}
 
record(ao, "APS4")
{
    field(DESC, "4 move absolutly in arcsec")
    field(DTYP, "stream")
    field(ASLO,"0.09")
    field(EGU,"arcsec")
    field(OUT,"@devka.proto zhuzhouAPS $(PORT) $(A)")
}
 
record(ao, "APS4_in_deg")
{
    field(DESC, "4 move absolutly in deg")
    field(DTYP, "stream")
    field(ASLO,"0.000025")
    field(EGU,"deg")
    field(OUT,"@devka.proto zhuzhouAPS $(PORT) $(A)")
}
 
record(ao,"RPS4_in_deg")
{
     field(DTYP,"stream")
     field(ASLO,"0.0000555")
     field(EGU,"deg")
     field(OUT,"@devka.proto zhuzhouRPS $(PORT) $(A)")
}
 
record(longin, "STP")
{
    field(DESC, "stop")
    field(DTYP, "stream")
    field(INP,  "@devka.proto STP $(PORT) $(A)")
}
 
record(longin, "RDP1")
{
    field(DESC, "axis 1 positon read")
    field(DTYP, "stream")
    field(INP,  "@devka.proto RDP1 $(PORT) $(A)")
    field(SCAN,"1 second")
}
 
record(longin, "RDP2")
{
    field(DESC, "axis 2 positon read")
    field(DTYP, "stream")
    field(INP,  "@devka.proto RDP2 $(PORT) $(A)")
    field(SCAN,"1 second")
}
 
record(longin, "RDP3")
{
    field(DESC, "axis 3 positon read")
    field(DTYP, "stream")
    field(INP,  "@devka.proto RDP3 $(PORT) $(A)")
    field(SCAN,"1 second")
}
 
record(longin, "RDP4")
{
    field(DESC, "axis 4 positon read")
    field(DTYP, "stream")
    field(INP,  "@devka.proto RDP4 $(PORT) $(A)")
    field(SCAN,"1 second")
}
 
record(longin, "RDE1")
{
    field(DESC, "axis 1 encode positon read")
    field(DTYP, "stream")
    field(INP,  "@devka.proto RDE1 $(PORT) $(A)")
    field(SCAN,"1 second")
}
 
record(longin, "RDE2")
{
    field(DESC, "axis 2 encode positon read")
    field(DTYP, "stream")
    field(INP,  "@devka.proto RDE2 $(PORT) $(A)")
    field(SCAN,"1 second")
}
 
record(longin, "RDE3")
{
    field(DESC, "axis 3 encode positon read")
    field(DTYP, "stream")
    field(INP,  "@devka.proto RDE3 $(PORT) $(A)")
    field(SCAN,"1 second")
}
 
record(longin, "RDE4")
{
    field(DESC, "axis 4 encode positon read")
    field(DTYP, "stream")
    field(INP,  "@devka.proto RDE4 $(PORT) $(A)")
    field(SCAN,"1 second")
}
 
record(calc, "distance1")
{
    field(DESC, "axis1 distance")
    field(EGU,"um")
    field(SCAN,"1 second")
    field(CALC, "B*0.1")
    field(INPB,"RDP1.VAL")
}
 
record(calc, "test")
{
    field(DESC, "move together")
    field(EGU,"deg")
    field(SCAN,"1 second")
    field(CALC, "E*1")
    field(INPE,"Encode_distance3_in_deg.VAL")
}
 
record(calc, "Encode_distance1")
{
    field(DESC, "axis1 encode distance")
    field(EGU,"um")
    field(SCAN,"1 second")
    field(CALC, "B*0.05")
    field(INPB,"RDE1.VAL")
}
 
record(calc, "distance2")
{
    field(DESC, "axis2 distance")
    field(EGU,"arcsec")
    field(SCAN,"1 second")
    field(CALC, "B*0.12")
    field(INPB,"RDP2.VAL")
}
 
record(calc, "Encode_distance2_in_deg")
{
    field(DESC, "axis2 encode distance")
    field(EGU,"deg")
    field(SCAN,"1 second")
    field(CALC, "B*0.0000179")
    field(INPB,"RDE2.VAL")
}
 
record(calc, "Encode_distance2_in_arcsec")
{
    field(DESC, "axis2 encode distance")
    field(EGU,"arcsec")
    field(SCAN,"1 second")
    field(CALC, "B*0.065")
    field(INPB,"RDE2.VAL")
}
 
record(calc, "distance2_in_deg")
{
    field(DESC, "axis2 distance in degree")
    field(EGU,"deg")
    field(SCAN,"1 second")
    field(CALC, "B*0.0000336")
    field(INPB,"RDP2.VAL")
}
 
 
record(calc, "distance3")
{
    field(DESC, "axis3 distance")
    field(EGU,"arcsec")
    field(SCAN,"1 second")
    field(CALC, "B*0.41")
    field(INPB,"RDP3.VAL")
}
 
record(calc, "Encode_distance3_in_deg")
{
    field(DESC, "axis3 encode distance")
    field(EGU,"deg")
    field(SCAN,"1 second")
    field(CALC, "B*0.0000237")
    field(INPB,"RDE3.VAL")
}
 
record(calc, "Encode_distance3_in_arcsec")
{
    field(DESC, "axis3 encode distance")
    field(EGU,"arcsec")
    field(SCAN,"1 second")
    field(CALC, "B*0.085")
    field(INPB,"RDE3.VAL")
}
 
 
record(calc, "distance3_in_deg")
{
    field(DESC, "axis3 distance in degree")
    field(EGU,"deg")
    field(SCAN,"1 second")
    field(CALC, "B*0.0001125")
    field(INPB,"RDP3.VAL")
}
 
record(calc, "distance4")
{
    field(DESC, "axis4 distance")
    field(EGU,"arcsec")
    field(SCAN,"1 second")
    field(CALC, "B*0.2")
    field(INPB,"RDP4.VAL")
}
 
record(calc, "Encode_distance4_in_deg")
{
    field(DESC, "axis4 encode distance")
    field(EGU,"deg")
    field(SCAN,"1 second")
    field(CALC, "B*0.000025")
    field(INPB,"RDE4.VAL")
}
 
record(calc, "Encode_distance4_in_arcsec")
{
    field(DESC, "axis4 encode distance")
    field(EGU,"arcsec")
    field(SCAN,"1 second")
    field(CALC, "B*0.09")
    field(INPB,"RDE4.VAL")
}
 
 
record(calc, "distance4_in_deg")
{
    field(DESC, "axis4 distance in degree")
    field(EGU,"deg")
    field(SCAN,"1 second")
    field(CALC, "B*0.0000555")
    field(INPB,"RDP4.VAL")
}
 
record(longin, "dis")
{
    field(DESC, "Output completion status")
    field(DTYP, "stream")
    field(FLNK, "distance")
    field(INP,  "distance.VAL")
}
 
record(calc,"1CW")
{
    field(SCAN,"1 second")
    field(CALC,"C>1?1:0")
    field(INPC,"STR1.VAL")
    field(PREC,"1")
}
 
record(calc,"1CCW")
{
    field(SCAN,"1 second")
    field(CALC,"A=1|A=3?1:0")
    field(INPA,"STR1.VAL")
    field(PREC,"1")
}
 
record(calc,"2CW")
{
    field(SCAN,"1 second")
    field(CALC,"C>1?1:0")
    field(INPC,"STR2.VAL")
    field(PREC,"1")
}
 
record(calc,"2CCW")
{
    field(SCAN,"1 second")
    field(CALC,"D=1|D=3?1:0")
    field(INPD,"STR2.VAL")
    field(PREC,"1")
}
 
record(calc,"3CW")
{
    field(SCAN,"1 second")
    field(CALC,"C>1?1:0")
    field(INPC,"STR3.VAL")
    field(PREC,"1")
}
 
record(calc,"3CCW")
{
    field(SCAN,"1 second")
    field(CALC,"D=1|D=3?1:0")
    field(INPD,"STR3.VAL")
    field(PREC,"1")
}
 
record(calc,"4CW")
{
    field(SCAN,"1 second")
    field(CALC,"C>1?1:0")
    field(INPC,"STR4.VAL")
    field(PREC,"1")
}
 
record(calc,"4CCW")
{
    field(SCAN,"1 second")
    field(CALC,"D=1|D=3?1:0")
    field(INPD,"STR4.VAL")
    field(PREC,"1")
}
 
record(calc, "STATE1-led")
{
    field(SCAN,"1 second")
    field(CALC,"E=0?0:1")
    field(INPE,"STATE1.VAL")
    field(PREC,"1")
}
 
record(calc, "STATE2-led")
{
    field(SCAN,"Passive")
    field(CALC,"E=0?0:1")
    field(INPE,"STATE2.VAL")
    field(PREC,"1")
}
 
record(calc, "STATE3-led")
{
    field(SCAN,"1 second")
    field(CALC,"E=1?1:0")
    field(INPE,"STATE3.VAL")
    field(PREC,"1")
}
 
record(calc, "STATE4-led")
{
    field(SCAN,"1 second")
    field(CALC,"E=0?0:1")
    field(INPE,"STATE4.VAL")
    field(PREC,"1")
}
 
record(calc, "feedback3-led")
{
    field(SCAN,"1 second")
    field(CALC,"E=0?0:1")
    field(INPE,"feedback3.VAL")
    field(PREC,"1")
}
 
record(calc, "ttest")
{
    field(DESC, "axis1 distance")
    field(SCAN,"1 second")
    field(CALC, "12.5/COS(B)-12.5")
    field(INPB,"Encode_distance4_in_deg.VAL")
}
 
record(calc, "R1")
{
    field(DESC, "R1 means that value R add one")
    field(SCAN,"1 second")
    field(CALC, "B+1")
    field(INPB,"R.VAL")
}
 
 
 

 

 

At 2016-04-13 20:51:12, "Mark Rivers" <[email protected]> wrote:
>Can you send me your motor.db and motor.proto files?
> 
>________________________________
>From: l123173 [[email protected]]
>Sent: Wednesday, April 13, 2016 7:04 AM
>To: Mark Rivers
>Subject: Re:RE: the way pv sent to serial changed
> 
>Hello Mark,
>    I want to achieve it, don't have an example.
>    I try to describe it more clearly.
>    Now I use motor.db and motor.proto to control the motor.
>    In motor.proto file, I set the speed for moving command, just like "\x02\RPS\1\{SPEED}\0".
>    Then all moving would be this speed, when I need to change the speed, I have to modify the motro.proto and change the speed value, then make it to compile.
>    The moving speed changed successfully.
> 
>    It is very inconvenient. So I think there should be some way that no need to make and modify the motro.proto file.
> 
>Thanks,
>Li X
> 
> 
> 
> 
> 
> 
> 
>At 2016-04-13 19:03:16, "Mark Rivers" <[email protected]> wrote:
>>I am not sure I understand what you mean.
>> 
>>Can you send some specific examples of commands you send to change the speed, and then another command that must contain the speed?
>> 
>>Mark
>> 
>>________________________________
>>From: [email protected] [[email protected]] on behalf of l123173 [[email protected]]
>>Sent: Tuesday, April 12, 2016 10:02 PM
>>To: [email protected]
>>Subject: the way pv sent to serial changed
>> 
>>Hi everyone ,
>>   I use 'epics 3.14.12.1 in linux' + asyn + stream + CSS.
>>   I controled the motor through serial.  Now I want to change a pv through CSS and then send it to serial.‍
>>   I mean these, For example:
>>   I set speed value 2 in CSS. Then all command about moving motor should send the string contain the speed value to‍ serial,like xxxx2
>>   When I set speed value 3 in CSS, all command sent to serial should contain 3, like xxx3.
>>   No need to change the xxx.proto file and make which is the way I use now , it is very inconvenient.
>> 
>>Could you introduce me a much better way.
>> 
>>Thanks,
>>Li X
>> 
>> 
>> 
>> 
> 
> 
> 
> 
> 

 

 


References:
the way pv sent to serial changed l123173
RE: the way pv sent to serial changed Mark Rivers

Navigate by Date:
Prev: RE: the way pv sent to serial changed Mark Rivers
Next: Force one record to run before all others kathryn.baker
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: the way pv sent to serial changed Mark Rivers
Next: Force one record to run before all others kathryn.baker
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 15 Jul 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·