3

I'm hoping to construct a feedback loop for a laser using an Chipkit UC32 and an analog-digitial converter ( the one of I have is an AD5780 evaluation board). I've been reading through Digilint's SPI library but I admit I am pretty lost.

( I believe this is on topic to Arduino because I am using an Arduino API. The micro-controller I use is basically an Arduino so I see no difference. )

I'd like to output something simple like a digital AC voltage to the DAC and have it convert it, but as I understand it from here, I am just using the digitalWritecommand which is basically binary. How do transfer something more complicated to have the DAC convert it?

Likewise, how do I get the DAC to do the reverse, ADC, where it reads in a voltage and sends the Arduino a digital signal through SPI pins?

  • 1
    What does this have to do with Arduino? It seems to me that you have this UC32 which has a PIC32 microcontroller on it and you need to write a library for the AD5780 using the chip's SPI peripheral. – Maximilian Gerhardt Feb 13 at 21:12
  • Also why would you write your own driver if Analog Devices has a reference driver at wiki.analog.com/resources/tools-software/uc-drivers/renesas/… where you only have to implement SPI_Init, SPI_Write and SPI_Read yourself using your board / platform's SPI lib? :) – Maximilian Gerhardt Feb 13 at 21:20
  • 1
    @MaximilianGerhardt chipKIT uses the Arduino API. It's as Arduino as the esp8266 or teensy. – Majenko Feb 13 at 22:15
  • @MaximilianGerhardt Have you tried to use the AD Driver before? I'm here becauseI tried that and it seems broken. It requests files that aren't included. They don't seem to be useful but even if you remove those #include commands, it references a lot of undefined functions. Perhaps its just the missing file but seems unusable. If you have any experience with this, I could open another thread and try to fix it. – Andrew Hardy Feb 21 at 15:25
  • @AndrewHardy Sure, I'll download the lib and interface with the Arduino SPI class so that in theory you can drop-in the result straight away. I'll let you know if I encounter a problem. If the lib requires functions beyond that what they say, it's kind of a bad lib.. – Maximilian Gerhardt Feb 21 at 18:36
3

I'd like to output something simple like a digital AC voltage to the DAC and have it convert it, but as I understand it from here, I am just using the digitalWritecommand which is basically binary. How do transfer something more complicated to have the DAC convert it?

SPI is a communication protocol. It uses digital signals, coupled with time, to transfer information.

To use DSPI you need to first define an SPI object

DSPI0 SPI;

From then on it's the same as using the Arduino SPI library.

Start it

SPI.begin();

Then transfer the correct commands (found in the DAC datasheet) to set the voltage of the output

digitalWrite(10, LOW);
SPI.transfer(0x43);
SPI.transfer(0x1A);
digitalWrite(10, HIGH);

The values there are just examples. The 10 is the chip select pin for the DAC, and the values used in the transfers (however many are needed) need to be found in the datasheet.

If you only want to use the pins associated with DSPI0 you can use the SPI library instead (which only supports one SPI channel - the uC32 has two), in which case it is identical to working with the Arduino SPI library.

Likewise, how do I get the DAC to do the reverse, ADC, where it reads in a voltage and sends the Arduino a digital signal through SPI pins?

You don't. DACs are DACs and ADCs are ADCs. They aren't interchangeable.

For ADC functionality just use any of pins A0 through A11 and the analogRead() function.

  • thanks for responding! You've helped me before so I appreciate the patience. I've been reading for a while, so can I run some things by you? I didn't find anything in the Data Sheet, but what bytes I write are just getting bit_number = (Pos REF V - Neg REF V ) / 2^(18) and convert to bytes? There doesn't seem to be a command for the actual conversion either? From what I've read when I send bytes it automatically converts to an analog voltage and outputs it? – Andrew Hardy Feb 21 at 16:02
  • Secondly, do you think it is worth trying to get the AD Drivers running? The missing file is ior5f100le.h . Is this a standard Arduino library I'm missing? The driver has commands for reading data from the register too, which I don't quite understand the point of. – Andrew Hardy Feb 21 at 16:04
  • That DAC uses a 3-byte (24 bit) control protocol. Page 21 onwards in the datasheet describe the commands. You need to first send the correct commands to turn the DAC on (using the "Control Register"). Once on you send a value to a specific register (not a real register, so it's not listed with the registers), and toggle LDAC (either the pin or the register bit) to output that value. I have never heard of ior5f100le.h. Probably something to do with a specific development board. – Majenko Feb 21 at 16:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.