Arduino DUE + DAC MCP4922 (SPI)



Similar documents
Part 1. MAX BIT DAC with an Arduino Board. MIDI to Voltage Converter Part1

DATASHEET. ADAM Arduino Display Adaptor Module. Arduino Compatible Shield P/N: 4Display-Shield-FT843 For the 4D Systems 4DLCD-FT843 Display

Introduction the Serial Communications Huang Sections 9.2, 10.2 SCI Block User Guide SPI Block User Guide

Using Arduino Microcontrollers to Sense DC Motor Speed and Position

Arduino ADK Back. For information on using the board with the Android OS, see Google's ADK documentation.

Using the HT46R46 I/O Ports to Implement Half-Duplex SPI Communication

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

A REST API for Arduino & the CC3000 WiFi Chip

Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board

1.8" TFT Display Breakout and Shield

Arduino Lesson 1. Blink

Android Controlled Based Interface

IR Communication a learn.sparkfun.com tutorial

Arduino Due Back. Warning: Unlike other Arduino boards, the Arduino Due board runs at 3.3V. The maximum. Overview

MCP4725 Digital to Analog Converter Hookup Guide

PN532 NFC RFID Module User Guide

How to Move Canon EF Lenses. Yosuke Bando

FR FAMILY MB91460 SPI - DAISY CHAIN COMMUNICATION 32-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

Arduino Lesson 16. Stepper Motors

2.2" TFT Display. Created by Ladyada. Last updated on :15:09 PM EDT

Lab 6 Introduction to Serial and Wireless Communication

Adafruit MCP9808 Precision I2C Temperature Sensor Guide

Adafruit BME280 Humidity + Barometric Pressure + Temperature Sensor Breakout

User s Manual of Board Microcontroller ET-MEGA2560-ADK ET-MEGA2560-ADK

Implementing SPI Communication Between MSP430 G2452 and LTC ADC

EARTH PEOPLE TECHNOLOGY SERIAL GRAPH TOOL FOR THE ARDUINO UNO USER MANUAL

Arduino Motor Shield (L298) Manual

Arduino Lesson 14. Servo Motors

WICE-SPI Hardware Operation Manual

Tiny Arduino Music Visualizer

Embedded Systems Design Course Applying the mbed microcontroller

JTAG-HS2 Programming Cable for Xilinx FPGAs. Overview. Revised January 22, 2015 This manual applies to the HTAG-HS2 rev. A

PHYS 2P32 Project: MIDI for Arduino/ 8 Note Keyboard

Implementing SPI Master and Slave Functionality Using the Z8 Encore! F083A

Microcomputers. Analog-to-Digital and Digital-to-Analog Conversion

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT BIT DIFFERENTIAL ADC WITH I2C LTC2485 DESCRIPTION

ARDUINO SEVERINO SERIAL SINGLE SIDED VERSION 3 S3v3 (REVISION 2) USER MANUAL

CAN-Bus Shield Hookup Guide

2.3" Monochrome 128x32 OLED Display Module

Yun Shield User Manual VERSION: 1.0. Yun Shield User Manual 1 / 22.

FEATURES DESCRIPTION. PT6321 Fluorescent Display Tube Controller Driver

1.5" & 2.1" Monochrome 128x64 OLED Display Module

Yun Shield Quick Start Guide VERSION: 1.0 Version Description Date 1.0 Release 2014-Jul-08 Yun Shield Quick Start Guide 1 / 14

Surveillance System Using Wireless Sensor Networks

CAN bus board. EB018

A DIY Hardware Packet Sniffer

3.2 inch Arduino LCD Shield User Guide

Arduino Microcontroller Guide W. Durfee, University of Minnesota ver. oct-2011 Available on-line at

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

Vinco Development Module. Datasheet

DAC Digital To Analog Converter

Introduction to Arduino

Arduino Lesson 13. DC Motors. Created by Simon Monk

Your Multimeter. The Arduino Uno 10/1/2012. Using Your Arduino, Breadboard and Multimeter. EAS 199A Fall Work in teams of two!

Doc: page 1 of 17

Raspberry Pi. Hans- Petter Halvorsen, M.Sc.

Newhaven Display International, Inc Galvin Ct. Elgin IL, Ph: Fax:

Atmel Norway XMEGA Introduction

MXL5007T TUNER RADIO

AN-812 APPLICATION NOTE

Arduino Lesson 9. Sensing Light

US-SPI New generation of High performances Ultrasonic device

USER GUIDE EDBG. Description

