0
Offline
Newbie
Karma: 0
Posts: 35
Arduino rocks
|
 |
« on: February 24, 2013, 04:44:00 am » |
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.pdfIt 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.
|
|
|
|
« Last Edit: February 24, 2013, 04:53:24 am by SuperR »
|
Logged
|
|
|
|
|
South England
Offline
Full Member
Karma: 3
Posts: 194
|
 |
« Reply #1 on: February 24, 2013, 09:56:54 am » |
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
|
|
|
|
|
Netherlands
Online
Tesla Member
Karma: 89
Posts: 9392
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #2 on: February 24, 2013, 10:00:33 am » |
you might use a couple of shift registers - http://arduino.cc/en/Tutorial/ShiftOut - to control it with 3 lines.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #3 on: February 24, 2013, 04:34:30 pm » |
You could use a couple of 595 shift registers: http://www.gammon.com.au/forum/?id=11518But by the time you have bought those you may as well buy an SPI DAC chip.
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 275
Posts: 25481
Solder is electric glue
|
 |
« Reply #4 on: February 24, 2013, 04:46:55 pm » |
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
Faraday Member
Karma: 30
Posts: 2911
I only know some basic electricity....
|
 |
« Reply #5 on: February 24, 2013, 04:52:39 pm » |
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
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #6 on: February 24, 2013, 06:38:46 pm » |
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
Faraday Member
Karma: 30
Posts: 2911
I only know some basic electricity....
|
 |
« Reply #7 on: February 24, 2013, 06:58:55 pm » |
Some of these are even bi-directional: http://www.futurlec.com/cgi-bin/search/search.cgi?search=shift_register&search_base=0&page_no=1I 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) 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
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 35
Arduino rocks
|
 |
« Reply #8 on: February 27, 2013, 07:26:57 am » |
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
Faraday Member
Karma: 30
Posts: 2911
I only know some basic electricity....
|
 |
« Reply #9 on: February 27, 2013, 08:04:37 am » |
Here's you pin map: http://arduino.cc/en/Hacking/PinMappingSAM3XYou 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
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 71
Posts: 6817
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #10 on: February 27, 2013, 08:22:47 am » |
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
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 275
Posts: 25481
Solder is electric glue
|
 |
« Reply #11 on: February 27, 2013, 09:08:25 am » |
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
Faraday Member
Karma: 30
Posts: 2911
I only know some basic electricity....
|
 |
« Reply #12 on: February 27, 2013, 09:36:44 am » |
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
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 35
Arduino rocks
|
 |
« Reply #13 on: February 27, 2013, 10:00:41 am » |
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
Newbie
Karma: 0
Posts: 35
Arduino rocks
|
 |
« Reply #14 on: February 27, 2013, 10:13:52 am » |
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
|
|
|
|
|
|