# Connecting D/A converter

1. Jul 23, 2007

Hello,

I want to connect a d/a converter [e.g, MAX515] to RS232.
I need a 0-5v output.

assuming that I know how to write a code to output binaric signal,
how do I connect the converter?
I don't really know what to do with the clk, sync and Vres legs at the DAC.

2. Jul 23, 2007

### Staff: Mentor

There are a lot of datasheets and application notes at the MAXIM website that will show you how to connect up a DAC in many applications. Can you please point us to one that shows a similar connection to what you are doing, and ask us some specific questions about it?

Also, keep in mind that RS-232 does not use 0V/+5V signals. It uses +/- split power supplies. You may want to consider using a MAX232 chip to convert your 5V signals to the RS-232 voltages.

What are you using to create the the digital codes that you are converting for the RS-232 signals? And why don't you just do it all digitally, if you already have digital information? Why the intermediate analog step?

3. Jul 23, 2007

### chroot

Staff Emeritus
You're definitely going to need some kind of RS-232 transciever chip, in addition to your DAC. After you choose one, we can help you figure out how to connect them.

Berkeman, I think Liad is trying to connect a DAC to an RS-232 bus so he can send digital data to it via RS-232, and have it converted to analog.

- Warren

4. Jul 23, 2007

### xez

You *could* use multiple chips -- RS232 to TTL level
converters, a SPI DAC, and an RS232 port with
controllable flow control and data lines in the direction of
the PC to the DAC to do this, but you wouldn't end up
with a very nice system.

You'd have to pick three state controllable RS232 lines
that are outputs from your PC or control device
e.g. RTS, TXD, DTR and use them through a level
converter to SCLK, CS, DIN, and then you'd have to
program the RS232 lines to toggle up and down a couple
of times for every *BIT* of data you want to send to the
DAC. You would NOT be able to just send a string of
serial data in the form of serial characters over the
RS232, you'd have to sit there and control the bits on
and off one by one in explicit software.

You might as well be using a parallel port to interface the
thing; it'd be easier than doing it with RS232 in the
way I've described.

The nicest solution to interfacing the thing to RS232
(or for that matter a parallel printer port) would be
to use:
b) RS232 level converters (line receiver RS232 to TTL)
c) a small microcontroller that has a UART port and
a SPI port and which is programmed to receive
and data from the RS232 port over its UART and then send
16 bits of data corresponding to your DAC values out to
the DAC over its SPI port. That way you get an efficient
use of RS232 serial transmissions the way they're intended
to be used, and you could have the whole thing run more
smoothly, quickly, and easily in terms of software
complexity. Actually if you look there are some
microcontrollers with UARTs and DACs built in to them
so you might only need the microcontroller and
a RS232 level converting line receiver chip.

5. Jul 24, 2007

First of all, thanks for the quick responses...

I need to control a 0-5V output via C# code [or any other language for that matter].

I thought on a 8bit-serial-DAC that will be connected to a serial port [RS232].
In the code I'll put a 0-100% scroll bar that will control the output.

8bit = 256 stpes. that's aprox. 2 steps per 1% in the scroll bar, meaning - aprox. 0.02V per 1%.

any other ways to accomplish the mission will be superb.

I don't really know much on DAC's , so any help will be useful.

6. Jul 24, 2007

### Staff: Mentor

Ahh, DAC output out of a PC. Got it.

You can buy relatively inexpensive serial or USB interface widgets to do ADC and DAC for your PC. Here's an example from B&B Electronics:

http://www.bb-elec.com/product.asp?sku=UD128A8D&TrailType=Sub (price is $270 USD) National Instruments also makes these kind of modules. 7. Jul 24, 2007 ### Liad And what about building this kind of circuit? what shall i need then? 8. Jul 24, 2007 ### berkeman ### Staff: Mentor Well, the challenge will be to convert the RS-232 data format to something that you can feed into a serial DAC chip. Here are a couple links with related information, in these cases it is for reading an ADC over the PC's RS-232 serial port: Serial A/D example tutorial: http://www.techlib.com/electronics/serialport.htm Serial A/D example circuit from MAXIM: http://www.maxim-ic.com/appnotes.cfm/appnote_number/827 The MAX7547 looks like it might work as the serial DAC, but I'm not sure what-all would be needed for glue logic between the serial data from the RS-232 port and the serial input control lines for the DAC. A better way to go might be to use USB, and to get a cheap Basic Stamp or PIC eval board that has a USB interface on it and some prototype area. Or keep looking for cheaper pre-made RS-232 DAC widgets. Here's one from StateLogic for$120 USD:

http://www.statelogic.com/

9. Jul 24, 2007

I'll start looking for a possibility to build a USB based circuit.
I'll look for a scheme of a pc-input circuit to analog...

