Go Down

Topic: 16bit DAC parallel bits, AD669 (Read 3013 times) previous topic - next topic

SuperR

Feb 24, 2013, 10:44 am Last Edit: Feb 24, 2013, 10:53 am by SuperR Reason: 1
I will be implementing a single channel DAC in my current/upcoming project.

The DAC IC that I have available is the AD669;

ftp://ftp.signalogic.com/data_sheets/AD_DA_Converters/AD669.pdf

It wants to receive a 16-bit parallel input. Fine by me, but what is the best/fastest way to do that? I can hook it up to 16 digital outputs on my Arduino Due, no problem, but maybe there are smarter options.

It would take 19 pins to drive the DAC. I need a lot of pins for the ADC's too, but I think it would be acceptable.

However, if I can use a shift register without adding "loop-time", that would be fine too.




BulletMagnet83

Why not use a serial DAC instead? I'm pretty sure you can get some reasonably fast single channel ones and you might find it easier to implement. If you can't find one in a package you like then there's always the option of a breakout board.

robtillaart

you might use a couple of shift registers - http://arduino.cc/en/Tutorial/ShiftOut - to control it with 3 lines.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Nick Gammon

You could use a couple of 595 shift registers:

http://www.gammon.com.au/forum/?id=11518

But by the time you have bought those you may as well buy an SPI DAC chip.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Grumpy_Mike

Quote
if I can use a shift register without adding "loop-time", that would be fine too.

What do you mean by loop time?

You an always use a MCP23S17, this is an SPI 16 bit port expander, that can run quite fast. How fast do you need?

GoForSmoke

If you use shift registers it will be a bit slower than writing 2 8-bit ports. But what do you need for speed? The difference is a small fraction of a millisecond.

Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

Nick Gammon

I withdraw my suggestion about the 595 register, that is an output one. But something like the 74HC165 will do input.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

GoForSmoke

#7
Feb 25, 2013, 12:58 am Last Edit: Feb 25, 2013, 01:04 am by GoForSmoke Reason: 1
Some of these are even bi-directional:
http://www.futurlec.com/cgi-bin/search/search.cgi?search=shift_register&search_base=0&page_no=1

I don't know those people but I have bought from them a few times and never a problem with an order. Obviously though, you don't just buy 1 or 2 50-cent chips on a $4+ shipping charge. But they have component bags and all kinds of goodies. The prices are close enough to eBay for me and these guys do have datasheets so I know what I'm ordering, not just hoping it is what it seems.

(ships from Hong Kong, there's a how-long table)

Quote
SHIPPING METHODS
For Australian, Canada, UK, EU and USA customers, we can offer domestic postage rates as follows,

USA, Canada, UK, European Union(EU) and Australia

   Standard Post*
   For orders up to US$29, Delivery Charge - US$4.00.
   For orders US$30 to US$49, Delivery Charge - US$6.00
   For order US$50 to US$99, Delivery Charge - US$9.00
   For order US$100 and above, Delivery Charge - US$14.00

   Express Post - Express Pak Only
   For orders up to US$99, Delivery Charge - US$22.00.
   For order US$100 and above, Delivery Charge - US$44.00
   For orders shipped in Cartons, Express Charges are charged at actual cost.

   Courier - Courier Pak Only
   For orders up to US$99, Delivery Charge - US$33.00.
   For orders US$100 and above, Delivery Charge - US$66.00
   For orders shipped in Cartons, Courier Charges are charged at actual cost.


All Other Countries

   Standard Post - Air Mail*
   For orders up to US$29, Delivery Charge - US$5.00.
   For orders US$30 to US$49, Delivery Charge - US$7.00
   For order US$50 to US$99, Delivery Charge - US$12.00
   For order US$100 and above, Delivery Charge - US$18.00

   Express Post - Express Pak Only - Where Available
   For orders up to US$99, Delivery Charge - US$28.00.
   For order US$100 and above, Delivery Charge - US$55.00
   For orders shipped in Cartons, Express Charges are charged at actual cost.

   Courier - Courier Pak Only
   For orders up to US$99, Delivery Charge - US$45.00.
   For orders US$100 and above, Delivery Charge - US$75.00
   For orders shipped in Cartons, Courier Charges are charged at actual cost.



Hmmmm, after the USPS charges thread I have to wonder if the site needs updating or they subsidize the difference. And heyyy, ship to Down-Under is the same as to the US!
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

SuperR

#8
Feb 27, 2013, 01:26 pm Last Edit: Feb 27, 2013, 02:01 pm by SuperR Reason: 1
Ok, I think I got it up and running. I now need to write some code to transform a value of desire to 16 parallel bits. I have enough digital output pin available so I would like to use just the 16 output pins for the data.

Any suggestions?

I have looked at bitRead. That seems to work but puts out a value of 1 or 0 while ideally, I want a LOW or HIGH.

for instance, for bit 0, I would like to output;

I did not expect this to work but it does;

  •   digitalWrite(2,bitRead(8,3));
      delay(2000);
      digitalWrite(2,bitRead(8,2));
      delay(2000);



GoForSmoke

Here's you pin map:
http://arduino.cc/en/Hacking/PinMappingSAM3X

You have Ports A, B, C, D with pins as SAM3X pin names PA##, PB##, etc.
If you can get 16 pins in a row on the same port then you should be able to write 16 bits to that port in one go. Once the bits are written however you do it, the pins should reflect what you wrote. It's a lot quicker than setting 16 pins 1 at a time.



Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

Graynomad

Quote
I can hook it up to 16 digital outputs on my Arduino Due, no problem, but maybe there are smarter options

I read the entire thread before I realised you're using a Due, just hook up 16 (or 19) pins and learn how to directly write to a port. Job done, there's no "better" way unless you're desperate to save pins for another purpose.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Grumpy_Mike

Quote
That seems to work but puts out a value of 1 or 0 while ideally, I want a LOW or HIGH.

So what is the difference between a 1 and a high?
I will tell you, nothing at all.
See it is ideal!

GoForSmoke


Quote
That seems to work but puts out a value of 1 or 0 while ideally, I want a LOW or HIGH.

So what is the difference between a 1 and a high?
I will tell you, nothing at all.
See it is ideal!


Once here I was warned that TRUE/FALSE and HIGH/LOW might some day not be 1/0 so my code should not assume that and won't be compatible. I had to LOL since hey, I should live so long! But then that person advocates using C++ Strings on UNO's and not being hardware-centered.

Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

SuperR

Ok, I got it working in "slow"-mode.
I indeed put each individual pin either High or Low. It is more of a proof-of concept than it is the end result. The loop now takes as much a 80-100uS with a analogread and normal digitalwrites (16 of them)
Now I know what kind of signals are required to use the DAC, I  will try to use one of the ports for a shorter looptime.

I will try to use portC to driving the DAC.

"So what is the difference between a 1 and a high?"
In the digitalWrite help it says explicitly it want either HIGH or LOW so I was under the assumption that those two inputs were the only ones accepted.

More to come.

SuperR

For the ADC I will be implementing I will use this code, which speeds up the digitalwrites and reads drastically. I will first try to implement the same type of bitsetting on the DAC and if that works nicely, keep it that way.

inline void digitalWriteDirect(int pin, boolean val){
  if(val) g_APinDescription[pin].pPort -> PIO_SODR = g_APinDescription[pin].ulPin;
  else    g_APinDescription[pin].pPort -> PIO_CODR = g_APinDescription[pin].ulPin;
}

inline int digitalReadDirect(int pin){
  return !!(g_APinDescription[pin].pPort -> PIO_PDSR & g_APinDescription[pin].ulPin);

Go Up