PLL frequency synthesizer

Adafruit Music Maker Shield

1 Coffee cooling : Part B : automated data acquisition

FLYPORT Wi-Fi G

Adafruit ATWINC1500 WiFi Breakout

Pmod peripheral modules are powered by the host via the interface s power and ground pins.

Final Project Example

1602 LCD adopts standard 14 pins(no backlight) or 16pins(with backlight) interface, Instruction of each pin interface is as follows:

SainSmart UNO R3 Starter Kit

MicroMag3 3-Axis Magnetic Sensor Module

Arduino Lesson 4. Eight LEDs and a Shift Register

Pulse Width Modulation

Basic Pulse Width Modulation

AND8336. Design Examples of On Board Dual Supply Voltage Logic Translators. Prepared by: Jim Lepkowski ON Semiconductor.

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Electronic Circuits Spring 2007

[F/T] [5] [KHz] [AMP] [3] [V] 4 ) To set DC offset to -2.5V press the following keys [OFS] [+/-] [2] [.] [5] [V]

H-Bridge Motor Control

Introduction. Getting familiar with chipkit Pi

Pololu DRV8835 Dual Motor Driver Shield for Arduino

ADS9850 Signal Generator Module

Serial Input, Voltage Output 12-/14-Bit Digital-to-Analog Converters AD5530/AD5531

AUTOMATIC NIGHT LAMP WITH MORNING ALARM USING MICROPROCESSOR

3.2 inch QVGA TFT Color LCD User s Guide Version 1 & 2

Interfacing Analog to Digital Data Converters

Application Note 120 Communicating Through the 1-Wire Master

C4DI Arduino tutorial 4 Things beginning with the letter i

Conversion Between Analog and Digital Signals

Character LCDs. Created by Ladyada. Last updated on :45:29 PM EDT

MOD-ENC28J60 development board Users Manual

In-System Programmer USER MANUAL RN-ISP-UM RN-WIFLYCR-UM

Arduino provides a standard form factor that breaks the functions of the micro-controller into a more accessible package.

Cornerstone Electronics Technology and Robotics I Week 15 Voltage Comparators Tutorial

Activity 1: Using base ten blocks to model operations on decimals

Digital Sampling Oscilloscope

Transcription:

Arduino DUE + DAC MCP4922 (SPI) v101 In this document it will described how to connect and let a Digital/Analog convert work with an Arduino DUE. The big difference between and Arduino DUE and other Arduinos about SPI is that with the DUE is possible to address up to 3 different SPI devices at the same time, instead on the Arduino UNO for you can address just one SPI device at a time. The most of the libraries are using the pin 10 as CS pin but that is up to software developer. Some libraries allows the user also to specify the CS pin at the beginning. On the DUE the pins (CS) with which it is possible to address SPI devices are: 10, 4, 52 (See picture below). The other SPI pins are available in middle of the board as shown in the following picture. The following table display on which pins the SPI lines are broken out on the different Arduino boards:

Arduino Board MOSI MISO SCK Uno or Duemilanove Mega1280 or Mega2560 11 or ICSP-4 51 or ICSP-4 12 or ICSP-1 50 or ICSP-1 13 or ICSP-3 52 or ICSP-3 SS (slave) 10-53 - SS (master) Leonardo ICSP-4 ICSP-1 ICSP-3 - - Due ICSP-4 ICSP-1 ICSP-3-4, 10, 52 Note that MISO, MOSI, and SCK are available in a consistent physical location on the ICSP header; this is useful, for example, in designing a shield that works on every board. In the following picture is displayed a scheme of the pins of the DAC MCP4922. So to let the DAC MCP4922 Digital Analog Converter work with the Arduino DUE the following connections can be made: ARDUINO DUE Pin 10 Pin 7 (Optional): It is used only if you want to have the possibility to shut down the DAC SCK (from the SPI pins in the middle of the DUE board) MOSI (from the SPI pins in the middle of the DUE board) MCP4922 Pin 3: CS Pin 9: SHDN Pin 4: SCK Pin 5: SDI (Serial Data In)