or...I'll try to make the: suitable for my needs...making it d/a from the serial port...

anyone with any idea is more then welcome...
:)

Last edited: Jul 24, 2007
10. Jul 25, 2007

11. Jul 25, 2007

### xez

Serial as in SPI as in SERIAL PERIPHERAL INTERFACE
DACs are great, if you have an SPI port. SPI just isn't
the same serial protocol as what comes out of an
RS232 port, that's all.

You didn't mention what frequency you're trying to
update this at; I don't know if the manually controlled
scroll bar thing is your REAL application, or if you'll be
using the DAC for more automated programmable type
uses.

If you need static slowly changing DC values, you should
use a real DAC.

If in the end you're trying to generate an AC waveform
at a moderately high frequency and NOT EVER DC, you
could just program a PC sound card to output the
analog amplitudes you want. But they have a built in
200 Hertz or so high pass filter, so you could only
generate waveforms between 200Hz and 22000 Hz
that way. But they have '16 bit' DACs, at least two
of them, in fact. Though really their quality may be
closer to 12 bits, depending on the card you get. :)
Actually if you wanted to 'hack up' a sould card you
MIGHT be able to find a really basic / cheap one and
take off the output coupling capacitor and get DC values
out of it, but that's something you'd have to experiment
with. I'd check REALTEK's data sheets to see if it's
possible with their common chips and then maybe look
for something with that chip.

If you want DC output you could do one of two sorts of
'clever hacks' to get DAC like function out of a PC with

a) PWM output -- if you have an integrator circuit,
e.g. a resistor and capacitor to filter the output and
eliminate most of the fluctuations / ripple of doing this,
you can use a single software controlled digital bit
as a DAC. For 8 bit resolution, generate a string of 256
bits. Take your desired 8 bit DAC output value and
set that many bits in your string of 256 bits to '1'.
Clear the rest of the bits in your string to '0.
At a constant frequency, successively output each bit in
the string to your digital output port bit (you could use
one of the serial flow control bits or parallel port bits).
The resistor/capacitor filter will generate an 'DC' output
equal to the average voltage in the waveform which
will of course be N / 256th of the peak voltage since
N of the 256 bits are set.

b) R-2R DAC: configure the parallel printer port in
basic PS/2 mode. You'll be able to output 8 data bits
to the port's data bits in software with the right
software. At the LSB connect resistor value 256R.
At the next more significant bit connect a resistor
of value 128R. etc. etc. so you end up with 8 resistors:
256R, 128R, 64R, 32R, 16R, 8R, 4R, 2R, 1R. LSB to MSB.
Tie the opposite ends of each of those resistors together.
Use 1% resistors with the smallest one being 2K or so.
Actually if you want best 8 bit accuracy pick your resistors
so they're actually around 0.5%. The current you get
out of the resistor set will be equal to your DAC output;
scale the current with a transimpedance op-amp if you
want to convert that to 0V to 5V easily.

Otherwise just hook up a SPI DAC like the one
you mentioned to the PC parallel port if you're ONLY
controlling it from your slider application. If you need
fast response, use a microcontroller connected to the
PC parallel port.

12. Jul 25, 2007

I can't use a parallel port because that in the end, the system should have more than 1 circuit.
The same apply for using sound card.

about the other possibilities, can you explain more?
any piece of information will be useful. :rofl:

How to connect such DAC, and how to calculate what should the program output?

13. Jul 25, 2007

### edmondng

you need to look at the datasheet. try to understand it.

sclk = clock.
cs = chip select
din = data input digital
clr = clear like a reset

if you see the timing waveform in the max515, in order to operate you need to toggle the cs low, sclk low high low high ..., etc

when you have many chips in the circuit, you need to know which is in control. that is why you have the chip select. also the chip cannot operate unless it has a clock. the faster your clock, the faster your output DAC. some DAC has Vref input, some the Vref is the Vdd itself. That measn if it is 8 bit DAC, 255 = Max Vref/VddV, 0 = 0V.

