Pages: [1] 2   Go Down
Author Topic: 16bit DAC parallel bits, AD669  (Read 2316 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I will be implementing a single channel DAC in my current/upcoming project.

The DAC IC that I have available is the AD669;

http://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.





* Application_AD669.png (58.87 KB, 587x473 - viewed 35 times.)
« Last Edit: February 24, 2013, 04:53:24 am by SuperR » Logged

South England
Offline Offline
Full Member
***
Karma: 3
Posts: 205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Rob Tillaart

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

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33362
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 93
Posts: 4749
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I withdraw my suggestion about the 595 register, that is an output one. But something like the 74HC165 will do input.
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 93
Posts: 4749
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
« Last Edit: February 24, 2013, 07:04:06 pm by GoForSmoke » Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
« Last Edit: February 27, 2013, 08:01:48 am by SuperR » Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 93
Posts: 4749
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.



Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8472
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33362
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 93
Posts: 4749
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
Logged

Pages: [1] 2   Go Up
Jump to: