linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Implementing real-time embedded system to sample from five SPI ADCs
@ 2010-11-03 23:06 Nicholas Kinar
  2010-11-04  8:29 ` Andre Puschmann
  0 siblings, 1 reply; 3+ messages in thread
From: Nicholas Kinar @ 2010-11-03 23:06 UTC (permalink / raw)
  To: linux-rt-users

Hello,

I would like to implement a real-time embedded Linux system on an 
AT91SAM ARM processor.  Attached to the SPI bus of this processor are 5 
Analog-to-Digital converters (ADCs) that can be read using the Linux SPI 
bus subsystem.

The ADCs are sampled by having the  AT91SAM ARM processor toggle a GPIO 
at a rate of at least 1 KHz.  The GPIO is attached to a pin on the ADC.  
A high voltage level on this pin instructs all of the ADCs to take a 
sample.  The sample is then read over the SPI bus by the embedded system 
master.  This implies that data will be read from each SPI slave device 
every (1 / 1000 Hz) = 1.0e-3 seconds.

I am wondering if the following could be done with real-time Linux:

(1) I would have to write a Linux kernel module to toggle the GPIO pin.  
The rate of toggling would be controlled by a high-resolution timer, and 
would occur with a period of at least 1 kHz.
(2) After the GPIO is brought to a high voltage level, the master must 
wait for at least 3.7 microseconds before reading from the SPI bus.
(3) Each ADC would be read in sequential order.

The ADC being used is the AD7691 from Analog Devices 
(http://www.analog.com/static/imported-files/data_sheets/AD7691.pdf).

The data from the ADCs could be used in a real-time control system 
loop.  Can this be done with real-time Linux, or is the latency too 
high?  What is the maximum rate at which I could read data from these 
ADCs?  Could it be 10 kHz or even 100 kHz?

Nicholas



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Implementing real-time embedded system to sample from five SPI ADCs
  2010-11-03 23:06 Implementing real-time embedded system to sample from five SPI ADCs Nicholas Kinar
@ 2010-11-04  8:29 ` Andre Puschmann
  2010-11-04 15:43   ` Nicholas Kinar
  0 siblings, 1 reply; 3+ messages in thread
From: Andre Puschmann @ 2010-11-04  8:29 UTC (permalink / raw)
  To: linux-rt-users

Hi Nicholas,

according to what I understood, you want to use the data coming from 
your ADCs in a userspace application which implements the control loop.

I think there is a good chance you can then do all the steps (1)-(3) 
within an userspace application. However, I am not 100% certain about 
the best solution to implement (2) on this setup. May be anybody else
knows something about the maximum sample frequency, but this also 
depends on how complicated your algorithms are.

Here [1] you can find a good example on how to write a RT userspace 
application. Using the SPI character devices it should also be possible 
to talk to your hardware.

Regards,
Andre


[1] https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO


On 11/04/2010 12:06 AM, Nicholas Kinar wrote:
> Hello,
>
> I would like to implement a real-time embedded Linux system on an
> AT91SAM ARM processor. Attached to the SPI bus of this processor are 5
> Analog-to-Digital converters (ADCs) that can be read using the Linux SPI
> bus subsystem.
>
> The ADCs are sampled by having the AT91SAM ARM processor toggle a GPIO
> at a rate of at least 1 KHz. The GPIO is attached to a pin on the ADC. A
> high voltage level on this pin instructs all of the ADCs to take a
> sample. The sample is then read over the SPI bus by the embedded system
> master. This implies that data will be read from each SPI slave device
> every (1 / 1000 Hz) = 1.0e-3 seconds.
>
> I am wondering if the following could be done with real-time Linux:
>
> (1) I would have to write a Linux kernel module to toggle the GPIO pin.
> The rate of toggling would be controlled by a high-resolution timer, and
> would occur with a period of at least 1 kHz.
> (2) After the GPIO is brought to a high voltage level, the master must
> wait for at least 3.7 microseconds before reading from the SPI bus.
> (3) Each ADC would be read in sequential order.
>
> The ADC being used is the AD7691 from Analog Devices
> (http://www.analog.com/static/imported-files/data_sheets/AD7691.pdf).
>
> The data from the ADCs could be used in a real-time control system loop.
> Can this be done with real-time Linux, or is the latency too high? What
> is the maximum rate at which I could read data from these ADCs? Could it
> be 10 kHz or even 100 kHz?
>
> Nicholas
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-rt-users" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Implementing real-time embedded system to sample from five SPI ADCs
  2010-11-04  8:29 ` Andre Puschmann
@ 2010-11-04 15:43   ` Nicholas Kinar
  0 siblings, 0 replies; 3+ messages in thread
From: Nicholas Kinar @ 2010-11-04 15:43 UTC (permalink / raw)
  To: Andre Puschmann; +Cc: linux-rt-users


> Hi Nicholas,
>
> according to what I understood, you want to use the data coming from 
> your ADCs in a userspace application which implements the control loop.
>
> I think there is a good chance you can then do all the steps (1)-(3) 
> within an userspace application. However, I am not 100% certain about 
> the best solution to implement (2) on this setup. May be anybody else
> knows something about the maximum sample frequency, but this also 
> depends on how complicated your algorithms are.
>
> Here [1] you can find a good example on how to write a RT userspace 
> application. Using the SPI character devices it should also be 
> possible to talk to your hardware.
>
> Regards,
> Andre
>
>
> [1] https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO
>
>

Thanks, Andre; that is a very good link, and thank you for the 
information.  I am hoping that I can sample from the ADCs at a rate of 
at least 1 kHz, and I am wondering if it is best to do this in a 
userspace program or in a kernel driver.

My processing algorithms are not very complicated.  If one of the ADC 
data values is greater than a certain value, then a digital-to-analog 
converter (DAC) control register is updated.  All that I want to do is 
to collect data at a rate of 1 kHz by toggling a port pin and then 
reading the data values over SPI.

Nicholas

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-11-04 15:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-03 23:06 Implementing real-time embedded system to sample from five SPI ADCs Nicholas Kinar
2010-11-04  8:29 ` Andre Puschmann
2010-11-04 15:43   ` Nicholas Kinar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).