To me you'll be better off getting a microcontroller, and program it through RS232 (depending how much time you have). Mic. have DACs, A/D etc all built and relatively cheap like $5. Some of the circuit shown in the datasheet (SPI Port to Max 515) they use MISO, MOSI which is Master IN Slave OUT or Master out Slave IN. These are SPI interface to talk to devices. So if i have 3 devices, i can talk to all three devices getting data in and out using MISO and MOSI. The trick to selecting which device to talk one at a time is to use the chip select Hope this helps 14. Jul 25, 2007 ### xez You could order one of the Tini2131_DKit products below, and then you'll have a serial interface and a microcontroller you can program to take serial data and send it to the SPI port. Then you could wire the SPI DACs from MAXIM to the SPI interface on the microcontroller and use some of the spare GPIO bits as chip selects so you could have a few additional DACs connected. I guess you could use the I2C port to hook up even more I2C DACS since they're addressable more easily. Just depends on the quantity of DACs you need etc. The drawback is that it'd involve some moderately complex microcontroller programming, but the advantage would be you would not need to do too much electrical wiring to get it all working, and the price isn't a bad compromise between completely doing it yourself and making PC boards, etc., versus the high(er) typical cost of "off the shelf ready to use" RS-232 DAC products. Actually you could use a single PC parallel port to hook up several SPI DAC chips, you'd need two output bits for SCLK and DIN, shared by all the DACs. Also you'd need one CS chip select for EACH DAC chip, so you could actually interface at least seven SPI DACs to one parallel port directly. But then you'd have to do some fairly complex PC programming at the hardware port I/O bit control level to send out the data; it's not at all hard, or a lot of code, it's just hard if you're not a low level programmer that's used to doing bit manipulation logic I/O coding.... http://www.newmicros.com/ http://www.newmicros.com/cgi-bin/store/order.cgi?form=prod_detail&part=Tini2131_DKit http://www.newmicros.com/cgi-bin/store/order.cgi?form=prod_detail&part=Tini2131 15. Jul 26, 2007 ### Liad Hey again! thanks for all the comments...:) and back to work...what about those three: AT89C52 DAC0800 MAX232 can i manage to output my 0-5V with them? and...how? how to connect them? never-giving-up-Liad. :grumpy: 16. Jul 27, 2007 ### xez ATMEL says the AT89C52 is not recommended for new designs, and suggests the AT89S52 instead. The AT89S52 doesn't look like it has both a SPI port (I didn't see one at all) and a UART, so it doesn't seem suitable. Anyway what's wrong with the development kit I mentioned before? It is all wired for you except for adding in a few DAC chips. There are plenty of microcontrollers out there that have both SPI and UARTs (though you'd almost always need to use a chip like the MAX232 to interface the UART pins to a RS232 port). Yes, using a microcontroller with both UART and SPI is technically by far the cleanest most well performing and most straightforward solution. But, the problems with just using "any old Microcontroller" are: a) How are you going to program it? Does it need special programming devices / cables / interfaces? b) How are you going to write the software? Do they have simple to use freely or inexpensively available software for an assembler or C compiler or FORTH, BASIC, or whatever? c) How are you going to build it? If you're just wiring it yourself with no printed circuit board, you'd need something that's easy to use in a DIP package which doesn't require too many connections to get it connected for programming, interfacing, and general use. If you use a surface mount package you'll need a PCB. Where will you get the PCB? Will you design one? Can you find a free template on the internet or in a book? You'll also need relatively advanced soldering skills, unless you get someone to assemble it for you. d) How many of these units total are you definitely going to build within the next few months? If you're only looking for one or a few, it's probably not worth the time and engineering effort to do something that will be really time consuming and difficult unless you're really committed to it as an educational process / hobby. Otherwise, financially you'd be better off spending$75 or \$200 or
whatever for a relatively off the shelf solution rather than
spending dozens of hours trying to build/program a
few of these.

e) How many DACs do you really need attached to ONE
PC? If you need somewhere between one and sixteen
you could easily just interface them all to a parallel port
without the complexity of using a microcontroller, though
the PC side of the software will be more complex, it's
probably worth it rather than trying to buy/build/program
microcontrollers that you're not familiar with.
This is assuming that you don't have any high performance
fast update / synchronization needs that'd make it hard,
though within reason one can get relatively simultaneous
updates pretty easily for several DACs.

f) Why are you doing this? Hobby? Business? School?
The 'right' answer to approach this probably depends on
why you're doing it as well as more detail about what you
need the thing for technically. You said 0-5V, but that
doesn't even get into things like output impedance,
output current capability, connectorization, initialization,
and other details that are sometimes relevant to choosing
an approach.

If you're looking for a uC with SPI *and* a UART, look
at some of the TI MSP430F2xxx series parts; there are
parts in (if I recall correctly) a 38 pin or larger surface
mount package that have multiple USART/SPI interfaces
so you can use one SPI and one UART mode simultaneously. The programming software is pretty much
free, and the programming hardware isn't that expensive,
but you'd really need a custom PC board.

If you just want to "get it done and over with", look at
something that's either an off the shelf RS232 or USB
DAC system, or a simple to use microcontroller board
with commercially available DAC modules like some of the
BASIC STAMP stuff or RABBIT's stuff or whatever.

If you want to do some programming and some hardware,
just get one of the uC development boards like the one
I mentioned that you can just solder your DACs onto
and program the thing.

17. Oct 8, 2007