You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by di...@gmail.com on 2020/10/21 14:34:58 UTC

NuttX and continuous ADC conversion

Is it possible to achieve a continuous ADC conversion, where the sample[0].am_data is written in a struct (and constantly updated) and where I can get and check the voltage from the ADC?

I have it working that the value I get is true and it also seems to measure the change, but after some time the conversion seems to stop. And it only seems to do n-counts.. even though I have not set a count.

I have set a TIM3 channel 1 with frequency 100Hz in make menuconfig.

With kind regards,
Ben


Re: NuttX and continuous ADC conversion

Posted by Brennan Ashton <ba...@brennanashton.com>.
You might find this interesting. It's about sensors, but ADCs are just a
voltage sensor so it might be possible to optionally wire the upper half.

https://github.com/apache/incubator-nuttx/pull/2039

On Wed, Oct 21, 2020, 11:48 AM <di...@gmail.com> wrote:

> I have implemented a daemon which uses sigaction. And indeed the ADC works
> with this solution until the FIFO is full... Maybe I have to add an IOCT
> that resets the ADC?... Or set the FIFO buffer back? Or make a ringbuffer
> instead of FIFO....
>
> Ben
>
> -----Oorspronkelijk bericht-----
> Van: Nathan Hartman <ha...@gmail.com>
> Verzonden: woensdag 21 oktober 2020 20:36
> Aan: dev@nuttx.apache.org
> Onderwerp: Re: NuttX and continuous ADC conversion
>
> On Wed, Oct 21, 2020 at 2:26 PM <di...@gmail.com> wrote:
>
> > Thats correct...  so I have to start the conversion every time over
> > again... and het the value after that conversion.... I have seen
> > continuous conversions ADC on an STM32...
> >
> > I will try to find a plausible solution.
> >
>
> Zero latency ISR to read ADC register into memory buffer?
>
>

Re: NuttX and continuous ADC conversion

Posted by Disruptive Solutions <di...@gmail.com>.
Fixed it (workaround) by opening and closing ADC device. Then the FIFO
cleans. It rather fast and performance is good enough for its purpose.

Op wo 21 okt. 2020 9:33 p.m. schreef <di...@gmail.com>:

> Nice.. I just want to use the ADC as feedback sensor for a plunger... I
> all works fine until the FIFO is full 😉
>
> -----Oorspronkelijk bericht-----
> Van: Daniel Pereira Carvalho <da...@gmail.com>
> Verzonden: woensdag 21 oktober 2020 21:01
> Aan: dev@nuttx.apache.org
> Onderwerp: Re: NuttX and continuous ADC conversion
>
> Maybe you could propose a modification on ADC upper-half driver to enable
> overwriting. So, if the FIFO is full the oldest value is replaced by the
> new one. This could be an option on the config system.
>
> At this moment I am working on STM32L4 ADC driver. I am implementing the
> low level operations, based on STM32 ADC driver. Using low level operations
> you don't need to use the upper-half.
>
> Daniel Pereira de Carvalho
>
>
> Em qua., 21 de out. de 2020 às 15:48, <di...@gmail.com>
> escreveu:
>
> > I have implemented a daemon which uses sigaction. And indeed the ADC
> > works with this solution until the FIFO is full... Maybe I have to add
> > an IOCT that resets the ADC?... Or set the FIFO buffer back? Or make a
> > ringbuffer instead of FIFO....
> >
> > Ben
> >
> > -----Oorspronkelijk bericht-----
> > Van: Nathan Hartman <ha...@gmail.com>
> > Verzonden: woensdag 21 oktober 2020 20:36
> > Aan: dev@nuttx.apache.org
> > Onderwerp: Re: NuttX and continuous ADC conversion
> >
> > On Wed, Oct 21, 2020 at 2:26 PM <di...@gmail.com> wrote:
> >
> > > Thats correct...  so I have to start the conversion every time over
> > > again... and het the value after that conversion.... I have seen
> > > continuous conversions ADC on an STM32...
> > >
> > > I will try to find a plausible solution.
> > >
> >
> > Zero latency ISR to read ADC register into memory buffer?
> >
> >
>
>

RE: NuttX and continuous ADC conversion

Posted by di...@gmail.com.
Nice.. I just want to use the ADC as feedback sensor for a plunger... I all works fine until the FIFO is full 😉

-----Oorspronkelijk bericht-----
Van: Daniel Pereira Carvalho <da...@gmail.com> 
Verzonden: woensdag 21 oktober 2020 21:01
Aan: dev@nuttx.apache.org
Onderwerp: Re: NuttX and continuous ADC conversion

Maybe you could propose a modification on ADC upper-half driver to enable overwriting. So, if the FIFO is full the oldest value is replaced by the new one. This could be an option on the config system.

At this moment I am working on STM32L4 ADC driver. I am implementing the low level operations, based on STM32 ADC driver. Using low level operations you don't need to use the upper-half.

Daniel Pereira de Carvalho


Em qua., 21 de out. de 2020 às 15:48, <di...@gmail.com>
escreveu:

> I have implemented a daemon which uses sigaction. And indeed the ADC 
> works with this solution until the FIFO is full... Maybe I have to add 
> an IOCT that resets the ADC?... Or set the FIFO buffer back? Or make a 
> ringbuffer instead of FIFO....
>
> Ben
>
> -----Oorspronkelijk bericht-----
> Van: Nathan Hartman <ha...@gmail.com>
> Verzonden: woensdag 21 oktober 2020 20:36
> Aan: dev@nuttx.apache.org
> Onderwerp: Re: NuttX and continuous ADC conversion
>
> On Wed, Oct 21, 2020 at 2:26 PM <di...@gmail.com> wrote:
>
> > Thats correct...  so I have to start the conversion every time over 
> > again... and het the value after that conversion.... I have seen 
> > continuous conversions ADC on an STM32...
> >
> > I will try to find a plausible solution.
> >
>
> Zero latency ISR to read ADC register into memory buffer?
>
>


