Using a DAC to convert digital to analog current

Hello everyone,

I am currently on a project that requires converting digital signals from my MEGA 2560 to an analog current that I specify using an arduino. I currently have a DAC, which is DAC7624P http://www.ti.com/lit/ds/symlink/dac7624.pdf. I don't know how to hook up the DAC to take these readings, because I do not understand what the acronyms mean even with the legend. Are there any sources to visit that will help me with this? I have hooked up the data bits to digital outputs on the Arduino Mega. I don't know how to power the arduino, and I do not know how to proceed from here.

Thank you for you suggestions in advance :)

That is not a good chip to use with an arduino. It has four outputs, do you need four? It has a parallel input, that means that it will take 12 output pins plus one or two others for control lines. A much better interface would be SPI. The D/A can only output a voltage, if you want to control a current then you have to have a constant load impedance or some sort of current monitoring. You need to know what current range you need, what voltage range you need and what accuracy you need. Do you want the supply to be a constant current that you set with the arduino or what?

Study the timing diagram on page 11. There will be a quiz later. Be prepared to describe in detail the required timing to use the dac. That's your homework.

ecause I do not understand what the acronyms mean even with the legend.

Try to understand what each pin on the chip does.

I could be wrong because I haven't carefully studied the data sheet... The Address lines A0 & A1 determine which of the 4 DAC outputs you are addressing. (But you are not directly controlling the analog output, you are writing to an internal register). The LDAC line loads the data from the 12 parallel inputs into the addressed register (to be converted to an analog voltage). It looks like the R/W line determines if you are reading data into the DAC registers or writing the register data out to an analog output (at any moment in time.)

The most important thing about the timing diagrams is the sequence.

Grumpy_Mike: That is not a good chip to use with an arduino. It has four outputs, do you need four? It has a parallel input, that means that it will take 12 output pins plus one or two others for control lines. A much better interface would be SPI. The D/A can only output a voltage, if you want to control a current then you have to have a constant load impedance or some sort of current monitoring. You need to know what current range you need, what voltage range you need and what accuracy you need. Do you want the supply to be a constant current that you set with the arduino or what?

I only need one output. This is the first DAC that I saw, so I decided to use it. In other words, I do not need 4 outputs. I do however have another DAC, this one http://www.ti.com.cn/cn/lit/ds/symlink/dac0808.pdf, and I am able to purchase a different one that you believe is much better. Please recommend one or let me know if the DAC0808 will be sufficient.

I actually am using a DAC, so I can maintain a constant voltage over the lens of an optical drive. So I believe I only need to and want to control current. I plan to use a manual DC power supply to determine the maximum voltage needed to raise the lens to the top.

I want to be able to vary the voltage across the the lens to be able to move it up and down by creating a program on the arduino or adjusting it on matlab while connecting the arduino to the computer through the serial cable.

I also understand that raschemmel and DVDdoug recommend studying the timing diagram. I don't know how to reading a timing diagram yet but I hope to understand it with some googling tonight.

To show you how much I understand and what my limit knowledge is, I just finished my first year of engineering and have not started op amps, DACs, or any microelectronics. I am currently learning :)

That new DAC also has parallel data bus which you would need to connect to the Arduino.

Picking up on Grumpy_Mike's earlier suggestion, try searching for a DAC that uses SPI or I2C to connect to the Arduino. Since DACs with these interfaces are often used with Arduinos, it might be easier to find sample programs or libraries that work with them.

Unless your electrical requirements are very specific, you could be better off looking for Arduino code to work with a chip, rather than choosing a chip and then looking for code.

Try Googling with search terms like "arduino dac spi library" or "arduino dac i2c tutorial".

I have used the MCP4725 DAC with the Arduino, using the I2C bus and Wire library to connect to it. Maybe get hold of the datasheet for that device, see if it will do what you need. I can post the code I used.

All the best

Ray

You keep talking about :-

constant voltage over the lens of an optical drive