The other pins of the DAC are connected according to the following picture: To test if the sketch that we will upload it is working we can use a digital multimeter. Of course this will work only if the frequency of the signal we want to generate is less than the maximum frequency we can observe with the multimeter. The multimeter will be connected with one end to the GND of the Arduino and the other one to the OUT_A of the previous picture. A sketch test which can be uploaded to test our DAC + DUE connections is (you can copy it and paste directly in the Arduino IDE for a better readability): /* DAC _MCP4922 to DUE This sketch allows you to interface the Arduino DUE with a DAC MCP4922. The DAC needs a 16 bit word to work. The first 4 bits are control bits and the remaining are bits which will contain the value you want to send. We have 12 bit available for our message so we will have a range of values between 0 and 4095. Connections ==================================================== +5V > 4922 pin 1

DUE pin CS > 4922 pin 3 (SS - slave select) DUE SCK > 4922 pin 4 (SCK - clock) DUE MOSI > 4922 pin 5 (MOSI - data out) Ground > 4922 pin 8 (LDAC) +3.3V > 4922 pin 11 (voltage ref DAC B) Ground > 4922 pin 12 +3.3v > 4922 pin 13 (voltage ref DAC A) 4922 pin 14 DAC A > 1k resistor > SignalOUT(you can put this signal in a multimeter or oscilloscope to look at it) The other wire of the multimeter/oscilloscope should be at the same GND of the Arduino */ #include <SPI.h> // Include the SPI Library // I suggest to give a first look to the following link: // http://arduino.cc/en/reference/spi #define CS 52 // It can be 10,4, or 52. Be careful if you use an Ethernet Shield void setup() { // put your setup code here, to run once: SPI.begin(CS); SPI.setBitOrder(MSBFIRST); pinmode(7,output); digitalwrite(7,high); /* Our DAC can operate at Mode 0,0 (which corresponds to mode 0 in the SPI library) and in mode 1,1 (which corresponds to mode 3 in the SPI library) */ /* I don t know why instead the DAC is working with the following instruction?? Everything works also without this instruction. I don t know why! it s working just with modes 2 and 3. Maybe these mode 2 and 3 corresponds to the mode 0,0 and 1,1 to which the MCP4922 datasheet is referring. To understand what I m talking about give a look to the following page: http://en.wikipedia.org/wiki/serial_peripheral_interface_bus in the section "Mode Numbers". */ SPI.setDataMode(CS, 2); /* From the datasheet we understand that the maximum frequency at which the DAC can operate is 20MHz. The Arduino DUE has a system clock of 84MHz so if we don t say anything to the SPI library it won t change the clock at which we will operate. 84 MHz is too big for the DAC, to change this we can use the function SPI.setClockDivider(SS,divider) This function set the clock, for the device on pin SS, to 84/divider. The divider variable can only be an integer. For this reason for example to have an operating clock for our device of 1MHz we

will write: SPI.setClockDivider(SS,84); to have an operating clock for our device of 2MHz we will write: SPI.setClockDivider(SS,42); and so on. By the way, seems that it works also without this instruction even if I have no idea what happens internally when you don t specify the clock of the device. Maybe, I guess it goes up to the maximum frequency of the DAC but I m not sure and for this reason I suggest to choose a frequency of operation and fix it with the instruction described before. */ SPI.setClockDivider(CS,21); // 4MHz } void loop() { // put your main code here, to run repeatedly: digitalwrite(7,high); // The entire message to send a 4095 number will be: // 0111 111111111111 // The following is the value we want to send ;) int value=1230; // With V_REF of 3.3 V and VDD of 5V, 2470 corresponds to 4.00V // 1230 corresponds to 2.00V // Value parsing (the following 3 lines are needed just to convert an int (32bit) in 2 bytes) if(value>=4095){ value=4095; } byte msg2=(byte)value; byte msg1=(byte)(value>>8); msg1=msg1 0b01010000; // byte msg1=0b01010100; // 01111111 // byte msg2=0b00000001; // 11111111 /* The DAC accepts only words of 16bit and here we are sending 2 bytes one after another one. For more info about the SPI.transfer(, ) function give a look to the following page: http://arduino.cc/en/reference/spitransfer */ SPI.transfer(CS,msg1,SPI_CONTINUE); SPI.transfer(CS,msg2,SPI_LAST); delay(4000); // Uncomment the following 3 lines if you want to ShutDown every 4 seconds the DAC // digitalwrite(7,low); // delay(4000);11111010000 // digitalwrite(7,high); }

Now what you will see on your multimeter depends from what is the V DD and V REF you chose for your circuit. As you can see from the datasheet, the V OUT (the value you will observe on the multimeter) depends from the gain, and from the V REF. In our case, a DAC MCP4922, n = 12. Moreover it depends also from the V DD because the maximum value the V OUT will be saturated at V DD 0.04. (Look at p. 4 of the Datasheet). In the following picture is showed the picture, just to show you that I made really what I m telling you: