Home Contact us Terms & conditions Shopping cart


Linux SoM


A/D converter lines

This article explains how to use the 4-channel 10 bit A/D converters built into the Atmel CPU used on the Acme Boards

The A/D converter lines are available as listed below:

Signal Description ARIAG25 TERRA DAISY-1 FOXG20
3.3V 3.3 volt power line W24 D14.1 D4.1 J6.1
AVDD Clean 3.24V out for A/D circuitry D14.2 D4.2 J6.33
VREF A/D voltage reference input W19 D14.3 D4.3 J6.34
AGND Analog GND D14.4 D4.4 J6.35
AD0 Analog input 0 W20 D14.5 D4.5 J6.30
AD1 Analog input 1 W21 D14.6 D4.6 J6.29
AD2 Analog input 2 W22 D14.7 D4.7 J6.28
AD3 Analog input 3 W23 D14.8 D4.8 J6.27
GND Digital GND W1 D14.10 D4.10 J6.40

A Daisy module called DAISY-20 is available to use these lines in the range of 0 to 10 volt elsewhere use this schematic to test quickly the A/D lines:

By wiring VREF to AVDD we can read a max voltage of 3.24 volt with a resolution of 10 bit (1024 sample points). In this way the max sample resolution we obtain is about 3.24V/1024 ~= 3mV.

On VREF cannot be applied voltage higher than 3.3 Volt. If you need to read a higher signal use a schematic like this:

This is an example to read signal in a range of 0 to 10 volt.

Install the adc driver

A ready to use binary version of the A/D converter Linux driver is available on this site. You can download it directly on your Acme board by typing:

FOXG20 or NETUSG20 with Kernel 2.6.38
debarm:~# wget http://www.acmesystems.it/www/adc/g20/at91-adc.ko


TERRA or ARIAG25 with Kernel 2.6.39
debarm:~# wget http://www.acmesystems.it/www/adc/g25/at91-adc.ko

Load the driver module inside the kernel by typing:

debarm:~# insmod at91-adc.ko
Major: 250; minor: 0                                                            
Registered device at91_adc.

now move in /sys/bus/platform/devices/at91_adc/ and read the sample from A/D channel 0 by typing:

debarm:~# cd /sys/bus/platform/devices/at91-adc/
debarm:~# cat chan0
512

Turn the trimmer and read the value again.

Python example

This simple Python code continuously reads the samples from all the four A/D channel and shown the voltage read.

read.py

debarm:~/playground/python/adc# python read.py
Channel 0 = 2.32 volt
Channel 1 = 1.69 volt
Channel 2 = 1.64 volt
Channel 3 = 1.57 volt
-------

C example

This is the same example written in C instead of Python:

read.c

debarm:~/playground/c/adc# gcc read.c -o read 
debarm:~/playground/c/adc# ./read
Channel 0 = 2.31
Channel 1 = 1.70
Channel 2 = 1.64
Channel 3 = 1.57
-------


The examples source on this article are available on the Playground repository. Click here to learn how to install them on your FOX Board G20

Compile the ADC driver from the sources:

The at91-adc driver source is available on this GitHub repository: https://github.com/tanzilli/at91-adc

To compile the driver from sources you need install the Linux Kernel tree on your Linux PC and the toolchain requested to compile it for ARM architecture.

Compile it and copy the module of your Acme board by typing:

$ git clone git://github.com/tanzilli/at91-adc.git
$ cd at91_adc
$ make
$ scp at91_adc.ko root@[ip address of your acmeboard]:/root

Related links

Credits

Many thanks to Claudio Mignanti, Stefano Barbato, Antonio Galea, Mark Richards, Douglas Gilbert for their contributes on this article.


DAISY-20 : Four channel A/D converter EURO 22.00

Front-end for the 4 channel A/D 10bits converter built-in the Atmel CPU.

Note: the daisy flat cable to wire this board is not included. Don't forget to buy it (code FLAT-20CM)

| Product description | Daisy catalog |




Acme Systems srl
Via Aldo Moro 53 - 00055 Ladispoli (RM) - Italy
P.IVA/C.F. 08114831004
Tel +39.06.99.12.187 - Fax +39.06.622.765.31
http://www.acmesystems.it -
Iscritta al Registro delle Imprese di Roma al n. 08114831004


Atmel© Certified Partner

Documentation Terms of Use
Acme Systems provides this documentation "as is" without warranty or guarantees of any kind. The mantainer of this site (Sergio Tanzilli), has gone to a great deal of effort into making this documentation as correct as possible. Acme Systems doesn't provide any direct support for the Open Source preinstalled software but provides, through these pages and forum posts, all the information required to obtain the sources, install, use and update the Open Source softwares runnable on the FOX Board, NetusG20, AriaG25 and Terra platforms. Please note that all the preinstalled softwares, used on the Acme Systems products, are Open Source and you will have to check the license terms provided (usually the GPL) by each author before using it in any commercial or non-commercial product, by yourself. Before sending emails or calling the Acme staff here are our contacts please note that WE ARE MAINLY HARDWARE DESIGNERS and NOT LINUX GURUS so could be better to post your questions directly to the forum listed below to be sure that all the contributors of this site and the large software developers community will read and reply to your questions.

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Creative Commons License