Re: NuttX and continuous ADC conversion

Posted by Daniel Pereira Carvalho <da...@gmail.com>.
Maybe you could propose a modification on ADC upper-half driver to enable
overwriting. So, if the FIFO is full the oldest value is replaced by the
new one. This could be an option on the config system.

At this moment I am working on STM32L4 ADC driver. I am implementing the
low level operations, based on STM32 ADC driver. Using low level operations
you don't need to use the upper-half.

Daniel Pereira de Carvalho


Em qua., 21 de out. de 2020 às 15:48, <di...@gmail.com>
escreveu:

> I have implemented a daemon which uses sigaction. And indeed the ADC works
> with this solution until the FIFO is full... Maybe I have to add an IOCT
> that resets the ADC?... Or set the FIFO buffer back? Or make a ringbuffer
> instead of FIFO....
>
> Ben
>
> -----Oorspronkelijk bericht-----
> Van: Nathan Hartman <ha...@gmail.com>
> Verzonden: woensdag 21 oktober 2020 20:36
> Aan: dev@nuttx.apache.org
> Onderwerp: Re: NuttX and continuous ADC conversion
>
> On Wed, Oct 21, 2020 at 2:26 PM <di...@gmail.com> wrote:
>
> > Thats correct...  so I have to start the conversion every time over
> > again... and het the value after that conversion.... I have seen
> > continuous conversions ADC on an STM32...
> >
> > I will try to find a plausible solution.
> >
>
> Zero latency ISR to read ADC register into memory buffer?
>
>

RE: NuttX and continuous ADC conversion

Posted by di...@gmail.com.
I have implemented a daemon which uses sigaction. And indeed the ADC works with this solution until the FIFO is full... Maybe I have to add an IOCT that resets the ADC?... Or set the FIFO buffer back? Or make a ringbuffer instead of FIFO....

Ben

-----Oorspronkelijk bericht-----
Van: Nathan Hartman <ha...@gmail.com> 
Verzonden: woensdag 21 oktober 2020 20:36
Aan: dev@nuttx.apache.org
Onderwerp: Re: NuttX and continuous ADC conversion

On Wed, Oct 21, 2020 at 2:26 PM <di...@gmail.com> wrote:

> Thats correct...  so I have to start the conversion every time over 
> again... and het the value after that conversion.... I have seen 
> continuous conversions ADC on an STM32...
>
> I will try to find a plausible solution.
>

Zero latency ISR to read ADC register into memory buffer?


Re: NuttX and continuous ADC conversion

Posted by Nathan Hartman <ha...@gmail.com>.
On Wed, Oct 21, 2020 at 2:26 PM <di...@gmail.com> wrote:

> Thats correct...  so I have to start the conversion every time over
> again... and het the value after that conversion.... I have seen continuous
> conversions ADC on an STM32...
>
> I will try to find a plausible solution.
>

Zero latency ISR to read ADC register into memory buffer?

RE: NuttX and continuous ADC conversion

Posted by di...@gmail.com.
Thats correct...  so I have to start the conversion every time over again... and het the value after that conversion.... I have seen continuous conversions ADC on an STM32...

I will try to find a plausible solution.

Ben

-----Oorspronkelijk bericht-----
Van: Daniel Pereira Carvalho <da...@gmail.com> 
Verzonden: woensdag 21 oktober 2020 17:14
Aan: dev@nuttx.apache.org
Onderwerp: Re: NuttX and continuous ADC conversion

If I understand well, you want to put the ADC to continuously sample an input at some sampling rate.The ADC ring buffer depth will be set to 1 and should store the value of the last sample. Is that correct?

If yes I think that is not possible because adc_receive() will refuse new data if FIFO is full.


Daniel Pereira de Carvalho


Em qua., 21 de out. de 2020 às 11:35, <di...@gmail.com>
escreveu:

> Is it possible to achieve a continuous ADC conversion, where the 
> sample[0].am_data is written in a struct (and constantly updated) and 
> where I can get and check the voltage from the ADC?
>
> I have it working that the value I get is true and it also seems to 
> measure the change, but after some time the conversion seems to stop. 
> And it only seems to do n-counts.. even though I have not set a count.
>
> I have set a TIM3 channel 1 with frequency 100Hz in make menuconfig.
>
> With kind regards,
> Ben
>
>


Re: NuttX and continuous ADC conversion

Posted by Daniel Pereira Carvalho <da...@gmail.com>.
If I understand well, you want to put the ADC to continuously sample an
input at some sampling rate.The ADC ring buffer depth will be set to 1 and
should store the value of the last sample. Is that correct?

If yes I think that is not possible because adc_receive() will refuse new
data if FIFO is full.


Daniel Pereira de Carvalho


Em qua., 21 de out. de 2020 às 11:35, <di...@gmail.com>
escreveu:

> Is it possible to achieve a continuous ADC conversion, where the
> sample[0].am_data is written in a struct (and constantly updated) and where
> I can get and check the voltage from the ADC?
>
> I have it working that the value I get is true and it also seems to
> measure the change, but after some time the conversion seems to stop. And
> it only seems to do n-counts.. even though I have not set a count.
>
> I have set a TIM3 channel 1 with frequency 100Hz in make menuconfig.
>
> With kind regards,
> Ben
>
>