Here is a code example using the Pi-SPi-2AO dual channel analog output module. The module uses a dual 12 bit DAC, the MCP4922. Each mA output has a mirror VDC output. The output circuit requires an external supply voltage, I am using a wall adapter style 24 VDC power supply. Each output has a signal strength LED, in this example mA Output 1 is set to 4 mA and mA Output 2 is set to 20 mA. Schematics can be found on the product page Pi-SPI-2AO link. The outputs are very easily defined as follows: Reference Vref = 3.3. The mA circuit is optimized to give 20 mA at a 3VDC output from the DAC. Therefore, 20 mA = 3/3.3 * 4096 DA Counts = 3723 DA Counts. Here is a very simple test routine written in C (using the Geany compiler on the RPi 3) /* * pispi_2ao.c * * Copyright 2016 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * * */#include #include #include #include #include #include #include // Define Pins#define PIN_EN_DA 22 // Prototypes void Initialize_Pi_Hardware(void);void Update_Analog_Output(unsigned int dac1, unsigned int dac2); // Variables unsigned int DAC1_Counts;unsigned int DAC2_Counts;// mainint main(void) { wiringPiSetupGpio(); Initialize_Pi_Hardware(); digitalWrite(PIN_EN_DA, HIGH); while(1) { // DAC1_Counts = 0; // 0 = 0 mA DAC1_Counts = 745; // 745 = 4 mA DAC2_Counts = 3723; // 3VDC/3.3Vref * 4096 = 3723 = 20 mA printf(