As a reminder, here is the problem:
>
> When trying to use the synApps motor record in conjunction with
> encoder readback, I set
> <motor>.URIP = Yes
> <motor>.RDBL = Name of encoder record
> <motor>.RRES = 1.0
>
> and the <encoder>.VAL field has the same EGU as the motor.
>
> After the first 2 moves, things seems to work fine. However, when the
> ioc is booted, the motor record does not pick up the initial value of
> the encoder and its DVAL field is zero.
Thanks to Tim Mooney, Ron Sluiter and Brian McAllister for their responses to
this problem. As Brian pointed out, the key to the solution is to note that
writing to the VAL field of the motor record when it is in "SET" mode will cause
it to pick up values from its RDBL field. This feature is described in the small
print of the motor record documentation but I confess that it had passed me by.
Brian also suggested using a sequence record to accomplish this setup. Given the
uncertain nature of some of the time delays involved, I believe that it is
better to use an SNL program to effect the initialisation. For completeness, I
append the source of a suitable SNL program. The program also takes care of the
following two points:
1) The value of the FOFF field should be set to 1 before setting the
VAL field. Otherwise the setting of the OFF field will get lost.
2) The actual value written to the VAL field is not particularly
critical. It must, however, lie within the LLM to HLM range of
the motor. Otherwise the motor record goes into "soft limit
violation" mode.
David
P.S. The problem of converting the appended SNL program to obtain the name of
the encoder record dynamically at run-time from the RDBL field of the motor
rather than having it supplied as an argument to the seq command is left as an
exercise for the student!
David
===========================================================================
/*
** motorSetup.st
** =============
**
** SNL program to initialise a motor record from an encoder at ioc boot
** time.
**
** Usage:
** On host:
** snc motorSetup.st
** compileppc motorSetup.c
** On ioc:
** ld < motorSetup.o
** seq &motorSetup, "m = Test-Motor, e = Test-encoder"
**
** Repository:
** $CVSROOT/PROJECTS/subsystems/X/X04SA/OP2/snl/motorSetup.st
**
** $Revision: 1.3 $ $Date: 2001/10/23 13:39:55 $
*/
program motorSetup ("m = ERROR, e = ERROR")
/* ==========
*/
/*----------------------------------------------------
** Assign variables to channels
*/
int ENC_UDF; /* != 0 if encoder value undefined */
assign ENC_UDF to "{e}.UDF";
monitor ENC_UDF;
int MOT_DMOV; /* == 1 if motor finished moving */
assign MOT_DMOV to "{m}.DMOV";
monitor MOT_DMOV;
int MOT_URIP; /* Motor "Use Readout If Present" */
assign MOT_URIP to "{m}.URIP";
int MOT_SSET; /* Motor "Set SET Mode" */
assign MOT_SSET to "{m}.SSET";
float MOT_VAL; /* Motor "Value" */
assign MOT_VAL to "{m}.VAL";
float MOT_LLM; /* Motor Low Limit */
assign MOT_LLM to "{m}.LLM";
float MOT_HLM; /* Motor Low Limit */
assign MOT_HLM to "{m}.HLM";
int MOT_SUSE; /* Motor "Set USE Mode" */
assign MOT_SUSE to "{m}.SUSE";
int MOT_FOFF; /* Motor "Offset-Freeze" if == 1 */
assign MOT_FOFF to "{m}.FOFF";
int foff_save;
%% void exit (); /* Suppress a cc warning message */
/*-----------------------------------------------------------------------
*/
ss motorSetup {
/*-------------
*/
state init { /* Wait until encoder setup is complete */
when (ENC_UDF == 0) {
printf ("\nLinking %s and %s ...",
macValueGet ("m"), macValueGet ("e"));
pvGet (MOT_FOFF); foff_save = MOT_FOFF; /* Save FOFF */
pvGet (MOT_LLM); pvGet (MOT_HLM); /* Get limits */
MOT_FOFF = 1; pvPut (MOT_FOFF); /* Freeze the offsets */
MOT_URIP = 1; pvPut (MOT_URIP); /* Tell motor to use enc */
MOT_SSET = 1; pvPut (MOT_SSET); /* Go to "Set" mode */
MOT_VAL = 0.5 * (MOT_LLM + MOT_HLM);
pvPut (MOT_VAL); /* Force motor record update */
} state waitForMotor
}
state waitForMotor { /* Wait for the motor setup to complete */
when (MOT_DMOV == 1) {
MOT_SUSE = 1; pvPut (MOT_SUSE); /* Go to "Use" mode */
MOT_FOFF = foff_save; pvPut (MOT_FOFF); /* Restore FOFF */
printf (" done\n");
} state finish
}
state finish {when () {exit ();} state finish}
}
===========================================================================
- Replies:
- Re: Summary: Motor Record with Encoder Brian McAllister
- References:
- Archive for Tech-Talk Leonard J. Reder
- Re: Archive for Tech-Talk Marty Kraimer
- Motor Record with Encoder David Maden
- Navigate by Date:
- Prev:
embedded linux experiences Geoff Savage
- Next:
Re: Summary: Motor Record with Encoder Brian McAllister
- 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:
Re: Motor Record with Encoder Brian McAllister
- Next:
Re: Summary: Motor Record with Encoder Brian McAllister
- 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
|