2023-09-29 21:40:42

by David Lechner

[permalink] [raw]
Subject: Re: [PATCH v3 14/27] staging: iio: resolver: ad2s1210: implement hysteresis as channel attr

On Fri, Sep 29, 2023 at 12:25 PM David Lechner <[email protected]> wrote:
>
> The AD2S1210 resolver has a hysteresis feature that can be used to
> prevent flicker in the LSB of the position register. This can be either
> enabled or disabled. Disabling hysteresis is useful for increasing
> precision by oversampling.
>
> Signed-off-by: David Lechner <[email protected]>
> ---

...

> +static int ad2s1210_read_avail(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + const int **vals, int *type,
> + int *length, long mask)
> +{
> + static const int hysteresis_available[] = { 0, 1 };

This is basically an enable/disable. Should the 1 value be changed to the
appropriate radians value since this is hysteresis on the position
(angle) channel?

> +
> + switch (mask) {
> + case IIO_CHAN_INFO_HYSTERESIS:
> + switch (chan->type) {
> + case IIO_ANGL:
> + *vals = hysteresis_available;
> + *type = IIO_VAL_INT;
> + *length = ARRAY_SIZE(hysteresis_available);
> + return IIO_AVAIL_LIST;
> + default:
> + return -EINVAL;
> + }
> + default:
> + return -EINVAL;
> + }
> +}
>


2023-09-30 15:02:58

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v3 14/27] staging: iio: resolver: ad2s1210: implement hysteresis as channel attr

On Fri, 29 Sep 2023 12:53:00 -0500
David Lechner <[email protected]> wrote:

> On Fri, Sep 29, 2023 at 12:25 PM David Lechner <[email protected]> wrote:
> >
> > The AD2S1210 resolver has a hysteresis feature that can be used to
> > prevent flicker in the LSB of the position register. This can be either
> > enabled or disabled. Disabling hysteresis is useful for increasing
> > precision by oversampling.
> >
> > Signed-off-by: David Lechner <[email protected]>
> > ---
>
> ...
>
> > +static int ad2s1210_read_avail(struct iio_dev *indio_dev,
> > + struct iio_chan_spec const *chan,
> > + const int **vals, int *type,
> > + int *length, long mask)
> > +{
> > + static const int hysteresis_available[] = { 0, 1 };
>
> This is basically an enable/disable. Should the 1 value be changed to the
> appropriate radians value since this is hysteresis on the position
> (angle) channel?

Good point. However it should be in the _raw units. The text is
slightly more explicit on this for
the variant of hysteresis applied to threshold events as it's
added or substracted from a threshold (and thresholds are in
_raw readings unless only _processed is available).

Does that make 0, 1 correct as we are talking about LSB only?

Jonathan


>
> > +
> > + switch (mask) {
> > + case IIO_CHAN_INFO_HYSTERESIS:
> > + switch (chan->type) {
> > + case IIO_ANGL:
> > + *vals = hysteresis_available;
> > + *type = IIO_VAL_INT;
> > + *length = ARRAY_SIZE(hysteresis_available);
> > + return IIO_AVAIL_LIST;
> > + default:
> > + return -EINVAL;
> > + }
> > + default:
> > + return -EINVAL;
> > + }
> > +}
> >

2023-10-01 00:22:08

by David Lechner

[permalink] [raw]
Subject: Re: [PATCH v3 14/27] staging: iio: resolver: ad2s1210: implement hysteresis as channel attr

On Sat, Sep 30, 2023 at 10:00 AM Jonathan Cameron <[email protected]> wrote:
>
> On Fri, 29 Sep 2023 12:53:00 -0500
> David Lechner <[email protected]> wrote:
>
> > On Fri, Sep 29, 2023 at 12:25 PM David Lechner <[email protected]> wrote:
> > >
> > > The AD2S1210 resolver has a hysteresis feature that can be used to
> > > prevent flicker in the LSB of the position register. This can be either
> > > enabled or disabled. Disabling hysteresis is useful for increasing
> > > precision by oversampling.
> > >
> > > Signed-off-by: David Lechner <[email protected]>
> > > ---
> >
> > ...
> >
> > > +static int ad2s1210_read_avail(struct iio_dev *indio_dev,
> > > + struct iio_chan_spec const *chan,
> > > + const int **vals, int *type,
> > > + int *length, long mask)
> > > +{
> > > + static const int hysteresis_available[] = { 0, 1 };
> >
> > This is basically an enable/disable. Should the 1 value be changed to the
> > appropriate radians value since this is hysteresis on the position
> > (angle) channel?
>
> Good point. However it should be in the _raw units. The text is
> slightly more explicit on this for
> the variant of hysteresis applied to threshold events as it's
> added or substracted from a threshold (and thresholds are in
> _raw readings unless only _processed is available).
>
> Does that make 0, 1 correct as we are talking about LSB only?
>

It is currently only correct (as a raw value) if the selected
resolution is 16-bit. So I will need to fix this so the value is `1 <<
(16 - resolution)`.