EPICS Home

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  2016  2017  2018  2019  2020  2021  2022  2023  <20242025  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  <20242025 
<== Date ==> <== Thread ==>

Subject: RE: Epics motor driver dval init
From: Paul-Elie GUILLOT via Tech-talk <tech-talk at aps.anl.gov>
To: Torsten Bögershausen <tboegi at edom.se>
Cc: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Tue, 13 Feb 2024 15:41:26 +0000
Hej Torsten,
I have solved the issue. On the initial motor-master, not on the motor-master-ess but I think I can do it on the motor-master-ess.
Basically, the issue comes from the fact that one is trying to read the DVAL field of the motor record before it is set according to RRBV which itself is not yet set according to REP or whatever is linked to readback.
Problem is you can't use RRBV or REP either because they are processed later.
For now, my fix is to use:
    double position = pPvt->status.position;
    double encoderposition = pPvt->status.encoderPosition;
which are set thanks to my initHookAfterInitDevSup, processing polling call before the init record.

Thanks to that I can then define:

    double position = pPvt->status.position;
    double encoderposition = pPvt->status.encoderPosition;
    double rdbd = (fabs(pmr->rdbd) < fabs(pmr->mres) ? fabs(pmr->mres) : fabs(pmr->rdbd) );
    int use_rel = (pmr->rtry != 0 && pmr->rmod != motorRMOD_I && (pmr->ueip || pmr->urip));
    int dval_non_zero_pos_near_zero = (fabs(encoderposition*pmr->eres) > rdbd) &&
                                      (pmr->mres != 0) && (fabs(position * pmr->mres) < rdbd);

Basically, just swapping the old pmr->dval by encoderposition

And

    if (initPos)
    {
        double setPos = (encoderposition*pmr->eres) / pmr->mres;

        /* Write setPos to the driver */
        pPvt->pasynUserSync->reason = pPvt->driverReasons[motorPosition];
        status = pasynFloat64SyncIO->write(pPvt->pasynUserSync, setPos, pasynUser->timeout);
        if (status) {
            asynPrint(pasynUser, ASYN_TRACE_ERROR,
                      "devMotorAsyn::init_controller, %s failed to set position to %f\n",
                      pmr->name, setPos );
        } else {
    		asynPrint(pasynUser, ASYN_TRACE_ERROR,"setposish\n");
            asynPrint(pasynUser, ASYN_TRACE_FLOW,
                      "devMotorAsyn::init_controller, %s set position to %f\n",
                      pmr->name, setPos );
        }
    }

This does indeed send the setposition according to the encoder position.
Let me know what you think.
Best Regards

Paul



-----Message d'origine-----
De : Torsten Bögershausen <tboegi at edom.se> 
Envoyé : mardi 13 février 2024 16:16
À : Paul-Elie GUILLOT <peguillot at irelec-alcen.com>
Objet : Re: Epics motor driver dval init

Hej Paul,
now I have some time to dig into the log.
Stay tuned ;-)
/Torsten


On 2024-02-13 16:02, Paul-Elie GUILLOT wrote:
> Sorry haha
> I think I see where you want to treat the rstm but I still have dval 0 
> though it is not
> 
> -----Message d'origine-----
> De : Torsten Bögershausen <tboegi at edom.se> Envoyé : mardi 13 février 
> 2024 14:37 À : Paul-Elie GUILLOT <peguillot at irelec-alcen.com> Objet : 
> Re: Epics motor driver dval init
> 
> Salut Paul,
> 
> good to here, that you made progress.
> I have been "fighting" with the DVAL/RSTM problem for weeks, and there are severe improvements in the ess-motor.
> Including traces ;-)
> 
> Suggestion a)
>     Could you step with a debugger through the code ?
> Or, may be:
>     run your code with the ess-motor version, and send the traces
>     to me ?
> 
> (Or do both ?)
> 
> BR
> /Torsten
> 
> 
> On 2024-02-13 14:10, Paul-Elie GUILLOT via Tech-talk wrote:
>> Hello everyone at tech-talks,
>>
>> Hope you are well.
>>
>> I am on the end of developing my motor driver. I am currently testing it.
>>
>> I have installed Epics on a VM on ubuntu and I am directly talking to 
>> my Hardware motor controller through TCP/IP.
>>
>> The driver I have developed is according to Model 3 Driver.
>>
>> Anyway, I was hoping to use the field of the motor record called RSTM 
>> to set the motor position (stepper counts) according to the DVAL 
>> field(encoder counts).
>>
>> The treatment of the RSTM field seems to be done in the function 
>> init_controller in the devMotorAsyn.c file.
>>
>> However, when called and the function asks for the motor record dval
>> (pmr->dval) the value is equal to 0.
>>
>> I think it is because the pmr->dval = pmr->drbv is done after the 
>> record is initialized.
>>
>> My question is then, does the RSTM field work as it is intended?
>>
>> How can I force Dval to be equal to the encoder position before the 
>> init_record?
>>
>> Thank you for your help and time
>>
>> Best Regards
>>
>> Paul
>>
>> Paul-Elie GUILLOT
>>
>> Technology Manager in Automation and Robotics
>>
>> Téléphone: +33 (0)4 76 44 9893
>>
>> 20 rue du Tour de l'Eau
>>
>> F-38400 St Martin d’Hères Cedex
>>
>> Phone : +33 (0)4 76 44 12 96
>>
>> irelec-alcen.com <http://www.irelec-alcen.com/en>
>>
>> *IRELEC after sales services – please send your request to 
>> support at irelec-alcen.zendesk.com 
>> <mailto:support at irelec-alcen.zendesk.com> *
>>
>> Any disclosure, use, dissemination or reproduction (either whole or
>> partial) of this message or the information contained herein is 
>> strictly prohibited without prior consent of Irelec.
>>

References:
Epics motor driver dval init Paul-Elie GUILLOT via Tech-talk

Navigate by Date:
Prev: Epics motor driver dval init Paul-Elie GUILLOT via Tech-talk
Next: Re: Failed to build archiver appliance Shankar, Murali via Tech-talk
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  <20242025 
Navigate by Thread:
Prev: Epics motor driver dval init Paul-Elie GUILLOT via Tech-talk
Next: ADPICam: epicsMutexOsdUnlock failed: ERROR Operation not permitted Fernando Ardana via Tech-talk
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  <20242025