Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| analog_shield:ref_manual [2015/04/22 21:47] – created Marshall | analog_shield:ref_manual [2022/10/04 11:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| The Analog Shield offers a high fidelity and easy way to connect your Arduino™ or chipKIT™ to analog circuits. In order to do this, the Digilent Analog Shield* provides: | The Analog Shield offers a high fidelity and easy way to connect your Arduino™ or chipKIT™ to analog circuits. In order to do this, the Digilent Analog Shield* provides: | ||
| - | {{: | + | {{: |
| Figure 1. The Analog Shield. | Figure 1. The Analog Shield. | ||
| + | ==Features== | ||
| * 4 Channel, 16 bit 100 ks/s SAR ADC. | * 4 Channel, 16 bit 100 ks/s SAR ADC. | ||
| * 4 Channel 16 bit 100 ks/s string DAC. | * 4 Channel 16 bit 100 ks/s string DAC. | ||
| Line 14: | Line 16: | ||
| In addition to providing many of the features available on other prototyping or breadboard shields, this shield provides substantially more sensitive inputs and outputs than the Arduino Uno™ or the chipKIT UNO32™, as well as providing the bipolar inputs and power supplies needed to drive many useful analog circuits. | In addition to providing many of the features available on other prototyping or breadboard shields, this shield provides substantially more sensitive inputs and outputs than the Arduino Uno™ or the chipKIT UNO32™, as well as providing the bipolar inputs and power supplies needed to drive many useful analog circuits. | ||
| The Analog Shield communicates with the Arduino using the SPI communication protocol. The Analog-to-Digital input converter (ADC) and Digital-to-Analog output converter (DAC) both use the standard Arduino form factor SPI bus pins and use independent chip selects. | The Analog Shield communicates with the Arduino using the SPI communication protocol. The Analog-to-Digital input converter (ADC) and Digital-to-Analog output converter (DAC) both use the standard Arduino form factor SPI bus pins and use independent chip selects. | ||
| - | |||
| - | |||
| ---- | ---- | ||
| - | + | ===== Applications ===== | |
| - | ===== 1. Applications ===== | + | |
| The Analog Shield allows better resolution for smaller and more sensitive signals that cannot reliably be recorded or generated using the standard pins on the Arduino. | The Analog Shield allows better resolution for smaller and more sensitive signals that cannot reliably be recorded or generated using the standard pins on the Arduino. | ||
| A few demos using the Analog Shield have been developed: | A few demos using the Analog Shield have been developed: | ||
| Line 59: | Line 58: | ||
| ===== Software ===== | ===== Software ===== | ||
| Included with the Analog Shield is a simple library that is built to optimize readability and performance. | Included with the Analog Shield is a simple library that is built to optimize readability and performance. | ||
| + | <code C> | ||
| #include < | #include < | ||
| + | </ | ||
| Once the analogShield library is included, a class variable called analog will be accessible. The analog variable will allow access to the analogShield library functions. | Once the analogShield library is included, a class variable called analog will be accessible. The analog variable will allow access to the analogShield library functions. | ||
| To sample one of the analog input channels, use the function below. | To sample one of the analog input channels, use the function below. | ||
| + | <code C> | ||
| unsigned int read(int channel, bool mode = false); | unsigned int read(int channel, bool mode = false); | ||
| + | </ | ||
| To read from channel 0 (without differential mode) the syntax will look like this: | To read from channel 0 (without differential mode) the syntax will look like this: | ||
| + | <code C> | ||
| unsigned int data; | unsigned int data; | ||
| data = analog.read(0); | data = analog.read(0); | ||
| + | </ | ||
| This method samples the selected analog input. ‘Mode’ is an optional parameter. False (the default value) is the normal, single-ended mode where each analog pin is referenced to ground. True enables ‘differential’ mode, where the value returned is the difference between the voltages on pairs of adjacent inputs (i.e., A0-A1 and A2-A3). signedRead() acts the same at read() but returns a signed integer. | This method samples the selected analog input. ‘Mode’ is an optional parameter. False (the default value) is the normal, single-ended mode where each analog pin is referenced to ground. True enables ‘differential’ mode, where the value returned is the difference between the voltages on pairs of adjacent inputs (i.e., A0-A1 and A2-A3). signedRead() acts the same at read() but returns a signed integer. | ||
| + | <code C> | ||
| signedRead(int channel, bool mode = false); | signedRead(int channel, bool mode = false); | ||
| + | </ | ||
| To read from channel 0 (without differential mode) the syntax will look like this: | To read from channel 0 (without differential mode) the syntax will look like this: | ||
| + | <code C> | ||
| int data; | int data; | ||
| data = analog.read(0); | data = analog.read(0); | ||
| + | </ | ||
| To write data to the DAC, there is a function called write(). | To write data to the DAC, there is a function called write(). | ||
| + | <code C> | ||
| write(int channel, unsigned int value); | write(int channel, unsigned int value); | ||
| write(unsigned int value0, unsigned int value1, bool mode); | write(unsigned int value0, unsigned int value1, bool mode); | ||
| Line 99: | Line 99: | ||
| write(unsigned int value0, unsigned int value1, unsigned int value2, | write(unsigned int value0, unsigned int value1, unsigned int value2, | ||
| unsigned int value3, bool mode); | unsigned int value3, bool mode); | ||
| + | </ | ||
| To write a value just for channel 1, the syntax will look like this: | To write a value just for channel 1, the syntax will look like this: | ||
| - | unsigned int data = 65535; | + | <code C> |
| - | + | unsigned int data = 65535; | |
| - | analog.write(1, | + | |
| + | analog.write(1, | ||
| + | </ | ||
| To write multiple values to channels 0, 1, and 2 and have them update at the same: | To write multiple values to channels 0, 1, and 2 and have them update at the same: | ||
| - | + | <code C> | |
| - | unsigned int data0 = 65535; | + | unsigned int data0 = 65535; |
| unsigned int data1 = 256; | unsigned int data1 = 256; | ||
| unsigned int data2 = 0; | unsigned int data2 = 0; | ||
| analog.write(data0, | analog.write(data0, | ||
| + | </ | ||
| Simultaneously updating methods are useful for higher speed applications where a small delay between channel outputs will produce unwanted signals or timing issues. For example, to use the shield to drive the X-Y input of an oscilloscope to draw a circle, a delay between writing the X and the Y channels produces a ghost ‘ellipse’ drawn during the interim between the X and Y DAC updates. | Simultaneously updating methods are useful for higher speed applications where a small delay between channel outputs will produce unwanted signals or timing issues. For example, to use the shield to drive the X-Y input of an oscilloscope to draw a circle, a delay between writing the X and the Y channels produces a ghost ‘ellipse’ drawn during the interim between the X and Y DAC updates. | ||
| - | This is a simple but powerful library to help the user get started. | + | This is a simple but powerful library to help the user get started. |
| ---- | ---- | ||

