I need to give an output between 0 and 4V with my Arduino DUE.
I have a Digital to Analog Converter MCP4922 but to use it I should change the SPI library because the stuff I was using for the Arduino UNO, on the DUE is not working because The sketch is written for an ATmega based Arduino. On a Due I can't use the direct port manipulation commands of the ATmega platform, so I have to rewrite the sketch to use digitalWrite() instead of the port manipulations and the SPI library instead of the register manipulations in the sketch.
I know that on the DUE there is already a DAC integrated, but the output can be only between 0 and 3.3V, actually they give an output between 0.549V and 2.775V.
I want an output between 0 and 4V. How can I have it?
I was thinking that there are mainly 2 ways:
Add an Operational Amplifier
Change the SPI library to let it work with the DUE.
What do you think is the best way? or what do you suggest to me and why?
See page 23-24.
You bring CS low, send out 2 bytes via SPI.transfer(x); bring CS high.
You really need a library for that?
Due does not support SPI.transfer( ) command?
Thanks for the reply but that page is not really useful for me because people are searching for a solution to connect the DUE as slave and it also seemed that they didn´t find a solution . By the way my problem is another one.
See page 23-24.
You bring CS low, send out 2 bytes via SPI.transfer(x); bring CS high.
You really need a library for that?
Due does not support SPI.transfer( ) command?
#include <SPI.h>
void setup() {
// put your setup code here, to run once:
SPI.begin(10);
}
void loop() {
// put your main code here, to run repeatedly:
// The entire message to send a 4095 number will be:
// 0011 | 111111111111
msg= ...
SPI.transfer(10,msg)
}
What is msg?
The problem now is how to create a message of 2 bytes on the Arduino DUE, because the integers are of 32 bits.
See page 23-24.
You bring CS low, send out 2 bytes via SPI.transfer(x); bring CS high.
You really need a library for that?
Due does not support SPI.transfer( ) command?
Won't work on the Due - the CS line is handled in hardware and you must not
drive it directly. See the extensions to SPI for the Due, its all mentioned on the
Due product page I believe. SPI.transfer() brings CS low and takes it high again
automagically on every call.
Note on the Due you are limited to 3 or 4 particular CS pins (4 and 10 and some others). However you can use other pins for CS, but have to use one of the hardware pins as well
since the SPI hardware needs to drive one of them automatically IIRC.