I don't know what that means. A lens is made of non conducting material so it makes little sense applying a voltage to it. You have still not said what sort of voltage and what sort of current you need. It is vital to know this before you can start to make even the block diagram of a design let alone specify the sort of D/A that you need.

you could be better off looking for Arduino code to work with a chip, rather than choosing a chip and then looking for code.

I would strongly disagree with that. Interface code for a D/A is almost trivial, you need it to do the right thing first.

Hello Grumpy_Mike,

Thank you for helping. I took a picture to help illustrate what I mean when I say lens. I realise that I am mostly likely using the wrong terminology when I say lens. The lens is the part of the object that will raise when a voltage is applied across it.

A picture would help explain what I am trying to do. I will be soldering wires to the metal pins instead of using gator clips. This is the picture of the lens.

https://www.dropbox.com/s/o3erl782gjmpi2s/20140506_095712.jpg.

I hooked applied a voltage across the object, so the lens in the middle will raise to the top. I found that the voltage needed to raise it to the top is 2.6V and the current drawn is 0.46 as illustrated in the circuit below:

https://www.dropbox.com/s/3epq29x3qjbfk5f/20140506_095655.jpg

I hope to be able to to apply a voltage that is between 0V and 2.6V, so I can keep it between its resting point and the topmost point. Thank you for spending time and effort to help me.

I hooked applied a voltage across the object, so the lens in the middle will raise to the top. I found that the voltage needed to raise it to the top is 2.6V and the current drawn is 0.46 as illustrated in the circuit below:

Well a DAC can generate the voltage it will never supply .46 amps by itself. It would require a current amplifier stage following the ADC output.

If we knew more about what is being manipulated in the lens to cause it to move, perhaps a simple electromagnet coil, you could most get by with a much simple arduino PWM output using analogWrite() commands and a simple switching transistor?

The word lens is just the transparent bit that does the optical focusing. It looks to me like this is some sort of read / write head from a CD or other optical reader. Normally with no power these will be in the center. There are galvanometer coils that do the movement and you have to apply power to these. I would try what lefty suggested and put out a PWM signal through a transistor or FET to increase the current. However the coils might respond to these rapid signal changes, see:- http://www.thebox.myzen.co.uk/Tutorial/PWM.html It could be they need smoothing. How fast do you want to change the voltage going to those coils? What sort of resolution do you want with the movement.

How about a photo and some documentation ?

hi every body,i want ask if i can get tree phase sine wave from DAC ? thanks

alyasa: hi every body,i want ask if i can get tree phase sine wave from DAC ? thanks

Your question has absolutely nothing to do with this thread. Start a new one.

firstly, thank you for reply. i am working on project that i have generate three phase sine waves by using arduino to drive AFPM motor. so i research on websites i found some codes to generate sine waves but i faced with DAC. thank you

this code i found it int led1 = 11; int led2 = 10; int led3 = 9; const float pi = 3.1415; float x = 0; int enable = 8; int freqpin = A0; unsigned char p1 = 0; unsigned char pp1 = 0; unsigned char pp2 = 0; unsigned char pp3 = 0; unsigned char p2 = 0; unsigned char p3 = 0; const float y = pi/30; const float ph1 = 2*pi/3; const float ph2 = 4*pi/3; const float ph3 = 2*pi;

void setup() { pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(enable, INPUT); pinMode(freqpin, INPUT); }

void loop() { while(digitalRead(enable) == HIGH) { x = x + y; analogWrite(led1, p1); analogWrite(led2, p2); analogWrite(led3, p3); pp1 = 126*sin(x+ph1); p1 = pp1+128; pp2 = 126*sin(x+ph2); p2 = pp2+128; pp3 = 126*sin(x+ph3); p3 = pp3+128; if(x >= 2*pi) x = 0; delay(freqpin); } analogWrite(led1, 0); analogWrite(led2, 0); analogWrite(led3, 0); x = 0; }