Difference between revisions of "AS1531"

From ArmadeusWiki
Jump to: navigation, search
(read values)
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
== Introduction ==
 
== Introduction ==
  
AS1531 is a 8 channels 12bits analog do digital converter made by [http://www.austriamicrosystems.com/ Austriamicrosystem]. The driver is included in ARMadeus distribution, but not currently on ARMadeus board.
+
AS1531 is a 12bits 8 channels Analog to Digital Converter made by [http://www.austriamicrosystems.com/ Austriamicrosystem]. Its use a SPI bus to communicate with a master microprocessor. A driver is included in the Armadeus BSP/SDK and can be used on the APF51Dev board.
  
== Soldering ==
+
== Connecting chip on APF boards ==
  
AS1531 chip use a SPI bus to communicate with the microprocessor, then to use it on APFx board it must be solder on a SPI bus. For example on APF27-Dev board it can be soldered on SPI3 bus, that can be found on connector J8.
+
* On the [[APF51Dev]], the AS1531 is connected to the SPI1 bus by default, so you can move to [[AS1531#Use_it|next chapter]].
 +
* On the [[APF27Dev]] board it can be soldered on SPI3 bus, which is available on connector J8.
  
 
{| class="wikitable" style="text-align:center; width:50%;"
 
{| class="wikitable" style="text-align:center; width:50%;"
Line 28: Line 29:
  
 
== Driver ==
 
== Driver ==
 
+
* Driver is by default included if you choose an [[APF51]] as target.
The driver is included in ARMadeus distribution, then to use it, select it :
+
* Otherwise, you can select it that way:
  
 
<pre class="host">
 
<pre class="host">
[  ] $ make linux26-menuconfig
+
$ make linux-menuconfig
 
</pre>
 
</pre>
  
Line 41: Line 42:
 
</pre>
 
</pre>
  
If the chip is plugged on SPI3 don't forget to select SPI3 and platform module :
+
* Then rebuild the Linux and rootfs images:
<pre class="config">
+
Device Drivers  --->
+
    [*] SPI support  --->
+
        [*]    CSPI3
+
</pre>
+
<pre class="config">
+
Device Drivers  --->
+
    Armadeus specific drivers  --->
+
        <M>  AS1531 platform data
+
</pre>
+
 
+
 
+
Then compile the distribution :
+
 
<pre class="host">
 
<pre class="host">
[  ] $ make linux26;make
+
$ make linux && make
 
</pre>
 
</pre>
  
 
== Use it ==
 
== Use it ==
=== modprobe ===
+
{{Warning|AS1531 is used with internal reference voltage of 2,5V, so DO NOT TRY to acquire signals with greater voltage range.}}
To use the ADC first load module hwmon and as1531 (if configured as module) :
+
  
<pre class="host">
+
=== Load driver ===
[ ] $ modprobe hwmon
+
To use the AS1531, first load ''as1531'' module:
[ ] $ modprobe as1531
+
 
[ ] $ modprobe as1531_plat
+
<pre class="apf">
 +
# modprobe as1531
 
</pre>
 
</pre>
  
=== read values ===
+
=== Read channels value ===
 
+
If chip is plugged on SPI3, adc input file will be found under directory :
+
  
 
<pre class="apf">
 
<pre class="apf">
# cd /sys/bus/spi/devices/spi2.0/
+
# cd /sys/bus/spi/devices/spi0.0/
 
# ls
 
# ls
 
driver    in1_input  in4_input  in7_input  modalias  subsystem
 
driver    in1_input  in4_input  in7_input  modalias  subsystem
Line 89: Line 75:
 
</pre>
 
</pre>
  
To read adc value just «cat» un input :
+
To read adc value just «cat» an input :
 
<pre class="apf">
 
<pre class="apf">
# cat in5_input  
+
# cat in5_input
 
887
 
887
 
</pre>
 
</pre>
  
 
All values read are in milivolts.
 
All values read are in milivolts.
 +
[[Category:ExternalDeviceControl]]
 +
[[Category:Linux drivers]]
 +
[[Category:Analog to Digital Converter]]
 +
 +
==Examples==
 +
* Script to read all values each 500ms and display them on console:
 +
<source lang="bash">
 +
#!/bin/sh
 +
 +
modprobe as1531
 +
 +
loop=1
 +
while [ "$loop" == 1 ]; do
 +
        for i in 0 1 2 3 4 5 6 7; do
 +
                value=`cat /sys/bus/spi/devices/spi0.0/in"$i"_input`
 +
                echo -n "$value  "
 +
        done
 +
        usleep 500000  # 500ms
 +
        echo
 +
done
 +
</source>

Latest revision as of 19:13, 12 February 2013

Introduction

AS1531 is a 12bits 8 channels Analog to Digital Converter made by Austriamicrosystem. Its use a SPI bus to communicate with a master microprocessor. A driver is included in the Armadeus BSP/SDK and can be used on the APF51Dev board.

Connecting chip on APF boards

  • On the APF51Dev, the AS1531 is connected to the SPI1 bus by default, so you can move to next chapter.
  • On the APF27Dev board it can be soldered on SPI3 bus, which is available on connector J8.
Soldering schema for SPI3 APF27-dev
J8 pin AS1531 pin
SD1_D0_SPI3_MISO DOUT
SD1_D3_SPI3_SS CSN
SD1_CMD_SPI3_MOSI DIN
SP1_CLK_SPI3_SCLK SCLK

Driver

  • Driver is by default included if you choose an APF51 as target.
  • Otherwise, you can select it that way:
$ make linux-menuconfig
Device Drivers  --->
    <M> Hardware Monitoring support  --->
        <M>   Austria Microsystems AS1531 Analog to Digital Converter
  • Then rebuild the Linux and rootfs images:
$ make linux && make

Use it

Warning Warning: AS1531 is used with internal reference voltage of 2,5V, so DO NOT TRY to acquire signals with greater voltage range.


Load driver

To use the AS1531, first load as1531 module:

# modprobe as1531

Read channels value

# cd /sys/bus/spi/devices/spi0.0/
# ls
driver     in1_input  in4_input  in7_input  modalias   subsystem
hwmon      in2_input  in5_input  in_max     name       uevent
in0_input  in3_input  in6_input  in_min     power

or:

# cd /sys/class/hwmon/hwmon0/device/
# ls
driver     in1_input  in4_input  in7_input  modalias   subsystem
hwmon      in2_input  in5_input  in_max     name       uevent
in0_input  in3_input  in6_input  in_min     power

To read adc value just «cat» an input :

# cat in5_input
887

All values read are in milivolts.

Examples

  • Script to read all values each 500ms and display them on console:
#!/bin/sh

modprobe as1531

loop=1
while [ "$loop" == 1 ]; do
        for i in 0 1 2 3 4 5 6 7; do
                value=`cat /sys/bus/spi/devices/spi0.0/in"$i"_input`
                echo -n "$value  "
        done
        usleep 500000   # 500ms
        echo
done