Difference between revisions of "MCP4912"

From ArmadeusWiki
Jump to: navigation, search
(set values)
m (Driver)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=Description=
+
==Description==
This 2 channels 10bits [[SPI]] DAC (Digital to Analog Converter) is mounted in standard on the [[APF51Dev]] development boards.
+
This 2 channels 10bits [[SPI]] DAC (Digital to Analog Converter) is mounted on the [[APF51Dev]] development boards.
  
 
==Connections==
 
==Connections==
On your Devlight/DevFull there are 3 signals to use the Max5821:
+
On your [[APF51Dev]] there are 2 signals to use:
* DAC_OUTA: corresponds to OUTA (pin 1 of J5 on the APF51Dev). It's the first output.
+
* DAC_OUTA: corresponds to OUTA (pin 1 of J5 on the [[APF51Dev]]). It's the first output.
* DAC_OUTB: corresponds to OUTB (pin 10 of J5 on the APF51Dev). It's the 2nd output.
+
* DAC_OUTB: corresponds to OUTB (pin 3 of J5 on the [[APF51Dev]]). It's the 2nd output.
  
The default output voltage range is 0->2.5V on the APF51Dev because the reference output of the [[AS1531]] is used as reference for the mcp4912
+
The default output voltage range is [0-2.5V] on the [[APF51Dev]] (because the 2,5V reference output of the [[AS1531]] is used as reference input for the MCP4912).
  
 
== Driver ==
 
== Driver ==
  
The driver is included in ARMadeus distribution, then to use it, select it :
+
The driver is included in the ARMadeus distribution, and has to be selected (done by default on [[APF51]]):
  
 
<pre class="host">
 
<pre class="host">
[  ] $ make linux26-menuconfig
+
$ make linux-menuconfig
 
</pre>
 
</pre>
  
Line 26: Line 26:
 
Then compile the distribution :
 
Then compile the distribution :
 
<pre class="host">
 
<pre class="host">
[  ] $ make linux26;make
+
$ make linux && make
 
</pre>
 
</pre>
  
 
== Use it ==
 
== Use it ==
=== modprobe ===
+
=== Load driver ===
 
To use the DAC first load module:
 
To use the DAC first load module:
  
Line 37: Line 37:
 
</pre>
 
</pre>
  
=== set values ===
+
=== Set channel values ===
 
<pre class="apf">
 
<pre class="apf">
 
# cd /sys/bus/spi/devices/spi0.1/device0
 
# cd /sys/bus/spi/devices/spi0.1/device0
 
# ls
 
# ls
dac_power_mode_0 out0_raw          power             uevent
+
dac_power_mode_0     dac_trigger_1    power
dac_power_mode_1 out1_raw         subsystem
+
dac_power_mode_1     out0_raw         subsystem
 +
dac_trigger_0        out1_raw          uevent
 
</pre>
 
</pre>
  
To set the dac value :
+
To set the DAC A channel value to 2.48V (max range) :
 
<pre class="apf">
 
<pre class="apf">
# cat in5_input
+
# echo 1023 > out0_raw
887
+
</pre>
 +
 
 +
To set the DAC B channel value to 1V :
 +
<pre class="apf">
 +
# echo 412 > out1_raw
 +
</pre>
 +
 
 +
=== Synchronize channels update ===
 +
To have both channels output updated simultaneously (value 2V) when setting the DAC B channel  :
 +
<pre class="apf">
 +
# echo 0 > dac_trigger_0
 +
# echo 1 > dac_trigger_1
 +
# echo 825 > out0_raw
 +
# echo 825 > out1_raw
 
</pre>
 
</pre>
  

Latest revision as of 19:39, 4 September 2013

Description

This 2 channels 10bits SPI DAC (Digital to Analog Converter) is mounted on the APF51Dev development boards.

Connections

On your APF51Dev there are 2 signals to use:

  • DAC_OUTA: corresponds to OUTA (pin 1 of J5 on the APF51Dev). It's the first output.
  • DAC_OUTB: corresponds to OUTB (pin 3 of J5 on the APF51Dev). It's the 2nd output.

The default output voltage range is [0-2.5V] on the APF51Dev (because the 2,5V reference output of the AS1531 is used as reference input for the MCP4912).

Driver

The driver is included in the ARMadeus distribution, and has to be selected (done by default on APF51):

$ make linux-menuconfig
Device Drivers  --->
    <*> Staging drivers  --->
        <*> Industrial I/O support  --->
            <M> Microchip MCP4902, MCP4912, MCP4922 driver

Then compile the distribution :

$ make linux && make

Use it

Load driver

To use the DAC first load module:

# modprobe mcp49x2

Set channel values

# cd /sys/bus/spi/devices/spi0.1/device0
# ls
dac_power_mode_0     dac_trigger_1     power
dac_power_mode_1     out0_raw          subsystem
dac_trigger_0        out1_raw          uevent

To set the DAC A channel value to 2.48V (max range) :

# echo 1023 > out0_raw

To set the DAC B channel value to 1V :

# echo 412 > out1_raw

Synchronize channels update

To have both channels output updated simultaneously (value 2V) when setting the DAC B channel  :

# echo 0 > dac_trigger_0
# echo 1 > dac_trigger_1
# echo 825 > out0_raw
# echo 825 > out1_raw

Links